-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathCMakeLists.txt
135 lines (111 loc) · 3.01 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
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(i3ipc++)
option(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
option(I3IPCpp_BUILD_EXAMPLES "Build example executables" OFF)
file(GLOB_RECURSE SRC src/*.cpp)
add_library(i3ipc++ ${SRC})
find_package(PkgConfig)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
pkg_check_modules(SIGCPP sigc++-3.0)
if(SIGCPP_FOUND)
target_compile_definitions(i3ipc++
PUBLIC I3CPP_IPC_SIGCPP3=${SIGCPP_FOUND}
)
else()
pkg_check_modules(SIGCPP REQUIRED sigc++-2.0)
endif()
set(I3IPCpp_INCLUDE_DIRS
${SIGCPP_INCLUDE_DIRS}
${i3ipc++_SOURCE_DIR}/3rd/auss/include
${i3ipc++_SOURCE_DIR}/include/
)
set(I3IPCpp_LIBRARY_DIRS
${SIGCPP_LIBRARY_DIRS}
${JSONCPP_LIBRARY_DIRS}
${PROJECT_BINARY_DIR}
)
set(I3IPCpp_LIBRARIES
${SIGCPP_LIBRARIES}
${JSONCPP_LIBRARIES}
)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wno-unused-parameter")
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -DDEBUG")
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
target_include_directories(i3ipc++
PUBLIC
${I3IPCpp_INCLUDE_DIRS}
PRIVATE
${JSONCPP_INCLUDE_DIRS}
${i3ipc++_SOURCE_DIR}/include/i3ipc++
)
link_directories(i3ipc++
PUBLIC
${I3IPCpp_LIBRARY_DIRS}
PRIVATE
${JSONCPP_LIBRARY_DIRS}
)
target_link_libraries(i3ipc++
PUBLIC
${I3IPCpp_LIBRARIES}
)
target_compile_options(i3ipc++
PRIVATE -std=c++17 -Wall -Wextra -Wno-unused-parameter
)
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
target_compile_options(i3ipc++
PUBLIC -g3
)
target_compile_definitions(i3ipc++
PRIVATE DEBUG=1
)
elseif (CMAKE_BUILD_TYPE EQUAL "RELEASE")
target_compile_options(i3ipc++
PUBLIC -O2
)
endif()
# set(I3IPCpp_LIBRARIES i3ipc++ ${SIGCPP_LIBRARIES} ${JSONCPP_LIBRARIES})
set(I3IPCpp_LIBRARY_DIRS "${I3IPCpp_LIBRARY_DIRS} ${PROJECT_BINARY_DIR}")
set(I3IPCpp_LIBRARIES "${I3IPCpp_LIBRARIES};i3ipc++")
get_directory_property(HAS_PARENT_DIRECTORY PARENT_DIRECTORY)
if(HAS_PARENT_DIRECTORY)
set(I3IPCpp_LIBRARY_DIRS ${I3IPCpp_LIBRARY_DIRS} PARENT_SCOPE)
set(I3IPCpp_INCLUDE_DIRS ${I3IPCpp_INCLUDE_DIRS} PARENT_SCOPE)
set(I3IPCpp_LIBRARIES ${I3IPCpp_LIBRARIES} PARENT_SCOPE)
endif()
if(I3IPCpp_BUILD_EXAMPLES)
add_subdirectory(${i3ipc++_SOURCE_DIR}/examples)
endif()
if(I3IPCpp_WITH_TESTS)
find_package(CxxTest)
if(CXXTEST_FOUND)
add_definitions(
-DTEST_SRC_ROOT="${i3ipc++_SOURCE_DIR}/test"
)
enable_testing()
file(GLOB SRC_TEST test/*.hpp)
CXXTEST_ADD_TEST(i3ipcpp_check test.cpp ${SRC_TEST})
target_compile_options(i3ipcpp_check
PUBLIC -std=c++11 -Wall -Wextra -Wno-unused-parameter -g3
)
target_compile_definitions(i3ipcpp_check
PRIVATE DEBUG=1
)
target_include_directories(i3ipcpp_check
PUBLIC
${I3IPCpp_INCLUDE_DIRS}
PRIVATE
${JSONCPP_INCLUDE_DIRS}
${i3ipc++_SOURCE_DIR}/include/i3ipc++
)
link_directories(i3ipcpp_check
PUBLIC
${I3IPCpp_LIBRARY_DIRS}
)
target_link_libraries(i3ipcpp_check
PUBLIC
${I3IPCpp_LIBRARIES}
)
else()
message(WARNING "CxxTest not found. Unable to run unit-tests")
endif()
endif()