-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
99 lines (81 loc) · 3.71 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
cmake_minimum_required(VERSION 3.16)
project(
libvsync
LANGUAGES C
VERSION 4.0.2
DESCRIPTION
"Verified library of atomics, synchronization primitives and concurrent data structures"
)
option(LIBVSYNC_ADDRESS_SANITIZER "Compile with -fsanitize=address" "off")
option(LIBVSYNC_CODECHECK_BINSCOPE "Compile with necessary flags for binscope"
"off")
include(GNUInstallDirs)
include(cmake/export.cmake)
include(CheckSymbolExists)
add_library(vsync INTERFACE)
target_include_directories(
vsync INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
install(DIRECTORY include/vsync DESTINATION include)
install(FILES vmm/vmm.cat DESTINATION share/vsync)
install(TARGETS vsync EXPORT ${PROJECT_TARGETS})
# ##############################################################################
# Check for memset_s memcpy_s existence
# ##############################################################################
check_symbol_exists(memset_s "string.h" VSYNC_MEMSET_S_EXISTS)
if(VSYNC_MEMSET_S_EXISTS)
target_compile_definitions(vsync INTERFACE "VSYNC_MEMSET_S_EXISTS")
endif()
check_symbol_exists(memcpy_s "string.h" VSYNC_MEMCPY_S_EXISTS)
if(VSYNC_MEMCPY_S_EXISTS)
target_compile_definitions(vsync INTERFACE "VSYNC_MEMCPY_S_EXISTS")
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# ##########################################################################
# Important Config must be set
# ##########################################################################
set(ATOMICS_DIR ${PROJECT_SOURCE_DIR})
# ##########################################################################
# Commands
# ##########################################################################
set(CMAKE_FMT_CMD ${PROJECT_SOURCE_DIR}/scripts/cmake-format.sh
${CMAKE_SOURCE_DIR})
set(CMAKE_STYLE_FILE ${PROJECT_SOURCE_DIR}/.cmake-format)
add_custom_target(cmake-format-apply COMMAND env STYLE=${CMAKE_STYLE_FILE}
SILENT=true ${CMAKE_FMT_CMD})
set(CLANG_FMT_CMD ${PROJECT_SOURCE_DIR}/scripts/clang-format.sh
${CMAKE_SOURCE_DIR})
set(CLANG_STYLE_FILE ${PROJECT_SOURCE_DIR}/.clang-format)
add_custom_target(clang-format-apply COMMAND env STYLE=${CLANG_STYLE_FILE}
SILENT=true ${CLANG_FMT_CMD})
add_custom_target(
sanitize-vsync
COMMAND ${PROJECT_SOURCE_DIR}/scripts/sanitize.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
add_custom_target(diff-check COMMAND git --no-pager diff --exit-code)
add_dependencies(clang-format-apply sanitize-vsync)
set(LIBVSYNC_OPEN_DISTRO_TESTING "on")
enable_testing()
include(CTest)
include(ProcessorCount)
include(${CMAKE_SOURCE_DIR}/cmake/v_add_test.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/check.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/lotto_test.cmake)
add_subdirectory(template)
add_subdirectory(test)
add_subdirectory(verify)
add_subdirectory(tmplr)
add_subdirectory(svcomp)
if(LIBVSYNC_ADDRESS_SANITIZER)
target_compile_options(vsync INTERFACE -fsanitize=address)
target_compile_definitions(vsync INTERFACE VSYNC_ADDRESS_SANITIZER)
target_link_options(vsync INTERFACE -fsanitize=address)
endif()
if(LIBVSYNC_CODECHECK_BINSCOPE)
target_compile_definitions(vsync INTERFACE _FORTIFY_SOURCE=2)
target_compile_options(
vsync INTERFACE -fstack-protector-strong -fstack-protector-all
-fPIE -fPIC -O2)
target_link_options(vsync INTERFACE -s -pie -Wl,-z,relro,-z,now)
endif()
endif()