forked from jeaye/color_coded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
126 lines (99 loc) · 3 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
cmake_minimum_required(VERSION 2.8)
project(color_coded)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE)
endif()
# Shut up the warning about CMake policy CMP0042.
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "Found 32bit system")
set(64_BIT_PLATFORM 0)
else()
message(STATUS "Found 64bit system")
set(64_BIT_PLATFORM 1)
endif()
# Add custom find modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Submodules
message(STATUS "Updating submodules")
execute_process(
COMMAND git submodule update --recursive --init
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
# C++14
include(cmake/cxx14.cmake)
# Boost
include(cmake/boost.cmake)
# Lua
include(cmake/lua.cmake)
# Curses
find_package(Curses REQUIRED)
# ZLib
find_package(ZLIB REQUIRED)
# PThread
find_package(Threads REQUIRED)
# Clang
include(cmake/clang/download.cmake)
include_directories(
include
${LLVM_INCLUDE_PATH}
${CURSES_INCLUDE_PATH}
${ZLIB_INCLUDE_PATH}
$ENV{PWD}/include/
)
include(cmake/generate_sources.cmake)
include(cmake/check_luajit.cmake)
add_library(${PROJECT_NAME} SHARED src/main.cpp)
add_custom_target(${PROJECT_NAME}_track_api
COMMAND ${CMAKE_CURRENT_LIST_DIR}/lib/track_api
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_track_api)
# Force the same naming across platforms
set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "")
set_property(TARGET ${PROJECT_NAME} PROPERTY OUTPUT_NAME "${PROJECT_NAME}.so")
set_property(TARGET ${PROJECT_NAME} PROPERTY SUFFIX "")
# Enable warnings
set(WARNING_FLAGS
"-Wall -Wextra -pedantic -Wno-missing-field-initializers -Wno-unused-variable -Wno-deprecated-declarations"
)
set_property(TARGET ${PROJECT_NAME} PROPERTY COMPILE_FLAGS ${WARNING_FLAGS})
# Fix compilation problem: relocation R_X86_64_32 against `a local symbol' can not be
# used when making a shared object; recompile with -fPIC.
# See http://www.cmake.org/pipermail/cmake/2007-May/014350.html
if(64_BIT_PLATFORM)
set_property(TARGET ${PROJECT_NAME}_boost PROPERTY COMPILE_FLAGS "-fPIC")
endif()
# Clang
include(cmake/clang/link.cmake)
target_link_libraries(${PROJECT_NAME}
${PROJECT_NAME}_boost
${LUA_LIBRARIES}
${CURSES_LIBRARY}
${ZLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
# Install locally
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR})
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
# Tests
include_directories(
lib/jest/include
test/include
)
add_executable(${PROJECT_NAME}_config_test ${CMAKE_CURRENT_LIST_DIR}/test/src/config/main.cpp)
target_link_libraries(${PROJECT_NAME}_config_test
${PROJECT_NAME}_boost
${LUA_LIBRARIES}
${CURSES_LIBRARY}
${ZLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
set_property(TARGET ${PROJECT_NAME}_config_test PROPERTY COMPILE_FLAGS ${WARNING_FLAGS})
add_custom_target(${PROJECT_NAME}_test
COMMAND ${PROJECT_NAME}_config_test
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
add_dependencies(${PROJECT_NAME}_test ${PROJECT_NAME}_config_test)