Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeExternals/ITK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
GIT_TAG ${revision_tag})
endif()

# On macOS, Apple's linker warns about duplicate -lm entries that arise from
# ITK's transitive dependency chains. The duplicates are harmless (the linker
# deduplicates them) but produce ~70 warnings per build. Suppress them at the
# linker level since the fix belongs upstream in ITK's exported targets.
set(_itk_extra_linker_flags)
if(APPLE)
set(_itk_extra_linker_flags
-DCMAKE_SHARED_LINKER_FLAGS:STRING=-Wl,-no_warn_duplicate_libraries
-DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,-no_warn_duplicate_libraries
-DCMAKE_MODULE_LINKER_FLAGS:STRING=-Wl,-no_warn_duplicate_libraries
)
endif()

ExternalProject_Add(${proj}
${${proj}_EXTERNAL_PROJECT_ARGS}
SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
Expand All @@ -59,6 +72,7 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
INSTALL_COMMAND ""
CMAKE_CACHE_ARGS
${ep_common_cache_args}
${_itk_extra_linker_flags}
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=ON
-DITK_LEGACY_REMOVE:BOOL=ON
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,17 @@ set(CMAKE_C_FLAGS ${CTK_C_FLAGS} CACHE STRING "CMake CXX Flags" FORCE)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT} ${CTK_EXE_LINKER_FLAGS}" CACHE STRING "Flags used when linking executables" FORCE)

# On macOS, Apple's linker warns about duplicate -lm entries inherited from
# external dependencies (notably ITK) via transitive target_link_libraries
# chains. The duplicates are harmless but produce spurious warnings.
if(APPLE)
foreach(_flag_var CMAKE_SHARED_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)
if(NOT "${${_flag_var}}" MATCHES "no_warn_duplicate_libraries")
set(${_flag_var} "${${_flag_var}} -Wl,-no_warn_duplicate_libraries" CACHE STRING "" FORCE)
endif()
endforeach()
endif()

#-----------------------------------------------------------------------------
# Set the header template which defines custom export/import macros
# for shared libraries
Expand Down
Loading