| 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 |
# |
| 12 |
# CMake variable for use by ${PROJECT_NAME}/${PACKAGE_NAME} clients. |
| 13 |
# |
| 14 |
# ${DISCOURAGE_EDITING} |
| 15 |
# |
| 16 |
############################################################################## |
| 17 |
|
| 18 |
if(CMAKE_VERSION VERSION_LESS 3.3) |
| 19 |
set(${PDOLLAR}{CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE |
| 20 |
"${PACKAGE_NAME} requires CMake 3.3 or later for 'if (... IN_LIST ...)'" |
| 21 |
) |
| 22 |
set(${PDOLLAR}{CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) |
| 23 |
return() |
| 24 |
endif() |
| 25 |
cmake_minimum_required(VERSION 3.3...${TRIBITS_CMAKE_MINIMUM_REQUIRED}) |
| 26 |
|
| 27 |
## --------------------------------------------------------------------------- |
| 28 |
## Compilers used by ${PROJECT_NAME}/${PACKAGE_NAME} build |
| 29 |
## --------------------------------------------------------------------------- |
| 30 |
|
| 31 |
set(${EXPORT_FILE_VAR_PREFIX}_CXX_COMPILER "${CMAKE_CXX_COMPILER_FOR_CONFIG_FILE}") |
| 32 |
|
| 33 |
set(${EXPORT_FILE_VAR_PREFIX}_C_COMPILER "${CMAKE_C_COMPILER_FOR_CONFIG_FILE}") |
| 34 |
|
| 35 |
set(${EXPORT_FILE_VAR_PREFIX}_Fortran_COMPILER "${CMAKE_Fortran_COMPILER_FOR_CONFIG_FILE}") |
| 36 |
# Deprecated! |
| 37 |
set(${EXPORT_FILE_VAR_PREFIX}_FORTRAN_COMPILER "${CMAKE_Fortran_COMPILER_FOR_CONFIG_FILE}") |
| 38 |
|
| 39 |
|
| 40 |
## --------------------------------------------------------------------------- |
| 41 |
## Compiler flags used by ${PROJECT_NAME}/${PACKAGE_NAME} build |
| 42 |
## --------------------------------------------------------------------------- |
| 43 |
|
| 44 |
## Give the build type |
| 45 |
set(${EXPORT_FILE_VAR_PREFIX}_CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}") |
| 46 |
|
| 47 |
## Set compiler flags, including those determined by build type |
| 48 |
set(${EXPORT_FILE_VAR_PREFIX}_CXX_FLAGS [[${CMAKE_CXX_FLAGS_ESCAPED} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}]]) |
| 49 |
|
| 50 |
set(${EXPORT_FILE_VAR_PREFIX}_C_FLAGS [[${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}]]) |
| 51 |
|
| 52 |
set(${EXPORT_FILE_VAR_PREFIX}_Fortran_FLAGS [[${CMAKE_FORTRAN_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}}]]) |
| 53 |
# Deprecated |
| 54 |
set(${EXPORT_FILE_VAR_PREFIX}_FORTRAN_FLAGS [[${CMAKE_FORTRAN_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}}]]) |
| 55 |
|
| 56 |
## Extra link flags (e.g., specification of fortran libraries) |
| 57 |
set(${EXPORT_FILE_VAR_PREFIX}_EXTRA_LD_FLAGS [[${${PROJECT_NAME}_EXTRA_LINK_FLAGS}]]) |
| 58 |
|
| 59 |
## This is the command-line entry used for setting rpaths. In a build |
| 60 |
## with static libraries it will be empty. |
| 61 |
set(${EXPORT_FILE_VAR_PREFIX}_SHARED_LIB_RPATH_COMMAND "${SHARED_LIB_RPATH_COMMAND}") |
| 62 |
set(${EXPORT_FILE_VAR_PREFIX}_BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS}") |
| 63 |
|
| 64 |
set(${EXPORT_FILE_VAR_PREFIX}_LINKER ${CMAKE_LINKER}) |
| 65 |
set(${EXPORT_FILE_VAR_PREFIX}_AR ${CMAKE_AR}) |
| 66 |
|
| 67 |
## --------------------------------------------------------------------------- |
| 68 |
## Set library specifications and paths |
| 69 |
## --------------------------------------------------------------------------- |
| 70 |
|
| 71 |
## Base install location (if not in the build tree) |
| 72 |
set(${EXPORT_FILE_VAR_PREFIX}_INSTALL_DIR "@CMAKE_INSTALL_PREFIX@") |
| 73 |
|
| 74 |
## List of package libraries |
| 75 |
set(${EXPORT_FILE_VAR_PREFIX}_LIBRARIES ${PACKAGE_NAME}::all_libs) |
| 76 |
|
| 77 |
## --------------------------------------------------------------------------- |
| 78 |
## MPI specific variables |
| 79 |
## These variables are provided to make it easier to get the mpi libraries |
| 80 |
## and includes on systems that do not use the mpi wrappers for compiling |
| 81 |
## --------------------------------------------------------------------------- |
| 82 |
|
| 83 |
set(${EXPORT_FILE_VAR_PREFIX}_MPI_LIBRARIES "${TPL_MPI_LIBRARIES}") |
| 84 |
set(${EXPORT_FILE_VAR_PREFIX}_MPI_LIBRARY_DIRS "${TPL_MPI_LIBRARY_DIRS}") |
| 85 |
set(${EXPORT_FILE_VAR_PREFIX}_MPI_INCLUDE_DIRS "${TPL_MPI_INCLUDE_DIRS}") |
| 86 |
set(${EXPORT_FILE_VAR_PREFIX}_MPI_EXEC "${MPI_EXEC}") |
| 87 |
set(${EXPORT_FILE_VAR_PREFIX}_MPI_EXEC_MAX_NUMPROCS "${MPI_EXEC_MAX_NUMPROCS}") |
| 88 |
set(${EXPORT_FILE_VAR_PREFIX}_MPI_EXEC_NUMPROCS_FLAG "${MPI_EXEC_NUMPROCS_FLAG}") |
| 89 |
|
| 90 |
## --------------------------------------------------------------------------- |
| 91 |
## Set useful general variables |
| 92 |
## --------------------------------------------------------------------------- |
| 93 |
|
| 94 |
${PACKAGE_CONFIG_CODE} |
| 95 |
|
| 96 |
## ---------------------------------------------------------------------------- |
| 97 |
## Create deprecated non-namespaced library targets for backwards compatibility |
| 98 |
## ---------------------------------------------------------------------------- |
| 99 |
|
| 100 |
set(${EXPORT_FILE_VAR_PREFIX}_EXPORTED_PACKAGE_LIBS_NAMES "${EXPORTED_PACKAGE_LIBS_NAMES}") |
| 101 |
|
| 102 |
foreach(libname IN LISTS ${EXPORT_FILE_VAR_PREFIX}_EXPORTED_PACKAGE_LIBS_NAMES) |
| 103 |
if (NOT TARGET ${PDOLLAR}{libname}) |
| 104 |
add_library(${PDOLLAR}{libname} INTERFACE IMPORTED) |
| 105 |
target_link_libraries(${PDOLLAR}{libname} |
| 106 |
INTERFACE ${PACKAGE_NAME}::${PDOLLAR}{libname}) |
| 107 |
set(deprecationMessage |
| 108 |
"WARNING: The non-namespaced target '${PDOLLAR}{libname}' is deprecated!" |
| 109 |
" If always using newer versions of the project '${PROJECT_NAME}', then use the" |
| 110 |
" new namespaced target '${PACKAGE_NAME}::${PDOLLAR}{libname}', or better yet," |
| 111 |
" '${PACKAGE_NAME}::all_libs' to be less sensitive to changes in the definition" |
| 112 |
" of targets in the package '${PACKAGE_NAME}'. Or, to maintain compatibility with" |
| 113 |
" older or newer versions the project '${PROJECT_NAME}', instead link against the" |
| 114 |
" libraries specified by the variable '${PACKAGE_NAME}_LIBRARIES'." |
| 115 |
) |
| 116 |
string(REPLACE ";" "" deprecationMessage "${PDOLLAR}{deprecationMessage}") |
| 117 |
set_target_properties(${PDOLLAR}{libname} |
| 118 |
PROPERTIES DEPRECATION "${PDOLLAR}{deprecationMessage}" ) |
| 119 |
endif() |
| 120 |
endforeach() |