2022-11-28 09:40:11 +00:00
|
|
|
include_guard(GLOBAL)
|
|
|
|
|
|
|
|
macro(myx_add_qtest TARGET_NAME)
|
|
|
|
set(options)
|
|
|
|
set(oneValueArgs)
|
|
|
|
set(multiValueArgs)
|
|
|
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
2022-11-28 09:53:13 +00:00
|
|
|
find_package(Qt5 COMPONENTS Core Test REQUIRED)
|
|
|
|
if(NOT Qt5Test_FOUND)
|
|
|
|
myx_message_fatal_error("Qt testing framework is not found")
|
|
|
|
return()
|
2022-11-28 09:40:11 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(filename ${ARG_UNPARSED_ARGUMENTS})
|
|
|
|
get_filename_component(basename ${filename} NAME_WE)
|
2024-03-11 10:51:29 +00:00
|
|
|
list(APPEND cpps "${CMAKE_CURRENT_SOURCE_DIR}/${basename}.cpp")
|
|
|
|
list(APPEND hpps "${CMAKE_CURRENT_SOURCE_DIR}/${basename}.hpp")
|
2022-11-28 09:40:11 +00:00
|
|
|
qt5_wrap_cpp(moc "${basename}.hpp")
|
|
|
|
list(APPEND mocs "${moc}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_executable(${TARGET_NAME} ${mocs} ${cpps} ${hpps})
|
2023-07-30 11:29:25 +00:00
|
|
|
target_link_libraries(${TARGET_NAME} PRIVATE Qt5::Core Qt5::Test)
|
2022-11-28 09:53:13 +00:00
|
|
|
|
2022-11-28 09:40:11 +00:00
|
|
|
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()
|
|
|
|
|