Skip to content
Snippets Groups Projects

Update gtest_helper.cmake

Merged Sergey Kosukhin requested to merge refactor-gtest-helper into master
All threads resolved!
Files
2
+ 18
10
@@ -10,23 +10,31 @@
@@ -10,23 +10,31 @@
# ---------------------------------------------------------------
# ---------------------------------------------------------------
# cmake-format: off
# cmake-format: off
# add_icon_c_test(<test>
# fs_add_c_test(<test_name>
# <source>)
# [SOURCES <sources>]
 
# [ARGS <args>])
# cmake-format: on
# cmake-format: on
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Compiles a test executable with the name <test> using the source code
# Compiles a test executable with the name <test_name> using the source code
# <source>. The googletest and fortran-support libraries will be linked
# <source>. Specify ctest arguments in <args> if necessary. The googletest and
# automatically.
# libfortran-support libraries will be linked automatically.
#
#
# The C++ standard is set to C++17.
# The C++ standard is set to C++17.
#
#
macro(add_icon_c_test test_name file_name)
function(fs_add_c_test test_name)
add_executable("CTest_${test_name}" ${file_name})
 
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "" "SOURCES;ARGS")
 
if(NOT ARG_SOURCES)
 
set(ARG_SOURCES "${ARG_UNPARSED_ARGUMENTS}")
 
endif()
 
 
add_executable("CTest_${test_name}" ${ARG_SOURCES})
target_link_libraries(
target_link_libraries(
"CTest_${test_name}" PRIVATE fortran-support::fortran-support
"CTest_${test_name}" PRIVATE fortran-support::fortran-support
GTest::gtest_main)
GTest::gtest_main stdc++fs)
add_test(NAME "CTest_${test_name}" COMMAND "CTest_${test_name}")
add_test(NAME "CTest_${test_name}" COMMAND "CTest_${test_name}" ${ARG_ARGS})
set_property(TEST "CTest_${test_name}" PROPERTY LABELS C)
set_property(TEST "CTest_${test_name}" PROPERTY LABELS C)
set_target_properties("CTest_${test_name}"
set_target_properties("CTest_${test_name}"
PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
endmacro()
 
endfunction()
Loading