Debian Codegraph @

cmake/tribits/core/test_support/TribitsAddExecutableTestHelpers.cmake

raw
1 # @HEADER
2 # *****************************************************************************
3 # TriBITS: Tribal Build, Integrate, and Test System
4 #
5 # Copyright 2013-2016 NTESS and the TriBITS contributors.
6 # SPDX-License-Identifier: BSD-3-Clause
7 # *****************************************************************************
8 # @HEADER
9
10 include_guard()
11
12 include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsCMakePolicies.cmake" NO_POLICY_SCOPE)
13
14 include("${CMAKE_CURRENT_LIST_DIR}/../utils/AdvancedSet.cmake")
15 include("${CMAKE_CURRENT_LIST_DIR}/../utils/MessageWrapper.cmake")
16
17 advanced_set( ${PROJECT_NAME}_CMAKE_EXECUTABLE_SUFFIX ".exe"
18 CACHE STRING
19 "Default exec suffix on all platforms (can be overridden by each executable added)." )
20
21
22 # Process the COMM arguments
23 #
24 # NOTE: The COMM array arguments is passed as ${ARGN}
25 #
26 function(tribits_process_comm_args ADD_SERIAL_FEATURE_OUT ADD_MPI_FEATURE_OUT )
27
28 set(COMM_ARRAY ${ARGN})
29
30 if (COMM_ARRAY)
31 set(ADD_SERIAL_FEATURE OFF)
32 set(ADD_MPI_FEATURE OFF)
33 foreach(COMM ${COMM_ARRAY})
34 if(${COMM} STREQUAL "serial")
35 set(ADD_SERIAL_FEATURE ON)
36 elseif (${COMM} STREQUAL "mpi")
37 set(ADD_MPI_FEATURE ON)
38 else()
39 message(SEND_ERROR "Error, the COMM value '${COMM}' is not valid."
40 " Only 'mpi' and 'serial' are allowed.")
41 endif()
42 endforeach()
43 else()
44 set(ADD_MPI_FEATURE ON)
45 set(ADD_SERIAL_FEATURE ON)
46 endif()
47
48 if (TPL_ENABLE_MPI)
49 set(ADD_SERIAL_FEATURE OFF)
50 if (NOT ADD_MPI_FEATURE)
51 set(EXCLUDED_FEATURE TRUE)
52 endif()
53 else()
54 set(ADD_MPI_FEATURE OFF)
55 if (NOT ADD_SERIAL_FEATURE)
56 set(EXCLUDED_FEATURE TRUE)
57 endif()
58 endif()
59
60 if (TEST_NAME AND EXCLUDED_FEATURE)
61 message_wrapper(
62 "-- ${TEST_NAME}: NOT added test because TPL_ENABLE_MPI='${TPL_ENABLE_MPI}' and COMM='${COMM_ARRAY}'!"
63 )
64 endif()
65
66 set(${ADD_SERIAL_FEATURE_OUT} ${ADD_SERIAL_FEATURE} PARENT_SCOPE)
67 set(${ADD_MPI_FEATURE_OUT} ${ADD_MPI_FEATURE} PARENT_SCOPE)
68
69 endfunction()
70
71
72 function(tribits_create_name_from_current_source_directory directoryNameOut)
73 set(directoryName "")
74
75 #Get the unique part of the path for this test directory
76 string(REGEX REPLACE ${PACKAGE_SOURCE_DIR} "" unique_dir_path
77 ${CMAKE_CURRENT_SOURCE_DIR})
78
79 #strip off the preceding "/"
80 string(LENGTH ${unique_dir_path} udp_length)
81 math(EXPR last_index "${udp_length}-1")
82 string(SUBSTRING ${unique_dir_path} 1 ${last_index} unique_dir_path)
83
84 # Make the name acceptable for filesystems. This may need to be made
85 # compatible with windows since they use a "\" instead of a "/" for
86 # directory delimiters. I'm not sure how this will react if we encounter a
87 # directory name with a space in it.
88 string(REGEX REPLACE "/" "_" directoryName "${unique_dir_path}")
89
90 set(${directoryNameOut} "${directoryName}" PARENT_SCOPE)
91 endfunction()