From 4d1630bf8b98215bb4160a95076fc43551d6d028 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 26 Jul 2021 14:27:52 +0200 Subject: [PATCH] CMake: tidy up automatic linking of Calamares libraries - Modules and plugins don't need to mention libcalamares themselves for linking -- we can do that automatically. Use the IMPORTED names so that it works in Calamares main repo and external repositories. - Complain about unknown module types. --- CMakeModules/CalamaresAddPlugin.cmake | 9 +++++++++ CMakeModules/CalamaresAddTest.cmake | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeModules/CalamaresAddPlugin.cmake b/CMakeModules/CalamaresAddPlugin.cmake index 5186bc54b..7e2a3f583 100644 --- a/CMakeModules/CalamaresAddPlugin.cmake +++ b/CMakeModules/CalamaresAddPlugin.cmake @@ -126,6 +126,15 @@ function( calamares_add_plugin ) # create target name once for convenience set( target "calamares_${PLUGIN_TYPE}_${PLUGIN_NAME}" ) + # automatic library linkage + if(PLUGIN_TYPE STREQUAL "view" OR PLUGIN_TYPE STREQUAL "viewmodule") + list(APPEND PLUGIN_LINK_PRIVATE_LIBRARIES Calamares::calamaresui) + elseif(PLUGIN_TYPE STREQUAL "job") + list(APPEND PLUGIN_LINK_PRIVATE_LIBRARIES Calamares::calamares) + else() + message(FATAL_ERROR "Unknown plugin type ${PLUGIN_TYPE}") + endif() + # determine target type if( NOT ${PLUGIN_SHARED_LIB} ) set( target_type "MODULE" ) diff --git a/CMakeModules/CalamaresAddTest.cmake b/CMakeModules/CalamaresAddTest.cmake index 228d7cbc0..cd757bb88 100644 --- a/CMakeModules/CalamaresAddTest.cmake +++ b/CMakeModules/CalamaresAddTest.cmake @@ -36,7 +36,7 @@ function( calamares_add_test ) TEST_NAME ${TEST_NAME} LINK_LIBRARIES - calamares + Calamares::calamares ${TEST_LIBRARIES} Qt5::Core Qt5::Test @@ -46,7 +46,7 @@ function( calamares_add_test ) # compiled, so that it can find test-files in that source dir. target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST="${CMAKE_CURRENT_SOURCE_DIR}" ${TEST_DEFINITIONS} ) if( TEST_GUI ) - target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui ) + target_link_libraries( ${TEST_NAME} Calamares::calamaresui Qt5::Gui ) endif() if( TEST_RESOURCES ) calamares_autorcc( ${TEST_NAME} ${TEST_RESOURCES} )