This repository was archived by the owner on Jan 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
103 lines (87 loc) · 2.9 KB
/
CMakeLists.txt
File metadata and controls
103 lines (87 loc) · 2.9 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
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
cmake_minimum_required(VERSION 3.15)
project(bi VERSION 0.1)
# For single-configuration generators, set the default build type to Release
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting 'CMAKE_BUILD_TYPE' to 'Release'. Use "
"'-DCMAKE_BUILD_TYPE=Debug' for debug builds")
set(CMAKE_BUILD_TYPE Release)
endif()
# if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# message(STATUS "Clang detected")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
# endif()
add_library(bi_compiler_flags INTERFACE)
target_compile_features(bi_compiler_flags INTERFACE cxx_std_20)
set(gcc_like "$<COMPILE_LANG_AND_ID:C,CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
set(msvc "$<COMPILE_LANG_AND_ID:C,CXX,MSVC>")
target_compile_options(
bi_compiler_flags INTERFACE
"$<${gcc_like}:$<BUILD_INTERFACE:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>>"
"$<${msvc}:$<BUILD_INTERFACE:-W3>>"
)
add_library(bi_common_defs INTERFACE)
target_compile_definitions(
bi_common_defs INTERFACE
BI_API_EXPORTS
$<$<BOOL:${BI_FORCE_64_BIT}>:BI_FORCE_64_BIT>
$<$<BOOL:${BI_FORCE_32_BIT}>:BI_FORCE_32_BIT>
)
if (APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
elseif (UNIX)
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_TESTS "Build the tests" ON)
option(BI_FORCE_64_BIT "Force 64-bit digit type" OFF)
option(BI_FORCE_32_BIT "Force 32-bit digit type" OFF)
if(BI_FORCE_64_BIT AND BI_FORCE_32_BIT)
message(FATAL_ERROR "BI_FORCE_64_BIT and BI_FORCE_32_BIT cannot both be set.")
endif()
enable_testing()
add_subdirectory(src)
if (BUILD_TESTS)
add_subdirectory(test)
endif()
install(
DIRECTORY include/
DESTINATION include
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/bi-config.cmake"
INSTALL_DESTINATION "lib/cmake/bi"
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/bi-config_version.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY SameMajorVersion
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/bi-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/bi-config_version.cmake"
DESTINATION "lib/cmake/bi"
)
install(
TARGETS
bi_compiler_flags
bi_common_defs
EXPORT bi_targets
)
install(
EXPORT bi_targets
FILE bi-targets.cmake
NAMESPACE bi::
DESTINATION lib/cmake/bi
)
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
include(CPack)