1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-25 20:02:40 +01:00

cmake: split cmake in interface + check interface

External projects do not need boost, glm or bullet specific options.
Though, we do want to enable sanitizers and coverage on them.
This commit is contained in:
Anonymous Maarten 2018-08-23 15:23:43 +02:00
parent c73e5d514d
commit 0e519d7295
2 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,10 @@
add_library(rw_interface INTERFACE)
add_library(openrw::interface ALIAS rw_interface)
add_library(rw_checks INTERFACE)
add_library(openrw::checks ALIAS rw_checks)
target_link_libraries(rw_interface INTERFACE rw_checks)
# target_compile_features(rw_interface INTERFACE cxx_std_14) is not supported by CMake 3.2
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 14)
@ -17,7 +21,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang
"$<IF:$<COMPILE_LANGUAGE:CXX>,-Wold-style-cast,>"
)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_definitions(rw_interface
target_compile_definitions(rw_checks
INTERFACE
"_SCL_SECURE_NO_WARNINGS"
"_CRT_SECURE_NO_WARNINGS"
@ -147,13 +151,13 @@ if(TEST_COVERAGE)
message("TEST_COVERAGE enabled. Enabling BUILD_TESTS.")
set(BUILD_TESTS "ON")
endif()
target_compile_options(rw_interface
target_compile_options(rw_checks
INTERFACE
"-O0"
"-fprofile-arcs"
"-ftest-coverage"
)
target_link_libraries(rw_interface
target_link_libraries(rw_checks
INTERFACE
gcov
)
@ -162,20 +166,20 @@ endif()
foreach(SAN ${ENABLE_SANITIZERS})
if(SAN STREQUAL "address")
message(STATUS "Address sanitizer enabled.")
target_compile_options(rw_interface INTERFACE "-fsanitize=address")
target_link_libraries(rw_interface INTERFACE "-fsanitize=address")
target_compile_options(rw_checks INTERFACE "-fsanitize=address")
target_link_libraries(rw_checks INTERFACE "-fsanitize=address")
elseif(SAN STREQUAL "leak")
message(STATUS "Leak sanitizer enabled.")
target_compile_options(rw_interface INTERFACE "-fsanitize=leak")
target_link_libraries(rw_interface INTERFACE "-fsanitize=leak")
target_compile_options(rw_checks INTERFACE "-fsanitize=leak")
target_link_libraries(rw_checks INTERFACE "-fsanitize=leak")
elseif(SAN STREQUAL "thread")
message(STATUS "Thread sanitizer enabled.")
target_compile_options(rw_interface INTERFACE "-fsanitize=thread")
target_link_libraries(rw_interface INTERFACE "-fsanitize=thread")
target_compile_options(rw_checks INTERFACE "-fsanitize=thread")
target_link_libraries(rw_checks INTERFACE "-fsanitize=thread")
elseif(SAN STREQUAL "undefined")
message(STATUS "Undefined behaviour sanitizer enabled.")
target_compile_options(rw_interface INTERFACE "-fsanitize=undefined")
target_link_libraries(rw_interface INTERFACE "-fsanitize=undefined")
target_compile_options(rw_checks INTERFACE "-fsanitize=undefined")
target_link_libraries(rw_checks INTERFACE "-fsanitize=undefined")
else()
message(FATAL_ERROR "Illegal sanitizer: ${SAN}")
endif()

View File

@ -18,6 +18,7 @@ find_package(Threads REQUIRED)
target_link_libraries(microprofile
PUBLIC
Threads::Threads
openrw::checks
)
add_library(microprofile::microprofile ALIAS microprofile)