-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
109 lines (85 loc) · 3.34 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
cmake_minimum_required(VERSION 3.12...3.13)
project(upmq
VERSION 3.5
DESCRIPTION "C++ MQ-Broker")
option(ENABLE_TESTS "Enable tests" ON)
option(ENABLE_EXAMPLES "Enable examples" ON)
option(ENABLE_WEB_ADMIN "Enable web-admin gui for broker" ON)
option(ENABLE_POSTGRESQL "Enable PostgreSQL support (usefull only for POCO greater or equal 1.10)" OFF)
option(ENABLE_ODBC "Enable ODBC support" OFF)
option(ENABLE_USING_SENDFILE "Enable using SendFile for file transfering (not applyable with cygwin)" ON)
option(MAKE_DISTR_BY_CPACK "Make distribuive with cpack" OFF)
if (POCO_ROOT_DIR)
list(APPEND CMAKE_MODULE_PATH "${POCO_ROOT_DIR}/lib/cmake/Poco")
list(APPEND CMAKE_PREFIX_PATH "${POCO_ROOT_DIR}")
endif ()
if (PROTOBUF_ROOT_DIR)
list(APPEND CMAKE_MODULE_PATH "${PROTOBUF_ROOT_DIR}/cmake")
list(APPEND CMAKE_PREFIX_PATH "${PROTOBUF_ROOT_DIR}")
endif ()
if (GTEST_ROOT_DIR)
list(APPEND CMAKE_MODULE_PATH "${GTEST_ROOT_DIR}/lib/cmake/GTest")
list(APPEND CMAKE_PREFIX_PATH "${GTEST_ROOT_DIR}")
endif ()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(MSVC_COMPILE_FLAGS "/MP")
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_COMPILE_FLAGS}")
if (MSVC_TOOLSET_VERSION GREATER 140)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W4")
endif ()
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wextra -Wshadow")
endif ()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
# Set a default build type if none was specified
set(default_build_type "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
include(CheckIPOSupported)
check_ipo_supported(RESULT result)
if (result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()
endif ()
if (WIN32)
set(VER_SCRIPT "${CMAKE_SOURCE_DIR}/version.bat")
else (WIN32)
set(VER_SCRIPT "${CMAKE_SOURCE_DIR}/version.sh")
endif (WIN32)
if (CYGWIN)
set(ENABLE_USING_SENDFILE OFF)
endif ()
execute_process(COMMAND ${VER_SCRIPT}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
file(STRINGS "${CMAKE_SOURCE_DIR}/VERSION.txt" VERSION)
message(STATUS "VERSION : ${VERSION}")
file(STRINGS "${CMAKE_SOURCE_DIR}/COMMIT.txt" COMMIT)
message(STATUS "COMMIT : ${COMMIT}")
string(REPLACE "." "," VER_FILE ${VERSION})
add_definitions(-DVER_FILEVERSION=${VER_FILE},0)
add_definitions(-DVER_FILEVERSION_STR=\"${VERSION}.0\")
add_definitions(-DVER_PRODUCTVERSION=${VER_FILE},0)
add_definitions(-DVER_PRODUCTVERSION_STR=\"${VERSION}.0\")
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_SOURCE_DIR}/share/Version.hpp")
set(SHARE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/share")
set(EXTERNAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external")
add_subdirectory(external)
add_subdirectory(libs)
add_subdirectory(bins)
if (ENABLE_TESTS)
add_subdirectory(tests)
endif ()
if (ENABLE_EXAMPLES)
add_subdirectory(examples)
endif ()