-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathCMakeLists.txt
145 lines (122 loc) · 3.69 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
cmake_minimum_required(VERSION 3.5)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_SOURCE_DIR}/cmake/Modules")
project(dextool)
enable_language(D)
include(common)
if(NOT LIBCLANG_LIB_PATH OR NOT LIBCLANG_LDFLAGS)
include(FindLibClang)
endif()
include(BuildD)
#
# Tool preparation
#
execute_process(
COMMAND ${D_COMPILER} ${CMAKE_SOURCE_DIR}/tools/symlink.d -of${CMAKE_BINARY_DIR}/symlink
)
#
# Main configuration.
#
set(TEST_WITH_COV false CACHE BOOL "true to run unittest with coverage")
set(BUILD_TEST false CACHE BOOL "true to build and run unittests")
if(BUILD_TEST)
enable_testing()
add_custom_target(check)
add_custom_target(check_integration)
# integration tests do NOT work if not all binaries are build
# this rule ensure that is suck
add_custom_target(check_integration_make_all
COMMAND cmake --build ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_dependencies(check_integration check_integration_make_all)
endif()
# Generally, we want to install everything into CMAKE_INSTALL_PREFIX, but when
# it is /usr, put the config files into /etc to meet common practice.
if(NOT DEFINED SYSCONF_INSTALL_DIR)
if(CMAKE_INSTALL_PREFIX STREQUAL "/usr")
set(SYSCONF_INSTALL_DIR "/etc")
else()
set(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc")
endif()
endif()
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR})
# Setup D compiler flags (DMD syntax, which also works with LDMD).
set(DDMD_DFLAGS "-w -wi -vcolumns -preview=dip1000")
set(DDMD_LFLAGS "")
set(DDMD_COV_FLAG "-cov")
# for multi-config builds, these options have to be added later to the custom command
if(CMAKE_BUILD_TYPE MATCHES "Debug")
append("-g -debug" DDMD_DFLAGS)
if("${D_COMPILER_ID}" STREQUAL "LDMD")
append("-link-debuglib" DDMD_DFLAGS)
elseif("${D_COMPILER_ID}" STREQUAL "DMD")
append("-verrors=context" DDMD_DFLAGS)
endif()
elseif(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
if("${D_COMPILER_ID}" STREQUAL "LDMD")
append("-g -enable-inlining -O5 -release" DDMD_DFLAGS)
elseif("${D_COMPILER_ID}" STREQUAL "DMD")
append("-g -release" DDMD_DFLAGS)
endif()
else()
# Default to a Release build type
append("-release" DDMD_DFLAGS)
if("${D_COMPILER_ID}" STREQUAL "LDMD")
append("-enable-inlining -O5" DDMD_DFLAGS)
else()
# -release do not work with dmd
#append("-release" DDMD_DFLAGS)
endif()
endif()
if(LOW_MEM)
append("-lowmem" DDMD_DFLAGS)
endif()
#
# Resources
#
append("-J${PROJECT_BINARY_DIR}/resources" DDMD_DFLAGS) # Needed for importing text files
# strip leading/trailing whitespace
string(STRIP "${DDMD_DFLAGS}" DDMD_DFLAGS)
#
# Emedded version
#
set(DEXTOOL_EMBEDDED_VERSION_PATH ${PROJECT_BINARY_DIR}/resources/version.txt)
# Generate the version description
execute_process(
COMMAND ${PROJECT_SOURCE_DIR}/tools/gen_version_from_git.sh
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_custom_target(dextool_embedded_version
DEPENDS
${DEXTOOL_EMBEDDED_VERSION_PATH}
)
#
# Configure the main executable that all underlying plugins adher to
#
set(DEXTOOL_MAIN_EXE "dextool")
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(DEXTOOL_MAIN_EXE "${DEXTOOL_MAIN_EXE}_debug")
endif()
set(DEXTOOL_MAIN_EXE_FULL ${PROJECT_BINARY_DIR}/${DEXTOOL_MAIN_EXE})
#
# Distribute building
#
# building vendor libs because internal dextool libs may have dependencies on
# these.
add_subdirectory(vendor)
# base libraries used by binaries
add_subdirectory(libs)
if(BUILD_TEST)
add_subdirectory(test)
endif()
# binary
add_subdirectory(source)
add_subdirectory(plugin)
#
# Install target.
#
#
# Packaging
#
include(cmake/CMakeCPack.cmake)
include(CPack)