generated from codeinred/cpp-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
155 lines (131 loc) · 3.63 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
cmake_minimum_required(VERSION 3.14)
project(
"noam"
VERSION 0.8.0
DESCRIPTION "A Parser Combinator Library Build With C++20"
HOMEPAGE_URL "https://github.com/codeinred/noam/"
LANGUAGES CXX
)
add_library(noam INTERFACE)
add_library(noam::noam ALIAS noam)
# For ${CMAKE_INSTALL_<DIR>} variables that are standarized
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
target_compile_features(
noam
INTERFACE
cxx_std_20
)
target_include_directories(
noam
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# Installation
# See: https://dominikberner.ch/cmake-interface-lib/
install(
TARGETS noam
EXPORT noam_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"noamConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/noamConfig.cmake.in"
"${PROJECT_BINARY_DIR}/noamConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/noam/cmake
)
install(
EXPORT noam_Targets
FILE noamTargets.cmake
NAMESPACE noam::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/noam/cmake
)
install(FILES "${PROJECT_BINARY_DIR}/noamConfig.cmake"
"${PROJECT_BINARY_DIR}/noamConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/noam/cmake
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/noam
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
include(helper)
find_or_fetch(
fast_float
https://github.com/fastfloat/fast_float.git
tags/v1.1.2)
find_or_fetch(
tuplet
https://github.com/codeinred/tuplet.git
main)
target_link_libraries(
noam
INTERFACE
fast_float
tuplet::tuplet)
if(PROJECT_IS_TOP_LEVEL)
include(CTest)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# Add all files in directory test as tests, and link against noam and
# threads
#if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# target_compile_options(
# test_kilo_tuple
# PRIVATE
# -fbracket-depth=1000)
#endif()
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF)
# Find the benchmark library, or download it in build/_deps
find_or_fetch(
benchmark
https://github.com/google/benchmark.git
main)
find_or_fetch(
fmt
https://github.com/fmtlib/fmt.git
master)
find_or_fetch(
rva
https://github.com/codeinred/rva.git
main)
# always_fetch(
# Catch2
# https://github.com/catchorg/catch2.git
# devel)
FetchContent_MakeAvailable(${remote_dependencies})
add_source_dir(
src
noam::noam
fmt::fmt
rva::rva)
add_source_dir(
bench
noam
benchmark)
# add_executable(
# test_noam
# test2/test_noam.cpp)
# target_link_libraries(
# test_noam
# noam::noam
# fmt::fmt
# Catch2::Catch2WithMain)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(CTest)
add_test_dir(test noam fmt)
# include(Catch)
# catch_discover_tests(test_noam)
else()
# If we're not at toplevel we still need to make remote dependencies available
FetchContent_MakeAvailable(${remote_dependencies})
endif()