Fix duplicate warning from Xcode

This commit is contained in:
Carles Fernandez 2024-04-12 18:15:33 +02:00
parent 7e79945529
commit 6fc04b34f2
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
7 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# SPDX-FileCopyrightText: 2011-2024 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
if(DEFINED __INCLUDED_XCODE_DELETE_DUPLICATES_CMAKE)
return()
endif()
set(__INCLUDED_XCODE_DELETE_DUPLICATES_CMAKE TRUE)
function(xcode_delete_duplicates target)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15.0.0")
# A bug in Xcode 15 adds duplicate flags to the linker. In addition, the
# `-warn_duplicate_libraries` is now enabled by default which may result
# in several 'duplicate libraries warning'.
# - https://gitlab.kitware.com/cmake/cmake/-/issues/25297 and
# - https://indiestack.com/2023/10/xcode-15-duplicate-library-linker-warnings/
target_link_options(${target} PUBLIC "LINKER:-no_warn_duplicate_libraries")
endif()
endif()
endfunction()

View File

@ -77,6 +77,9 @@ if(UNIX)
)
endif()
include(XcodeDeleteDuplicates)
xcode_delete_duplicates(volk_gnsssdr_profile)
if(ENABLE_STRIP)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
set_target_properties(volk_gnsssdr_profile
@ -106,6 +109,8 @@ if(UNIX)
)
endif()
xcode_delete_duplicates(volk_gnsssdr-config-info)
if(ENABLE_STRIP)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
set_target_properties(volk_gnsssdr-config-info

View File

@ -0,0 +1,23 @@
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# SPDX-FileCopyrightText: 2011-2024 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
if(DEFINED __INCLUDED_XCODE_DELETE_DUPLICATES_CMAKE)
return()
endif()
set(__INCLUDED_XCODE_DELETE_DUPLICATES_CMAKE TRUE)
function(xcode_delete_duplicates target)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15.0.0")
# A bug in Xcode 15 adds duplicate flags to the linker. In addition, the
# `-warn_duplicate_libraries` is now enabled by default which may result
# in several 'duplicate libraries warning'.
# - https://gitlab.kitware.com/cmake/cmake/-/issues/25297 and
# - https://indiestack.com/2023/10/xcode-15-duplicate-library-linker-warnings/
target_link_options(${target} PUBLIC "LINKER:-no_warn_duplicate_libraries")
endif()
endif()
endfunction()

View File

@ -4,6 +4,7 @@
# SPDX-FileCopyrightText: 2010-2021 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
include(XcodeDeleteDuplicates)
########################################################################
# header file detection
@ -595,6 +596,9 @@ if(NOT (ENABLE_STATIC_LIBS AND (CMAKE_GENERATOR STREQUAL Xcode)))
else()
target_link_libraries(volk_gnsssdr PUBLIC ${volk_gnsssdr_libraries})
endif()
xcode_delete_duplicates(volk_gnsssdr)
target_include_directories(volk_gnsssdr
PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
@ -676,6 +680,8 @@ if(ENABLE_STATIC_LIBS)
)
set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr)
xcode_delete_duplicates(volk_gnsssdr_static)
install(TARGETS volk_gnsssdr_static
EXPORT VOLK_GNSSSDR-export
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel"
@ -702,6 +708,9 @@ if(ENABLE_TESTING)
TARGET_DEPS volk_gnsssdr
)
endif()
xcode_delete_duplicates(volk_gnsssdr_test_all)
foreach(kernel ${h_files})
get_filename_component(kernel ${kernel} NAME)
string(REPLACE ".h" "" kernel ${kernel})

View File

@ -65,6 +65,9 @@ if(ENABLE_STRIP)
set_target_properties(gnss-sdr PROPERTIES LINK_FLAGS "-s")
endif()
include(XcodeDeleteDuplicates)
xcode_delete_duplicates(gnss-sdr)
if(ENABLE_CLANG_TIDY)
if(CLANG_TIDY_EXE)
set_target_properties(gnss-sdr

View File

@ -8,6 +8,8 @@
add_subdirectory(unit-tests/signal-processing-blocks/libs)
add_subdirectory(system-tests/libs)
include(XcodeDeleteDuplicates)
################################################################################
# Google Test - https://github.com/google/googletest
################################################################################
@ -645,6 +647,7 @@ if(ENABLE_UNIT_TESTING)
target_compile_definitions(run_tests PRIVATE -DGNSSTK_OLDER_THAN_9=1)
endif()
endif()
xcode_delete_duplicates(run_tests)
if(ENABLE_STRIP)
set_target_properties(run_tests PROPERTIES LINK_FLAGS "-s")
endif()
@ -823,6 +826,9 @@ function(add_system_test executable)
${LOCAL_INSTALL_BASE_DIR}/install/$<TARGET_FILE_NAME:${executable}>
)
endif()
xcode_delete_duplicates(${executable})
if(ENABLE_CLANG_TIDY)
if(CLANG_TIDY_EXE)
set_target_properties(${executable}
@ -937,6 +943,9 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA)
PRIVATE
${GNSSSDR_SOURCE_DIR}/src/algorithms/libs
)
xcode_delete_duplicates(flowgraph_test)
add_test(flowgraph_test flowgraph_test)
set_property(TEST flowgraph_test PROPERTY TIMEOUT 30)
@ -992,6 +1001,8 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA)
target_compile_definitions(gnss_block_test PRIVATE -DENABLE_FPGA=1)
endif()
xcode_delete_duplicates(gnss_block_test)
add_test(gnss_block_test gnss_block_test)
set_property(TEST gnss_block_test PROPERTY TIMEOUT 60)
@ -1029,6 +1040,8 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA)
algorithms_libs
)
xcode_delete_duplicates(gnuradio_block_test)
add_test(gnuradio_block_test gnuradio_block_test)
set_property(TEST gnuradio_block_test PROPERTY TIMEOUT 30)
@ -1063,6 +1076,8 @@ target_include_directories(matio_test
${GNSSSDR_SOURCE_DIR}/src/tests/common-files
)
xcode_delete_duplicates(matio_test)
add_test(matio_test matio_test)
set_property(TEST matio_test PROPERTY TIMEOUT 30)
@ -1112,6 +1127,8 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA)
)
endif()
xcode_delete_duplicates(acq_test)
add_test(acq_test acq_test)
if(USE_GENERIC_LAMBDAS)
@ -1208,6 +1225,8 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA)
)
endif()
xcode_delete_duplicates(trk_test)
add_test(trk_test trk_test)
set_property(TEST trk_test PROPERTY TIMEOUT 30)
@ -1239,6 +1258,8 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA)
core_receiver
)
xcode_delete_duplicates(control_thread_test)
add_test(control_thread_test control_thread_test)
set_property(TEST control_thread_test PROPERTY TIMEOUT 30)

View File

@ -102,6 +102,9 @@ if(PMT_USES_BOOST_ANY)
)
endif()
include(XcodeDeleteDuplicates)
xcode_delete_duplicates(front-end-cal)
if(ENABLE_STRIP)
set_target_properties(front-end-cal PROPERTIES LINK_FLAGS "-s")
endif()