Skip to content
Snippets Groups Projects
Commit 8324968b authored by Administrator's avatar Administrator
Browse files

Fix warnings about duplicate libs when linking

With XCode 15 and the Command Line Tools 15 the linker or the settings were
changed such that on macosx one gets a warning about duplicate libraries when
linking for several libraries and binaries.
The fix simply suppress the warning when using XCode or CLT with a version
equal or above 15.

fix
parent acc2b8d1
No related branches found
No related tags found
1 merge request!2069Fix warnings about duplicate libs when linking
Pipeline #33610 passed
......@@ -228,6 +228,44 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
# Suppress warnings about duplicate libraries in the call of the
# linker
# Need to check the XCode/CommandLineTools version since the
# warning is only available since XCode 15
execute_process(COMMAND xcode-select -p
OUTPUT_VARIABLE XCODE_PATH
)
string(FIND ${XCODE_PATH} "CommandLineTools" CLT_IS_AVAILABLE)
if(${CLT_IS_AVAILABLE} GREATER_EQUAL 0) # CommandLineTools are installed
execute_process(COMMAND pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
COMMAND grep version
OUTPUT_VARIABLE CLT_VERSION_INFO
)
string(REGEX MATCH ".*[ ]([0-9]+)\\.([0-9]+)\\.([0-9]+).*" _version_matches "${CLT_VERSION_INFO}")
set(CLT_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3})
if (${CLT_VERSION} VERSION_GREATER 15.0.0)
set(_suppress_linker_warnings TRUE)
message(STATUS "Found CLT ${CLT_VERSION} > 15.0.0. Suppress linker warnings on macosx")
endif()
else()
execute_process(COMMAND /usr/bin/xcodebuild -version
OUTPUT_VARIABLE XCODE_VERSION_INFO
)
string(REGEX MATCH "Xcode[ ]([0-9]+)\\.([0-9]+).*" _version_matches "${XCODE_VERSION_INFO}")
set(XCODE_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2})
if (${XCODE_VERSION} VERSION_GREATER 15.0.0)
set(_suppress_linker_warnings TRUE)
message(STATUS "Found XCode ${XCODE_VERSION} > 15.0.0. Suppress linker warnings on macosx")
endif()
endif()
if(_suppress_linker_warnings)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-no_warn_duplicate_libraries")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-no_warn_duplicate_libraries")
endif()
else (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Message("CXX Compiler: ${CMAKE_CXX_COMPILER}")
Message("CXX Compiler ABI: ${CMAKE_CXX_COMPILER_ABI}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment