-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
50 lines (37 loc) · 1.32 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
cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
project(LockTest
VERSION 2024.1
DESCRIPTION "Xiyou Linux Group LockTest Task"
LANGUAGES C CXX)
# Compilre setup
if(NOT DEFINED LOCK_SANITIZER)
set(LOCK_SANITIZER address)
endif()
# Find GTest library
find_package(GTest REQUIRED)
if(NOT GTest_FOUND)
include(gtest)
else()
message(STATUS "GTest library found.")
endif()
message(STATUS "${LOCK_SANITIZER} sanitizer will be enabled.")
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER_ID}")
# Compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -fsanitize=${LOCK_SANITIZER} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# Output directory.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Includes.
set(LOCK_SRC_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/include)
include_directories(${LOCK_SRC_INCLUDE_DIR})
include_directories(BEFORE src)
enable_testing()
# Other CMake modules
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
add_subdirectory(src)
add_subdirectory(test)