-
Notifications
You must be signed in to change notification settings - Fork 46
/
CMakeLists.txt
81 lines (64 loc) · 2.05 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
cmake_minimum_required(VERSION 3.14.0)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
project(timsort VERSION 3.0.1 LANGUAGES CXX)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# Project options
option(BUILD_TESTING "Build the tests" ON)
option(BUILD_BENCHMARKS "Build the benchmarks" OFF)
# Create gfx::timsort as an interface library
add_library(timsort INTERFACE)
target_include_directories(timsort INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_features(timsort INTERFACE cxx_std_20)
add_library(gfx::timsort ALIAS timsort)
# Install targets and files
install(
TARGETS timsort
EXPORT gfx-timsort-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
EXPORT gfx-timsort-targets
NAMESPACE gfx::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gfx
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/gfx/timsort.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gfx
)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/gfx-timsort-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/gfx-timsort-config.cmake
INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/gfx
)
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/cmake/gfx-timsort-config-version.cmake
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/gfx-timsort-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/gfx-timsort-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gfx
)
# Export target so that it can be used in subdirectories
export(
EXPORT gfx-timsort-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/gfx-timsort-targets.cmake
NAMESPACE gfx::
)
# Build tests and/or benchmarks if this is the main project
if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
if (BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
if (BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
endif()