This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
75 lines (64 loc) · 3.2 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
cmake_minimum_required(VERSION 3.20)
project(OS2DSRules VERSION 0.1.0)
# Detect available compiler on the host system.
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
# Build Configuration types.
set(CMAKE_CONFIGURATION_TYPES Debug Release)
# Define C++ standard and compiler flags as a target library.
add_library(os2dsrules_compiler_flags INTERFACE)
#target_compile_features(os2dsrules_compiler_flags INTERFACE cxx_std_20)
# Build flags.
target_compile_options(os2dsrules_compiler_flags INTERFACE
"$<${gcc_like_cxx}:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused;-Wconversion;-Wpedantic;-Werror;-std=c++20>"
"$<${msvc_cxx}:/W4;/WX;/std:c++20>"
)
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g -O0 -fsanitize=address,memory,thread,undefined -fsanitize-memory-track-origins")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3")
# Compile as a shared library.
file(GLOB SRC_FILES lib/*.cpp)
add_library(os2dsrules SHARED ${SRC_FILES})
include_directories(os2dsrules include)
target_link_libraries(os2dsrules PUBLIC os2dsrules_compiler_flags)
# Compile test suite.
enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
## CPRRule
add_executable(testcpr tests/testcpr.cpp)
target_include_directories(testcpr PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR/include}")
target_link_libraries(testcpr ${GTEST_LIBRARIES} os2dsrules os2dsrules_compiler_flags)
## Data Structures
add_executable(testds tests/testds.cpp)
target_include_directories(testds PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR/include}")
target_link_libraries(testds ${GTEST_LIBRARIES} os2dsrules os2dsrules_compiler_flags)
## NameRule
add_executable(testname tests/testname.cpp)
target_include_directories(testname PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR/include}")
target_link_libraries(testname ${GTEST_LIBRARIES} os2dsrules os2dsrules_compiler_flags)
## AddressRule
add_executable(testaddress tests/testaddress.cpp)
target_include_directories(testaddress PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR/include}")
target_link_libraries(testaddress ${GTEST_LIBRARIES} os2dsrules os2dsrules_compiler_flags)
## WordListRule
add_executable(testwordlist tests/testwordlist.cpp)
target_include_directories(testwordlist PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR/include}")
target_link_libraries(testwordlist ${GTEST_LIBRARIES} os2dsrules os2dsrules_compiler_flags)
## HealthRule
add_executable(testhealth tests/testhealth.cpp)
target_include_directories(testhealth PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR/include}")
target_link_libraries(testhealth ${GTEST_LIBRARIES} os2dsrules os2dsrules_compiler_flags)
add_test(cpr_unittests testcpr)
add_test(datastructures_unittests testds)
add_test(name_unittests testname)
add_test(address_unittests testaddress)
add_test(wordlist_unittests testwordlist)
add_test(health_unittests testhealth)
# Install library on system.
set(installable_libs os2dsrules os2dsrules_compiler_flags)
install(TARGETS ${installable_libs} DESTINATION lib)
# Install header files on system.
file(GLOB HEADER_FILES include/*.hpp)
install(FILES ${HEADER_FILES} DESTINATION include)
# CPack for making package distributions.
include(CPack)