Debian Codegraph @

cmake/tribits/dashboard_driver/TribitsDriverCMakeLists.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 #
11 # CMakeLists.txt body used by the TriBITS driver job.
12 #
13
14 # The base directory is the parent of the binary directory.
15 # FIXME This is duplicated information. The base directory is set in
16 # tdd_driver.py. We need to go through two separate CTest invocations
17 # to get to this point from there. Since environment variables are the
18 # only way to pass data to CTest, we need to pass this directory
19 # through the environment.
20 get_filename_component(TD_BASE_DIR ${CMAKE_BINARY_DIR} PATH)
21
22 # CMake versions greater than 2.8.4 have CMAKE_CURRENT_LIST_DIR. Make
23 # sure it's defined.
24 if( NOT DEFINED CMAKE_CURRENT_LIST_DIR )
25 get_filename_component( CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH )
26 endif()
27
28 # Locate the TriBITS dependencies.
29 if (NOT TRIBITS_ROOT)
30 get_filename_component(TRIBITS_ROOT "${CMAKE_CURRENT_LIST_DIR}/..")
31 endif()
32 get_filename_component(TRIBITS_ROOT "${TRIBITS_ROOT}" ABSOLUTE)
33
34 set(CMAKE_MODULE_PATH
35 ${CMAKE_CURRENT_LIST_DIR}
36 ${TRIBITS_ROOT}/core/utils
37 ${TRIBITS_ROOT}/core/package_arch
38 ${TRIBITS_ROOT}/core/config_tests
39 )
40
41 set(TRIBITS_PYTHON_UTILS_DIR "${TRIBITS_ROOT}/python_utils")
42
43 include(SetDefaultAndFromEnv)
44 include(CTest)
45 include(TribitsDriverSupport)
46 include(TribitsConfigureCTestCustom)
47
48 tribits_configure_ctest_custom(${PROJECT_HOME_DIR} ${CMAKE_CURRENT_BINARY_DIR})
49
50
51 # Function to make exactly one add_subdirectory call based on the site
52 # name of the machine we're running on. By default, the subdirectory
53 # is taken to be the site name. The environment variable
54 # TDD_DRIVER_SUBDIRECTORY can be used to override the default value.
55 #
56 function(tdd_project)
57
58 site_name(site)
59 set(subdir "${site}")
60 message("site='${site}'")
61
62 # But if that directory does not exist as named, and there's a regex match
63 # with the name of a subdirectory, use the exact subdirectory name instead:
64 #
65 file(GLOB filesAndDirs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
66 "${CMAKE_CURRENT_SOURCE_DIR}/*")
67
68 set(dirs "")
69 foreach(dir ${filesAndDirs})
70 if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${dir}")
71 set(dirs ${dirs} "${dir}")
72 endif()
73 endforeach()
74
75 foreach(dir ${dirs})
76 if("${site}" MATCHES "${dir}")
77 set(subdir "${dir}")
78 message("site='${site}' MATCHES directory name dir='${dir}'")
79 endif()
80 endforeach()
81
82 # Allow an environment variable to override the test directory.
83 set_default_and_from_env(TDD_DRIVER_SUBDIRECTORY "${subdir}")
84
85 # The one add_subdirectory call:
86 #
87 message("TDD_DRIVER_SUBDIRECTORY='${TDD_DRIVER_SUBDIRECTORY}'")
88
89 if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${TDD_DRIVER_SUBDIRECTORY}")
90 message(FATAL_ERROR "error: there is no subdirectory of ${CMAKE_CURRENT_SOURCE_DIR} matching '${TDD_DRIVER_SUBDIRECTORY}'")
91 endif()
92
93 if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${TDD_DRIVER_SUBDIRECTORY}/CMakeLists.txt")
94 message(FATAL_ERROR "error: there is no CMakeLists.txt file in '${CMAKE_CURRENT_SOURCE_DIR}/${TDD_DRIVER_SUBDIRECTORY}'")
95 endif()
96
97 add_subdirectory("${TDD_DRIVER_SUBDIRECTORY}")
98
99 endfunction()