From 8c9c5c5b998bcf526e7564a62feb2c2c1f3067aa Mon Sep 17 00:00:00 2001 From: binary1248 Date: Tue, 3 Oct 2023 05:52:40 +0200 Subject: [PATCH] Added missing SFML_USE_STATIC_STD_LIBS checks to CMake configuration. --- cmake/Macros.cmake | 27 ++++++++++++++------------- test/CMakeLists.txt | 5 +++++ test/install/CMakeLists.txt | 4 ++++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 5890c298c..7c2a0a93f 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -20,11 +20,17 @@ endmacro() # example: sfml_set_stdlib(sfml-system) function(sfml_set_stdlib target) # for gcc on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled - if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC) - if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM) - target_link_libraries(${target} PRIVATE "-static-libgcc" "-static-libstdc++") - elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM) - target_link_libraries(${target} PRIVATE "-shared-libgcc" "-shared-libstdc++") + if(SFML_OS_WINDOWS) + if(SFML_COMPILER_GCC) + if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM) + target_link_libraries(${target} PRIVATE "-static-libgcc" "-static-libstdc++") + elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM) + target_link_libraries(${target} PRIVATE "-shared-libgcc" "-shared-libstdc++") + endif() + elseif(SFML_COMPILER_MSVC) + if(SFML_USE_STATIC_STD_LIBS) + set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() endif() endif() endfunction() @@ -134,10 +140,6 @@ macro(sfml_add_library module) set_target_properties(${target} PROPERTIES RELEASE_POSTFIX -s) set_target_properties(${target} PROPERTIES MINSIZEREL_POSTFIX -s) set_target_properties(${target} PROPERTIES RELWITHDEBINFO_POSTFIX -s) - - if(SFML_USE_STATIC_STD_LIBS) - set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() endif() # set the version and soversion of the target (for compatible systems -- mostly Linuxes) @@ -289,10 +291,6 @@ macro(sfml_add_example target) add_executable(${target} ${target_input}) endif() - if(SFML_USE_STATIC_STD_LIBS) - set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() - # enable precompiled headers if (SFML_ENABLE_PCH) message(VERBOSE "enabling PCH for SFML example '${target}'") @@ -349,6 +347,9 @@ function(sfml_add_test target SOURCES DEPENDS) # set the target's folder (for IDEs that support it, e.g. Visual Studio) set_target_properties(${target} PROPERTIES FOLDER "Tests") + # set the target flags to use the appropriate C++ standard library + sfml_set_stdlib(${target}) + # link the target to its SFML dependencies target_link_libraries(${target} PRIVATE ${DEPENDS} sfml-test-main) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0f9ba8e65..04f87f056 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -33,6 +33,11 @@ target_include_directories(sfml-test-main PUBLIC TestUtilities) target_link_libraries(sfml-test-main PUBLIC SFML::System Catch2::Catch2WithMain) set_target_warnings(sfml-test-main) +# set the target flags to use the appropriate C++ standard library +sfml_set_stdlib(Catch2) +sfml_set_stdlib(Catch2WithMain) +sfml_set_stdlib(sfml-test-main) + sfml_set_option(SFML_RUN_DISPLAY_TESTS ON BOOL "TRUE to run tests that require a display, FALSE to ignore it") if(SFML_RUN_DISPLAY_TESTS) target_compile_definitions(sfml-test-main PRIVATE SFML_RUN_DISPLAY_TESTS) diff --git a/test/install/CMakeLists.txt b/test/install/CMakeLists.txt index da6f70296..610fbda3a 100644 --- a/test/install/CMakeLists.txt +++ b/test/install/CMakeLists.txt @@ -18,3 +18,7 @@ endif() add_executable(test-sfml-install Install.cpp) target_link_libraries(test-sfml-install PRIVATE SFML::Graphics SFML::Network SFML::Audio) + +if(SFML_USE_STATIC_STD_LIBS) + set_target_properties(test-sfml-install PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif()