forked from chfast/intx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
103 lines (79 loc) · 2.77 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
# intx: extended precision integer library.
# Copyright 2019 Pawel Bylica.
# Licensed under the Apache License, Version 2.0.
cmake_minimum_required(VERSION 3.16...3.25)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(CableCompilerSettings)
include(CMakeDependentOption)
set(INTX_DEPS_DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/download)
get_directory_property(has_parent PARENT_DIRECTORY)
if(NOT has_parent)
set(is_main_project TRUE)
endif()
option(INTX_INSTALL "Enable intx install target" ${is_main_project})
option(INTX_TESTING "Enable intx testing" ${is_main_project})
cmake_dependent_option(INTX_BENCHMARKING "Build intx with benchmark tools" ON "INTX_TESTING" OFF)
cmake_dependent_option(INTX_FUZZING "Build intx fuzzers" OFF "INTX_TESTING" OFF)
if(INTX_TESTING)
include(Hunter/init)
endif()
project(intx LANGUAGES CXX)
set(PROJECT_VERSION 0.10.0)
cable_configure_compiler(NO_STACK_PROTECTION)
if(INTX_FUZZING)
set(fuzzing_flags -fsanitize=fuzzer-no-link,undefined,address)
add_compile_options(${fuzzing_flags})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${fuzzing_flags}")
endif()
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(INTX_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
add_library(intx INTERFACE)
add_library(intx::intx ALIAS intx)
target_compile_features(intx INTERFACE cxx_std_20)
target_sources(intx INTERFACE $<BUILD_INTERFACE:${INTX_INCLUDE_DIR}/intx/intx.hpp>)
target_include_directories(intx INTERFACE $<BUILD_INTERFACE:${INTX_INCLUDE_DIR}>$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
if(INTX_TESTING)
enable_testing()
add_subdirectory(test)
endif()
if(INTX_INSTALL)
write_basic_package_version_file(intxConfigVersion.cmake COMPATIBILITY ExactVersion)
set(config_dir ${CMAKE_INSTALL_LIBDIR}/cmake/intx)
configure_package_config_file(
cmake/Config.cmake.in
intxConfig.cmake
INSTALL_DESTINATION ${config_dir}
)
install(
TARGETS intx
EXPORT intxTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
EXPORT intxTargets
NAMESPACE intx::
DESTINATION ${config_dir}
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/intxConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/intxConfigVersion.cmake
DESTINATION ${config_dir}
)
install(
DIRECTORY
${INTX_INCLUDE_DIR}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if(WIN32)
set(CPACK_GENERATOR ZIP)
else()
set(CPACK_GENERATOR TGZ)
endif()
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION})
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE)
include(CPack)
endif()