-
Notifications
You must be signed in to change notification settings - Fork 35
/
CMakeLists.txt
104 lines (85 loc) · 4.27 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
cmake_minimum_required (VERSION 2.8.12)
project (KRAKENAPI)
add_definitions("-std=c++11")
#-------------------------------------------------------------------------------
IF (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
add_definitions("-Wno-tautological-compare")
ENDIF()
#-------------------------------------------------------------------------------
IF (APPLE)
set (CMAKE_MODULE_LINKER_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
ENDIF (APPLE)
#-------------------------------------------------------------------------------
IF (POLICY CMP0043)
cmake_policy(SET CMP0043 OLD)
ENDIF()
#-------------------------------------------------------------------------------
# Control CMAKE_BUILD_TYPE, default: Debug
#-------------------------------------------------------------------------------
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Debug" CACHE string "Build type" FORCE)
endif (NOT CMAKE_BUILD_TYPE)
message (STATUS "Build type: " ${CMAKE_BUILD_TYPE})
#-------------------------------------------------------------------------------
# Find OpenSSL
#-------------------------------------------------------------------------------
find_package (OpenSSL REQUIRED)
include_directories (${OPENSSL_INCLUDE_DIR})
list(APPEND LIBS ${OPENSSL_LIBRARIES})
#-------------------------------------------------------------------------------
# Find CURL
#-------------------------------------------------------------------------------
find_package (CURL REQUIRED)
include_directories (${CURL_INCLUDE_DIR})
list(APPEND LIBS ${CURL_LIBRARIES})
#-------------------------------------------------------------------------------
# Add library kapi (krakenapi)
#-------------------------------------------------------------------------------
aux_source_directory(kraken KAPI_FILES)
add_library (kapi STATIC ${KAPI_FILES})
# set some properties when CMAKE_BUILD_TYPE is "Debug"
set_target_properties (kapi PROPERTIES
COMPILE_DEFINITIONS_DEBUG "JSON_DEBUG;JSON_SAFE;JSON_ISO_STRICT"
DEBUG_POSTFIX "d")
list (INSERT LIBS 0 kapi)
#-------------------------------------------------------------------------------
# Add library libjson
#-------------------------------------------------------------------------------
set (LIBJSON_SOURCE_DIR ${CMAKE_HOME_DIRECTORY}/libjson/_internal/Source)
aux_source_directory (${LIBJSON_SOURCE_DIR} LIBJSON_SOURCE_FILES)
add_library (libjson STATIC ${LIBJSON_SOURCE_FILES})
# remove "lib" prefix from the name of the libjson archive
set_target_properties (libjson PROPERTIES PREFIX "")
# set some properties when CMAKE_BUILD_TYPE is "Debug"
set_target_properties (libjson PROPERTIES
COMPILE_DEFINITIONS_DEBUG "JSON_DEBUG;JSON_SAFE;JSON_ISO_STRICT"
DEBUG_POSTFIX "d")
list (APPEND LIBS libjson)
#-------------------------------------------------------------------------------
# Add the executable 'kph'
#-------------------------------------------------------------------------------
add_executable (kph kph.cpp)
set_target_properties (kph PROPERTIES
COMPILE_DEFINITIONS_DEBUG "JSON_DEBUG;JSON_SAFE;JSON_ISO_STRICT")
target_link_libraries (kph ${LIBS})
#-------------------------------------------------------------------------------
# Add the executable 'krt'
#-------------------------------------------------------------------------------
add_executable (krt krt.cpp)
set_target_properties (krt PROPERTIES
COMPILE_DEFINITIONS_DEBUG "JSON_DEBUG;JSON_SAFE;JSON_ISO_STRICT")
target_link_libraries (krt ${LIBS})
#-------------------------------------------------------------------------------
# Add the executable 'private_method'
#-------------------------------------------------------------------------------
add_executable (private_method examples/private_method.cpp kapi.cpp)
set_target_properties (private_method PROPERTIES
COMPILE_DEFINITIONS_DEBUG "JSON_DEBUG;JSON_SAFE;JSON_ISO_STRICT")
target_link_libraries (private_method ${LIBS})
#-------------------------------------------------------------------------------
# Add the executable 'public_method'
#-------------------------------------------------------------------------------
add_executable (public_method examples/public_method.cpp kapi.cpp)
set_target_properties (public_method PROPERTIES
COMPILE_DEFINITIONS_DEBUG "JSON_DEBUG;JSON_SAFE;JSON_ISO_STRICT")
target_link_libraries (public_method ${LIBS})