forked from sandialabs/maskman
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
144 lines (120 loc) · 4.77 KB
/
Copy pathCMakeLists.txt
File metadata and controls
144 lines (120 loc) · 4.77 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
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
# Copyright (c) 2022, Sandia National Laboratories
# All rights reserved.
cmake_minimum_required(VERSION 3.19)
set(INSTALL_NAME "default" CACHE STRING "This is the installation name to organize multiple builds side-by-side.")
# set the project name
project(maskman VERSION 1.0.3 LANGUAGES C)
# turn on CTest
include(CTest)
enable_testing()
# so packages can find artifacts
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# create compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# add compile-time application types
# build app
option(Maskman_Application "Build Maskman Application" ON)
# build documentation
option(Maskman_Documentation "Build Maskman Documentation" OFF)
# maximum buffer size for methods that may need it
set(Maskman_Buffer_Size_Bits 2048 CACHE STRING "Maskman Buffer Size (bits)")
# automatically set GNU-based code coverage to be off
option(GNU_COVERAGE "GNU Coverage" OFF)
# automatically set LLVM-based code coverage to be off
option(LLVM_COVERAGE "LLVM Coverage" OFF)
# automatically set flags for GNU Address Sanitizer
option(GNU_ASAN "GNU Address Sanitizer" OFF)
# automatically set flags for LLVM Address Sanitizer
option(LLVM_ASAN "LLVM Address Sanitizer" OFF)
# automatically set flags for LLVM Clang Tidy Static Analyzer
option(LLVM_CLANG_TIDY "LLVM Clang Tidy Static Analyzer" OFF)
# automatically set flags to turn on pedantic warnings
option(WARNING "Increase warnings and treat them as errors" OFF)
if(WARNING)
add_compile_options(-Wall -Wextra -Wpedantic)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
endif(WARNING)
if(LLVM_COVERAGE)
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
add_link_options(-fprofile-instr-generate -fcoverage-mapping)
endif(LLVM_COVERAGE)
if(GNU_COVERAGE)
add_compile_options(--coverage -fprofile-arcs -ftest-coverage)
add_link_options(--coverage -lgcov)
endif(GNU_COVERAGE)
if(GNU_ASAN)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer )
add_link_options(-fsanitize=address)
if(UNIX AND NOT APPLE)
add_link_options(-static-libasan)
endif()
endif(GNU_ASAN)
if(LLVM_ASAN)
# add_compile_options(-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-ignorelist=${CMAKE_CURRENT_SOURCE_DIR}/test/asan/llvm_asan_ignorelist.txt)
# add_compile_options(-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer )
add_link_options(-fsanitize=address)
endif(LLVM_ASAN)
# add projects
if(Maskman_Application)
add_subdirectory(libKillist)
add_subdirectory(libMaskman)
add_subdirectory(methodLUIS)
add_subdirectory(methodSimpleSTDOUT)
add_subdirectory(appMaskman)
endif(Maskman_Application)
if(Maskman_Documentation)
add_subdirectory(doc)
endif(Maskman_Documentation)
# manage CMake export
if(Maskman_Application)
set(cmakeModulesDir cmake)
set(Maskman_Application_Architecture_Display ${CMAKE_HOST_SYSTEM_PROCESSOR})
if(COSMOPOLITAN)
set(Maskman_Application_Architecture_Display ape)
endif(COSMOPOLITAN)
install(
EXPORT MaskmanTargets
FILE MaskmanTargets.cmake
NAMESPACE Maskman::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Maskman
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/MaskmanConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/MaskmanConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Maskman"
PATH_VARS cmakeModulesDir
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/MaskmanConfigVersion.cmake"
VERSION "${maskman_VERSION_MAJOR}.${maskman_VERSION_MINOR}.${maskman_VERSION_PATCH}"
COMPATIBILITY AnyNewerVersion
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/MaskmanConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/MaskmanConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Maskman"
)
export(
EXPORT MaskmanTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/MaskmanTargets.cmake"
)
# use CPack for creating packages
get_filename_component(PACK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}"
REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME maskman)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "${maskman_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${maskman_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${maskman_VERSION_PATCH}")
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_PACKAGE_DIRECTORY ${PACK_INSTALL_DIR}/package)
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-v${maskman_VERSION}-${CMAKE_SYSTEM_NAME}-${Maskman_Application_Architecture_Display})
include(CPack)
endif(Maskman_Application)