1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

cmake: only set C and C++ standard for "core targets"

core targets = developed by us
This commit is contained in:
Anonymous Maarten 2018-11-27 19:56:25 +01:00
parent 35731f2031
commit 58c0dcd8ce
8 changed files with 38 additions and 20 deletions

View File

@ -5,11 +5,6 @@ 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 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(rw_interface
INTERFACE
@ -189,7 +184,13 @@ endforeach()
function(openrw_target_apply_options)
set(IWYU_MAPPING "${PROJECT_SOURCE_DIR}/openrw_iwyu.imp")
cmake_parse_arguments("ORW" "INSTALL;INSTALL_PDB;COVERAGE" "TARGET" "COVERAGE_EXCEPT" ${ARGN})
cmake_parse_arguments("ORW" "CORE;INSTALL;INSTALL_PDB;COVERAGE" "TARGET" "COVERAGE_EXCEPT" ${ARGN})
if(TEST_COVERAGE AND ORW_COVERAGE)
coverage_add_target("${ORW_TARGET}" EXCEPT ${ORW_COVERAGE_EXCEPT})
endif()
if(ORW_CORE)
if(CHECK_IWYU)
iwyu_check(TARGET "${ORW_TARGET}"
EXTRA_OPTS
@ -197,9 +198,13 @@ function(openrw_target_apply_options)
)
endif()
if(TEST_COVERAGE AND ORW_COVERAGE)
coverage_add_target("${ORW_TARGET}" EXCEPT ${ORW_COVERAGE_EXCEPT})
endif()
set_target_properties("${ORW_TARGET}"
PROPERTIES
CXX_EXTENSIONS OFF
CXX_STANDARD 17
C_EXTENSIONS OFF
C_STANDARD 11
)
if(CHECK_CLANGTIDY)
clang_tidy_check_target(
@ -209,6 +214,7 @@ function(openrw_target_apply_options)
CHECK_ALL
)
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set_property(

View File

@ -25,4 +25,10 @@ openrw_target_apply_options(
TARGET microprofile
)
set_target_properties(microprofile
PROPERTIES
CXX_EXTENSIONS OFF
CXX_STANDARD 11
)
add_library(microprofile::microprofile ALIAS microprofile)

View File

@ -1,4 +1,3 @@
add_library(rwcore
# GL stuff is only here temporarily, hoping to move it back to rwengine
gl/gl_core_3_3.c
@ -67,6 +66,7 @@ target_link_libraries(rwcore
)
openrw_target_apply_options(TARGET rwcore
CORE
COVERAGE
COVERAGE_EXCEPT gl/gl_core_3_3.c gl/gl_core_3_3.h
)

View File

@ -169,6 +169,7 @@ target_include_directories(rwengine
)
openrw_target_apply_options(TARGET rwengine
CORE
COVERAGE
)

View File

@ -46,6 +46,7 @@ add_library(librwgame STATIC
openrw_target_apply_options(
TARGET librwgame
CORE
COVERAGE
)
@ -78,6 +79,7 @@ target_link_libraries(rwgame
openrw_target_apply_options(
TARGET rwgame
CORE
COVERAGE
INSTALL INSTALL_PDB
)

View File

@ -13,6 +13,7 @@ target_link_libraries(rwfontmap
openrw_target_apply_options(
TARGET rwfontmap
CORE
COVERAGE
INSTALL INSTALL_PDB
)

View File

@ -56,6 +56,7 @@ target_link_libraries(rwviewer
openrw_target_apply_options(
TARGET rwviewer
CORE
COVERAGE
INSTALL INSTALL_PDB
)

View File

@ -72,6 +72,7 @@ target_link_libraries(rwtests
openrw_target_apply_options(
TARGET rwtests
CORE
COVERAGE
INSTALL INSTALL_PDB
)