mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-30 23:03:05 +00:00 
			
		
		
		
	Remove duplicate dependencies when linking
This commit is contained in:
		
							
								
								
									
										20
									
								
								cmake/Modules/RemoveDuplicates.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								cmake/Modules/RemoveDuplicates.cmake
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| # GNSS-SDR is a Global Navigation Satellite System software-defined receiver. | ||||
| # This file is part of GNSS-SDR. | ||||
| # | ||||
| # SPDX-FileCopyrightText: 2024 C. Fernandez-Prades cfernandez(at)cttc.es | ||||
| # SPDX-License-Identifier: BSD-3-Clause | ||||
|  | ||||
| # Usage: | ||||
| # include(RemoveDuplicates) | ||||
| # remove_duplicate_linked_libraries(my_target) | ||||
|  | ||||
| if(DEFINED __INCLUDED_REMOVE_DUPLICATE_LINKED_LIBRARIES_MODULE) | ||||
|     return() | ||||
| endif() | ||||
| set(__INCLUDED_REMOVE_DUPLICATE_LINKED_LIBRARIES_MODULE TRUE) | ||||
|  | ||||
| function(remove_duplicate_linked_libraries target_name) | ||||
|     get_target_property(LINK_LIBRARIES ${target_name} LINK_LIBRARIES) | ||||
|     list(REMOVE_DUPLICATES LINK_LIBRARIES) | ||||
|     set_target_properties(${target_name} PROPERTIES LINK_LIBRARIES "${LINK_LIBRARIES}") | ||||
| endfunction() | ||||
| @@ -60,6 +60,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
|         target_link_libraries(gnss-sdr PRIVATE "-lc++") | ||||
|     endif() | ||||
| endif() | ||||
| include(RemoveDuplicates) | ||||
| remove_duplicate_linked_libraries(gnss-sdr) | ||||
|  | ||||
| if(ENABLE_STRIP) | ||||
|     set_target_properties(gnss-sdr PROPERTIES LINK_FLAGS "-s") | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
|  | ||||
| add_subdirectory(unit-tests/signal-processing-blocks/libs) | ||||
| add_subdirectory(system-tests/libs) | ||||
| include(RemoveDuplicates) | ||||
|  | ||||
| ################################################################################ | ||||
| # Google Test - https://github.com/google/googletest | ||||
| @@ -645,6 +646,7 @@ if(ENABLE_UNIT_TESTING) | ||||
|             target_compile_definitions(run_tests PRIVATE -DGNSSTK_OLDER_THAN_9=1) | ||||
|         endif() | ||||
|     endif() | ||||
|     remove_duplicate_linked_libraries(run_tests) | ||||
|     if(ENABLE_STRIP) | ||||
|         set_target_properties(run_tests PROPERTIES LINK_FLAGS "-s") | ||||
|     endif() | ||||
| @@ -767,6 +769,7 @@ if(ENABLE_FPGA) | ||||
|     target_include_directories(gps_l1_ca_dll_pll_tracking_test_fpga | ||||
|         INTERFACE ${GNSSSDR_SOURCE_DIR}/src/tests/common-files | ||||
|     ) | ||||
|     remove_duplicate_linked_libraries(gps_l1_ca_dll_pll_tracking_test_fpga) | ||||
|     install(TARGETS gps_l1_ca_dll_pll_tracking_test_fpga | ||||
|         RUNTIME DESTINATION bin | ||||
|         COMPONENT "fpga-test" | ||||
| @@ -856,6 +859,7 @@ if(ENABLE_SYSTEM_TESTING) | ||||
|     ) | ||||
|     if(NOT ENABLE_PACKAGING) | ||||
|         add_system_test(ttff) | ||||
|         remove_duplicate_linked_libraries(ttff) | ||||
|     endif() | ||||
|  | ||||
|     if(ENABLE_SYSTEM_TESTING_EXTRA) | ||||
| @@ -877,6 +881,7 @@ if(ENABLE_SYSTEM_TESTING) | ||||
|                 ) | ||||
|             endif() | ||||
|         endif() | ||||
|         remove_duplicate_linked_libraries(position_test) | ||||
|         if(NOT GNSSSIMULATOR_FOUND OR ENABLE_GNSS_SIM_INSTALL) | ||||
|             if(NOT CMAKE_CROSSCOMPILING) | ||||
|                 add_dependencies(position_test gnss-sim) | ||||
| @@ -937,7 +942,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) | ||||
|         PRIVATE | ||||
|             ${GNSSSDR_SOURCE_DIR}/src/algorithms/libs | ||||
|     ) | ||||
|  | ||||
|     remove_duplicate_linked_libraries(flowgraph_test) | ||||
|     add_test(flowgraph_test flowgraph_test) | ||||
|  | ||||
|     set_property(TEST flowgraph_test PROPERTY TIMEOUT 30) | ||||
| @@ -992,7 +997,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) | ||||
|     if(ENABLE_FPGA) | ||||
|         target_compile_definitions(gnss_block_test PRIVATE -DENABLE_FPGA=1) | ||||
|     endif() | ||||
|  | ||||
|     remove_duplicate_linked_libraries(gnss_block_test) | ||||
|     add_test(gnss_block_test gnss_block_test) | ||||
|  | ||||
|     set_property(TEST gnss_block_test PROPERTY TIMEOUT 60) | ||||
| @@ -1029,7 +1034,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) | ||||
|             core_receiver | ||||
|             algorithms_libs | ||||
|     ) | ||||
|  | ||||
|     remove_duplicate_linked_libraries(gnuradio_block_test) | ||||
|     add_test(gnuradio_block_test gnuradio_block_test) | ||||
|  | ||||
|     set_property(TEST gnuradio_block_test PROPERTY TIMEOUT 30) | ||||
| @@ -1063,7 +1068,7 @@ target_include_directories(matio_test | ||||
|     INTERFACE | ||||
|         ${GNSSSDR_SOURCE_DIR}/src/tests/common-files | ||||
| ) | ||||
|  | ||||
| remove_duplicate_linked_libraries(matio_test) | ||||
| add_test(matio_test matio_test) | ||||
|  | ||||
| set_property(TEST matio_test PROPERTY TIMEOUT 30) | ||||
| @@ -1112,6 +1117,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) | ||||
|                 -DPMT_USES_BOOST_ANY=1 | ||||
|         ) | ||||
|     endif() | ||||
|     remove_duplicate_linked_libraries(acq_test) | ||||
|     add_test(acq_test acq_test) | ||||
|  | ||||
|     if(USE_GENERIC_LAMBDAS) | ||||
| @@ -1207,7 +1213,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) | ||||
|                 -DPMT_USES_BOOST_ANY=1 | ||||
|         ) | ||||
|     endif() | ||||
|  | ||||
|     remove_duplicate_linked_libraries(trk_test) | ||||
|     add_test(trk_test trk_test) | ||||
|  | ||||
|     set_property(TEST trk_test PROPERTY TIMEOUT 30) | ||||
| @@ -1238,7 +1244,7 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) | ||||
|             algorithms_libs | ||||
|             core_receiver | ||||
|     ) | ||||
|  | ||||
|     remove_duplicate_linked_libraries(control_thread_test) | ||||
|     add_test(control_thread_test control_thread_test) | ||||
|  | ||||
|     set_property(TEST control_thread_test PROPERTY TIMEOUT 30) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez