From a13f01e15cf2d0b4c7a1bca6d0da30d73f16646d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 16 May 2024 09:25:40 +0200 Subject: [PATCH] No longer use CMAKE_BUILD_TYPE to allow configuration choice at build time. --- src/CMakeLists.txt | 37 ++++++++++++++----------------------- tester/CMakeLists.txt | 4 ---- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a35548..e70149b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,30 +148,22 @@ if(WIN32) endif() target_compile_definitions(bctoolbox PRIVATE "BCTBX_EXPORTS") if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") # Fix error on 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker'' - get_target_property(BC_LINK_FLAGS bctoolbox LINK_FLAGS) - if(NOT BC_LINK_FLAGS) - set(BC_LINK_FLAGS "") - endif() - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - list(APPEND BC_LINK_FLAGS "/nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib") - else() - list(APPEND BC_LINK_FLAGS "/nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib") - endif() + list(APPEND BC_LINK_OPTIONS_DEBUG "/nodefaultlib:vccorlibd" "/nodefaultlib:msvcrtd" "vccorlibd.lib" "msvcrtd.lib") + list(APPEND BC_LINK_OPTIONS_RELEASE "/nodefaultlib:vccorlib" "/nodefaultlib:msvcrt" "vccorlib.lib" "msvcrt.lib") + target_link_options(bctoolbox PUBLIC "$,${BC_LINK_OPTIONS_DEBUG},${BC_LINK_OPTIONS_RELEASE}>") if(MSVC) set_target_properties(bctoolbox PROPERTIES VS_WINRT_COMPONENT TRUE) else() target_compile_options(bctoolbox PRIVATE -ZW -EHsc) endif() - set_target_properties(bctoolbox PROPERTIES LINK_FLAGS "${BC_LINK_FLAGS}") endif() endif() if(MSVC AND BUILD_SHARED_LIBS) - if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - install(FILES $ - DESTINATION ${CMAKE_INSTALL_BINDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - ) - endif() + install(FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + CONFIGURATIONS Debug RelWithDebInfo + ) endif() if(HAVE_LIBRT) @@ -214,23 +206,22 @@ if(ENABLE_TESTS_COMPONENT) set_target_properties(bctoolbox-tester PROPERTIES SOVERSION ${BCTOOLBOXTESTER_SO_VERSION}) endif() if(MSVC AND BUILD_SHARED_LIBS) - if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - install(FILES $ - DESTINATION ${CMAKE_INSTALL_BINDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - ) - endif() + install(FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + CONFIGURATIONS Debug RelWithDebInfo + ) endif() endif() if(APPLE AND IOS) add_library(bctoolbox-ios SHARED ${BCTOOLBOX_IOS_SOURCE_FILES}) target_link_libraries(bctoolbox-ios PRIVATE bctoolbox) + target_link_libraries(bctoolbox-ios PRIVATE "-framework UIKit" "-framework Foundation" "-framework CoreFoundation") set_target_properties(bctoolbox-ios PROPERTIES FRAMEWORK TRUE MACOSX_FRAMEWORK_IDENTIFIER org.linphone.bctoolbox-ios MACOSX_FRAMEWORK_INFO_PLIST "${PROJECT_SOURCE_DIR}/build/osx/Info.plist.in" - LINK_FLAGS "-framework UIKit -framework Foundation -framework CoreFoundation" ) endif() diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 7b84d07..d42cc98 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -40,12 +40,8 @@ if(ENABLE_UNIT_TESTS AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND NOT A list(APPEND TESTER_SOURCES ios_utils.cc) endif() - string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}") bc_apply_compile_flags(TESTER_SOURCE STRICT_OPTIONS_CPP STRICT_OPTIONS_C) add_executable(bctoolbox-tester-exe ${TESTER_SOURCES}) - if(NOT "${LINK_FLAGS_STR}" STREQUAL "") - set_target_properties(bctoolbox-tester-exe PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}") - endif() set_target_properties(bctoolbox-tester-exe PROPERTIES OUTPUT_NAME bctoolbox-tester) target_link_libraries(bctoolbox-tester-exe PRIVATE bctoolbox bctoolbox-tester) if(MbedTLS_FOUND)