From 6f996d8eedb80d9d53de14595f26f2119ef3bdcb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 14:55:12 +0100 Subject: [PATCH] CMake: give yamlcpp a proper imported target - This makes linking easier, - Adds the right includes (needed on FreeBSD), - Lets us drop silly GUI setting for non-GUI tests (I think this was a side-effect of compiling on FreeBSD, where UI would pull in /usr/local/include). --- CMakeModules/FindYAMLCPP.cmake | 17 ++++++++++++++--- src/modules/contextualprocess/CMakeLists.txt | 3 +-- src/modules/fsresizer/CMakeLists.txt | 2 +- src/modules/hostinfo/CMakeLists.txt | 3 +-- src/modules/initcpio/CMakeLists.txt | 3 +-- src/modules/initramfs/CMakeLists.txt | 3 +-- src/modules/locale/CMakeLists.txt | 2 +- src/modules/shellprocess/CMakeLists.txt | 3 +-- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CMakeModules/FindYAMLCPP.cmake b/CMakeModules/FindYAMLCPP.cmake index 1ec9798d5..395c794bb 100644 --- a/CMakeModules/FindYAMLCPP.cmake +++ b/CMakeModules/FindYAMLCPP.cmake @@ -1,9 +1,11 @@ # Locate yaml-cpp # # This module defines -# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp -# YAMLCPP_LIBRARY, where to find yaml-cpp -# YAMLCPP_INCLUDE_DIR, where to find yaml.h +# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp +# YAMLCPP_LIBRARY, where to find yaml-cpp +# YAMLCPP_INCLUDE_DIR, where to find yaml.h +# There is also one IMPORTED library target, +# yamlcpp # # By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead, # you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...). @@ -48,3 +50,12 @@ find_library(YAMLCPP_LIBRARY include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) + +# Add an imported target +if( YAMLCPP_LIBRARY ) + add_library( yamlcpp UNKNOWN IMPORTED ) + set_property( TARGET yamlcpp PROPERTY IMPORTED_LOCATION ${YAMLCPP_LIBRARY} ) + if ( YAMLCPP_INCLUDE_DIR ) + set_property( TARGET yamlcpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} ) + endif() +endif() diff --git a/src/modules/contextualprocess/CMakeLists.txt b/src/modules/contextualprocess/CMakeLists.txt index 05ed9a91b..2df4cfe37 100644 --- a/src/modules/contextualprocess/CMakeLists.txt +++ b/src/modules/contextualprocess/CMakeLists.txt @@ -10,10 +10,9 @@ calamares_add_plugin( contextualprocess calamares_add_test( contextualprocesstest - GUI # It's not SOURCES Tests.cpp ContextualProcessJob.cpp # Builds it a second time LIBRARIES - ${YAMLCPP_LIBRARY} + yamlcpp ) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 37890f66e..01f673eb8 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -36,7 +36,7 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND Tests.cpp LIBRARIES calamares_job_fsresizer # From above - ${YAMLCPP_LIBRARY} + yamlcpp ) if( TARGET fsresizertest ) target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} ) diff --git a/src/modules/hostinfo/CMakeLists.txt b/src/modules/hostinfo/CMakeLists.txt index 125254ef9..3d6e0973f 100644 --- a/src/modules/hostinfo/CMakeLists.txt +++ b/src/modules/hostinfo/CMakeLists.txt @@ -34,10 +34,9 @@ endif() calamares_add_test( hostinfotest - GUI # It's not SOURCES Tests.cpp HostInfoJob.cpp LIBRARIES - ${YAMLCPP_LIBRARY} + yamlcpp ) diff --git a/src/modules/initcpio/CMakeLists.txt b/src/modules/initcpio/CMakeLists.txt index fc0daea6f..5140c97e0 100644 --- a/src/modules/initcpio/CMakeLists.txt +++ b/src/modules/initcpio/CMakeLists.txt @@ -10,10 +10,9 @@ calamares_add_plugin( initcpio calamares_add_test( initcpiotest - GUI # It's not SOURCES Tests.cpp LIBRARIES calamares_job_initcpio # From above - ${YAMLCPP_LIBRARY} + yamlcpp ) diff --git a/src/modules/initramfs/CMakeLists.txt b/src/modules/initramfs/CMakeLists.txt index 7b59e140d..b3287c896 100644 --- a/src/modules/initramfs/CMakeLists.txt +++ b/src/modules/initramfs/CMakeLists.txt @@ -10,10 +10,9 @@ calamares_add_plugin( initramfs calamares_add_test( initramfstest - GUI # It's not SOURCES Tests.cpp LIBRARIES calamares_job_initramfs # From above - ${YAMLCPP_LIBRARY} + yamlcpp ) diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 58788541e..cae2ea41c 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -27,7 +27,7 @@ calamares_add_plugin( locale calamaresui Qt5::Network ${geoip_libs} - ${YAMLCPP_LIBRARY} + yamlcpp SHARED_LIB ) diff --git a/src/modules/shellprocess/CMakeLists.txt b/src/modules/shellprocess/CMakeLists.txt index 3899ef642..ec1cf0bcf 100644 --- a/src/modules/shellprocess/CMakeLists.txt +++ b/src/modules/shellprocess/CMakeLists.txt @@ -10,9 +10,8 @@ calamares_add_plugin( shellprocess calamares_add_test( shellprocesstest - GUI # It's not SOURCES Tests.cpp LIBRARIES - ${YAMLCPP_LIBRARY} + yamlcpp )