-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
122 lines (106 loc) · 3.25 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
cmake_minimum_required(VERSION 3.23)
project(stralgo
VERSION 1.3.2
LANGUAGES CXX
HOMEPAGE_URL "https://github.com/arturbac/stralgo"
)
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
)
endif()
include(FeatureSummary)
option(STRALGO_ENABLE_UNIT_TESTS "unit tests available from CTest" ${PROJECT_IS_TOP_LEVEL} )
add_feature_info("STRALGO_ENABLE_UNIT_TESTS" STRALGO_ENABLE_UNIT_TESTS "unit test available from CTest")
if( PROJECT_IS_TOP_LEVEL AND STRALGO_ENABLE_UNIT_TESTS)
set(SMALL_VECTORS_ENABLE_UNIT_TESTS ON)
enable_testing()
endif()
include(cmake/CPM.cmake)
# ---- Add dependencies via CPM ----
# see https://github.com/cpm-cmake/CPM.cmake for more info
CPMAddPackage(
NAME PackageProject.cmake
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
VERSION 1.11.2
)
#----------------------------------------------------------------
# small_vectors
#----------------------------------------------------------------
CPMAddPackage(
small_vectors
GITHUB_REPOSITORY arturbac/small_vectors
GIT_TAG v3.1.8
)
if( PROJECT_IS_TOP_LEVEL )
#----------------------------------------------------------------
# boost-ext/ut
#----------------------------------------------------------------
CPMAddPackage(
ut
GITHUB_REPOSITORY arturbac/ut-ext
GIT_TAG master
)
endif()
if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 20 )
message(STATUS "Assuming by default c++20 standard")
set( CMAKE_CXX_STANDARD 20 )
endif()
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF)
add_library(stralgo INTERFACE )
if(PROJECT_IS_TOP_LEVEL)
add_library(stralgo::stralgo ALIAS stralgo )
endif()
if(NOT DEFINED INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR include/${PROJECT_NAME})
endif()
target_include_directories(stralgo
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
)
target_link_libraries(stralgo INTERFACE small_vectors::small_vectors)
packageProject(
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
NAMESPACE stralgo
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
INCLUDE_DESTINATION ${INCLUDE_INSTALL_DIR}
COMPATIBILITY SameMajorVersion
)
if( PROJECT_IS_TOP_LEVEL )
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(STRALGO_COMPILE_OPTIONS
-Weverything
-Werror
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-pre-c++14-compat
-Wno-pre-c++17-compat
-Wno-pre-c++20-compat-pedantic
-Wno-c++20-compat
-Wno-c++2b-extensions
-Wno-unused-parameter
-Wno-padded
-Wno-unused-command-line-argument
)
check_cxx_compiler_flag(-Wunsafe-buffer-usage WUNSAFE_BUFFER_USAGE)
if(WUNSAFE_BUFFER_USAGE)
list(APPEND STRALGO_COMPILE_OPTIONS -Wno-unsafe-buffer-usage)
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(STRALGO_COMPILE_OPTIONS
-Wall
-Wextra
-Werror
)
endif()
endif()
if( STRALGO_ENABLE_UNIT_TESTS)
add_subdirectory( unittests )
endif()
#
# add_subdirectory(perf)