| 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 |
include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsConstants.cmake") |
| 12 |
include(TribitsListHelpers) |
| 13 |
|
| 14 |
include(PrintVar) |
| 15 |
include(Split) |
| 16 |
|
| 17 |
|
| 18 |
# @MACRO: tribits_repository_define_tpls() |
| 19 |
# |
| 20 |
# Define the list of `TriBITS External Packages/TPLs`_ for a given `TriBITS |
| 21 |
# Repository`_ which includes the external package/TPL name, TriBITS TPL find |
| 22 |
# module, and classification . This macro is typically called from inside of |
| 23 |
# a TriBITS Repository's `<repoDir>/TPLsList.cmake`_ file. |
| 24 |
# |
| 25 |
# Usage:: |
| 26 |
# |
| 27 |
# tribits_repository_define_tpls( |
| 28 |
# <tpl0_name> <tpl0_findmod> <tpl0_classif> |
| 29 |
# <tpl1_name> <tpl1_findmod> <tpl1_classif> |
| 30 |
# ... |
| 31 |
# ) |
| 32 |
# |
| 33 |
# This macro sets up a 2D array of ``NumTPLS`` by ``NumColumns`` listing out |
| 34 |
# the `TriBITS TPLs`_ for a `TriBITS Repository`_. Each row (with 3 entries) |
| 35 |
# specifies a different TriBITS external package/TPL which contains the columns |
| 36 |
# (ordered 0-2): |
| 37 |
# |
| 38 |
# 0. **TPL** (``<tpli_name>``): The name of the TriBITS external package/TPL |
| 39 |
# ``<tplName>``. This name must be unique across all other TriBITS TPLs in |
| 40 |
# this or any other TriBITS repo that might be combined into a single |
| 41 |
# TriBITS project meta-build (see `Globally unique TriBITS TPL names`_). |
| 42 |
# However, a TPL can be redefined from an upstream repo (see below). The |
| 43 |
# name should be a valid identifier (e.g. matches the regex |
| 44 |
# ``[a-zA-Z_][a-zA-Z0-9_]*``). TPL names typically use mixed case |
| 45 |
# (e.g. ``SomeTpl``, not ``SOMETPL``). |
| 46 |
# |
| 47 |
# 1. **FINDMOD** (``<tpli_findmod>``): For a TriBITS external package/TPL that |
| 48 |
# **is not** a `TriBITS-compliant external package`_, this is set to the |
| 49 |
# relative or absolute path for the TriBITS TPL find module, usually with |
| 50 |
# the name `FindTPL<tplName>.cmake`_. If it is a relative path, it is |
| 51 |
# considered relative to the repository base directory ``<repoDir>``. If |
| 52 |
# just the base path for the find module is given, ending with ``"/"`` |
| 53 |
# (e.g. ``"cmake/tpls/"``), then the find module will be assumed to be |
| 54 |
# under that this directory with the standard name |
| 55 |
# ``FindTPL<tplName>.cmake``. (See `Creating the FindTPL<tplName>.cmake |
| 56 |
# file`_.) However, if the external package **is** a `TriBITS-compliant |
| 57 |
# external package`_, provide the value ``TRIBITS_PKG`` instead and no |
| 58 |
# ``FindTPL<tplName>.cmake`` file is needed. If a |
| 59 |
# ``FindTPL<tplName>Dependencies.cmake`` file is needed in this case, then |
| 60 |
# provide the path to that file (relative or absolute, directory or file |
| 61 |
# path) using ``TRIBITS_PKG:<path-to-dir-or-file>``. This field is used to |
| 62 |
# set the variables `<tplName>_FINDMOD`_ and |
| 63 |
# `<tplName>_DEPENDENCIES_FILE`_. |
| 64 |
# |
| 65 |
# 2. **CLASSIFICATION** (``<pkgi_classif>``): Gives the `Package Test Group`_ |
| 66 |
# `PT`_, `ST`_, or `EX`_ and the maturity level ``EP``, ``RS``, ``PG``, |
| 67 |
# ``PM``, ``GRS``, ``GPG``, ``GPM``, ``UM``. These are separated by a coma |
| 68 |
# with no space in between such as ``"RS,PT"`` for a "Research Stable", |
| 69 |
# "Primary Tested" package. No spaces are allowed so that CMake treats |
| 70 |
# this a one field in the array. The maturity level can be left off in |
| 71 |
# which case it is assumed to be ``UM`` for "Unspecified Maturity". This |
| 72 |
# field is used to set the variable `<tplName>_TESTGROUP`_ and |
| 73 |
# ``<tplName>_MATURITY_LEVEL``. |
| 74 |
# |
| 75 |
# A TPL defined in a upstream repo can be listed again in a downstream repo, |
| 76 |
# which allows redefining the find module that is used to specify the external |
| 77 |
# package/TPL. This allows downstream repos to add additional requirements |
| 78 |
# for a given TPL (i.e. add more libraries, headers, etc.). However, the |
| 79 |
# downstream repo's find module file must find the TPL components that are |
| 80 |
# fully compatible with the upstream defined find module in terms of what it |
| 81 |
# provides for packages in the upstream repos. |
| 82 |
# |
| 83 |
macro(tribits_repository_define_tpls) |
| 84 |
assert_defined(REPOSITORY_NAME) |
| 85 |
set(${REPOSITORY_NAME}_TPLS_FINDMODS_CLASSIFICATIONS "${ARGN}") |
| 86 |
endmacro() |
| 87 |
|
| 88 |
|
| 89 |
# @MACRO: tribits_process_tpls_lists() |
| 90 |
# |
| 91 |
# This macro that processes the project-level variable:: |
| 92 |
# |
| 93 |
# ${REPOSITORY_NAME}_TPLS_FINDMODS_CLASSIFICATIONS |
| 94 |
# |
| 95 |
# This updates the project-level variables: |
| 96 |
# |
| 97 |
# * `${PROJECT_NAME}_DEFINED_TPLS`_ |
| 98 |
# * `${PROJECT_NAME}_NUM_DEFINED_TPLS`_ |
| 99 |
# |
| 100 |
# For each TPL, it also sets the variables: |
| 101 |
# |
| 102 |
# * `${TPL_NAME}_FINDMOD`_ |
| 103 |
# * `${TPL_NAME}_TESTGROUP`_ |
| 104 |
# * `${TPL_NAME}_DEPENDENCIES_FILE`_ |
| 105 |
# * `${TPL_NAME}_TPLS_LIST_FILE`_ |
| 106 |
# * `${TPL_NAME}_PACKAGE_BUILD_STATUS`_ (to ``EXTERNAL``) |
| 107 |
# |
| 108 |
# See `Function call tree for constructing package dependency graph`_ |
| 109 |
# |
| 110 |
macro(tribits_process_tpls_lists REPOSITORY_NAME REPOSITORY_DIR) |
| 111 |
|
| 112 |
if (${PROJECT_NAME}_VERBOSE_CONFIGURE) |
| 113 |
message("TRIBITS_PROCESS_TPLS_LISTS: '${REPOSITORY_NAME}' '${REPOSITORY_DIR}'") |
| 114 |
endif() |
| 115 |
|
| 116 |
#set(TRIBITS_PROCESS_TPLS_LISTS_DEBUG ON) |
| 117 |
set(TRIBITS_PROCESS_TPLS_LISTS_DEBUG OFF) |
| 118 |
|
| 119 |
set(TPL_NAME_OFFSET 0) |
| 120 |
set(TPL_FINDMOD_OFFSET 1) |
| 121 |
set(TPL_CLASSIFICATION_OFFSET 2) |
| 122 |
set(TPL_NUM_COLUMNS 3) |
| 123 |
|
| 124 |
list(LENGTH ${REPOSITORY_NAME}_TPLS_FINDMODS_CLASSIFICATIONS |
| 125 |
${REPOSITORY_NAME}_CURR_NUM_TPLS_FULL) |
| 126 |
math(EXPR ${REPOSITORY_NAME}_CURR_NUM_TPLS |
| 127 |
"${${REPOSITORY_NAME}_CURR_NUM_TPLS_FULL}/${TPL_NUM_COLUMNS}") |
| 128 |
|
| 129 |
if (${REPOSITORY_NAME}_CURR_NUM_TPLS GREATER 0) |
| 130 |
|
| 131 |
math(EXPR ${REPOSITORY_NAME}_LAST_TPL_IDX |
| 132 |
"${${REPOSITORY_NAME}_CURR_NUM_TPLS}-1") |
| 133 |
|
| 134 |
foreach(TPL_IDX RANGE ${${REPOSITORY_NAME}_LAST_TPL_IDX}) |
| 135 |
|
| 136 |
if (TRIBITS_PROCESS_TPLS_LISTS_DEBUG) |
| 137 |
print_var(TPL_IDX) |
| 138 |
endif() |
| 139 |
|
| 140 |
# Get fields for this TPL |
| 141 |
|
| 142 |
math(EXPR TPL_NAME_IDX |
| 143 |
"${TPL_IDX}*${TPL_NUM_COLUMNS}+${TPL_NAME_OFFSET}") |
| 144 |
list(GET ${REPOSITORY_NAME}_TPLS_FINDMODS_CLASSIFICATIONS ${TPL_NAME_IDX} |
| 145 |
TPL_NAME) |
| 146 |
if (TRIBITS_PROCESS_TPLS_LISTS_DEBUG) |
| 147 |
print_var(TPL_NAME) |
| 148 |
endif() |
| 149 |
|
| 150 |
math(EXPR TPL_FINDMOD_IDX |
| 151 |
"${TPL_IDX}*${TPL_NUM_COLUMNS}+${TPL_FINDMOD_OFFSET}") |
| 152 |
list(GET ${REPOSITORY_NAME}_TPLS_FINDMODS_CLASSIFICATIONS ${TPL_FINDMOD_IDX} |
| 153 |
TPL_FINDMOD) |
| 154 |
if (TRIBITS_PROCESS_TPLS_LISTS_DEBUG) |
| 155 |
print_var(TPL_FINDMOD) |
| 156 |
endif() |
| 157 |
|
| 158 |
math(EXPR TPL_CLASSIFICATION_IDX |
| 159 |
"${TPL_IDX}*${TPL_NUM_COLUMNS}+${TPL_CLASSIFICATION_OFFSET}") |
| 160 |
list(GET ${REPOSITORY_NAME}_TPLS_FINDMODS_CLASSIFICATIONS ${TPL_CLASSIFICATION_IDX} |
| 161 |
TPL_CLASSIFICATION) |
| 162 |
if (TRIBITS_PROCESS_TPLS_LISTS_DEBUG) |
| 163 |
print_var(TPL_CLASSIFICATION) |
| 164 |
endif() |
| 165 |
|
| 166 |
# ToDo: Parse out TESTGROUP and MATURITYLEVEL (Trilinos #6042) |
| 167 |
set(TPL_TESTGROUP ${TPL_CLASSIFICATION}) |
| 168 |
|
| 169 |
tribits_update_ps_pt_ss_st(TPL ${TPL_NAME} TPL_TESTGROUP) |
| 170 |
|
| 171 |
# Update TPLS list (unless the TPL already exists) |
| 172 |
|
| 173 |
if (${TPL_NAME}_FINDMOD) |
| 174 |
# If the variable ${TPL_NAME}_FINDMOD already exists, then this TPL |
| 175 |
# has already been defined in a previous repository. In this case, we |
| 176 |
# will just leave the TPL in its current position. |
| 177 |
if (${PROJECT_NAME}_VERBOSE_CONFIGURE) |
| 178 |
message("-- " "NOTE: The TPL ${TPL_NAME} has already been defined so leaving it" |
| 179 |
" in the same location and not adding it again!") |
| 180 |
endif() |
| 181 |
else() |
| 182 |
list(APPEND ${PROJECT_NAME}_DEFINED_TPLS ${TPL_NAME}) |
| 183 |
endif() |
| 184 |
|
| 185 |
# Set ${TPL_NAME}_TESTGROUP |
| 186 |
|
| 187 |
if (TPL_TESTGROUP STREQUAL PT |
| 188 |
OR TPL_TESTGROUP STREQUAL ST |
| 189 |
OR TPL_TESTGROUP STREQUAL TT |
| 190 |
OR TPL_TESTGROUP STREQUAL EX |
| 191 |
) |
| 192 |
else() |
| 193 |
message(FATAL_ERROR "Error the TPL classification '${TPL_TESTGROUP}'" |
| 194 |
" for the TPL ${TPL_NAME} is not a valid classification." ) |
| 195 |
endif() |
| 196 |
|
| 197 |
if (NOT ${TPL_NAME}_TESTGROUP) # Allow for testing override |
| 198 |
set(${TPL_NAME}_TESTGROUP ${TPL_TESTGROUP}) |
| 199 |
endif() |
| 200 |
|
| 201 |
# Set ${TPL_NAME}_FINDMOD |
| 202 |
|
| 203 |
if ("${REPOSITORY_DIR}" STREQUAL "." OR IS_ABSOLUTE ${TPL_FINDMOD}) |
| 204 |
set(REPOSITORY_DIR_AND_SEP "") |
| 205 |
else() |
| 206 |
set(REPOSITORY_DIR_AND_SEP "${REPOSITORY_DIR}/") |
| 207 |
endif() |
| 208 |
|
| 209 |
set(TPL_FINDMOD "${REPOSITORY_DIR_AND_SEP}${TPL_FINDMOD}") |
| 210 |
|
| 211 |
set(TPL_FINDMOD_STD_NAME "FindTPL${TPL_NAME}.cmake") |
| 212 |
|
| 213 |
if (TPL_FINDMOD) |
| 214 |
string(REGEX MATCH ".+/$" FINDMOD_IS_DIR "${TPL_FINDMOD}") |
| 215 |
if (FINDMOD_IS_DIR) |
| 216 |
set(${TPL_NAME}_FINDMOD "${TPL_FINDMOD}${TPL_FINDMOD_STD_NAME}") |
| 217 |
else() |
| 218 |
set(${TPL_NAME}_FINDMOD ${TPL_FINDMOD}) |
| 219 |
endif() |
| 220 |
else() |
| 221 |
set(${TPL_NAME}_FINDMOD ${TPL_FINDMOD_STD_NAME}) |
| 222 |
endif() |
| 223 |
|
| 224 |
# Set ${TPL_NAME}_DEPENDENCIES_FILE |
| 225 |
|
| 226 |
# Breakdown ${${TPL_NAME}_FINDMOD} into parts <dir>/<base>.<ext> |
| 227 |
get_filename_component(tpl_findmod_dir ${${TPL_NAME}_FINDMOD} DIRECTORY) |
| 228 |
get_filename_component(tpl_findmod_base ${${TPL_NAME}_FINDMOD} NAME_WLE) |
| 229 |
get_filename_component(tpl_findmod_ext ${${TPL_NAME}_FINDMOD} LAST_EXT) |
| 230 |
|
| 231 |
set(${TPL_NAME}_DEPENDENCIES_FILE |
| 232 |
"${tpl_findmod_dir}/${tpl_findmod_base}Dependencies${tpl_findmod_ext}") |
| 233 |
|
| 234 |
# Set ${TPL_NAME}_TPLS_LIST_FILE |
| 235 |
|
| 236 |
assert_defined(${REPOSITORY_NAME}_TPLS_FILE) |
| 237 |
set(${TPL_NAME}_TPLS_LIST_FILE ${${REPOSITORY_NAME}_TPLS_FILE}) |
| 238 |
|
| 239 |
# Set ${TPL_NAME}_PACKAGE_BUILD_STATUS |
| 240 |
|
| 241 |
set(${TPL_NAME}_PACKAGE_BUILD_STATUS EXTERNAL) |
| 242 |
|
| 243 |
# Set ${TPL_NAME}_IS_TRIBITS_COMPLIANT |
| 244 |
|
| 245 |
if (${TPL_NAME}_FINDMOD STREQUAL "TRIBITS_PKG") |
| 246 |
set(${TPL_NAME}_IS_TRIBITS_COMPLIANT TRUE) |
| 247 |
else() |
| 248 |
set(${TPL_NAME}_IS_TRIBITS_COMPLIANT FALSE) |
| 249 |
endif() |
| 250 |
|
| 251 |
# Print variables/properties for the TPL |
| 252 |
|
| 253 |
if (${PROJECT_NAME}_VERBOSE_CONFIGURE OR TRIBITS_PROCESS_TPLS_LISTS_VERBOSE) |
| 254 |
print_var(${TPL_NAME}_TESTGROUP) |
| 255 |
print_var(${TPL_NAME}_FINDMOD) |
| 256 |
print_var(${TPL_NAME}_DEPENDENCIES_FILE) |
| 257 |
print_var(${TPL_NAME}_TPLS_LIST_FILE) |
| 258 |
print_var(${TPL_NAME}_PACKAGE_BUILD_STATUS) |
| 259 |
print_var(${TPL_NAME}_IS_TRIBITS_COMPLIANT) |
| 260 |
endif() |
| 261 |
|
| 262 |
# Set cache var TPL_ENABLE_${TPL_NAME} with default "" |
| 263 |
|
| 264 |
multiline_set(DOCSTR |
| 265 |
"Enable support for the TPL ${TPL_NAME} in all supported ${PROJECT_NAME} packages." |
| 266 |
" This can be set to 'ON', 'OFF', or left empty ''." |
| 267 |
) |
| 268 |
set_cache_on_off_empty( TPL_ENABLE_${TPL_NAME} "" ${DOCSTR} ) |
| 269 |
|
| 270 |
# 2008/11/25: rabartl: Above, we use the prefix TPL_ instead of |
| 271 |
# ${PROJECT_NAME}_ in order to make it clear that external TPLs are |
| 272 |
# different from packages so users don't get confused and think that the |
| 273 |
# project actually includes the source code and internal build for some |
| 274 |
# TPL when it does not! |
| 275 |
|
| 276 |
endforeach() |
| 277 |
|
| 278 |
endif() |
| 279 |
|
| 280 |
if (${PROJECT_NAME}_VERBOSE_CONFIGURE) |
| 281 |
print_var(${PROJECT_NAME}_DEFINED_TPLS) |
| 282 |
endif() |
| 283 |
|
| 284 |
# Get and print length |
| 285 |
list(LENGTH ${PROJECT_NAME}_DEFINED_TPLS ${PROJECT_NAME}_NUM_DEFINED_TPLS) |
| 286 |
message("-- After reading above TPLsList.cmake file: " |
| 287 |
"${PROJECT_NAME}_NUM_DEFINED_TPLS='${${PROJECT_NAME}_NUM_DEFINED_TPLS}'") |
| 288 |
|
| 289 |
endmacro() |