41 lines
1.0 KiB
CMake
41 lines
1.0 KiB
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 Core Test REQUIRED)
|
|
if(NOT Qt5Test_FOUND)
|
|
myx_message_fatal_error("Qt testing framework is not found")
|
|
return()
|
|
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})
|
|
target_link_libraries(${TARGET_NAME} PRIVATE Qt5::Core Qt5::Test)
|
|
|
|
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()
|
|
|