forked from hazelcast/hazelcast-cpp-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
115 lines (80 loc) · 3.86 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
cmake_minimum_required (VERSION 3.1)
project (HazelcastClient)
# FLAGS
# -DHZ_LIB_TYPE=[STATIC | SHARED]
# -DHZ_BIT=[32 | 64]
# -DHZ_CODE_COVERAGE=ON
# -DHZ_VALGRIND=ON
# -DHZ_ADDRESS_SANITIZER=ON
INCLUDE(TestBigEndian)
SET(HZ_VERSION 3.6-RC1-SNAPSHOT)
message(STATUS "Preparing hazelcast client ..... ")
include_directories( ${CMAKE_SOURCE_DIR}/external/include/)
#detect endianness
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if (${IS_BIG_ENDIAN})
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DHZ_BIG_ENDIAN")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DHZ_BIG_ENDIAN")
ENDIF (${IS_BIG_ENDIAN})
FILE(GLOB_RECURSE HZ_SOURCES "./hazelcast/src/*cpp")
FILE(GLOB_RECURSE HZ_HEADERS "./hazelcast/include/*h")
include_directories(${CMAKE_SOURCE_DIR}/hazelcast/include )
IF(NOT (${HZ_BIT} MATCHES "32") AND NOT (${HZ_BIT} MATCHES "64") )
message( STATUS "Build needs HZ_BIT. Setting default as -DHZ_BIT=64 (other option -DHZ_BIT=32)" )
set(HZ_BIT 64)
ENDIF(NOT (${HZ_BIT} MATCHES "32") AND NOT (${HZ_BIT} MATCHES "64"))
SET(HZ_BIT_FLAG " ")
IF(${HZ_BIT} MATCHES "32")
SET(HZ_BIT_FLAG " -m32 ")
ENDIF(${HZ_BIT} MATCHES "32")
message(STATUS "${HZ_BIT} Bit")
IF(NOT (${HZ_LIB_TYPE} MATCHES "STATIC") AND NOT (${HZ_LIB_TYPE} MATCHES "SHARED") )
message( STATUS "Build needs HZ_LIB_TYPE. Setting default as -DHZ_LIB_TYPE=STATIC (other option -DHZ_LIB_TYPE=SHARED)" )
set(HZ_LIB_TYPE STATIC)
ENDIF(NOT (${HZ_LIB_TYPE} MATCHES "STATIC") AND NOT (${HZ_LIB_TYPE} MATCHES "SHARED") )
message(STATUS "Generating ${HZ_LIB_TYPE} Library")
SET(HZ_LIB_NAME HazelcastClient${HZ_VERSION}_${HZ_BIT})
add_library(${HZ_LIB_NAME} ${HZ_LIB_TYPE} ${HZ_SOURCES} ${HZ_HEADERS})
set(HZ_CODE_COVERAGE_COMPILE_FLAGS " ")
set(HZ_CODE_COVERAGE_LINK_FLAGS " ")
IF(${HZ_CODE_COVERAGE} MATCHES "ON")
message(STATUS "Code coverage is on")
set(HZ_CODE_COVERAGE_COMPILE_FLAGS " -fprofile-arcs -ftest-coverage -fPIC -O0 ")
set(HZ_CODE_COVERAGE_LINK_FLAGS " -lgcov -fprofile-arcs -ftest-coverage -fPIC -O0 ")
ENDIF(${HZ_CODE_COVERAGE} MATCHES "ON")
set(HZ_VALGRIND_COMPILE_FLAGS " ")
set(HZ_VALGRIND_LINK_FLAGS " ")
IF(${HZ_VALGRIND} MATCHES "ON")
message(STATUS "Valgrind is on")
set(HZ_VALGRIND_COMPILE_FLAGS " -O0 ")
set(HZ_VALGRIND_LINK_FLAGS " -O0 ")
ENDIF(${HZ_VALGRIND} MATCHES "ON")
message(STATUS "${CMAKE_SYSTEM}")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message(STATUS "APPLE ENVIRONMENT DETECTED")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Werror ")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
target_link_libraries(${HZ_LIB_NAME} )
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message(STATUS "LINUX ENVIRONMENT DETECTED")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall -Werror ")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
set_target_properties(${HZ_LIB_NAME} PROPERTIES COMPILE_FLAGS "${HZ_BIT_FLAG} ${HZ_CODE_COVERAGE_COMPILE_FLAGS} ${HZ_VALGRIND_COMPILE_FLAGS}" LINK_FLAGS "${HZ_BIT_FLAG} ${HZ_CODE_COVERAGE_LINK_FLAGS} ${HZ_VALGRIND_LINK_FLAGS}")
target_link_libraries(${HZ_LIB_NAME} pthread rt )
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
message(STATUS "WINDOWS ENVIRONMENT DETECTED ${CMAKE_GENERATOR} ${CMAKE_BUILD_TYPE} ")
add_definitions(-D__WIN${HZ_BIT}__ -DWIN${HZ_BIT} -D_WIN${HZ_BIT})
IF(${HZ_LIB_TYPE} MATCHES "SHARED")
add_definitions(-DHAZELCAST_EXPORTS=1)
ELSE(${HZ_LIB_TYPE} MATCHES "STATIC")
add_definitions(-DHAZELCAST_EXPORTS=0)
ENDIF(${HZ_LIB_TYPE} MATCHES "SHARED")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP")
set_target_properties(${HZ_LIB_NAME} PROPERTIES COMPILE_FLAGS " /EHsc " )
target_link_libraries(${HZ_LIB_NAME} )
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
ADD_SUBDIRECTORY(hazelcast/test)
ADD_SUBDIRECTORY(examples)