File: CMakeLists.txt

package info (click to toggle)
adios2 2.10.2%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,764 kB
  • sloc: cpp: 175,964; ansic: 160,510; f90: 14,630; yacc: 12,668; python: 7,275; perl: 7,126; sh: 2,825; lisp: 1,106; xml: 1,049; makefile: 579; lex: 557
file content (174 lines) | stat: -rw-r--r-- 5,913 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# ------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0.  See
# accompanying file Copyright.txt for details.
# ------------------------------------------------------------------------------#

if(ADIOS2_HAVE_MPI)
  set(MPIEXEC_EXTRA_FLAGS "" CACHE STRING
    "Extra flags to set after mpiexec and before the num_procs flag"
  )
  mark_as_advanced(MPIEXEC_EXTRA_FLAGS)
  separate_arguments(MPIEXEC_EXTRA_FLAGS)

  set(MPIEXEC_COMMAND
    ${MPIEXEC_EXECUTABLE} ${MPIEXEC_EXTRA_FLAGS}
    ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
  )
endif()

include(GoogleTest)

# gtest_add_tests_helper:
# Create a wrapper around gtest_add_tests that uses common patterns for test
# names, execurtable names, mpi usage, etc.
#
# Arguments:
# testname - The basename of the test file
# mpi      - MPI_ALLOW - build MPI test, execute with mpiexec; also build Serial test
# MPI_NONE - build Serial test only
# MPI_ONLY - build MPI test only, execute with mpiexec
# src_pfx  - Source filename prefix, Test${src_pfs}${testname}.cpp
# tst_pfx  - Test name prefix to be added to CTest
# tst_sfx  - Test name suffix to be added to CTest
# all additional arguments are passed directly to gtest_add_tests
#
# Example:
# You have a gtest file, TestFooThings.cpp that containst Test1 and Test2
# gtest functions that can be called with different sets of arguments.
#
# gtest_add_tests_helper(Things MPI_ALLOW Foo Foo. .Bar EXTRA_ARGS "Bar")
# gtest_add_tests_helper(Things MPI_ALLOW Foo Foo. .Baz EXTRA_ARGS "Baz")
#
# will create the executable Test.Foo.Things and add the tests
# Foo.Things.Test1.Bar.Serial
# Foo.Things.Test1.Bar.MPI
# Foo.Things.Test2.Bar.Serial
# Foo.Things.Test2.Bar.MPI
# Foo.Things.Test1.Baz.Serial
# Foo.Things.Test1.Baz.MPI
# Foo.Things.Test2.Baz.Serial
# Foo.Things.Test2.Baz.MPI
#
function(gtest_add_tests_helper testname mpi src_pfx tst_pfx tst_sfx)
  set(test_targets "")

  if(NOT mpi MATCHES "^MPI_(ALLOW|NONE|ONLY)$")
    message(FATAL_ERROR "Invalid mpi argument value '${mpi}'.")
  endif()

  set(all_tests)

  if(NOT mpi STREQUAL "MPI_ONLY")
    set(tgt Test.${tst_pfx}${testname}.Serial)
    list(APPEND test_targets "${tgt}")

    if(NOT TARGET ${tgt})
      add_executable(${tgt} Test${src_pfx}${testname}.cpp)
      target_link_libraries(${tgt} adios2::cxx11 adios2::c adios2_core adios2::thirdparty::gtest)
    endif()

    gtest_add_tests(TARGET ${tgt}
      TEST_PREFIX "${tst_pfx}"
      TEST_SUFFIX "${tst_sfx}.Serial"
      TEST_LIST added_tests
      ${ARGN}
    )
    list(APPEND all_tests ${added_tests})
  endif()

  if(ADIOS2_HAVE_MPI AND NOT mpi STREQUAL "MPI_NONE")
    set(tgt Test.${tst_pfx}${testname}.MPI)
    list(APPEND test_targets "${tgt}")

    if(NOT TARGET ${tgt})
      add_executable(${tgt} Test${src_pfx}${testname}.cpp)
      target_link_libraries(${tgt} adios2::cxx11_mpi adios2::c_mpi adios2_core_mpi MPI::MPI_C adios2::thirdparty::gtest)
    endif()

    gtest_add_tests(TARGET ${tgt}
      TEST_PREFIX "${tst_pfx}"
      TEST_SUFFIX "${tst_sfx}.MPI"
      EXEC_WRAPPER ${MPIEXEC_COMMAND}
      TEST_LIST added_tests
      ${ARGN}
    )
    list(APPEND all_tests ${added_tests})
    set_tests_properties(${added_tests} PROPERTIES PROCESSORS "${MPIEXEC_MAX_NUMPROCS}")
  endif()

  set("Test.${tst_pfx}${testname}-TESTS" "${all_tests}" PARENT_SCOPE)
  set("Test.${tst_pfx}${testname}-TARGETS" "${test_targets}" PARENT_SCOPE)
