-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
164 lines (122 loc) · 4.19 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required(VERSION 3.21)
project(wl VERSION 0.1.1)
##############################################################
# Language setup
##############################################################
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
##############################################################
# Build Targets
##############################################################
option(BUILD_PYKWL "Build" OFF)
option(BUILD_TESTS "Build" OFF)
option(BUILD_PROFILING "Build" OFF)
##############################################################
# Common Settings
##############################################################
# make cache variables for install destinations
include(GNUInstallDirs)
if(MSVC)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W1 /EHsc /bigobj /MP")
string(APPEND CMAKE_EXE_LINKER_FLAGS " /IGNORE:4006,4044,4075")
else()
# TODO: Add -Wextra and fix all warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -DNDEBUG")
set(CMAKE_CXX_FLAGS_PROFILING "-O3 -Wall -pg")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -Wall -g3 -ggdb")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
message(STATUS "Build configuration: ${CMAKE_BUILD_TYPE}")
set(DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data/")
add_definitions(-DDATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/")
message("DATA_DIR: ${DATA_DIR}")
##############################################################
# CMake modules and macro files
##############################################################
list(APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake"
)
include("configure_ccache")
##############################################################
# CCache
##############################################################
# CCache
configure_ccache()
##############################################################
# Dependency Handling
##############################################################
# set(CMAKE_FIND_DEBUG_MODE TRUE)
##############################################################
# Add library and executable targets
##############################################################
message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
# ------------
# Target WL
# ------------
add_subdirectory(src)
# -------------------
# Target Python WL
# -------------------
if(BUILD_PYKWL)
add_subdirectory(python/src)
endif()
# ----------
# Target Exe
# ----------
# add_subdirectory(exe)
# ----------------
# Target Profiling
# ----------------
if(BUILD_PROFILING)
# add_subdirectory(benchmark)
endif()
# -----------
# Target Test
# -----------
if(BUILD_TESTS)
add_subdirectory(tests)
endif()
###########
# Install #
###########
# Install header files
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/wl"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# Install cmake scripts
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wl/cmake"
)
###########
# Exports #
###########
# https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html
include(CMakePackageConfigHelpers)
# Generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/wlConfigVersion.cmake"
VERSION ${wl_VERSION}
COMPATIBILITY ExactVersion
)
# Create config file
# https://cmake.org/cmake/help/book/mastering-cmake/cmake/Help/guide/importing-exporting/index.html
# https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#generating-a-package-configuration-file
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/wlConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wl"
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# Install config files
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/wlConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/wlConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wl"
)