-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
58 lines (49 loc) · 1.61 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
cmake_minimum_required(VERSION 3.10)
include(CMakePackageConfigHelpers)
project(lzokay VERSION 0.1 LANGUAGES CXX)
add_library(lzokay lzokay.hpp lzokay.cpp)
add_executable(lzokaytest test.cpp)
target_include_directories(lzokay PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(lzokaytest lzokay)
target_compile_features(lzokay PRIVATE cxx_std_14)
target_compile_features(lzokaytest PRIVATE cxx_std_14)
set_target_properties(lzokay PROPERTIES CXX_STANDARD 14)
set_target_properties(lzokaytest PROPERTIES CXX_STANDARD 14)
# Set installation for headers
install(
FILES "${PROJECT_SOURCE_DIR}/lzokay.hpp"
DESTINATION "include/lzokay"
)
set(version_config_file "${PROJECT_BINARY_DIR}/lzokayConfigVersion.cmake")
set(config_file "${PROJECT_BINARY_DIR}/lzokayConfig.cmake")
set(config_install_dir "lib/cmake/lzokay")
# Associate target with export
install(
TARGETS lzokay
EXPORT lzokayTargets
ARCHIVE DESTINATION "lib"
INCLUDES DESTINATION "include/lzokay" # This sets the INTERFACE_INCLUDE_DIRECTORIES property of the target.
)
# Install the target config files
install(
EXPORT lzokayTargets
NAMESPACE "lzokay::"
DESTINATION "${config_install_dir}"
)
# Generate version config file
write_basic_package_version_file(
"${version_config_file}"
COMPATIBILITY SameMajorVersion
)
# Generate config file
configure_package_config_file(
"Config.cmake.in"
"${config_file}"
INSTALL_DESTINATION "lib/cmake/lzokay"
)
# Install the config files
install(
FILES "${config_file}" "${version_config_file}"
DESTINATION ${config_install_dir}
)
add_subdirectory("lzokay-c")