-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
94 lines (76 loc) · 2.27 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
cmake_minimum_required (VERSION 3.24 FATAL_ERROR)
project (tuple VERSION 0.1 LANGUAGES C CXX)
# Make including this file idempotent
#
if(TARGET tuple::tuple)
return()
endif()
# If this is the current project.
#
if(PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME)
# Laod the cmake recipes and utilities.
#
include(${CMAKE_CURRENT_LIST_DIR}/cmake/load_cmake_helpers.cmake)
# Options for generating tests and documentation.
#
option(TUPLE_TEST "Generate the tests." ON)
option(TUPLE_DOCS "Generate the docs." OFF)
# compile_commands.json
#
symlink_compile_commands()
# Convenience targets for git operations
#
make_submodule_pull_target()
else()
option(TUPLE_TEST "Generate the tests." OFF)
option(TUPLE_DOCS "Generate the docs." OFF)
endif()
# Put executables in the top-level binary directory
#
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Output configuration
#
message("-- tuple: Configuration: ${CMAKE_CURRENT_SOURCE_DIR}")
message("-- tuple: Included from: ${CMAKE_SOURCE_DIR}")
message("-- tuple: Install prefix: ${CMAKE_INSTALL_PREFIX}")
message("-- tuple: Binary dir: ${CMAKE_BINARY_DIR}")
message("-- tuple: core dir: ${CPP_CORE_DIR}")
message("-- tuple: test ${TUPLE_TEST}")
message("-- tuple: docs ${TUPLE_DOCS}")
# Setup compilation before adding dependencies
#
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-Wall)
add_compile_options(-stdlib=libc++)
add_compile_options(-O)
add_link_options(-stdlib=libc++)
# Add our dependencies
#
add_repo(mp)
# Build the library
#
add_library(tuple INTERFACE)
add_library(tuple::tuple ALIAS tuple) # Allow interop between FetchContent and FindPackage.
# Define the header files for this library.
#
file(GLOB_RECURSE PUBLIC_INCLUDE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/*.h)
target_sources(tuple INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${PUBLIC_INCLUDE_FILES})
target_link_libraries(tuple INTERFACE mp::mp)
add_executable(tuple0 src/tools/tuple0.cpp)
target_link_libraries(tuple0 tuple mp::mp)
# Optionally configure the tests
#
if(TUPLE_TEST)
add_gtest()
add_subdirectory(test)
endif()
# Optionally configure the documentation
#
if(TUPLE_DOCS)
add_subdirectory(docs)
endif()
# Install config
#
install_config(tuple)