-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
53 lines (38 loc) · 1.95 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
cmake_minimum_required(VERSION 3.21)
project(small_unique_ptr VERSION 0.1 LANGUAGES CXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build")
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo)$")
message(WARNING "The specified build type [${CMAKE_BUILD_TYPE}] is not recognized. Defaulting to Release.")
set(CMAKE_BUILD_TYPE "Release")
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -permissive- -W4 -WX -wd4324 -diagnostics:caret")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror -pedantic-errors -g")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
endif()
endif()
if(CMAKE_BUILD_TYPE MATCHES "(Release|RelWithDebInfo)")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
add_library(small_unique_ptr INTERFACE)
target_include_directories(small_unique_ptr SYSTEM INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_compile_features(small_unique_ptr INTERFACE "cxx_std_20")
target_compile_options(small_unique_ptr INTERFACE "$<$<CXX_COMPILER_ID:MSVC>:-Zc:preprocessor>" "$<$<CXX_COMPILER_ID:MSVC>:-Zc:__cplusplus>")
install(TARGETS small_unique_ptr EXPORT smp-config)
install(DIRECTORY "src/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.hpp")
install(EXPORT smp-config
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/smp"
NAMESPACE smp::)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/smp-config-version.cmake"
COMPATIBILITY "SameMajorVersion")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/smp-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/smp")
include(CTest)
enable_testing()
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/test")