-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
99 lines (88 loc) · 3.75 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
# Copyright © 2023 Alexandre Coderre-Chabot
#
# This file is licensed under the MIT license. For more information, visit:
# https://mit-license.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# - The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# This file was originally obtained from:
# https://github.com/acodcha/cpp-utilities
# Check the CMake version.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
# Define the global settings.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -O3 -Wall -Wextra -Wno-return-type -Wpedantic")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_BUILD_TYPE Release)
# Define the C++ Utilities project and its options.
project(
"Utilities"
VERSION 1.0.0
LANGUAGES CXX
DESCRIPTION "Various utilities that extend the C++ Standard Library"
HOMEPAGE_URL "https://github.com/acodcha/cpp-utilities"
)
option(
TEST_CPP_UTILITIES
"Build testing executable."
OFF
)
# Define the C++ Utilities library.
add_library(
${PROJECT_NAME}
INTERFACE
)
target_include_directories(
${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# Configure the C++ Utilities library tests.
if(TEST_CPP_UTILITIES)
# Search for the GoogleTest library.
find_package(GTest QUIET)
if(GTest_FOUND)
message(STATUS "The GoogleTest library was found at: ${GTest_CONFIG}")
else()
# In this case, the GoogleTest library is not found, so fetch it instead.
include(FetchContent)
FetchContent_Declare(
GoogleTest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(GoogleTest)
message(STATUS "The GoogleTest library was fetched from: https://github.com/google/googletest.git")
endif()
# Include the GoogleTest library and enable testing.
include(GoogleTest)
enable_testing()
# Define the C++ Utilities library test executables.
add_executable(test_constexpr_sqrt ${PROJECT_SOURCE_DIR}/test/constexpr_sqrt.cpp)
target_link_libraries(test_constexpr_sqrt GTest::gtest_main)
gtest_discover_tests(test_constexpr_sqrt)
add_executable(test_updatable_priority_queue ${PROJECT_SOURCE_DIR}/test/updatable_priority_queue.cpp)
target_link_libraries(test_updatable_priority_queue GTest::gtest_main)
gtest_discover_tests(test_updatable_priority_queue)
message(STATUS "The C++ Utilities library tests were configured. Build the tests with \"make --jobs=16\" and run them with \"make test\"")
else()
message(STATUS "The C++ Utilities library tests were not configured. Run \"cmake .. -DTEST_CPP_UTILITIES=ON\" to configure the tests.")
endif()