Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit ce9560f

Browse files
Update CMakeLists.txt.
1 parent 19c8bf1 commit ce9560f

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

CMakeLists.txt

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.20)
22

33
project(OS2DSRules VERSION 0.0.1)
44

5-
set(CMAKE_CXX_STANDARD 20)
6-
set(CMAKE_CXX_STANDARD_REQUIRED True)
5+
# Detect available compiler on the host system.
6+
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
7+
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
78

9+
# Define C++ standard and compiler flags as a target library.
10+
add_library(os2dsrules_compiler_flags INTERFACE)
11+
target_compile_features(os2dsrules_compiler_flags INTERFACE cxx_std_20)
12+
# Build flags.
13+
target_compile_options(os2dsrules_compiler_flags INTERFACE
14+
"$<${gcc_like_cxx}:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused;-Wconversion;-Wpedantic;-Werror;-O3>"
15+
"$<${msvc_cxx}:-W3>"
16+
)
17+
18+
# Compile as a shared library.
819
add_library(os2dsrules SHARED lib/cpr-detector.cpp)
920
include_directories(os2dsrules include)
21+
target_link_libraries(os2dsrules PUBLIC os2dsrules_compiler_flags)
1022

11-
add_executable(test tests/test.cpp)
12-
target_include_directories(test PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR/include}")
13-
target_link_libraries(test os2dsrules)
23+
# Compile test suite.
24+
enable_testing()
25+
add_executable(testsuite tests/test.cpp)
26+
target_include_directories(testsuite PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR/include}")
27+
target_link_libraries(testsuite os2dsrules os2dsrules_compiler_flags)
28+
add_test(unittests testsuite)
1429

30+
# Install library on system.
31+
set(installable_libs os2dsrules os2dsrules_compiler_flags)
32+
install(TARGETS ${installable_libs} DESTINATION lib)
1533

34+
# Install header files on system.
35+
install(FILES include/os2dsrules.hpp include/cpr-detector.hpp DESTINATION include)

0 commit comments

Comments
 (0)