-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
149 lines (118 loc) · 4.56 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
cmake_minimum_required(VERSION 3.20.0)
project(cli-cpp)
enable_language(CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
macro (FailIfNotSet VARIABLE name)
if (NOT ${VARIABLE})
set(MSG "** A required include file, " ${name} ", was not found on your system **")
message(FATAL_ERROR ${MSG})
endif (NOT ${VARIABLE})
endmacro(FailIfNotSet)
check_include_file_cxx(cstdio HAVE_CSTDIO)
FailIfNotSet(HAVE_CSTDIO cstdio)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/target/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/target/lib)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "64 bits compiler detected")
set(DTEST_BUILD_PLATFORM 64)
set(DTEST_BUILD_PLATFORM_NAME "x64")
add_definitions(-DENABLE_IMPLICIT_CONVERSIONS)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "32 bits compiler detected")
set(DTEST_BUILD_PLATFORM 32)
set(DTEST_BUILD_PLATFORM_NAME "i686")
message(STATUS "Implicit conversions are disabled")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if (WIN32)
set(PROTON_INCLUDE_DIR "C:/Proton/qpid-proton-winsdk/include" CACHE String "Proton include directory")
set(PROTON_LIBRARY_DIR "C:/Proton/qpid-proton-winsdk/lib" CACHE String "Proton library directory")
endif (WIN32)
set(ENABLE_QPID_PROTON ON CACHE BOOL "Enable qpid proton clients")
set(BUILD_WITH_UNIT_TESTS OFF CACHE BOOL "Build unit tests for the CPP client code")
if (NOT WIN32)
find_package(Proton REQUIRED Core Proactor)
find_package(ProtonCpp REQUIRED)
include_directories(
${ProtonCpp_INCLUDE_DIRS}
${Qpid_INCLUDE_DIRS}
)
link_libraries(
${Proton_Core_LIBRARIES}
${Proton_Proactor_LIBRARIES}
${ProtonCpp_LIBRARIES}
${Qpid_LIBRARIES}
)
endif (NOT WIN32)
if (WIN32)
if (EXISTS "${PROTON_INCLUDE_DIR}")
include_directories(${PROTON_INCLUDE_DIR})
else (EXISTS "${PROTON_INCLUDE_DIR}")
message(FATAL_ERROR "Proton ${PROTON_VERSION} headers were not found in ${PROTON_INCLUDE_DIR}")
endif (EXISTS "${PROTON_INCLUDE_DIR}")
if (EXISTS "${PROTON_LIBRARY_DIR}")
link_directories(${PROTON_LIBRARY_DIR})
else (EXISTS "${PROTON_LIBRARY_DIR}")
message(FATAL_ERROR "Proton ${PROTON_VERSION} libraries were not found in ${PROTON_LIBRARY_DIR}")
endif (EXISTS "${PROTON_LIBRARY_DIR}")
endif (WIN32)
include_directories(
src/contrib/
src/common/
src/common/exceptions
src/common/options
)
SET(CPP_RUNTIME_DIR "bin")
SET(CPP_LIBRARY_DIR "lib")
SET(CPP_INCLUDE_DIR "include")
INCLUDE(${CMAKE_SOURCE_DIR}/dist/CMakeInstall.cmake)
# Set default build type. Must use FORCE because project() sets default to ""
if(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: None Debug Release."
FORCE
)
endif(NOT CMAKE_BUILD_TYPE)
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_C_FLAGS "-Wall -Wshadow -fdiagnostics-color=auto" CACHE STRING
"Flags used by the compiler during all build types." FORCE
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -pipe" CACHE STRING
"Flags used by the compiler during all build types." FORCE
)
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O2 -g -pipe ${CMAKE_USER_C_FLAGS}" CACHE STRING
"Flags used by the compiler during all build types." FORCE
)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -Weffc++ -Wshadow -pipe" CACHE STRING
"Flags used by the compiler during release." FORCE
)
endif (CMAKE_COMPILER_IS_GNUCXX)
add_custom_target(distclean
COMMAND ${CMAKE_BUILD_TOOL} clean
COMMAND ${CMAKE_COMMAND} -P clean-all.cmake
)
add_custom_target(documentation
COMMAND ${CMAKE_COMMAND} -P documentation.cmake
)
if (BUILD_WITH_UNIT_TESTS)
set (CTEST_BINARY_DIRECTORY ${CMAKE_BINARY_DIR}/target/tests/bin)
endif (BUILD_WITH_UNIT_TESTS)
add_subdirectory(src/contrib)
add_subdirectory(src/common)
if (ENABLE_QPID_PROTON)
add_definitions(-DENABLE_QPID_PROTON)
add_subdirectory(src/api/qpid-proton)
endif(ENABLE_QPID_PROTON)
set(CPPCHECK_EXECUTABLE "/usr/bin/cppcheck" CACHE STRING "Path to cppcheck")
set(CPPCHECK_FLAGS "--report-progress" "-v" "--enable=all" "--xml"
CACHE STRING "Options for cppcheck")
set(CPPCHECK_DEFS "-DENABLE_PROTON"
"-DQPIDSYSEPOCH" CACHE STRING "Defines for cppcheck")
add_custom_target(check
COMMAND ${CPPCHECK_EXECUTABLE} ${CPPCHECK_DEFS} ${CPPCHECK_FLAGS} ${CMAKE_BINARY_DIR}
)