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.
This commit is contained in:
Adriaan de Groot 2021-07-26 14:27:52 +02:00
parent cbb1a5ef36
commit 4d1630bf8b
2 changed files with 11 additions and 2 deletions

View File

@ -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" )

View File

@ -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} )