-
Notifications
You must be signed in to change notification settings - Fork 292
/
CMakeLists.txt
135 lines (114 loc) · 3.39 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
cmake_minimum_required(VERSION 3.13)
# Allow CMake 3.13+ to override options when using FetchContent/add_subdirectory.
# option honors normal variables
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
# INTERFACE_LINK_LIBRARIES defines the link interface.
if (POLICY CMP0022)
cmake_policy (SET CMP0022 NEW)
endif()
# PICT version, build, and product info
set(PICT_VERSION_MAJOR 3 CACHE STRING "PICT major version")
set(PICT_VERSION_MINOR 7 CACHE STRING "PICT minor version")
set(PICT_VERSION_BUILD 4 CACHE STRING "PICT build version")
set(PICT_VERSION_SHORT "${PICT_VERSION_MAJOR}.${PICT_VERSION_MINOR}")
set(PICT_VERSION_FULL "${PICT_VERSION_SHORT}.${PICT_VERSION_BUILD}")
message(STATUS "PICT version ${PICT_VERSION_FULL}")
# Set project name and properties
project(
PICT
DESCRIPTION "Pairwise Independent Combinatorial Tool"
HOMEPAGE_URL "https://github.com/microsoft/pict"
LANGUAGES CXX
VERSION ${PICT_VERSION_FULL}
)
# Build configuration
option(PICT_RUN_TESTS_ENABLED "Enable running tests after build" ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(PICT_BUILD_OPTIONS PictBuildOptions)
add_library(${PICT_BUILD_OPTIONS}
INTERFACE
)
if (MSVC)
# Enable multi-threaded build with MSVC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
target_compile_options(${PICT_BUILD_OPTIONS}
INTERFACE
/W4 /WX
/wd4189 # DOUT(arg) has unused parameters. Suppressing the warning here.
)
target_compile_definitions(${PICT_BUILD_OPTIONS}
INTERFACE
UNICODE
WIN32_LEAN_AND_MEAN
)
else()
target_compile_options(${PICT_BUILD_OPTIONS}
INTERFACE
-fPIC # Position-independent code: necessary for static libraries that are linked in dynamic libraries
-pipe
-fno-omit-frame-pointer
-fvisibility=hidden # By default, hide symbols on ELF binaries
-g # add debug symbols for build pdb
-pedantic
-Wall
-Werror
$<$<CXX_COMPILER_ID:GNU>:-Wno-unused-but-set-variable>
-Wno-unused-variable
)
# AppleClang is not accepting -flto as linker option
if(NOT APPLE)
target_link_options(${PICT_BUILD_OPTIONS}
INTERFACE
$<IF:$<CONFIG:Debug>,,LINKER:-flto$<COMMA>-flto-partition=none> #Enable LTO
$<IF:$<CONFIG:Debug>,,LINKER:--no-undefined> # Have Linker error out if any symbols are undefined.
)
endif()
endif()
target_compile_definitions(${PICT_BUILD_OPTIONS}
INTERFACE
$<IF:$<CONFIG:Debug>,_DEBUG,NDEBUG>
)
add_subdirectory (api)
add_subdirectory (cli)
add_subdirectory (clidll)
if(PICT_RUN_TESTS_ENABLED)
enable_testing()
add_subdirectory(test)
endif()
if(WIN32)
add_subdirectory(api-usage)
add_subdirectory(clidll-usage)
endif()
if(WIN32)
set(CPACK_GENERATOR ZIP NUGET)
else()
set(CPACK_GENERATOR TGZ)
endif()
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES
\\.git/
build/
".*~$"
)
set(CPACK_VERBATIM_VARIABLES YES)
execute_process(
COMMAND git log --pretty=format:%H -n 1
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git log --pretty=format:%h -n 1
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_SHORT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CPACK_SOURCE_PACKAGE_FILE_NAME
${CMAKE_PROJECT_NAME}-${GIT_SHORT_COMMIT_HASH}
)
include(CPack)