CMake: add DEFINITIONS option to calamares_add_test

- There's a handful of tests that need this, it's possible
  there will be more, so just add it to the infrastructure.
This commit is contained in:
Adriaan de Groot 2020-02-19 22:26:55 +01:00
parent 1bb43e06e2
commit fba1bf7072
3 changed files with 5 additions and 11 deletions

View File

@ -34,7 +34,7 @@ function( calamares_add_test )
# parse arguments (name needs to be saved before passing ARGN into the macro) # parse arguments (name needs to be saved before passing ARGN into the macro)
set( NAME ${ARGV0} ) set( NAME ${ARGV0} )
set( options GUI ) set( options GUI )
set( multiValueArgs SOURCES LIBRARIES ) set( multiValueArgs SOURCES LIBRARIES DEFINITIONS )
cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} ) cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} )
set( TEST_NAME ${NAME} ) set( TEST_NAME ${NAME} )
@ -50,7 +50,7 @@ function( calamares_add_test )
Qt5::Test Qt5::Test
) )
calamares_automoc( ${TEST_NAME} ) calamares_automoc( ${TEST_NAME} )
target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST ) target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST ${TEST_DEFINITIONS} )
if( TEST_GUI ) if( TEST_GUI )
target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui ) target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui )
endif() endif()

View File

@ -35,10 +35,8 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND
LIBRARIES LIBRARIES
calamares_job_fsresizer # From above calamares_job_fsresizer # From above
yamlcpp yamlcpp
DEFINITIONS ${_partition_defs}
) )
if( TARGET fsresizertest )
target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} )
endif()
else() else()
if ( NOT KPMcore_FOUND ) if ( NOT KPMcore_FOUND )
calamares_skip_module( "fsresizer (missing suitable KPMcore)" ) calamares_skip_module( "fsresizer (missing suitable KPMcore)" )

View File

@ -26,10 +26,8 @@ calamares_add_test(
SOURCES ${partitionjobtests_SRCS} SOURCES ${partitionjobtests_SRCS}
LIBRARIES LIBRARIES
kpmcore kpmcore
DEFINITIONS ${_partition_defs}
) )
if( TARGET partitionjobtests )
target_compile_definitions( partitionjobtests PRIVATE ${_partition_defs} )
endif()
calamares_add_test( calamares_add_test(
clearmountsjobtests clearmountsjobtests
@ -38,8 +36,6 @@ calamares_add_test(
ClearMountsJobTests.cpp ClearMountsJobTests.cpp
LIBRARIES LIBRARIES
kpmcore kpmcore
DEFINITIONS ${_partition_defs}
) )
if( TARGET clearmountsjobtests )
target_compile_definitions( clearmountsjobtests PRIVATE ${_partition_defs} )
endif()