Avoid setting CMAKE_* variables globally

Instead set their target-specific equivalents.

The POSITION_INDEPENDENT_CODE property isn't set because it already defaults to ON for shared libraries.
This commit is contained in:
Oliver Hamlet
2025-10-03 17:41:33 +01:00
parent 24e3f99d9e
commit 961642ad6e
2 changed files with 9 additions and 5 deletions
+5 -5
View File
@@ -19,10 +19,6 @@ option(RUN_CLANG_TIDY "Whether or not to run clang-tidy during build. Has no eff
option(LIBLOOT_BUILD_TESTS "Whether or not to build libloot's tests." ON)
option(LIBLOOT_INSTALL_DOCS "Whether or not to install libloot's docs (which need to be built separately)." ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
##############################
# External Projects
##############################
@@ -171,6 +167,10 @@ target_include_directories(loot PRIVATE ${LIBLOOT_INCLUDE_DIRS})
target_include_directories(loot SYSTEM PRIVATE
${LIBLOOT_COMMON_SYSTEM_INCLUDE_DIRS})
set_target_properties(loot PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_compile_definitions(loot PRIVATE UNICODE _UNICODE LOOT_EXPORT)
@@ -228,7 +228,7 @@ if(MSVC)
"/MP"
"/sdl"
"$<$<CONFIG:Debug>:/RTC1>")
target_link_options(loot PRIVATE "/LTCG")
target_link_options(loot PRIVATE "/INCREMENTAL:NO" "/LTCG")
endif()
##############################
+4
View File
@@ -89,6 +89,10 @@ target_include_directories(libloot_tests PRIVATE ${LIBLOOT_INCLUDE_DIRS})
target_include_directories(libloot_tests SYSTEM PRIVATE
${LIBLOOT_COMMON_SYSTEM_INCLUDE_DIRS})
set_target_properties(libloot_tests PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_compile_definitions(libloot_tests PRIVATE UNICODE _UNICODE)