forked from kokkos/kokkos-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
61 lines (51 loc) · 1.82 KB
/
CMakeLists.txt
File metadata and controls
61 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Add an executable and its related test.
#
# The executable is always linked to 'kokkostools' and 'test_common'.
#
# Arguments:
# TARGET_NAME : name of the test (required)
# SOURCE_FILE : source file, defaults to <TARGET_NAME>.cpp (optional)
# KOKKOS_TOOLS_LIBS : the test environment will received the variable 'KOKKOS_TOOLS_LIBS' that is set as the path
# to the target file of this argument (optional)
function(kp_add_executable_and_test)
cmake_parse_arguments(kaeat_args "" "TARGET_NAME;SOURCE_FILE;KOKKOS_TOOLS_LIBS" "" ${ARGN})
if(NOT DEFINED kaeat_args_TARGET_NAME)
message(FATAL_ERROR "'TARGET_NAME' is a required argument.")
endif()
if(NOT DEFINED kaeat_args_SOURCE_FILE)
set(kaeat_args_SOURCE_FILE "${kaeat_args_TARGET_NAME}.cpp")
endif()
add_executable(${kaeat_args_TARGET_NAME})
target_sources(
${kaeat_args_TARGET_NAME}
PRIVATE
${kaeat_args_SOURCE_FILE}
)
target_link_libraries(
${kaeat_args_TARGET_NAME}
PRIVATE
kokkostools test_common
)
add_test(
NAME ${kaeat_args_TARGET_NAME}
COMMAND $<TARGET_FILE:${kaeat_args_TARGET_NAME}>
)
if(DEFINED kaeat_args_KOKKOS_TOOLS_LIBS)
set_property(
TEST ${kaeat_args_TARGET_NAME}
APPEND
PROPERTY
ENVIRONMENT "KOKKOS_TOOLS_LIBS=$<TARGET_FILE:${kaeat_args_KOKKOS_TOOLS_LIBS}>"
)
endif()
endfunction(kp_add_executable_and_test)
# Create a test library that contains the required Kokkos and Google Test
# initialization sequence.
add_library(test_common OBJECT)
target_sources(
test_common
PRIVATE
UnitTestMain.cpp
)
target_link_libraries(test_common PUBLIC GTest::gtest GTest::gmock Kokkos::kokkos)
add_subdirectory(space-time-stack)