Debian Codegraph @

cmake/tribits/core/package_arch/TribitsGeneralMacros.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(AppendSet)
11 include(AssertDefined)
12 include(MessageWrapper)
13 include(TribitsParseArgumentsHelpers)
14 include(TribitsSortListAccordingToMasterList)
15 include(TribitsDeprecatedHelpers)
16 include(TribitsGetPackageEnableStatus)
17
18
19 # Set the combined directory name taking into account '.' repos.
20 #
21 function(tribits_get_repo_name REPO_DIR REPO_NAME_OUT)
22 if (REPO_DIR STREQUAL ".")
23 set(REPO_NAME ${PROJECT_NAME})
24 else()
25 set(REPO_NAME ${REPO_DIR})
26 endif()
27 set(${REPO_NAME_OUT} "${REPO_NAME}" PARENT_SCOPE)
28 endfunction()
29
30
31 # Get the REPO_NAME and REPO_DIR given the REPO
32 #
33 function(tribits_get_repo_name_dir REPO_IN REPO_NAME_OUT REPO_DIR_OUT)
34 #message("TRIBITS_GET_REPO_NAME_DIR: '${REPO_IN}' '${REPO_NAME_OUT}' '${REPO_DIR_OUT}'")
35 # This list of repositories is the list of directories!
36 set(REPO_DIR ${REPO_IN})
37 # Get the Repository name
38 if (REPO_IN STREQUAL ".")
39 # The Project and the Reposiotry are one and the same
40 set(REPO_NAME ${PROJECT_NAME})
41 else()
42 # The Repository name is the same as the repository directory
43 set(REPO_NAME ${REPO_IN})
44 endif()
45 set(${REPO_NAME_OUT} ${REPO_NAME} PARENT_SCOPE)
46 set(${REPO_DIR_OUT} ${REPO_DIR} PARENT_SCOPE)
47 endfunction()
48
49
50 # Set the combined directory name taking into account '.' repos.
51 #
52 function(tribits_set_base_repo_dir BASE_DIR REPO_DIR BASE_REPO_DIR_OUT)
53 if (REPO_DIR STREQUAL ".")
54 set(REPO_DIR_STR "")
55 else()
56 set(REPO_DIR_STR "/${REPO_DIR}")
57 endif()
58 set(${BASE_REPO_DIR_OUT} "${BASE_DIR}${REPO_DIR_STR}" PARENT_SCOPE)
59 endfunction()
60
61
62 # @FUNCTION: tribits_set_st_for_dev_mode()
63 #
64 # Function that allows packages to easily make a feature ``ST`` for
65 # development builds and ``PT`` for release builds by default.
66 #
67 # Usage::
68 #
69 # tribits_set_st_for_dev_mode(<outputVar>)
70 #
71 # This function is typically called in a package's top-level
72 # `<packageDir>/CMakeLists.txt`_ file before defining other options for the
73 # package. The output variable ``${<outputVar>}`` is set to ``ON`` or ``OFF``
74 # based on the configure state. In development mode
75 # (i.e. ``${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE==ON``), ``${<outputVar>}``
76 # will be set to ``ON`` only if ``ST`` code is enabled
77 # (i.e. ``${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE==ON``), otherwise it is
78 # set to ``OFF``. In release mode
79 # (i.e. ``${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE==OFF``), ``${<outputVar>}``
80 # is always set to ``ON``. This allows some parts of a TriBITS package to be
81 # considered ``ST`` for development mode (thereby reducing testing time by not
82 # enabling the dependent features/tests), while still having important
83 # functionality available to users by default in a release of the package.
84 #
85 function(tribits_set_st_for_dev_mode OUTPUT_VAR)
86 if(${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE)
87 set(OUTPUT_VAL ${${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE})
88 else()
89 set(OUTPUT_VAL ON)
90 endif()
91 set(${OUTPUT_VAR} ${OUTPUT_VAL} PARENT_SCOPE)
92 endfunction()
93
94
95 # For backward compatibility
96 macro(tribits_set_ss_for_dev_mode OUTPUT_VAR)
97 tribits_deprecated_command(tribits_set_ss_for_dev_mode
98 MESSAGE "Use tribits_set_st_for_dev_mode() instead.")
99 tribits_set_st_for_dev_mode(${OUTPUT_VAR})
100 endmacro()
101
102
103 # @FUNCTION: tribits_trace_file_processing()
104 #
105 # Print trace of file processing when
106 # ``${PROJECT_NAME}_TRACE_FILE_PROCESSING`` is ``TRUE``.
107 #
108 # Usage::
109 #
110 # tribits_trace_file_processing( <type> <processingType> <filePath>)
111 #
112 # Arguments:
113 #
114 # * ``<type>``: Allowed values "PROJECT", "REPOSITORY", "PACKAGE", or "TPL"
115 #
116 # * ``<processingType>``: Allowed values "INCLUDE", "ADD_SUBDIR", "READ", or
117 # "CONFIGURE"
118 #
119 # * ``<filePath>``: Path of the file being processed
120 #
121 function(tribits_trace_file_processing TYPE_IN PROCESSING_TYPE_IN FILE_PATH)
122
123 if (${PROJECT_NAME}_TRACE_FILE_PROCESSING)
124
125 if (TYPE_IN STREQUAL "PROJECT")
126 set(TYPE_STR "PROJECT ")
127 elseif (TYPE_IN STREQUAL "REPOSITORY")
128 set(TYPE_STR "REPOSITORY")
129 elseif (TYPE_IN STREQUAL "PACKAGE")
130 set(TYPE_STR "PACKAGE ")
131 elseif ("${TYPE_IN}" STREQUAL "TPL")
132 set(TYPE_STR "TPL ")
133 else()
134 message(FATAL_ERROR
135 "Error: TYPE_IN='${TYPE_IN}' is invalid!")
136 endif()
137
138 if (PROCESSING_TYPE_IN STREQUAL "INCLUDE")
139 set(PROCESSING_TYPE_STR "INCLUDE ")
140 elseif (PROCESSING_TYPE_IN STREQUAL "ADD_SUBDIR")
141 set(PROCESSING_TYPE_STR "ADD_SUBDIR")
142 elseif (PROCESSING_TYPE_IN STREQUAL "READ")
143 set(PROCESSING_TYPE_STR "READ ")
144 elseif (PROCESSING_TYPE_IN STREQUAL "CONFIGURE")
145 set(PROCESSING_TYPE_STR "CONFIGURE ")
146 else()
147 message(FATAL_ERROR
148 "Error: PROCESSING_TYPE_IN='${PROCESSING_TYPE_IN}' is invalid!")
149 endif()
150
151 message("-- " "File Trace: ${TYPE_STR} ${PROCESSING_TYPE_STR} ${FILE_PATH}")
152
153 endif()
154
155 endfunction()