endfunction()

if(ADIOS2_HAVE_Fortran)
  function(gtest_add_tests_helper_Fortran testname mpi src_pfx tst_pfx tst_sfx wrk_dir extra_args)
    set(test_targets "")

    # message(STATUS "Add testname=${testname} src_pfx=${src_pfx} tst_pfx=${tst_pfx} tst_sfx=${tst_sfx} wrk_dir=${wrk_dir} extra=${extra_args}")
    if(NOT mpi MATCHES "^MPI_(ALLOW|NONE|ONLY)$")
      message(FATAL_ERROR "Invalid mpi argument value '${mpi}'.")
    endif()

    set(all_tests)

    if(NOT mpi STREQUAL "MPI_ONLY")
      set(tgt Test.${tst_pfx}${testname}.Serial)
      list(APPEND test_targets "${tgt}")

      if(NOT TARGET ${tgt})
        add_executable(${tgt} Test${src_pfx}${testname}.F90)
        set_target_properties(${tgt} PROPERTIES LINKER_LANGUAGE Fortran)
        target_link_libraries(${tgt} adios2::fortran adios2::thirdparty::gtest)
      endif()

      add_test(
        NAME ${tst_pfx}${src_pfx}${testname}${tst_sfx}.Serial
        COMMAND ${tgt} ${extra_args}
        WORKING_DIRECTORY ${wrk_dir}
      )
      list(APPEND all_tests ${added_tests})
    endif()

    if(ADIOS2_HAVE_MPI AND NOT mpi STREQUAL "MPI_NONE")
      set(tgt Test.${tst_pfx}${testname}.MPI)
      list(APPEND test_targets "${tgt}")

      if(NOT TARGET ${tgt})
        add_executable(${tgt} Test${src_pfx}${testname}.F90)
        set_target_properties(${tgt} PROPERTIES LINKER_LANGUAGE Fortran)
        target_link_libraries(${tgt} adios2::fortran_mpi MPI::MPI_Fortran adios2::thirdparty::gtest)
      endif()

      set(test_name ${tst_pfx}${src_pfx}${testname}${tst_sfx}.MPI)
      add_test(
        NAME ${test_name}
        COMMAND ${MPIEXEC_COMMAND} $<TARGET_FILE:${tgt}> ${extra_args}
        WORKING_DIRECTORY ${wrk_dir}
      )
      set_tests_properties(${test_name} PROPERTIES
        PROCESSORS "${MPIEXEC_MAX_NUMPROCS}"
      )
      list(APPEND all_tests ${added_tests})
      set_tests_properties(${added_tests} PROPERTIES PROCESSORS "${MPIEXEC_MAX_NUMPROCS}")
    endif()

    # message(STATUS "Creating Fortran tests ${all_tests}")
    set("Test.${tst_pfx}${testname}-TESTS" "${all_tests}" PARENT_SCOPE)
    set("Test.${tst_pfx}${testname}-TARGETS" "${test_targets}" PARENT_SCOPE)
  endfunction()
endif(ADIOS2_HAVE_Fortran)

add_subdirectory(adios2)
add_subdirectory(utils)

if(ADIOS2_RUN_INSTALL_TEST)
  add_subdirectory(install)
endif()

if(ADIOS2_BUILD_EXAMPLES)
  add_subdirectory(examples)
endif()

if(ADIOS2_HAVE_HDF5_VOL)
  add_subdirectory(h5vol)
endif()