-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
63 lines (51 loc) · 1.66 KB
/
CMakeLists.txt
File metadata and controls
63 lines (51 loc) · 1.66 KB
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
cmake_minimum_required(VERSION 3.28)
project(nbytes VERSION 0.1.4) # x-release-please-version
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
option(NBYTES_DEVELOPMENT_CHECKS "Enable development checks" OFF)
include(GNUInstallDirs)
include(FetchContent)
include(CTest)
option(NBYTES_ENABLE_TESTING "Enable testing" ${BUILD_TESTING})
add_subdirectory(src)
if (NBYTES_ENABLE_TESTING)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
URL_HASH SHA256=edd885a1ab32b6999515a880f669efadb80b3f880215f315985fa3f6eca7c4d3
FIND_PACKAGE_ARGS NAMES GTest
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
add_subdirectory(tests)
endif()
install(
FILES include/nbytes.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT nbytes_development
)
install(
TARGETS nbytes
EXPORT nbytes_targets
RUNTIME COMPONENT nbytes_runtime
LIBRARY COMPONENT nbytes_runtime
NAMELINK_COMPONENT nbytes_development
ARCHIVE COMPONENT nbytes_development
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
# Configure and install pkg-config file
configure_file(
"${PROJECT_SOURCE_DIR}/nbytes.pc.in"
"${PROJECT_BINARY_DIR}/nbytes.pc"
@ONLY
)
install(
FILES "${PROJECT_BINARY_DIR}/nbytes.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
COMPONENT nbytes_development
)