Skip to content

Commit

Permalink
No longer use CMAKE_BUILD_TYPE to allow configuration choice at build…
Browse files Browse the repository at this point in the history
… time.
  • Loading branch information
Ghislain MARY committed Jun 6, 2024
1 parent df78055 commit a13f01e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
37 changes: 14 additions & 23 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<IF:$<CONFIG:Debug>,${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 $<TARGET_PDB_FILE:bctoolbox>
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(FILES $<TARGET_PDB_FILE:bctoolbox>
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)
Expand Down Expand Up @@ -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 $<TARGET_PDB_FILE:bctoolbox-tester>
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(FILES $<TARGET_PDB_FILE:bctoolbox-tester>
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()

Expand Down
4 changes: 0 additions & 4 deletions tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a13f01e

Please sign in to comment.