forked from daormar/thot
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
126 lines (102 loc) · 3.11 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 OLD)
endif()
if(POLICY CMP0127)
set(CMAKE_POLICY_DEFAULT_CMP0127 OLD)
endif()
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
project(Thot VERSION 3.4.6 LANGUAGES CXX C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(OpenMP REQUIRED)
include(CheckSymbolExists)
check_symbol_exists(getdelim "stdio.h" HAVE_GETDELIM)
if(HAVE_GETDELIM)
add_compile_definitions(THOT_HAVE_GETDELIM)
endif()
check_symbol_exists(getline "stdio.h" HAVE_GETLINE)
if(HAVE_GETLINE)
add_compile_definitions(THOT_HAVE_GETLINE)
endif()
include(CheckTypeSize)
check_type_size(ssize_t SSIZE_T)
if(HAVE_SSIZE_T)
add_compile_definitions(THOT_HAVE_SSIZE_T)
endif()
include(CheckIncludeFiles)
check_include_files("sys/time.h;time.h" TIME_WITH_SYS_TIME)
if(TIME_WITH_SYS_TIME)
add_compile_definitions(THOT_TIME_WITH_SYS_TIME)
else()
check_include_files("sys/time.h" HAVE_SYS_TIME_H)
if(HAVE_SYS_TIME_H)
add_compile_definitions(THOT_HAVE_SYS_TIME_H)
endif()
endif()
option(USE_GMP, "Use GMP library")
if(USE_GMP)
find_package(GMP)
if(GMP_FOUND)
add_compile_definitions(THOT_HAVE_GMP)
include_directories(${GMP_INCLUDE_DIRS})
endif()
endif()
option(BUILD_SHARED_LIBRARY "Build shared library" ON)
option(BUILD_PYTHON_MODULE "Build Python module" ON)
option(BUILD_TESTS "Build unit tests" ON)
if(WIN32)
add_compile_options(/D_ITERATOR_DEBUG_LEVEL=0)
endif()
if(APPLE)
add_compile_options(-mmacosx-version-min=10.9 -Werror=partial-availability)
add_link_options(-mmacosx-version-min=10.9 -Wl,-no_weak_imports)
endif()
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.5)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
endif()
include(FetchContent)
FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG yaml-cpp-0.7.0
)
set(YAML_CPP_BUILD_TESTS OFF)
set(YAML_CPP_BUILD_TOOLS OFF)
FetchContent_MakeAvailable(yaml-cpp)
if(UNIX)
target_compile_options(yaml-cpp PRIVATE -Wno-effc++)
endif()
if(APPLE)
target_compile_options(yaml-cpp PRIVATE -Wno-shadow)
endif()
if(BUILD_PYTHON_MODULE)
FetchContent_Declare(
pybind11
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.10.3.zip
)
FetchContent_MakeAvailable(pybind11)
endif()
if(UNIX)
add_compile_options(-Wall -Werror)
endif()
if(WIN32)
add_compile_options(/WX)
add_link_options(/WX)
endif()
add_subdirectory(src)
if(BUILD_TESTS)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f54a28552929.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_subdirectory(tests)
endif()