Skip to content

Commit

Permalink
Merge branch 'tribits_github_snapshot' into tribits-299-modern-cmake-…
Browse files Browse the repository at this point in the history
…targets-1 (TriBITSPub/TriBITS#299)
  • Loading branch information
bartlettroscoe committed Nov 19, 2021
2 parents 625f3ae + 5ab3736 commit 9f83190
Show file tree
Hide file tree
Showing 36 changed files with 899 additions and 69 deletions.
14 changes: 12 additions & 2 deletions cmake/tribits/ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
Release Notes for TriBITS
----------------------------------------

2021/11/18:

(*) MAJOR: The default <Project>_GENERATE_REPO_VERSION_FILE_DEFAULT will be
overridden to OFF if the 'git' executable cannot be found at configure
time. See updated TriBITS Developer's Guilde documenation.

(*) MAJOR: The default value for <Project>_ENABLE_Fortran is set to OFF on
WIN32 systems. (Getting a Fortran compiler for native Windows is not
typically very easy.)

2021/10/11:

(*) MAJOR: The `<Package>Config.cmake` for each enabled package generated in
the build directory tree have been moved from
`<buildDir>/packages/<packageDir>/` to
`<buildDir>/cmake_packages/<PackageName>/`. This makes it easy for
`find_package(<PackageName>)` to fine these files by simply adding the
`find_package(<PackageName>)` to find these files by simply adding the
directory ``<buildDir>/cmake_packages` to `CMAKE_PREFIX_PATH` and then
`<Package>Config.cmake` for any enabled package will be found
automatically found by CMake.
Expand All @@ -19,7 +29,7 @@ Release Notes for TriBITS
has been removed along with the cache variable
<Project>_ENABLE_EXPORT_MAKEFILES. This is to allow the refactoring of
TriBITS to use modern CMake targets that propagate all information and
removing complex dependency tracking inforamtion from TriBITS (see
removing complex dependency tracking information from TriBITS (see
TriBITSPub/TriBITS#63 and TriBITSPub/TriBITS#299).

2021/06/17:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ endif()
# Initialize ${PROJECT_NAME}_FOUND with true, and set it to FALSE if any of
# the required components wasn't found.
set(${PROJECT_NAME}_FOUND TRUE)
set(${PROJECT_NAME}_NOT_FOUND_MESSAGE "")
foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST})
set(
INCLUDE_FILE
Expand All @@ -121,10 +122,10 @@ foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST})
list(APPEND ${PROJECT_NAME}_TPL_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARY_DIRS})
list(APPEND ${PROJECT_NAME}_TPL_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARIES})
else()
# Set ${PROJECT_NAME}_<component>_FOUND to FALSE.
set(${PROJECT_NAME}_${PDOLLAR}{comp}_FOUND FALSE)
# Set ${PROJECT_NAME}_FOUND to FALSE if component is not optional.
if(${PROJECT_NAME}_FIND_REQUIRED_${PDOLLAR}{comp})
string(APPEND ${PROJECT_NAME}_NOT_FOUND_MESSAGE
"ERROR: Could not find component '${PDOLLAR}{comp}'!\n")
set(${PROJECT_NAME}_FOUND FALSE)
endif()
endif()
Expand Down
2 changes: 2 additions & 0 deletions cmake/tribits/core/package_arch/TribitsConstants.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ set(${PROJECT_NAME}_PACKAGE_DEPS_TABLE_HTML_FILE_NAME ${PROJECT_NAME}PackageDepe

set(${PROJECT_NAME}_PACKAGE_DEPS_FILES_DIR "cmake/dependencies")

set(${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR "external_packages")

set(${PROJECT_NAME}_BUILD_DIR_CMAKE_PKGS_DIR "cmake_packages")

# Other stuff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,46 @@ function(tribits_external_package_write_config_file tplName tplConfigFile)
endfunction()


# @FUNCTION: tribits_external_package_write_config_version_file()
#
# Write out a ``<tplName>ConfigVersion.cmake`` file.
#
# Usage::
#
# tribits_write_external_package_config_version_file(
# <tplName> <tplConfigVersionFile> )
#
# ToDo: Add version arguments!
#
# The arguments are:
#
# ``<tplName>``: Name of the external package/TPL
#
# ``<tplConfigVersionFile>``: Full file path for the
# ``<tplName>ConfigVersion.cmake`` file that will be written out.
#
function(tribits_external_package_write_config_version_file tplName tplConfigVersionFile)
set(tplConfigVersionFileStr "")
string(APPEND tplConfigVersionFileStr
"# Package config file for external package/TPL '${tplName}'\n"
"#\n"
"# Generated by CMake, do not edit!\n"
"\n"
"if (TRIBITS_FINDING_RAW_${tplName}_PACKAGE_FIRST)\n"
" set(PACKAGE_VERSION_COMPATIBLE FALSE)\n"
" set(PACKAGE_VERSION_UNSUITABLE TRUE)\n"
"else()\n"
" set(PACKAGE_VERSION_COMPATIBLE TRUE)\n"
"endif()\n"
"\n"
"# Currently there is no version information\n"
"set(PACKAGE_VERSION UNKNOWN)\n"
"set(PACKAGE_VERSION_EXACT FALSE)\n"
)
file(WRITE "${tplConfigVersionFile}" "${tplConfigVersionFileStr}")
endfunction()


# @FUNCTION: tribits_external_package_install_config_file()
#
# Install an already-generated ``<tplName>Config.cmake`` file.
Expand All @@ -88,7 +128,34 @@ endfunction()
function(tribits_external_package_install_config_file tplName tplConfigFile)
install(
FILES "${tplConfigFile}"
DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}/cmake/${tplName}"
DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}/external_packages/${tplName}"
)
endfunction()


# @FUNCTION: tribits_external_package_install_config_version_file()
#
# Install an already-generated ``<tplName>ConfigVersion.cmake`` file.
#
# Usage::
#
# tribits_write_external_package_install_config_version_file(
# <tplName> <tplConfigVersionFile> )
#
# The arguments are:
#
# ``<tplName>``: Name of the external package/TPL
#
# ``<tplConfigVersionFile>``: Full file path for the
# ``<tplName>ConfigVersion.cmake`` file that will be installed into the
# correct location.
#
function(tribits_external_package_install_config_version_file tplName
tplConfigVersionFile
)
install(
FILES "${tplConfigVersionFile}"
DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}/external_packages/${tplName}"
)
endfunction()

Expand Down Expand Up @@ -370,11 +437,17 @@ function(tribits_external_package_get_libname_from_full_lib_path full_lib_path
if (full_libname_len LESS 0)
tribits_print_invalid_lib_name(${tplName} "${full_libname}")
endif()
string(SUBSTRING "${full_libname}" 0 3 libPart)
if (NOT libPart STREQUAL "lib")
tribits_print_invalid_lib_name(${tplName} "${full_libname}")
if (WIN32)
# Native windows compilers does not prepend library names with 'lib'
set(libname "${full_libname}")
else()
# Every other system prepends the library name with 'lib'
string(SUBSTRING "${full_libname}" 0 3 libPart)
if (NOT libPart STREQUAL "lib")
tribits_print_invalid_lib_name(${tplName} "${full_libname}")
endif()
string(SUBSTRING "${full_libname}" 3 -1 libname)
endif()
string(SUBSTRING "${full_libname}" 3 -1 libname)
set(${libnameOut} ${libname} PARENT_SCOPE)
endfunction()

Expand Down
11 changes: 9 additions & 2 deletions cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,11 @@ macro(tribits_define_global_options_and_define_extra_repos)
set(${PROJECT_NAME}_ENABLE_CXX11 ON)

if ("${${PROJECT_NAME}_ENABLE_Fortran_DEFAULT}" STREQUAL "")
set(${PROJECT_NAME}_ENABLE_Fortran_DEFAULT ON)
if (WIN32)
set(${PROJECT_NAME}_ENABLE_Fortran_DEFAULT OFF)
else()
set(${PROJECT_NAME}_ENABLE_Fortran_DEFAULT ON)
endif()
endif()

option(${PROJECT_NAME}_ENABLE_Fortran
Expand Down Expand Up @@ -649,7 +653,9 @@ macro(tribits_define_global_options_and_define_extra_repos)
)
tribits_get_invalid_categories(${PROJECT_NAME}_TEST_CATEGORIES)

if ("${${PROJECT_NAME}_GENERATE_REPO_VERSION_FILE_DEFAULT}" STREQUAL "" )
if (NOT GIT_EXECUTABLE)
set(${PROJECT_NAME}_GENERATE_REPO_VERSION_FILE_DEFAULT OFF)
elseif ("${${PROJECT_NAME}_GENERATE_REPO_VERSION_FILE_DEFAULT}" STREQUAL "" )
set(${PROJECT_NAME}_GENERATE_REPO_VERSION_FILE_DEFAULT OFF)
endif()
advanced_set(
Expand Down Expand Up @@ -1387,6 +1393,7 @@ function(tribits_generate_repo_version_output_and_file_and_install)
# A) Create the ${PROJECT_NAME}RepoVersion.txt file if requested
#

print_var(${PROJECT_NAME}_GENERATE_REPO_VERSION_FILE)
if (${PROJECT_NAME}_GENERATE_REPO_VERSION_FILE)

# A) Make sure that there is a .git dir in the project before generating
Expand Down
28 changes: 28 additions & 0 deletions cmake/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@


# Standard TriBITS Includes
include(TribitsExternalPackageWriteConfigFile)
include(TribitsTplFindIncludeDirsAndLibraries)
include(TribitsGeneralMacros)

Expand Down Expand Up @@ -103,7 +104,18 @@ function(tribits_process_enabled_tpl TPL_NAME)

# Process the FindTPL${TPL_NAME}.cmake module
tribits_trace_file_processing(TPL INCLUDE "${CURRENT_TPL_PATH}")
set(TRIBITS_FINDING_RAW_${TPL_NAME}_PACKAGE_FIRST TRUE)
include("${CURRENT_TPL_PATH}")
unset(TRIBITS_FINDING_RAW_${TPL_NAME}_PACKAGE_FIRST)
# NOTE: Above, setting TRIBITS_FINDING_RAW_${TPL_NAME}_PACKAGE_FIRST=TRUE
# triggers special logic in the TriBITS-created
# ${TPL_NAME}ConfigVersion.cmake file to set
# PACKAGE_VERSION_COMPATIBLE=FALSE and result in find_package(${TPL_NAME})
# that may be called inside of ${TPL_NAME}_FINDMOD to not find a
# TriBITS-generated ${TPL_NAME}Config.cmake file. This allows
# find_package(${TPL_NAME}) to usae a proper non-TriBITS
# Find${TPL_NAME}.cmake module or find a non-TriBITS
# ${TPL_NAME}Config.cmake module.

if (${PROJECT_NAME}_VERBOSE_CONFIGURE)
print_var(TPL_${TPL_NAME}_NOT_FOUND)
Expand Down Expand Up @@ -152,6 +164,22 @@ function(tribits_process_enabled_tpl TPL_NAME)
# ToDo: Make TPL_${TPL_NAME}_LIBRARY_DIRS go away. It is not needed for
# anything.

# Generate the <tplName>ConfigVersion.cmake file if it has not been
# created yet and add install targets for <tplName>Config[Version].cmake
if (TARGET ${TPL_NAME}::all_libs)
set(buildDirExternalPkgsDir
"${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}")
set(tplConfigFile
"${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}Config.cmake")
set(tplConfigVersionFile
"${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}ConfigVersion.cmake")
tribits_external_package_write_config_version_file(${TPL_NAME}
"${tplConfigVersionFile}")
tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}")
tribits_external_package_install_config_version_file(${TPL_NAME}
"${tplConfigVersionFile}")
endif()

endif()

endfunction()
Original file line number Diff line number Diff line change
Expand Up @@ -677,15 +677,17 @@ function(tribits_tpl_find_include_dirs_and_libraries TPL_NAME)
global_set(TPL_${TPL_NAME}_NOT_FOUND FALSE)
endif()

set(buildDirCMakePkgsDir
"${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_CMAKE_PKGS_DIR}")
set(buildDirExternalPkgsDir
"${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}")
set(tplConfigFile
"${buildDirCMakePkgsDir}/${TPL_NAME}/${TPL_NAME}Config.cmake")
"${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}Config.cmake")
tribits_external_package_write_config_file(${TPL_NAME} "${tplConfigFile}")
if (NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING)
include("${tplConfigFile}")
endif()
tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}")
# NOTE: The file <tplName>ConfigVersion.cmake will get created elsewhere as
# will the install targets for the files <tplName>Config and
# <tplName>ConfigVersion.cmake.

endfunction()

Expand Down
34 changes: 21 additions & 13 deletions cmake/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ endfunction()
#
function(tribits_generate_package_config_file_for_build_tree packageName)

set(BUILD_DIR_CMAKE_PKGS_DIR
set(buildDirExtPkgsDir
"${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}")
set(buildDirCMakePkgsDir
"${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_CMAKE_PKGS_DIR}")

if (PARSE_PACKAGE_CONFIG_FOR_BUILD_BASE_DIR
Expand All @@ -382,7 +384,8 @@ function(tribits_generate_package_config_file_for_build_tree packageName)
set(PACKAGE_CONFIG_CODE "")

tribits_append_dependent_package_config_file_includes(${packageName}
CONFIG_FILE_BASE_DIR "${BUILD_DIR_CMAKE_PKGS_DIR}"
EXT_PKG_CONFIG_FILE_BASE_DIR "${buildDirExtPkgsDir}"
PKG_CONFIG_FILE_BASE_DIR "${buildDirCMakePkgsDir}"
CONFIG_FILE_STR_INOUT PACKAGE_CONFIG_CODE )

# Import build tree targets into applications.
Expand Down Expand Up @@ -469,7 +472,9 @@ function(tribits_generate_package_config_file_for_install_tree packageName)
set(PACKAGE_CONFIG_CODE "")

tribits_append_dependent_package_config_file_includes(${packageName}
CONFIG_FILE_BASE_DIR "\${CMAKE_CURRENT_LIST_DIR}/.."
EXT_PKG_CONFIG_FILE_BASE_DIR
"\${CMAKE_CURRENT_LIST_DIR}/../../${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}"
PKG_CONFIG_FILE_BASE_DIR "\${CMAKE_CURRENT_LIST_DIR}/.."
CONFIG_FILE_STR_INOUT PACKAGE_CONFIG_CODE )

# Import install targets
Expand Down Expand Up @@ -499,14 +504,15 @@ endfunction()

# @FUNCTION: tribits_append_dependent_package_config_file_includes()
#
# Append the includes for upstream internal packages and external packages
# (TPLs) to a `<Package>Config.cmake` file string.
# Append the includes for upstream external packages (TPLs) and internal
# packages to a `<Package>Config.cmake` file string.
#
# Usage::
#
# tribits_append_dependent_package_config_file_includes(
# <packageName>
# CONFIG_FILE_BASE_DIR <configFileBaseDir>
# EXT_PKG_CONFIG_FILE_BASE_DIR <extPkgconfigFileBaseDir>
# PKG_CONFIG_FILE_BASE_DIR <pkgConfigFileBaseDir>
# CONFIG_FILE_STR_INOUT <configFileStrInOut>
# )
#
Expand All @@ -517,20 +523,22 @@ function(tribits_append_dependent_package_config_file_includes packageName)
cmake_parse_arguments(
PARSE #prefix
"" #options
"CONFIG_FILE_BASE_DIR;CONFIG_FILE_STR_INOUT" #one_value_keywords
#one_value_keywords
"EXT_PKG_CONFIG_FILE_BASE_DIR;PKG_CONFIG_FILE_BASE_DIR;CONFIG_FILE_STR_INOUT"
"" #multi_value_keywords
${ARGN}
)
tribits_check_for_unparsed_arguments()

set(configFileBaseDir "${PARSE_CONFIG_FILE_BASE_DIR}")
set(extPkgConfigFileBaseDir "${PARSE_EXT_PKG_CONFIG_FILE_BASE_DIR}")
set(pkgConfigFileBaseDir "${PARSE_PKG_CONFIG_FILE_BASE_DIR}")
set(configFileStr "${${PARSE_CONFIG_FILE_STR_INOUT}}")

# Include configurations of dependent packages
string(APPEND configFileStr
"# Include configuration of dependent packages\n")
foreach(depPkg IN LISTS ${packageName}_FULL_ENABLED_DEP_PACKAGES)
set(cmakePkgDir "${configFileBaseDir}/${depPkg}")
set(cmakePkgDir "${pkgConfigFileBaseDir}/${depPkg}")
string(APPEND configFileStr
"include(\"${cmakePkgDir}/${depPkg}Config.cmake\")\n")
endforeach()
Expand All @@ -540,14 +548,14 @@ function(tribits_append_dependent_package_config_file_includes packageName)
"\n# Include configuration of dependent external packages/TPls\n")
foreach(depTpl IN LISTS ${packageName}_LIB_REQUIRED_DEP_TPLS)
if (TARGET ${depTpl}::all_libs)
set(cmakeTplDir "${configFileBaseDir}/${depTpl}")
set(cmakeTplDir "${extPkgConfigFileBaseDir}/${depTpl}")
string(APPEND configFileStr
"include(\"${cmakeTplDir}/${depTpl}Config.cmake\")\n")
endif()
endforeach()
foreach(depTpl IN LISTS ${packageName}_LIB_OPTIONAL_DEP_TPLS)
if (${packageName}_ENABLE_${depTpl} AND TARGET ${depTpl}::all_libs)
set(cmakeTplDir "${configFileBaseDir}/${depTpl}")
set(cmakeTplDir "${extPkgConfigFileBaseDir}/${depTpl}")
string(APPEND configFileStr
"include(\"${cmakeTplDir}/${depTpl}Config.cmake\")\n")
endif()
Expand Down Expand Up @@ -645,7 +653,7 @@ function(tribits_write_package_client_export_files PACKAGE_NAME)
message("\nTRIBITS_WRITE_PACKAGE_CLIENT_EXPORT_FILES: ${PACKAGE_NAME}")
endif()

set(BUILD_DIR_CMAKE_PKGS_DIR
set(buildDirCMakePkgsDir
"${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_CMAKE_PKGS_DIR}")

set(EXPORT_FILES_ARGS PACKAGE_NAME ${PACKAGE_NAME})
Expand All @@ -655,7 +663,7 @@ function(tribits_write_package_client_export_files PACKAGE_NAME)
message("For package ${PACKAGE_NAME} creating ${PACKAGE_NAME}Config.cmake")
endif()
set(PACKAGE_CONFIG_FOR_BUILD_BASE_DIR
"${BUILD_DIR_CMAKE_PKGS_DIR}/${PACKAGE_NAME}" )
"${buildDirCMakePkgsDir}/${PACKAGE_NAME}" )
set(PACKAGE_CONFIG_FOR_INSTALL_BASE_DIR
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles" )
append_set(EXPORT_FILES_ARGS
Expand Down
3 changes: 3 additions & 0 deletions cmake/tribits/core/utils/CMakeBuildTypesList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@

set(CMAKE_BUILD_TYPES_LIST
DEBUG MINSIZEREL RELEASE RELWITHDEBINFO NONE)

set(CMAKE_CONFIG_FILE_BUILD_TYPES_LIST
Debug Release RelWithDebInfo MinSizeRel NoConfig)
Loading

0 comments on commit 9f83190

Please sign in to comment.