mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
chore: Add IMPORTED_TARGET
to pkg-config packages.
Also use `PRIVATE` for `target_link_libraries`. This helps avoid implicit transitive dependencies.
This commit is contained in:
parent
895a6af122
commit
c58928cc89
|
@ -423,7 +423,7 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
|
||||||
function(unit_test subdir target)
|
function(unit_test subdir target)
|
||||||
add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
|
add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
|
||||||
target_link_modules(unit_${target}_test toxcore)
|
target_link_modules(unit_${target}_test toxcore)
|
||||||
target_link_libraries(unit_${target}_test GTest::GTest GTest::Main)
|
target_link_libraries(unit_${target}_test PRIVATE GTest::GTest GTest::Main)
|
||||||
set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
|
set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
|
||||||
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
|
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
|
||||||
set_property(TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw")
|
set_property(TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw")
|
||||||
|
|
|
@ -24,7 +24,7 @@ find_package(PkgConfig)
|
||||||
function(pkg_use_module mod pkgs)
|
function(pkg_use_module mod pkgs)
|
||||||
foreach(pkg IN ITEMS ${pkgs})
|
foreach(pkg IN ITEMS ${pkgs})
|
||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
pkg_search_module(${mod} ${pkg})
|
pkg_search_module(${mod} ${pkg} IMPORTED_TARGET)
|
||||||
endif()
|
endif()
|
||||||
if(NOT ${mod}_FOUND)
|
if(NOT ${mod}_FOUND)
|
||||||
find_package(${pkg} QUIET)
|
find_package(${pkg} QUIET)
|
||||||
|
@ -151,9 +151,9 @@ function(target_link_modules target)
|
||||||
foreach(dep ${ARGN})
|
foreach(dep ${ARGN})
|
||||||
foreach(_target ${_targets})
|
foreach(_target ${_targets})
|
||||||
if(TARGET ${dep}_${${_target}_primary})
|
if(TARGET ${dep}_${${_target}_primary})
|
||||||
target_link_libraries(${_target} ${dep}_${${_target}_primary})
|
target_link_libraries(${_target} PRIVATE ${dep}_${${_target}_primary})
|
||||||
elseif(TARGET ${dep}_${${_target}_secondary})
|
elseif(TARGET ${dep}_${${_target}_secondary})
|
||||||
target_link_libraries(${_target} ${dep}_${${_target}_secondary})
|
target_link_libraries(${_target} PRIVATE ${dep}_${${_target}_secondary})
|
||||||
else()
|
else()
|
||||||
# We record the modules linked to this target, so that we can collect
|
# We record the modules linked to this target, so that we can collect
|
||||||
# them later when linking a composed module.
|
# them later when linking a composed module.
|
||||||
|
@ -162,7 +162,7 @@ function(target_link_modules target)
|
||||||
set(LINK_MODULES ${LINK_MODULES} ${dep})
|
set(LINK_MODULES ${LINK_MODULES} ${dep})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${_target} ${dep})
|
target_link_libraries(${_target} PRIVATE ${dep})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
|
@ -25,6 +25,6 @@ if(NOT MSVC)
|
||||||
if(OpenMP_C_FOUND)
|
if(OpenMP_C_FOUND)
|
||||||
add_executable(cracker cracker.c)
|
add_executable(cracker cracker.c)
|
||||||
target_link_modules(cracker ${LIBSODIUM_LIBRARIES})
|
target_link_modules(cracker ${LIBSODIUM_LIBRARIES})
|
||||||
target_link_libraries(cracker OpenMP::OpenMP_C)
|
target_link_libraries(cracker PRIVATE OpenMP::OpenMP_C)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -13,14 +13,14 @@ endif()
|
||||||
|
|
||||||
# Fuzzes the toxsave API
|
# Fuzzes the toxsave API
|
||||||
add_executable(toxsave_fuzzer toxsave_harness.cc)
|
add_executable(toxsave_fuzzer toxsave_harness.cc)
|
||||||
target_link_libraries(toxsave_fuzzer toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
|
target_link_libraries(toxsave_fuzzer PRIVATE toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
|
||||||
|
|
||||||
# Fuzzes the bootstrap process
|
# Fuzzes the bootstrap process
|
||||||
add_executable(bootstrap_fuzzer bootstrap_harness.cc)
|
add_executable(bootstrap_fuzzer bootstrap_harness.cc)
|
||||||
target_link_libraries(bootstrap_fuzzer toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
|
target_link_libraries(bootstrap_fuzzer PRIVATE toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
|
||||||
|
|
||||||
add_executable(DHT_fuzz_test ../../toxcore/DHT_fuzz_test.cc)
|
add_executable(DHT_fuzz_test ../../toxcore/DHT_fuzz_test.cc)
|
||||||
target_link_libraries(DHT_fuzz_test toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
|
target_link_libraries(DHT_fuzz_test PRIVATE toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
|
||||||
|
|
||||||
add_executable(tox_events_fuzz_test ../../toxcore/tox_events_fuzz_test.cc)
|
add_executable(tox_events_fuzz_test ../../toxcore/tox_events_fuzz_test.cc)
|
||||||
target_link_libraries(tox_events_fuzz_test toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
|
target_link_libraries(tox_events_fuzz_test PRIVATE toxcore_static fuzz_support ${LIBFUZZER_LINKER_FLAGS})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user