This repository has been archived by the owner on Nov 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
152 lines (126 loc) · 5.16 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# TODO: Use PCHs (`target_precompile_headers`).
cmake_minimum_required(VERSION 3.24.0 FATAL_ERROR)
cmake_policy(SET CMP0144 NEW)
include(CMakeDependentOption)
include(CheckIPOSupported)
include(FindBoost)
add_compile_definitions(BUILDING_SUPDEF=1)
add_compile_options(-ftrack-macro-expansion=0)
if ($ENV{SUPDEF_CREATOR_MODE})
set(SUPDEF_CREATOR_MODE $ENV{SUPDEF_CREATOR_MODE})
else()
set(SUPDEF_CREATOR_MODE OFF)
endif()
if (DEFINED ENV{SUPDEF_CREATOR})
set(SUPDEF_CREATOR $ENV{SUPDEF_CREATOR})
else()
set(SUPDEF_CREATOR "Unknown")
endif()
if (${SUPDEF_CREATOR_MODE} STREQUAL "ON")
message(STATUS "Maintainer mode enabled")
set(COMP_TOOLCHAIN_DIR "/usr/local/bin/")
set(BINUTILS_TOOLCHAIN_DIR "/toolchains/native/x64/custom-")
set(CMAKE_C_COMPILER "${COMP_TOOLCHAIN_DIR}gcc")
set(CMAKE_CXX_COMPILER "${COMP_TOOLCHAIN_DIR}g++")
#set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_AR "${COMP_TOOLCHAIN_DIR}gcc-ar")
set(CMAKE_RANLIB "${COMP_TOOLCHAIN_DIR}gcc-ranlib")
set(CMAKE_LINKER "${BINUTILS_TOOLCHAIN_DIR}ld")
set(CMAKE_NM "${COMP_TOOLCHAIN_DIR}gcc-nm")
set(CMAKE_OBJCOPY "${BINUTILS_TOOLCHAIN_DIR}objcopy")
set(CMAKE_OBJDUMP "${BINUTILS_TOOLCHAIN_DIR}objdump")
set(CMAKE_STRIP "${BINUTILS_TOOLCHAIN_DIR}strip")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
message(STATUS "C compiler: ${CMAKE_C_COMPILER}")
message(STATUS "C++ compiler: ${CMAKE_CXX_COMPILER}")
set(BOOST_VER_NEEDED "1.83.0")
else ()
set(BOOST_VER_NEEDED "1.72.0")
endif()
if (NOT CMAKE_BUILD_TYPE)
# Release with debug info
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
message(STATUS "Build type not specified: defaulting to ${CMAKE_BUILD_TYPE}")
else()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_DEBUG_PYTHON OFF)
if (${SUPDEF_CREATOR_MODE} STREQUAL "ON")
set(BOOST_ROOT "/usr/local/")
set(Boost_USE_STATIC_RUNTIME ON)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(Boost_USE_DEBUG_LIBS ON)
set(Boost_USE_RELEASE_LIBS OFF)
set(Boost_USE_DEBUG_RUNTIME ON)
else()
set(Boost_USE_DEBUG_LIBS OFF)
set(Boost_USE_RELEASE_LIBS ON)
set(Boost_USE_DEBUG_RUNTIME OFF)
endif()
else()
set(Boost_USE_DEBUG_RUNTIME OFF)
set(Boost_USE_DEBUG_LIBS OFF)
set(Boost_USE_RELEASE_LIBS ON)
endif()
set(PROJVER_MAJ 0)
set(PROJVER_MIN 1)
set(PROJVER_PATCH 0)
set(EXTERNAL_TOOL_NAME "supdef")
set(CMAKE_CXX_STANDARD 23)
#set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(SupDef VERSION ${PROJVER_MAJ}.${PROJVER_MIN}.${PROJVER_PATCH} LANGUAGES CXX C)
set(SUPDEF_PROJECT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/sup_def/cmake")
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_NOT_SUPPORTED LANGUAGES CXX)
option(SUPDEF_BUILD_LIB_ONLY "Build only the common library" OFF)
option(SUPDEF_BUILD_TESTS "Build tests" OFF)
if (IPO_SUPPORTED AND ("${CMAKE_BUILD_TYPE}" STREQUAL "Release"))
option(SUPDEF_ENABLE_LTO "Enable link-time optimization" ON)
message(STATUS "Link-time optimization is supported by the compiler")
elseif (IPO_SUPPORTED AND NOT (${CMAKE_BUILD_TYPE} STREQUAL "Release"))
option(SUPDEF_ENABLE_LTO "Enable link-time optimization" OFF)
message(WARNING "Link-time optimization is only supported in Release mode")
else()
option(SUPDEF_ENABLE_LTO "Enable link-time optimization" OFF)
message(WARNING "Link-time optimization is not supported by the compiler: ${IPO_NOT_SUPPORTED}")
endif()
# SUPDEF_BUILD_EXTERNAL is only available if SUPDEF_BUILD_LIB_ONLY is OFF.
# Same goes for SUPDEF_BUILD_GCC_PLUGIN and SUPDEF_BUILD_CLANG_PLUGIN
cmake_dependent_option(SUPDEF_BUILD_EXTERNAL "Build external command-line tool" ON "NOT SUPDEF_BUILD_LIB_ONLY" OFF)
cmake_dependent_option(SUPDEF_BUILD_GCC_PLUGIN "Build GCC plugin" OFF "NOT SUPDEF_BUILD_LIB_ONLY" OFF)
cmake_dependent_option(SUPDEF_BUILD_CLANG_PLUGIN "Build Clang plugin" OFF "NOT SUPDEF_BUILD_LIB_ONLY" OFF)
option(SUPDEF_STD_STACKTRACE "Use standard library stacktrace" OFF)
cmake_dependent_option(SUPDEF_BOOST_STACKTRACE "Use Boost stacktrace" ON "NOT SUPDEF_STD_STACKTRACE" OFF)
if (SUPDEF_ENABLE_LTO AND IPO_SUPPORTED AND ("${CMAKE_BUILD_TYPE}" STREQUAL "Release"))
message(STATUS "Link-time optimization enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "Link-time optimization disabled")
endif()
if (SUPDEF_BUILD_LIB_ONLY)
message(STATUS "Building only the common library")
endif()
if (SUPDEF_BUILD_EXTERNAL)
message(STATUS "Building external command-line tool")
else()
message(STATUS "Not building external command-line tool")
endif()
if (SUPDEF_BUILD_GCC_PLUGIN)
message(STATUS "Building GCC plugin")
else()
message(STATUS "Not building GCC plugin")
endif()
if (SUPDEF_BUILD_CLANG_PLUGIN)
message(STATUS "Building Clang plugin")
else()
message(STATUS "Not building Clang plugin")
endif()
if (SUPDEF_BUILD_TESTS)
message(STATUS "Building tests")
else()
message(STATUS "Not building tests")
endif()
add_subdirectory("./sup_def")