-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
71 lines (58 loc) · 2.21 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
# This CMakeLists.txt file is only for use with C++ projects and not used by setup.py
# See also https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html
cmake_minimum_required(VERSION 3.20)
project(wlplan)
# make cache variables for install destinations
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -pedantic -fPIC -O3 -DNDEBUG -fomit-frame-pointer")
# Gather source files
# Do NOT glob src/main.cpp because that is only for creating Python bindings and requires pybind11
file(GLOB_RECURSE SRC_FILES "src/**/*.cpp")
# Define the library target
add_library(wlplan ${SRC_FILES})
# Add compile definitions
target_compile_definitions(wlplan PRIVATE WLPLAN_VERSION="${WLPLAN_VERSION}")
# Specify include directories for the target
target_include_directories(wlplan PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
# Export the targets to a file
install(TARGETS wlplan
EXPORT wlplanTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Install header files
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Create and install the package configuration file
include(CMakePackageConfigHelpers)
# Generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/wlplanConfigVersion.cmake"
VERSION "${WLPLAN_VERSION}"
COMPATIBILITY ExactVersion
)
# Create config file
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/wlplanConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wlplan"
)
# Install the config files
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/wlplanConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/wlplanConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wlplan"
)
# Export and install the targets
install(
EXPORT wlplanTargets
FILE wlplanTargets.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wlplan"
)