Linking with Conan targets only when they exists (resolves #98)

This commit is contained in:
Mateusz Pusz
2020-05-08 11:56:07 +02:00
parent 2f6ecb113a
commit d18480879d
4 changed files with 9 additions and 6 deletions

View File

@@ -38,6 +38,9 @@ add_example(kalman_filter-alpha_beta_filter_example2)
conan_check_testing(linear_algebra)
add_example(linear_algebra)
target_link_libraries(linear_algebra PRIVATE CONAN_PKG::linear_algebra)
target_link_libraries(linear_algebra
PRIVATE
$<IF:$<TARGET_EXISTS:CONAN_PKG::linear_algebra>, CONAN_PKG::linear_algebra, linear_algebra::linear_algebra>
)
add_subdirectory(alternative_namespaces)

View File

@@ -55,7 +55,7 @@ add_library(units INTERFACE)
target_compile_features(units INTERFACE cxx_std_20)
target_link_libraries(units
INTERFACE
CONAN_PKG::fmt
$<IF:$<TARGET_EXISTS:CONAN_PKG::fmt>, CONAN_PKG::fmt, fmt::fmt>
)
target_include_directories(units
INTERFACE
@@ -65,7 +65,7 @@ target_include_directories(units
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_link_libraries(units
INTERFACE
CONAN_PKG::range-v3
$<IF:$<TARGET_EXISTS:CONAN_PKG::range-v3>, CONAN_PKG::range-v3, range-v3::range-v3>
)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(units
@@ -81,7 +81,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
)
target_link_libraries(units
INTERFACE
CONAN_PKG::range-v3
$<IF:$<TARGET_EXISTS:CONAN_PKG::range-v3>, CONAN_PKG::range-v3, range-v3::range-v3>
)
endif()
endif()

View File

@@ -26,7 +26,7 @@ function(add_metabench_test target name erb_path range)
target_compile_features(${target} PUBLIC cxx_std_20)
target_link_libraries(${target}
PUBLIC
CONAN_PKG::range-v3
$<IF:$<TARGET_EXISTS:CONAN_PKG::range-v3>, CONAN_PKG::range-v3, range-v3::range-v3>
)
target_compile_options(${target}
PUBLIC

View File

@@ -33,7 +33,7 @@ add_executable(unit_tests_runtime
target_link_libraries(unit_tests_runtime
PRIVATE
mp::units
CONAN_PKG::Catch2
$<IF:$<TARGET_EXISTS:CONAN_PKG::Catch2>, CONAN_PKG::Catch2, Catch2::Catch2>
)
include(lib/cmake/Catch2/Catch)