38 lines
981 B
CMake
38 lines
981 B
CMake
|
include_guard(GLOBAL)
|
||
|
|
||
|
macro(myx_add_qtest TARGET_NAME)
|
||
|
set(options)
|
||
|
set(oneValueArgs)
|
||
|
set(multiValueArgs)
|
||
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||
|
|
||
|
find_package(Qt5 COMPONENTS Test REQUIRED)
|
||
|
if(Qt5_Test_FOUND)
|
||
|
target_link_libraries(${TARGET_NAME} Qt5::Core Qt5::Test)
|
||
|
endif()
|
||
|
|
||
|
foreach(filename ${ARG_UNPARSED_ARGUMENTS})
|
||
|
get_filename_component(basename ${filename} NAME_WE)
|
||
|
list(APPEND cpps "${basename}.cpp")
|
||
|
list(APPEND hpps "${basename}.hpp")
|
||
|
qt5_wrap_cpp(moc "${basename}.hpp")
|
||
|
list(APPEND mocs "${moc}")
|
||
|
endforeach()
|
||
|
|
||
|
add_executable(${TARGET_NAME} ${mocs} ${cpps} ${hpps})
|
||
|
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME})
|
||
|
|
||
|
unset(cpps)
|
||
|
unset(hpps)
|
||
|
unset(moc)
|
||
|
unset(mocs)
|
||
|
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
|
||
|
unset(ARG_${__iter})
|
||
|
endforeach()
|
||
|
unset(ARG_UNPARSED_ARGUMENTS)
|
||
|
unset(multiValueArgs)
|
||
|
unset(oneValueArgs)
|
||
|
unset(options)
|
||
|
endmacro()
|
||
|
|