From 1ee206f77c4571ebb2c1b280795f592d9469574b Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 29 Apr 2020 16:43:45 -0600 Subject: [PATCH 1/6] Automatic snapshot commit from tribits at 889fa64 Origin repo remote tracking branch: 'github/master' Origin repo remote repo URL: 'github = git@github.com:TriBITSPub/TriBITS.git' At commit: commit 889fa648b58503cba5b4c52ec732e78f0045ef27 Author: Roscoe A. Bartlett Date: Thu Apr 23 17:42:54 2020 -0600 Summary: Implement recursive chgrp and chmod for installed files/directories (#314, ATDV-241) --- .../CMakeLists.txt | 17 + .../installation/cmake_pbp_install.cmake.in | 18 +- ...t_installed_group_and_permissions.cmake.in | 89 +++++ .../package_arch/TribitsAddExecutable.cmake | 3 +- ...TribitsAddInstallGroupAndPermsFixups.cmake | 57 +++ .../package_arch/TribitsCMakePolicies.cmake | 3 + .../package_arch/TribitsGlobalMacros.cmake | 133 ++++-- .../package_arch/TribitsLibraryMacros.cmake | 11 +- .../core/utils/TribitsFilepathHelpers.cmake | 96 +++++ .../core/utils/UseCcacheIfExists.cmake | 9 + ...dd-CTEST_RESOURCE_SPEC_FILE-variable.patch | 377 ++++++++++++++++++ .../tribits/devtools_install/install-cmake.py | 9 + .../build_ref/TribitsBuildReferenceBody.rst | 90 +++-- .../TribitsDevelopersGuide.rst | 96 ++++- .../with_subpackages/b/CMakeLists.txt | 7 + .../with_subpackages/b/stuff/exec_script.sh | 2 + .../with_subpackages/b/stuff/regular_file.txt | 1 + 17 files changed, 948 insertions(+), 70 deletions(-) create mode 100644 cmake/tribits/core/add_install_group_and_perms_fixups/CMakeLists.txt create mode 100644 cmake/tribits/core/installation/set_installed_group_and_permissions.cmake.in create mode 100644 cmake/tribits/core/package_arch/TribitsAddInstallGroupAndPermsFixups.cmake create mode 100644 cmake/tribits/core/utils/TribitsFilepathHelpers.cmake create mode 100644 cmake/tribits/core/utils/UseCcacheIfExists.cmake create mode 100644 cmake/tribits/devtools_install/0001-CTest-Add-CTEST_RESOURCE_SPEC_FILE-variable.patch create mode 100755 cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/exec_script.sh create mode 100644 cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/regular_file.txt diff --git a/cmake/tribits/core/add_install_group_and_perms_fixups/CMakeLists.txt b/cmake/tribits/core/add_install_group_and_perms_fixups/CMakeLists.txt new file mode 100644 index 000000000000..aca219885f92 --- /dev/null +++ b/cmake/tribits/core/add_install_group_and_perms_fixups/CMakeLists.txt @@ -0,0 +1,17 @@ +INCLUDE(TribitsAddInstallGroupAndPermsFixups) + +TRIBITS_ADD_INSTALL_GROUP_AND_PERMS_FIXUPS() + +# NOTE: This is a workaround for a problem with an issue with CMake where you +# must call install(SCRIPT ...) in a subdirectory added with +# add_subdirectory() in order for CMake to run that install script after all +# of the other subdirectories (which are TriBITS packages). As of CMake 3.14, +# you can set the policy set_policy(CMP0082 NEW) which would have allowed us +# to put this in the base TRIBITS_PROJECT_IMPL() macro. But since TriBITS is +# not allowed to require CMake 3.14 yet, we must use this workaround. To make +# super sure that this install(SCRIPTS ...) script will get called last, the +# policy CMP0082 is set to NEW in the TribitsCMakePolicies.cmake file. In +# automated testing of TriBITS, this seems to show that this custom script +# runs after all of the other files get installed (even with CMake 3.11) and +# passes the automated tests that ensures that the last file installed is +# given the correct permissions! At least that is what happened with TriBITS. diff --git a/cmake/tribits/core/installation/cmake_pbp_install.cmake.in b/cmake/tribits/core/installation/cmake_pbp_install.cmake.in index 2bca9a8adabe..14ee7e532aea 100644 --- a/cmake/tribits/core/installation/cmake_pbp_install.cmake.in +++ b/cmake/tribits/core/installation/cmake_pbp_install.cmake.in @@ -4,12 +4,15 @@ # 'cmake -P cmake_install.cmake' command fails. # +set(PROJECT_BINARY_DIR @PROJECT_BINARY_DIR@) set(TRIBITS_ENABLED_PACKAGES_BINARY_DIRS @TRIBITS_ENABLED_PACKAGES_BINARY_DIRS@) -execute_process(COMMAND @CMAKE_COMMAND@ -P cmake_install.cmake +execute_process( + COMMAND @CMAKE_COMMAND@ -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" RESULT_VARIABLE global_install_rtn) if (NOT global_install_rtn EQUAL 0) + message( "\n" "***\n" @@ -17,10 +20,23 @@ if (NOT global_install_rtn EQUAL 0) "***\n" "\n" ) + foreach (pkg_binary_dir ${TRIBITS_ENABLED_PACKAGES_BINARY_DIRS}) execute_process(COMMAND @CMAKE_COMMAND@ -P cmake_install.cmake WORKING_DIRECTORY ${pkg_binary_dir} RESULT_VARIABLE global_install_rtn) endforeach() message(SEND_ERROR "Error, full install failed!") + + set(set_installed_group_and_permissions_file + "${PROJECT_BINARY_DIR}/set_installed_group_and_permissions.cmake") + if (EXISTS "${set_installed_group_and_permissions_file}") + execute_process( + COMMAND @CMAKE_COMMAND@ -P "${set_installed_group_and_permissions_file}" + RESULT_VARIABLE set_installed_rtn) + if (NOT global_install_rtn EQUAL 0) + message(SEND_ERROR "ERROR: Fixup of group and permissions filed!") + endif() + endif() + endif() diff --git a/cmake/tribits/core/installation/set_installed_group_and_permissions.cmake.in b/cmake/tribits/core/installation/set_installed_group_and_permissions.cmake.in new file mode 100644 index 000000000000..196cc0c56492 --- /dev/null +++ b/cmake/tribits/core/installation/set_installed_group_and_permissions.cmake.in @@ -0,0 +1,89 @@ +#!/bin/sh + +# +# Configured inputs +# + +# Base install dir and subdirs where last element in array gives CMAKE_INSTALL_PREFIX +SET(projectInstallBaseDir "@PROJECT_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR@") +SET(projectSubdirPathsArray "@PROJECT_SUBDIR_PATHS_ARRAY@") +# Group and permissions +SET(PROJECT_MAKE_INSTALL_GROUP "@PROJECT_MAKE_INSTALL_GROUP@") +SET(PROJECT_MAKE_INSTALL_PERMS_CHANGE "@PROJECT_MAKE_INSTALL_PERMS_CHANGE@") + +# Helper functions + +SET(CHMOD_CHGRP_IDX 0) + +FUNCTION(ECHO_AND_RUN_CMND) + STRING(REPLACE ";" " " CMND_STR "${ARGN}") + MESSAGE(STATUS "${CHMOD_CHGRP_IDX}: Running: ${CMND_STR}") + EXECUTE_PROCESS(COMMAND ${ARGN} RESULT_VARIABLE RTN_CODE) + IF (NOT RTN_CODE EQUAL 0) + MESSAGE(SEND_ERROR "ERROR: Above command failed!") + ENDIF() +ENDFUNCTION() + +FUNCTION(SET_DIR_OWNER_AND_PERMS dirPath recurseFlag) + + IF (NOT "${PROJECT_MAKE_INSTALL_GROUP}" STREQUAL "") + ECHO_AND_RUN_CMND( + chgrp ${PROJECT_MAKE_INSTALL_GROUP} ${recurseFlag} "${dirPath}") + ENDIF() + + IF (NOT "${PROJECT_MAKE_INSTALL_PERMS_CHANGE}" STREQUAL "") + ECHO_AND_RUN_CMND( + chmod ${PROJECT_MAKE_INSTALL_PERMS_CHANGE} ${recurseFlag} "${dirPath}") + ENDIF() + + MATH(EXPR CHMOD_CHGRP_IDX "${CHMOD_CHGRP_IDX}+1") + SET(CHMOD_CHGRP_IDX ${CHMOD_CHGRP_IDX} PARENT_SCOPE) + +ENDFUNCTION() + +# Executable script + +IF (EXISTS "${projectInstallBaseDir}") + + LIST(LENGTH projectSubdirPathsArray numSubDirs) + + # Get projectSubdirPathsArrayLessOne and CMAKE_INSTALL_PREFIX + SET(projectSubdirPathsArrayLessOne "${projectSubdirPathsArray}") + IF (numSubDirs GREATER 0) + LIST(REMOVE_AT projectSubdirPathsArrayLessOne -1) + ENDIF() + + # Loop over base dirs and set group and permissions and set CMAKE_INSTALL_PREFIX + SET(dirPath "${projectInstallBaseDir}") + IF (numSubDirs EQUAL 0) + # The base dir is CMAKE_INSTALL_PREFIX + SET(CMAKE_INSTALL_PREFIX "${dirPath}") + ELSE() + # Non-recursive set of the group and permissions + SET_DIR_OWNER_AND_PERMS("${dirPath}" "") + FOREACH(subDirEle ${projectSubdirPathsArrayLessOne}) + SET(dirPath "${dirPath}/${subDirEle}") + SET_DIR_OWNER_AND_PERMS("${dirPath}" "") + ENDFOREACH() + # Append last subdir which gives CMAKE_INSTALL_PREFIX + LIST(GET projectSubdirPathsArray -1 lastSubdir) + SET(CMAKE_INSTALL_PREFIX "${dirPath}/${lastSubdir}") + ENDIF() + + # Recursive set of group and permsisions on CMAKE_INSTALL_PREFIX + SET_DIR_OWNER_AND_PERMS("${CMAKE_INSTALL_PREFIX}" "-R") + +ELSE() + + MESSAGE(FATAL_ERROR + "" + "*** ERROR: The directory:" + "***" + "*** ${projectInstallBaseDir}" + "***" + "*** does not exist so can't fix group and permissions!" + "***" + "" + ) + +ENDIF() diff --git a/cmake/tribits/core/package_arch/TribitsAddExecutable.cmake b/cmake/tribits/core/package_arch/TribitsAddExecutable.cmake index f264a66a1eaa..d7a18c3c8414 100644 --- a/cmake/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/cmake/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -326,8 +326,7 @@ INCLUDE(CMakeParseArguments) # CMake command ``INSTALL(TARGETS ...)`` is added to install # the built executable into the ``${CMAKE_INSTALL_PREFIX}/bin/`` directory # (actual install directory path is determined by -# ``${PROJECT_NAME}_INSTALL_RUNTIME_DIR``, see `Setting the install prefix at -# configure time`_) . +# ``${PROJECT_NAME}_INSTALL_RUNTIME_DIR``, see `Setting the install prefix`_). # FUNCTION(TRIBITS_ADD_EXECUTABLE EXE_NAME) diff --git a/cmake/tribits/core/package_arch/TribitsAddInstallGroupAndPermsFixups.cmake b/cmake/tribits/core/package_arch/TribitsAddInstallGroupAndPermsFixups.cmake new file mode 100644 index 000000000000..011cf860f859 --- /dev/null +++ b/cmake/tribits/core/package_arch/TribitsAddInstallGroupAndPermsFixups.cmake @@ -0,0 +1,57 @@ +INCLUDE(Join) +INCLUDE(TribitsFilepathHelpers) + + +FUNCTION(TRIBITS_CONFIGURE_SET_INSTALLED_GROUP_AND_PERMS_FILE TARGET_FILE) + + SET(PROJECT_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR + "${${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}") + + TRIBITS_GET_DIR_ARRAY_BELOW_BASE_DIR( + "${${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" + "${CMAKE_INSTALL_PREFIX}" + PROJECT_SUBDIR_PATHS_ARRAY + ) + + SET(PROJECT_MAKE_INSTALL_GROUP "${${PROJECT_NAME}_MAKE_INSTALL_GROUP}") + + SET(group_perms "") + IF (${PROJECT_NAME}_MAKE_INSTALL_GROUP_WRITABLE) + SET(group_perms "g+rwX") + ELSEIF (${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE) + SET(group_perms "g+rX") + ENDIF() + + SET(other_perms "") + IF (${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE) + SET(other_perms "o+rX") + ENDIF() + + JOIN(PROJECT_MAKE_INSTALL_PERMS_CHANGE "," FALSE + ${group_perms} ${other_perms} ) + + SET(tribits_install_src + "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}") + CONFIGURE_FILE( + "${tribits_install_src}/set_installed_group_and_permissions.cmake.in" + "${TARGET_FILE}" @ONLY ) + +ENDFUNCTION() + + +FUNCTION(TRIBITS_ADD_INSTALL_GROUP_AND_PERMS_FIXUPS) + + IF (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") + + SET(set_installed_group_and_permissions_file + "${PROJECT_BINARY_DIR}/set_installed_group_and_permissions.cmake") + + TRIBITS_CONFIGURE_SET_INSTALLED_GROUP_AND_PERMS_FILE( + "${set_installed_group_and_permissions_file}" ) + + # Fix up install for default 'install' command + INSTALL(SCRIPT "${set_installed_group_and_permissions_file}") + + ENDIF() + +ENDFUNCTION() \ No newline at end of file diff --git a/cmake/tribits/core/package_arch/TribitsCMakePolicies.cmake b/cmake/tribits/core/package_arch/TribitsCMakePolicies.cmake index 23d41527efa6..7e99bbe802e7 100644 --- a/cmake/tribits/core/package_arch/TribitsCMakePolicies.cmake +++ b/cmake/tribits/core/package_arch/TribitsCMakePolicies.cmake @@ -45,3 +45,6 @@ CMAKE_POLICY(SET CMP0011 NEW) IF (POLICY CMP0053) CMAKE_POLICY(SET CMP0053 NEW) ENDIF() +IF (POLICY CMP0082) + CMAKE_POLICY(SET CMP0082 NEW) +ENDIF() diff --git a/cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake b/cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake index 9c8aa9231076..9fdaf019a270 100644 --- a/cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -69,6 +69,7 @@ INCLUDE(RemoveGlobalDuplicates) INCLUDE(Split) INCLUDE(TimingUtils) INCLUDE(SetDefaultAndFromEnv) # Used by some call-back files +INCLUDE(TribitsFilepathHelpers) # Standard CMake includes INCLUDE(CheckIncludeFileCXX) @@ -188,6 +189,44 @@ MACRO(TRIBITS_READ_IN_OPTIONS_FROM_FILE) ENDMACRO() +# +# Assert ${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR set +# correctly +# + +FUNCTION(ASSERT_PROJECT_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR) + + IF ( + (NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "") + AND + (NOT "${${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" STREQUAL "") + ) + TRIBITS_DIR_IS_BASEDIR( + "${${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" + "${CMAKE_INSTALL_PREFIX}" + isBaseDir) + IF (NOT isBaseDir) + MESSAGE(FATAL_ERROR + "\n" + "***\n" + "*** ERROR in ${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR!\n" + "***\n" + "\n" + "${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=${${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}\n" + "\n" + "is not a strict base dir of:\n" + "\n" + "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}\n" + "\n" + "Either remove ${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR from the cache or set it to be a base dir of CMAKE_INSTALL_PREFIX!\n" + "\n" + ) + ENDIF() + ENDIF() + +ENDFUNCTION() + + # # Define all of the standard global package architecture options. # @@ -273,27 +312,48 @@ MACRO(TRIBITS_DEFINE_GLOBAL_OPTIONS_AND_DEFINE_EXTRA_REPOS) "Skip the Fortran/C++ compatibility test" OFF ) - IF (NOT CMAKE_VERSION VERSION_LESS 3.11.0) + ADVANCED_SET( + ${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE + "${${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE_DEFAULT}" + CACHE BOOL + "If TRUE, the directory and file permissions on the installed directories and files will be set to world readable. NOTE: Empty '' (the default) leaves default CMake permissions in place." + ) - ADVANCED_SET( - ${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE - "${${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE_DEFAULT}" - CACHE BOOL - "If TRUE, the directory and file permissions on the installed directories and files will be set to world readable. NOTE: Empty '' (the default) leaves default CMake permissions in place." - ) - - IF ("${${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE_DEFAULT}" STREQUAL "") + ADVANCED_SET( + ${PROJECT_NAME}_MAKE_INSTALL_GROUP_WRITABLE "" + CACHE BOOL + "If TRUE, the directory and file permissions on the installed directories and files will be set to group-writable. Setting to TRUE also implies ${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE=TRUE. NOTE: Empty '' (the default) avoid adding the group write permission." + ) + + IF ("${${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE_DEFAULT}" STREQUAL "") + IF (${PROJECT_NAME}_MAKE_INSTALL_GROUP_WRITABLE) + SET(${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE_DEFAULT TRUE) + ELSE() SET(${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE_DEFAULT "${${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE}") ENDIF() - ADVANCED_SET( - ${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE - "${${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE_DEFAULT}" - CACHE BOOL - "If TRUE, the directory and file permissions on the installed directories and files will be set to group readable. Setting ${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE=ON implies this is 'ON' as well. NOTE: Empty '' (the default) leaves default CMake permissions in place." - ) - ENDIF() + ADVANCED_SET( + ${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE + "${${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE_DEFAULT}" + CACHE BOOL + "If TRUE, the directory and file permissions on the installed directories and files will be set to group readable. Setting ${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE=ON implies this is 'ON' as well. NOTE: Empty '' (the default) leaves default CMake permissions in place." + ) + + ADVANCED_SET( + ${PROJECT_NAME}_MAKE_INSTALL_GROUP "" + CACHE STRING + "If set, then the installed files and directories from ${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR on down will be given over to this owning group. The default is empty '' which means the default group will not be changed." + ) + + ADVANCED_SET( + ${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR + "${CMAKE_INSTALL_PREFIX}" + CACHE FILEPATH + "Set the base path for which a recursive chmod and chgrp will be called to set the group and permissions after the install is complete. The default directory is give by CMAKE_INSTALL_PREFIX." + ) + + ASSERT_PROJECT_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR() IF ("${${PROJECT_NAME}_SET_INSTALL_RPATH_DEFAULT}" STREQUAL "") SET(${PROJECT_NAME}_SET_INSTALL_RPATH_DEFAULT TRUE) @@ -2888,10 +2948,13 @@ ENDMACRO() # Setup for installation # -MACRO(TRIBITS_SETUP_FOR_INSTALLATION) - # Set up to install Config.cmake, Config.cmake, and export - # makefiles. +# Set up to install Config.cmake, Config.cmake, and export +# makefiles. +FUNCTION(TRIBITS_ADD_PROJECT_EXPORT_FILE_INSTALL_TARGETS) + + SET(tribits_install_src + "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}") IF((${PROJECT_NAME}_ENABLE_INSTALL_CMAKE_CONFIG_FILES OR ${PROJECT_NAME}_ENABLE_EXPORT_MAKEFILES) @@ -2907,7 +2970,7 @@ MACRO(TRIBITS_SETUP_FOR_INSTALLATION) # where was previously installed to warn and load the new file. SET(COMPATIBILITY_CONFIG_INCLUDE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake) CONFIGURE_FILE( - ${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}/TribitsConfigInclude.cmake.in + "${tribits_install_src}/TribitsConfigInclude.cmake.in" ${COMPATIBILITY_CONFIG_INCLUDE} @ONLY ) @@ -2919,18 +2982,24 @@ MACRO(TRIBITS_SETUP_FOR_INSTALLATION) ENDIF() - # Create custom 'install/package_by_package' target +ENDFUNCTION() + + +# Create custom 'install_package_by_package' target +FUNCTION(TRIBITS_ADD_INSTALL_PACKAGE_BY_PACKAGE_TARGET) SET(TRIBITS_ENABLED_PACKAGES_BINARY_DIRS) FOREACH(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES}) LIST(APPEND TRIBITS_ENABLED_PACKAGES_BINARY_DIRS "${${TRIBITS_PACKAGE}_BINARY_DIR}") ENDFOREACH() + SET(tribits_install_src + "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}") + CONFIGURE_FILE( - ${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}/cmake_pbp_install.cmake.in + "${tribits_install_src}/cmake_pbp_install.cmake.in" cmake_pbp_install.cmake - @ONLY - ) + @ONLY ) ADVANCED_SET(${PROJECT_NAME}_INSTALL_PBP_RUNNER "" CACHE FILEPATH "Program used to run cmake -P cmake_pbp_install.cmake to change user for 'install_package_by_package' target") @@ -2941,6 +3010,22 @@ MACRO(TRIBITS_SETUP_FOR_INSTALLATION) WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ) +ENDFUNCTION() + + +MACRO(TRIBITS_SETUP_FOR_INSTALLATION) + + # Set up to install Config.cmake, Config.cmake, and export + # makefiles. + TRIBITS_ADD_PROJECT_EXPORT_FILE_INSTALL_TARGETS() + + # Set up for fixing group and permissions after the install + ADD_SUBDIRECTORY("${${PROJECT_NAME}_TRIBITS_DIR}/core/add_install_group_and_perms_fixups" + add_install_group_and_perms_fixups) + + # Create custom 'install_package_by_package' target + TRIBITS_ADD_INSTALL_PACKAGE_BY_PACKAGE_TARGET() + ENDMACRO() diff --git a/cmake/tribits/core/package_arch/TribitsLibraryMacros.cmake b/cmake/tribits/core/package_arch/TribitsLibraryMacros.cmake index 0674b1b97d16..787a6a152ab1 100644 --- a/cmake/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/cmake/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -416,8 +416,8 @@ ENDFUNCTION() # By default, an install target for the library is created using # ``INSTALL(TARGETS ...)`` to install into the directory # ``${CMAKE_INSTALL_PREFIX}/lib/`` (actual install directory is given by -# ``${PROJECT}_INSTALL_LIB_DIR``, see `Setting the install prefix at configure -# time`_). However, this install target will not get created if +# ``${PROJECT}_INSTALL_LIB_DIR``, see `Setting the install prefix`_). +# However, this install target will not get created if # `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE`` and # ``BUILD_SHARD_LIBS=OFF``. But when ``BUILD_SHARD_LIBS=ON``, the install # target will get added. Also, this install target will *not* get added if @@ -430,10 +430,9 @@ ENDFUNCTION() # `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE``. If this # install target is added, then the headers get installed into the flat # directory ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/`` (default is -# ``${CMAKE_INSTALL_PREFIX}/include/``, see `Setting the install prefix at -# configure time`_). If ``HEADERS_INSTALL_SUBDIR`` is set, then the headers -# will be installed under -# ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}//``. +# ``${CMAKE_INSTALL_PREFIX}/include/``, see `Setting the install prefix`_). +# If ``HEADERS_INSTALL_SUBDIR`` is set, then the headers will be installed +# under ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}//``. # # Note that an install target will *not* get created for the headers listed in # ``NOINSTALLHEADERS``. diff --git a/cmake/tribits/core/utils/TribitsFilepathHelpers.cmake b/cmake/tribits/core/utils/TribitsFilepathHelpers.cmake new file mode 100644 index 000000000000..e4040c08029e --- /dev/null +++ b/cmake/tribits/core/utils/TribitsFilepathHelpers.cmake @@ -0,0 +1,96 @@ +INCLUDE(MessageWrapper) +INCLUDE(Split) + +# +# @FUNCTION: TRIBITS_DIR_IS_BASEDIR() +# +# Function to determine if a given path is a base dir of another path. +# +# Usage:: +# +# TRIBITS_DIR_IS_BASEDIR( ) +# +# If the absolute path ```` is a subdir of the absolute path +# ````, then the variable ```` is set to +# ``TRUE``. Otherwise, ```` is set to ``FALSE``. +# +# For example, the output var ``isBaseDir`` would be set to ``TRUE`` in the +# following examples:: +# +# TRIBITS_DIR_IS_BASEDIR(/some/base/path /some/base/path/more isBaseDir) +# +# TRIBITS_DIR_IS_BASEDIR(/some/base/path /some/base/path isBaseDir) +# +# However, in the following examples, ``isBaseDir`` would be set to ``FALSE``:: +# +# TRIBITS_DIR_IS_BASEDIR(/some/base/path/more /some/base/path isBaseDir) +# +# TRIBITS_DIR_IS_BASEDIR(/some/base/path /some/other/path isBaseDir) +# +FUNCTION(TRIBITS_DIR_IS_BASEDIR absBaseDir absFullDir isBaseDirVarOut) + + # Assume not base dir by default unless we find it is + SET(isBaseDir FALSE) + + STRING(LENGTH "${absBaseDir}" absBaseDirLen) + STRING(LENGTH "${absFullDir}" absFullDirLen) + + IF (absBaseDir STREQUAL absFullDir) + SET(isBaseDir TRUE) + ELSEIF (NOT absBaseDirLen GREATER absFullDirLen) + STRING(FIND "${absFullDir}" "${absBaseDir}/" baseDirIdx) + IF (baseDirIdx EQUAL 0) + SET(isBaseDir TRUE) + ENDIF() + ENDIF() + + SET(${isBaseDirVarOut} ${isBaseDir} PARENT_SCOPE) + +ENDFUNCTION() + + +# +# @FUNCTION: TRIBITS_GET_DIR_ARRAY_BELOW_BASE_DIR() +# +# Returns the array of directories below a base directory. +# +# Usage:: +# +# TRIBITS_GET_DIR_ARRAY_BELOW_BASE_DIR( +# ) +# +# The following show examples of what this returns: +# +# TRIBITS_GET_DIR_ARRAY_BELOW_BASE_DIR("/a/b/c" "/a/b/c", dirArray) +# => dirArray = "" +# +# TRIBITS_GET_DIR_ARRAY_BELOW_BASE_DIR("/a/b/c" "/a/b/c/d", dirArray) +# => dirArray = "d" +# +# TRIBITS_GET_DIR_ARRAY_BELOW_BASE_DIR("/a/b/c" "/a/b/c/d/e", dirArray) +# => dirArray = "d;e" +# +FUNCTION(TRIBITS_GET_DIR_ARRAY_BELOW_BASE_DIR absBaseDir absFullDir + trailingDirArrayVarOut + ) + + TRIBITS_DIR_IS_BASEDIR("${absBaseDir}" "${absFullDir}" isBaseDir) + IF (NOT isBaseDir) + MESSAGE_WRAPPER(FATAL_ERROR + "ERROR: '${absBaseDir}' is not a base dir of '${absFullDir}'") + ENDIF() + + STRING(LENGTH "${absBaseDir}" absBaseDirLen) + STRING(LENGTH "${absFullDir}" absFullDirLen) + + IF (absBaseDirLen EQUAL absFullDirLen) + SET(trailingDirArray "") + ELSE() + MATH(EXPR trailingDirsStrStartIdx "${absBaseDirLen}+1") + STRING(SUBSTRING "${absFullDir}" ${trailingDirsStrStartIdx} -1 trailingDirsStr) + SPLIT("${trailingDirsStr}" "/" trailingDirArray) + ENDIF() + + SET(${trailingDirArrayVarOut} "${trailingDirArray}" PARENT_SCOPE) + +ENDFUNCTION() diff --git a/cmake/tribits/core/utils/UseCcacheIfExists.cmake b/cmake/tribits/core/utils/UseCcacheIfExists.cmake new file mode 100644 index 000000000000..b3021d2bc0c6 --- /dev/null +++ b/cmake/tribits/core/utils/UseCcacheIfExists.cmake @@ -0,0 +1,9 @@ +# Include this file in your CMake project with either -C +# UseCcacheIfExists.cmake or with the TriBITS option -D +# _CONFIGURE_OPTIONS_FILE=UseCcacheIfExists.cmake. + +FIND_PROGRAM(CCACHE_EXEC ccache) +IF (CCACHE_EXEC) + MESSAGE("-- NOTE: ccache program exists so using it for RULE_LAUNCH_COMPILE!") + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_EXEC}") +ENDIF() diff --git a/cmake/tribits/devtools_install/0001-CTest-Add-CTEST_RESOURCE_SPEC_FILE-variable.patch b/cmake/tribits/devtools_install/0001-CTest-Add-CTEST_RESOURCE_SPEC_FILE-variable.patch new file mode 100644 index 000000000000..ad9103dff286 --- /dev/null +++ b/cmake/tribits/devtools_install/0001-CTest-Add-CTEST_RESOURCE_SPEC_FILE-variable.patch @@ -0,0 +1,377 @@ +From 230de4e06240f48715685ea184386d7314137d59 Mon Sep 17 00:00:00 2001 +From: Kyle Edwards +Date: Thu, 2 Apr 2020 16:16:15 -0400 +Subject: [PATCH] CTest: Add CTEST_RESOURCE_SPEC_FILE variable + +--- + Help/manual/cmake-variables.7.rst | 1 + + Help/manual/ctest.1.rst | 8 +++-- + Help/variable/CTEST_RESOURCE_SPEC_FILE.rst | 5 +++ + Source/CTest/cmCTestTestCommand.cxx | 7 ++++ + Source/CTest/cmCTestTestHandler.cxx | 37 +++++++++++++--------- + Source/CTest/cmCTestTestHandler.h | 2 +- + Source/cmLocalGenerator.cxx | 7 ++++ + .../CTestResourceAllocation/RunCMakeTest.cmake | 28 +++++++++------- + .../checkfree1-ctest-s-res-cache-check.cmake | 1 + + .../checkfree1-ctest-s-res-variable-check.cmake | 1 + + .../notenough1-ctest-s-res-cache-check.cmake | 3 ++ + .../notenough1-ctest-s-res-cache-result.txt | 1 + + .../notenough1-ctest-s-res-cache-stderr.txt | 14 ++++++++ + .../notenough1-ctest-s-res-variable-check.cmake | 3 ++ + .../notenough1-ctest-s-res-variable-result.txt | 1 + + .../notenough1-ctest-s-res-variable-stderr.txt | 14 ++++++++ + .../RunCMake/CTestResourceAllocation/test.cmake.in | 14 +++++--- + 17 files changed, 113 insertions(+), 34 deletions(-) + create mode 100644 Help/variable/CTEST_RESOURCE_SPEC_FILE.rst + create mode 100644 Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-cache-check.cmake + create mode 100644 Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-variable-check.cmake + create mode 100644 Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-check.cmake + create mode 100644 Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-result.txt + create mode 100644 Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-stderr.txt + create mode 100644 Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-check.cmake + create mode 100644 Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-result.txt + create mode 100644 Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-stderr.txt + +diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst +index fc27739..312346d 100644 +--- a/Help/manual/cmake-variables.7.rst ++++ b/Help/manual/cmake-variables.7.rst +@@ -621,6 +621,7 @@ Variables for CTest + /variable/CTEST_P4_COMMAND + /variable/CTEST_P4_OPTIONS + /variable/CTEST_P4_UPDATE_OPTIONS ++ /variable/CTEST_RESOURCE_SPEC_FILE + /variable/CTEST_RUN_CURRENT_SCRIPT + /variable/CTEST_SCP_COMMAND + /variable/CTEST_SITE +diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst +index 6503f0e..f2033b7 100644 +--- a/Help/manual/ctest.1.rst ++++ b/Help/manual/ctest.1.rst +@@ -994,8 +994,12 @@ Configuration settings include: + + ``ResourceSpecFile`` + Specify a +- :ref:`resource specification file `. See +- :ref:`ctest-resource-allocation` for more information. ++ :ref:`resource specification file `. ++ ++ * `CTest Script`_ variable: :variable:`CTEST_RESOURCE_SPEC_FILE` ++ * :module:`CTest` module variable: ``CTEST_RESOURCE_SPEC_FILE`` ++ ++ See :ref:`ctest-resource-allocation` for more information. + + ``LabelsForSubprojects`` + Specify a semicolon-separated list of labels that will be treated as +diff --git a/Help/variable/CTEST_RESOURCE_SPEC_FILE.rst b/Help/variable/CTEST_RESOURCE_SPEC_FILE.rst +new file mode 100644 +index 0000000..59f365f +--- /dev/null ++++ b/Help/variable/CTEST_RESOURCE_SPEC_FILE.rst +@@ -0,0 +1,5 @@ ++CTEST_RESOURCE_SPEC_FILE ++------------------------ ++ ++Specify the CTest ``ResourceSpecFile`` setting in a :manual:`ctest(1)` ++dashboard client script. +diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx +index 0f9b695..c5f683d 100644 +--- a/Source/CTest/cmCTestTestCommand.cxx ++++ b/Source/CTest/cmCTestTestCommand.cxx +@@ -52,6 +52,13 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() + } + } + this->CTest->SetTimeOut(timeout); ++ ++ const char* resourceSpecFile = ++ this->Makefile->GetDefinition("CTEST_RESOURCE_SPEC_FILE"); ++ if (this->ResourceSpecFile.empty() && resourceSpecFile) { ++ this->ResourceSpecFile = resourceSpecFile; ++ } ++ + cmCTestGenericHandler* handler = this->InitializeActualHandler(); + if (!this->Start.empty() || !this->End.empty() || !this->Stride.empty()) { + handler->SetOption( +diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx +index 4f324ea..25d6710 100644 +--- a/Source/CTest/cmCTestTestHandler.cxx ++++ b/Source/CTest/cmCTestTestHandler.cxx +@@ -406,7 +406,9 @@ int cmCTestTestHandler::ProcessHandler() + // start the real time clock + auto clock_start = std::chrono::steady_clock::now(); + +- this->ProcessDirectory(passed, failed); ++ if (!this->ProcessDirectory(passed, failed)) { ++ return -1; ++ } + + auto clock_finish = std::chrono::steady_clock::now(); + +@@ -543,22 +545,11 @@ bool cmCTestTestHandler::ProcessOptions() + if (val) { + this->ExcludeFixtureCleanupRegExp = val; + } +- this->SetRerunFailed(cmIsOn(this->GetOption("RerunFailed"))); +- + val = this->GetOption("ResourceSpecFile"); + if (val) { +- this->UseResourceSpec = true; + this->ResourceSpecFile = val; +- auto result = this->ResourceSpec.ReadFromJSONFile(val); +- if (result != cmCTestResourceSpec::ReadFileResult::READ_OK) { +- cmCTestLog(this->CTest, ERROR_MESSAGE, +- "Could not read/parse resource spec file " +- << val << ": " +- << cmCTestResourceSpec::ResultToString(result) +- << std::endl); +- return false; +- } + } ++ this->SetRerunFailed(cmIsOn(this->GetOption("RerunFailed"))); + + return true; + } +@@ -1259,7 +1250,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, std::string& value, + return ret; + } + +-void cmCTestTestHandler::ProcessDirectory(std::vector& passed, ++bool cmCTestTestHandler::ProcessDirectory(std::vector& passed, + std::vector& failed) + { + this->ComputeTestList(); +@@ -1283,7 +1274,17 @@ void cmCTestTestHandler::ProcessDirectory(std::vector& passed, + } else { + parallel->SetTestLoad(this->CTest->GetTestLoad()); + } +- if (this->UseResourceSpec) { ++ if (!this->ResourceSpecFile.empty()) { ++ this->UseResourceSpec = true; ++ auto result = this->ResourceSpec.ReadFromJSONFile(this->ResourceSpecFile); ++ if (result != cmCTestResourceSpec::ReadFileResult::READ_OK) { ++ cmCTestLog(this->CTest, ERROR_MESSAGE, ++ "Could not read/parse resource spec file " ++ << this->ResourceSpecFile << ": " ++ << cmCTestResourceSpec::ResultToString(result) ++ << std::endl); ++ return false; ++ } + parallel->InitResourceAllocator(this->ResourceSpec); + } + +@@ -1344,6 +1345,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector& passed, + this->ElapsedTestingTime = + std::chrono::steady_clock::now() - elapsed_time_start; + *this->LogFile << "End testing: " << this->CTest->CurrentTime() << std::endl; ++ ++ return true; + } + + void cmCTestTestHandler::GenerateTestCommand( +@@ -1742,6 +1745,10 @@ void cmCTestTestHandler::GetListOfTests() + if (cmSystemTools::GetErrorOccuredFlag()) { + return; + } ++ const char* specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE"); ++ if (this->ResourceSpecFile.empty() && specFile) { ++ this->ResourceSpecFile = specFile; ++ } + cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Done constructing a list of tests" << std::endl, + this->Quiet); +diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h +index b1c8755..bb41c79 100644 +--- a/Source/CTest/cmCTestTestHandler.h ++++ b/Source/CTest/cmCTestTestHandler.h +@@ -278,7 +278,7 @@ private: + /** + * Run the tests for a directory and any subdirectories + */ +- void ProcessDirectory(std::vector& passed, ++ bool ProcessDirectory(std::vector& passed, + std::vector& failed); + + /** +diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx +index cf6802d..5e78911 100644 +--- a/Source/cmLocalGenerator.cxx ++++ b/Source/cmLocalGenerator.cxx +@@ -299,6 +299,13 @@ void cmLocalGenerator::GenerateTestFiles() + << "# testing this directory and lists subdirectories to " + << "be tested as well." << std::endl; + ++ std::string resourceSpecFile = ++ this->Makefile->GetSafeDefinition("CTEST_RESOURCE_SPEC_FILE"); ++ if (!resourceSpecFile.empty()) { ++ fout << "set(CTEST_RESOURCE_SPEC_FILE \"" << resourceSpecFile << "\")" ++ << std::endl; ++ } ++ + const char* testIncludeFile = + this->Makefile->GetProperty("TEST_INCLUDE_FILE"); + if (testIncludeFile) { +diff --git a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake +index 8584786..777f192 100644 +--- a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake ++++ b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake +@@ -140,9 +140,13 @@ run_ctresalloc_verify(ctresalloc-verify-noend "test1") + # Now test the resource allocation feature of CTest + ############################################################################### + +-function(run_ctest_resource name parallel random) +- run_ctest("${name}-ctest-s-res" "-DCTEST_RESOURCE_ALLOC_ENABLED=1" "-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" "-DCTEST_PARALLEL=${parallel}" "-DCTEST_RANDOM=${random}") +- run_ctest("${name}-ctest-s-nores" "-DCTEST_RESOURCE_ALLOC_ENABLED=0" "-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" "-DCTEST_PARALLEL=${parallel}" "-DCTEST_RANDOM=${random}") ++function(run_ctest_resource name parallel random extra) ++ run_ctest("${name}-ctest-s-res" "-DCTEST_RESOURCE_ALLOC_ENABLED=1" "-DCTEST_RESOURCE_SPEC_SOURCE=ARG" "-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" "-DCTEST_PARALLEL=${parallel}" "-DCTEST_RANDOM=${random}") ++ run_ctest("${name}-ctest-s-nores" "-DCTEST_RESOURCE_ALLOC_ENABLED=0" "-DCTEST_RESOURCE_SPEC_SOURCE=NONE" "-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" "-DCTEST_PARALLEL=${parallel}" "-DCTEST_RANDOM=${random}") ++ if(extra) ++ run_ctest("${name}-ctest-s-res-variable" "-DCTEST_RESOURCE_ALLOC_ENABLED=1" "-DCTEST_RESOURCE_SPEC_SOURCE=VARIABLE" "-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" "-DCTEST_PARALLEL=${parallel}" "-DCTEST_RANDOM=${random}") ++ run_ctest("${name}-ctest-s-res-cache" "-DCTEST_RESOURCE_ALLOC_ENABLED=1" "-DCTEST_RESOURCE_SPEC_SOURCE=CACHE" "-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" "-DCTEST_PARALLEL=${parallel}" "-DCTEST_RANDOM=${random}") ++ endif() + endfunction() + + function(verify_ctest_resources) +@@ -155,15 +159,15 @@ function(verify_ctest_resources) + endif() + endfunction() + +-run_ctest_resource(lotsoftests 10 1) +-run_ctest_resource(checkfree1 2 0) +-run_ctest_resource(checkfree2 1 0) +-run_ctest_resource(notenough1 1 0) +-run_ctest_resource(notenough2 1 0) +-run_ctest_resource(notenough3 1 0) +-run_ctest_resource(combine 1 0) +-run_ctest_resource(ensure_parallel 2 0) ++run_ctest_resource(lotsoftests 10 1 0) ++run_ctest_resource(checkfree1 2 0 1) ++run_ctest_resource(checkfree2 1 0 0) ++run_ctest_resource(notenough1 1 0 1) ++run_ctest_resource(notenough2 1 0 0) ++run_ctest_resource(notenough3 1 0 0) ++run_ctest_resource(combine 1 0 0) ++run_ctest_resource(ensure_parallel 2 0 0) + + set(ENV{CTEST_RESOURCE_GROUP_COUNT} 2) +-run_ctest_resource(process_count 1 0) ++run_ctest_resource(process_count 1 0 0) + unset(ENV{CTEST_RESOURCE_GROUP_COUNT}) +diff --git a/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-cache-check.cmake b/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-cache-check.cmake +new file mode 100644 +index 0000000..ceda72e +--- /dev/null ++++ b/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-cache-check.cmake +@@ -0,0 +1 @@ ++verify_ctest_resources() +diff --git a/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-variable-check.cmake b/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-variable-check.cmake +new file mode 100644 +index 0000000..ceda72e +--- /dev/null ++++ b/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-variable-check.cmake +@@ -0,0 +1 @@ ++verify_ctest_resources() +diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-check.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-check.cmake +new file mode 100644 +index 0000000..321e9a2 +--- /dev/null ++++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-check.cmake +@@ -0,0 +1,3 @@ ++if(EXISTS "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log") ++ set(RunCMake_TEST_FAILED "ctresalloc.log should not exist") ++endif() +diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-result.txt b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-result.txt +new file mode 100644 +index 0000000..b57e2de +--- /dev/null ++++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-result.txt +@@ -0,0 +1 @@ ++(-1|255) +diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-stderr.txt +new file mode 100644 +index 0000000..521a34b +--- /dev/null ++++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache-stderr.txt +@@ -0,0 +1,14 @@ ++^Insufficient resources for test Test1: ++ ++ Test requested resources of type 'fluxcapacitors' in the following amounts: ++ 200 slots ++ but only the following units were available: ++ 'outatime': 121 slots ++ ++Resource spec file: ++ ++ [^ ++]*/Tests/RunCMake/CTestResourceAllocation/resspec.json ++CMake Error at [^ ++]*/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-cache/test\.cmake:[0-9]+ \(message\): ++ Tests did not pass$ +diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-check.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-check.cmake +new file mode 100644 +index 0000000..321e9a2 +--- /dev/null ++++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-check.cmake +@@ -0,0 +1,3 @@ ++if(EXISTS "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log") ++ set(RunCMake_TEST_FAILED "ctresalloc.log should not exist") ++endif() +diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-result.txt b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-result.txt +new file mode 100644 +index 0000000..b57e2de +--- /dev/null ++++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-result.txt +@@ -0,0 +1 @@ ++(-1|255) +diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-stderr.txt +new file mode 100644 +index 0000000..dcf13e0 +--- /dev/null ++++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable-stderr.txt +@@ -0,0 +1,14 @@ ++^Insufficient resources for test Test1: ++ ++ Test requested resources of type 'fluxcapacitors' in the following amounts: ++ 200 slots ++ but only the following units were available: ++ 'outatime': 121 slots ++ ++Resource spec file: ++ ++ [^ ++]*/Tests/RunCMake/CTestResourceAllocation/resspec.json ++CMake Error at [^ ++]*/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-variable/test\.cmake:[0-9]+ \(message\): ++ Tests did not pass$ +diff --git a/Tests/RunCMake/CTestResourceAllocation/test.cmake.in b/Tests/RunCMake/CTestResourceAllocation/test.cmake.in +index 4b426f1..54eb4e9 100644 +--- a/Tests/RunCMake/CTestResourceAllocation/test.cmake.in ++++ b/Tests/RunCMake/CTestResourceAllocation/test.cmake.in +@@ -8,15 +8,21 @@ set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") + set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") + +-ctest_start(Experimental QUIET) +-ctest_configure(OPTIONS ++set(config_options + "-DCTEST_RESOURCE_ALLOC_ENABLED=${CTEST_RESOURCE_ALLOC_ENABLED};-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" + ) +-ctest_build() + +-if(CTEST_RESOURCE_ALLOC_ENABLED) ++if(CTEST_RESOURCE_SPEC_SOURCE STREQUAL "ARG") + set(resspec RESOURCE_SPEC_FILE "@RunCMake_SOURCE_DIR@/resspec.json") ++elseif(CTEST_RESOURCE_SPEC_SOURCE STREQUAL "VARIABLE") ++ set(CTEST_RESOURCE_SPEC_FILE "@RunCMake_SOURCE_DIR@/resspec.json") ++elseif(CTEST_RESOURCE_SPEC_SOURCE STREQUAL "CACHE") ++ list(APPEND config_options "-DCTEST_RESOURCE_SPEC_FILE=@RunCMake_SOURCE_DIR@/resspec.json") + endif() ++ ++ctest_start(Experimental QUIET) ++ctest_configure(OPTIONS "${config_options}") ++ctest_build() + ctest_test(${resspec} RETURN_VALUE retval PARALLEL_LEVEL ${CTEST_PARALLEL} SCHEDULE_RANDOM ${CTEST_RANDOM}) + if(retval) + message(FATAL_ERROR "Tests did not pass") +-- +2.7.4 + diff --git a/cmake/tribits/devtools_install/install-cmake.py b/cmake/tribits/devtools_install/install-cmake.py index 10551c72e007..ddc0362bc55a 100755 --- a/cmake/tribits/devtools_install/install-cmake.py +++ b/cmake/tribits/devtools_install/install-cmake.py @@ -56,6 +56,9 @@ from InstallProgramDriver import * from GeneralScriptSupport import * +import os.path + +devtools_install_dir = os.path.dirname(os.path.abspath(__file__)) class CMakeInstall: @@ -102,6 +105,9 @@ def getExtraHelpStr(self, version): This build script sets the environment vars CXXFLAGS=-O3 AND CFLAGS=-O3 when doing the configure. Therefore, this builds and installs an optimized version of CMake by default. + +If CMake 3.17 is selected, a patch is applied which adds the CTEST_RESOURCE_SPEC_FILE +variable. (For versions 3.18+ this is not needed.) """ def injectExtraCmndLineOptions(self, clp, version): @@ -160,6 +166,9 @@ def doUntar(self): createDir(self.cmakeSrcDir, verbose=True) echoRunSysCmnd("tar -xzf "+self.cmakeTarball \ +" -C "+self.cmakeSrcDir+" --strip-components 1") + if self.inOptions.version.startswith("3.17"): + echoRunSysCmnd("patch -d "+self.cmakeSrcDir+" -p1 -i " \ + +os.path.join(devtools_install_dir, "0001-CTest-Add-CTEST_RESOURCE_SPEC_FILE-variable.patch")) def doConfigure(self): createDir(self.cmakeBuildBaseDir, True, True) diff --git a/cmake/tribits/doc/build_ref/TribitsBuildReferenceBody.rst b/cmake/tribits/doc/build_ref/TribitsBuildReferenceBody.rst index c9fdb3c9a0d4..4b9575f53f66 100644 --- a/cmake/tribits/doc/build_ref/TribitsBuildReferenceBody.rst +++ b/cmake/tribits/doc/build_ref/TribitsBuildReferenceBody.rst @@ -3037,6 +3037,7 @@ For more details, see the following subsections: * `Avoiding installing libraries and headers`_ * `Installing the software`_ + Setting the install prefix -------------------------- @@ -3074,43 +3075,78 @@ WARNING: To overwrite default relative paths, you must use the data type current binary directory for the base path. Otherwise, if you want to specify absolute paths, use the data type ``PATH`` as shown above. -Setting install directory permissions -------------------------------------- -By default, when installing with the ``install`` target, any directories -created are given the default permissions for the user that runs the install -command (just as if they typed ``mkdir ``). (On Unix/Linux systems, -one can use ``umask`` and set the default group and the group sticky bit to -control how directories are created.) However, for versions of CMake 3.11.0+, -CMake supports the CMake variable -``CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`` which will result in directory -permissions according to these and not the user/system defaults. To make this -easier to use, the ```` CMake build system defines the options:: +Setting install ownership and permissions +----------------------------------------- +By default, when installing with the ``install`` (or +``install_package_by_package``) target, any files and directories created are +given the default permissions for the user that runs the install command (just +as if they typed ``mkdir `` or ``touch ``). On most +Unix/Linux systems, one can use ``umask`` to set default permissions and one +can set the default group and the group sticky bit to control what groups owns +the newly created files and directories. However, some computer systems do +not support the group sticky bit and there are cases where one wants or needs +to provide different group ownership and write permissions. + +To control what group owns the install-created files and directories related +to ``CMAKE_INSTALL_PREFIX`` and define the permissions on those, one can set +one or more of the following options:: + + -D _SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR= \ + -D _MAKE_INSTALL_GROUP=[] \ -D _MAKE_INSTALL_GROUP_READABLE=[TRUE|FALSE] \ + -D _MAKE_INSTALL_GROUP_WRITABLE=[TRUE|FALSE] \ -D _MAKE_INSTALL_WORLD_READABLE=[TRUE|FALSE] \ -that automatically sets up ``CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`` -with the correct permissions according to these options when either of these -two variables are set to non-empty. To make the install group and world -readable, set:: +(where ``_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR`` must be a +base directory of ``CMAKE_INSTALL_PREFIX``). This has the impact of both +setting the built-in CMake variable +``CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`` with the correct permissions +according to these and also triggers the automatic running of the recursive +``chgrp`` and ``chmod`` commands starting from the directory +```` on down, after all of the other project files have been +installed. The directory set by +``_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR`` and those below it +may be created by the ``install`` command by CMake (as it may not exist before +the install). If ``_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR`` +is not given, then it is set internally to the same directory as +``CMAKE_INSTALL_PREFIX``. + +For an example, to configure for an install based on a dated base directory +where a non-default group should own the installation and have group +read/write permissions, and "others" only have read access, one would +configure with:: + + -D CMAKE_INSTALL_PREFIX=$HOME/2020-04-25/my-proj \ + -D _SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=$HOME/2020-04-25 \ + -D _MAKE_INSTALL_GROUP=some-other-group \ + -D _MAKE_INSTALL_GROUP_WRITABLE=TRUE \ + -D _MAKE_INSTALL_WORLD_READABLE=TRUE \ + +Using these settings, after all of the files and directories have been +installed using the ``install`` or ``install_package_by_package`` build +targets, the following commands are automatically run at the very end:: - -D _MAKE_INSTALL_WORLD_READABLE=TRUE + chgrp some-other-group $HOME/2020-04-25 + chmod g+rwX,o+rX $HOME/2020-04-25 + chgrp some-other-group -R $HOME/2020-04-25/my-proj + chmod g+rwX,o+rX -R $HOME/2020-04-25/my-proj -To make the install group readable but not world readable, set:: +That allows the owning group ``some-other-group`` to later modify or delete +the installation and allows all users to use the installation. + +NOTES: - -D _MAKE_INSTALL_GROUP_READABLE=TRUE +* Setting ``_MAKE_INSTALL_GROUP_WRITABLE=TRUE`` implies + ``_MAKE_INSTALL_GROUP_READABLE=TRUE``. -(In that case, make sure and set the desired group in the base install -directory and set the group sticky bit using ``chmod g+s `` -before running the ``install`` target.) +* Non-recursive ``chgrp`` and ``chmod`` commands are run on the directories + above ``CMAKE_INSTALL_PREFIX``. Recursive ``chgrp`` and ``chmod`` commands + are only run on the base ``CMAKE_INSTALL_PREFIX`` directory itself. (This + avoids touching any files or directories not directly involved in this + install.) -When both of these variables are empty, -``CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`` is not set and therefore the -default user/system directory permissions are used for new directories. When -the version of CMake is less than 3.11.0, then setting these variables and -``CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`` have no effect and the default -user/system directory permissions are used. Setting install RPATH --------------------- diff --git a/cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst b/cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst index d7d9254df8df..d935db2d1f5b 100644 --- a/cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst +++ b/cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst @@ -6519,6 +6519,69 @@ ready to compile code. All of the major variables set as part of this process are printed to the ``cmake`` stdout when the project is configured. +Installation considerations +--------------------------- + +For the most part, installation is pretty straightforward with a TriBITS-based +CMake project. TriBITS automatically puts in appropriate default +``install()`` commands to install header files, libraries, executables, and +other commonly installed artifacts (such as TriBITS-autogenerated +``Config.cmake`` files). And packages can add their own custom +``install()`` commands to install items under ``CMAKE_INSTALL_PREFIX`` (or the +subdirs under ``CMAKE_INSTALL_PREFIX`` mentioned in `Setting the install +prefix`_). However, there are some special situations that need to be +addressed and some tweaks to built-in CMake support that need to be made. + +One issue that can occur is that there are cases where a Unix/Linux system is +set up not to honor the group sticky bit and therefore one cannot control what +group owns the created installed files and directories (i.e. the default group +will be used). Also, there are cases were one cannot easily control the +default file or directory creation permissions using ``umask``. And there are +cases where one would like to recursively install a set of directories and +files where some of these files may be scripts that need to have the execute +permission set on them for them to work. The only to flexiable accomplish +that with CMake (if one does not know the exist list of those files or +extensions of those files) is to pass in the ``SOURCE_PERMISSIONS`` option to +the ``install(DIRECTORY ...)`` command. An example of this is shown in: + +* ``TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt`` + +that has:: + + INSTALL( DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/stuff" + DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${PACKAGE_NAME}" + USE_SOURCE_PERMISSIONS PATTERN "*~" EXCLUDE ) + +In this case, CMake will preserve the execute permission on any of the scripts +contained under the ``stuff/`` subdirectory but ``group`` and ``other`` +permissions will not be set based on ``umask`` or the default CMake install +permissions. Instead, these permissions are set based on the source directory +permissions (which is often set to ``700`` or ``rwx------``). + +To address cases like this, TriBITS can automatically run ``chgrp`` and +``chmod`` on the created files and directories that are created during the +``install`` target as described in `Setting install ownership and +permissions`_. This is completely automatic and requires nothing for the +TriBITS Project developers to do to enable support for this (other than to +note the below warning). + +**WARNING**: Do not add any ``install()`` commands after the +`TRIBITS_PROJECT()`_ command completes. Otherwise, any extra files or +directories will not have their group and permissions fixed by these special +TriBITS-added ``chgrp`` and ``chmod`` commands run at install time. Instead, +try to put all ``install()`` commands inside of a package's +`/CMakeLists.txt`_ file. Currently, there really is no good place +to add repo-level or project-level ``install()`` commands. But if one had to +sneak them in, they could add various ``install()`` commands to files like +`/CMakeLists.txt`_ (before the ``TRIBITS_PROJECT_()`` command), +`/cmake/CallbackSetupExtraOptions.cmake`_, +`/cmake/CallbackDefineProjectPackaging.cmake`_ and/or +`/cmake/CallbackDefineRepositoryPackaging.cmake`_. (Note that +install commands from the former two files are run before install commands for +the enabled packages while install commands from the latter two files are run +after.) + + RPATH Handling -------------- @@ -8091,6 +8154,7 @@ a given TriBITS project are: * `${PROJECT_NAME}_GENERATE_REPO_VERSION_FILE`_ * `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ * `${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE`_ +* `${PROJECT_NAME}_MAKE_INSTALL_GROUP_WRITABLE`_ * `${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE`_ * `${PROJECT_NAME}_MUST_FIND_ALL_TPL_LIBS`_ * `${PROJECT_NAME}_REQUIRES_PYTHON`_ @@ -8546,29 +8610,39 @@ These options are described below. .. _${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE: +.. _${PROJECT_NAME}_MAKE_INSTALL_GROUP_WRITABLE: + .. _${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE: **${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE** +**${PROJECT_NAME}_MAKE_INSTALL_GROUP_WRITABLE** **${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE** - Determines the permissions for directories created during the execution of - the of the ``install`` target. The default permissions are those for the - user running the ``install`` target. For CMake versions 3.11.0+, the user - can change these permissions explicitly by setting the CMake vars - ``${PROJECT_NAME}_MAKE_INSTALL_GROUP_READABLE`` and/or - ``${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE``. + Determines the permissions for directories and files created during the + execution of the of the ``install`` and ``isntall_package_by_package`` + targets. - To make the created directories by world readable for the project by + To make the created directories by only group readable for the project by default, set:: SET(${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE_DEFAULT TRUE) - To make the created directories by only group readable for the project by + To make the created directories by only group writable (and readable) for + the project by default, set:: + + SET(${PROJECT_NAME}_MAKE_INSTALL_WORLD_WRITABLE_DEFAULT TRUE) + + To make the created directories by world readable for the project by default, set:: SET(${PROJECT_NAME}_MAKE_INSTALL_WORLD_READABLE_DEFAULT TRUE) - These can be set in the `/ProjectName.cmake`_ file. + On non-Windows systems, these set permissions for all files and directories + from the the user-set base directory + ``${PROJECT_NAME}_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR`` on down. + For more details see `Installation considerations`_. + + These defaults can be set in the `/ProjectName.cmake`_ file. .. _${PROJECT_NAME}_MUST_FIND_ALL_TPL_LIBS: @@ -9227,7 +9301,9 @@ Below is a snapshot of the output from ``install_devtools.py --help``. .. _make dashboard: TribitsBuildReference.html#dashboard-submissions -.. _Setting the install prefix at configure time: TribitsBuildReference.html#setting-the-install-prefix-at-configure-time +.. _Setting the install prefix: TribitsBuildReference.html#setting-the-install-prefix + +.. _Setting install ownership and permissions: TribitsBuildReference.html#setting-install-ownership-and-permissions .. _TRIBITS_2ND_CTEST_DROP_SITE: TribitsBuildReference.html#tribits-2nd-ctest-drop-site diff --git a/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt b/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt index 6637ed10cb50..d31a7f6106df 100644 --- a/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt +++ b/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt @@ -4,4 +4,11 @@ ADD_SUBDIRECTORY(src) TRIBITS_ADD_TEST_DIRECTORIES(tests) +INSTALL( DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/stuff" + DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${PACKAGE_NAME}" + USE_SOURCE_PERMISSIONS PATTERN "*~" EXCLUDE ) +# Above, we must use 'USE_SOURCE_PERMISSIONS' to preserve the executable +# permission on the scripts in that directory. (TriBITS will add commands to +# fix the permissions after the install.) + TRIBITS_SUBPACKAGE_POSTPROCESS() diff --git a/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/exec_script.sh b/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/exec_script.sh new file mode 100755 index 000000000000..b64e0abfd85f --- /dev/null +++ b/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/exec_script.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "exec_script.sh executed and returned this string" diff --git a/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/regular_file.txt b/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/regular_file.txt new file mode 100644 index 000000000000..3d7b2ecbc570 --- /dev/null +++ b/cmake/tribits/examples/TribitsExampleProject/packages/with_subpackages/b/stuff/regular_file.txt @@ -0,0 +1 @@ +This is just a regular non-executable test file we want in the install From 7d7e7fd848b4efc3e73f7d694ecf44f796535e4c Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 29 Apr 2020 17:38:31 -0600 Subject: [PATCH 2/6] ATDM: Setup for chgrp and chmod install fixups (ATDV-241) --- cmake/ctest/drivers/atdm/utils/setup_env.sh | 13 +++++++++- cmake/std/atdm/ATDMDevEnvSettings.cmake | 11 ++++++++ cmake/std/atdm/README.md | 25 +++++++++++++++++++ cmake/std/atdm/ats1/environment.sh | 4 +++ cmake/std/atdm/ats2/environment.sh | 3 ++- cmake/std/atdm/cts1/environment.sh | 3 +++ cmake/std/atdm/sems-rhel6/environment.sh | 1 + .../unset_atdm_config_vars_environment.sh | 8 ++++++ cmake/std/atdm/van1-tx2/environment.sh | 1 + cmake/std/atdm/waterman/environment.sh | 1 + 10 files changed, 68 insertions(+), 2 deletions(-) diff --git a/cmake/ctest/drivers/atdm/utils/setup_env.sh b/cmake/ctest/drivers/atdm/utils/setup_env.sh index 7f7739359e63..34de4cf2dabd 100644 --- a/cmake/ctest/drivers/atdm/utils/setup_env.sh +++ b/cmake/ctest/drivers/atdm/utils/setup_env.sh @@ -78,6 +78,11 @@ if [ "${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE}" != "" ] ; then # pages where this build will end up. CDASH_TESTING_DATE=`${WORKSPACE}/Trilinos/cmake/ctest/drivers/trilinos_cdash_build_testing_day.sh` + if [[ "${ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" == "" ]] ; then + export ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR="${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE}/${CDASH_TESTING_DATE}" + fi + echo "ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=${ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" + # Get a unique name for the build that includes the system name, but not the # 'Trilinos-atdm-' prefix. For example, for the build name # 'Trilinos-atdm-cee-rhel6_clang-5.0.1_openmpi-1.10.2_serial_static_opt' @@ -89,9 +94,15 @@ if [ "${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE}" != "" ] ; then SYSTEM_AND_BUILD_NAME=`echo $JOB_NAME | sed 's/.*Trilinos-atdm-\(.*\)$/\1/'` # Full install dir path // - export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX="${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE}/${CDASH_TESTING_DATE}/${SYSTEM_AND_BUILD_NAME}" + export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX="${ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}/${SYSTEM_AND_BUILD_NAME}" # Show the full install dir path echo "ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX=${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX}" fi + +if [[ "${ATDM_CONFIG_MAKE_INSTALL_GROUP}" == "" ]] \ + && [[ "${ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT}" != "" ]] ; then + export ATDM_CONFIG_MAKE_INSTALL_GROUP="${ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT}" +fi +echo "ATDM_CONFIG_MAKE_INSTALL_GROUP=${ATDM_CONFIG_MAKE_INSTALL_GROUP}" diff --git a/cmake/std/atdm/ATDMDevEnvSettings.cmake b/cmake/std/atdm/ATDMDevEnvSettings.cmake index 1a99ab63b11f..f9f6a760543f 100644 --- a/cmake/std/atdm/ATDMDevEnvSettings.cmake +++ b/cmake/std/atdm/ATDMDevEnvSettings.cmake @@ -471,6 +471,17 @@ IF (COMMAND INSTALL AND NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "") $ENV{ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX} CACHE FILEPATH ) ENDIF() + IF (NOT "$ENV{ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" STREQUAL "") + ATDM_SET_CACHE(Trilinos_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR + "$ENV{ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" + CACHE FILEPATH) + ENDIF() + + ATDM_SET_CACHE(Trilinos_MAKE_INSTALL_GROUP "$ENV{ATDM_CONFIG_MAKE_INSTALL_GROUP}" + CACHE STRING) + ATDM_SET_ENABLE(Trilinos_MAKE_INSTALL_GROUP_WRITABLE TRUE) + ATDM_SET_ENABLE(Trilinos_MAKE_INSTALL_WORLD_READABLE TRUE) + ATDM_SET_CACHE(Trilinos_INSTALL_PBP_RUNNER "$ENV{ATDM_CONFIG_INSTALL_PBP_RUNNER}" CACHE FILEPATH) diff --git a/cmake/std/atdm/README.md b/cmake/std/atdm/README.md index f7b9dc003441..1972571dc292 100644 --- a/cmake/std/atdm/README.md +++ b/cmake/std/atdm/README.md @@ -358,6 +358,31 @@ value that might be passed in or set otherwise. (This is a `FORCE`D cache variable set on `CMAKE_INSTALL_PREFIX` so this value will appear in the `CMakeCache.txt` file.) +If permissions need to be set on a basdir of `CMAKE_INSTALL_PREFIX`, then one +can set a base dir of this through: + +``` +$ export ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR= +``` + +where `` must be a base directory of ``. If +not explicitly set in this way, then it is assumed to be whatever the set +value is for `CMAKE_INSTALL_PREFIX`. + +By default, every file and directory created during the install under +`` will be made explicitly group read/write and "other" +readable. (That can be changed by setting CMake Cache vars starting wtih +`Trilinos_MAKE_INSTALL_`.) + +The owning group for everything under `` can be set using: + +``` +$ export ATDM_CONFIG_MAKE_INSTALL_GROUP= +``` + +Otherwise, the owning group will be set by the group sticky bit or by the +default user's group (on systems that don't support the group sticky bit). + The name of the installed script `load_matching_env.sh` can be changed at configure-time using the CMake cache variable: diff --git a/cmake/std/atdm/ats1/environment.sh b/cmake/std/atdm/ats1/environment.sh index ca11f44c70e1..8dadc92c1ca2 100755 --- a/cmake/std/atdm/ats1/environment.sh +++ b/cmake/std/atdm/ats1/environment.sh @@ -199,4 +199,8 @@ export EUCLID_ROOT=${sparc_tpl_prefix_path}/${system_name}-${node_arch}/euclid-2 # Define and export atdm_run_script_on_compute_node source $ATDM_SCRIPT_DIR/common/define_run_on_slurm_compute_node_func.sh +# Install-related stuff +export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs +export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops + export ATDM_CONFIG_COMPLETED_ENV_SETUP=TRUE diff --git a/cmake/std/atdm/ats2/environment.sh b/cmake/std/atdm/ats2/environment.sh index 12f24769e382..e3598706ad7d 100644 --- a/cmake/std/atdm/ats2/environment.sh +++ b/cmake/std/atdm/ats2/environment.sh @@ -255,8 +255,9 @@ export F77=mpifort export FC=mpifort export F90=mpifort -# Default install location +# Install-related stuff export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs/ +export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops # System-info for what ATS-2 system we are using if [[ "${ATDM_CONFIG_KNOWN_HOSTNAME}" == "vortex" ]] ; then diff --git a/cmake/std/atdm/cts1/environment.sh b/cmake/std/atdm/cts1/environment.sh index 048c68663226..9b637657aee6 100755 --- a/cmake/std/atdm/cts1/environment.sh +++ b/cmake/std/atdm/cts1/environment.sh @@ -33,3 +33,6 @@ export ATDM_CONFIG_SLURM_DEFAULT_ACCOUNT=fy150090 source $ATDM_SCRIPT_DIR/common/toss3/environment_new.sh export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs/ +export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops + +export ATDM_CONFIG_COMPLETED_ENV_SETUP=TRUE diff --git a/cmake/std/atdm/sems-rhel6/environment.sh b/cmake/std/atdm/sems-rhel6/environment.sh index df87880de03d..12a265acad5e 100755 --- a/cmake/std/atdm/sems-rhel6/environment.sh +++ b/cmake/std/atdm/sems-rhel6/environment.sh @@ -214,6 +214,7 @@ export ATDM_CONFIG_MPI_PRE_FLAGS="--bind-to;none" export ATDM_CONFIG_WORKSPACE_BASE_DEFAULT=/home/atdm-devops-admin/jenkins export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/home/atdm-devops-admin/trilinos_installs +export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops export ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT=/home/atdm-devops-admin/tools/run-as-atdm-devops-admin # diff --git a/cmake/std/atdm/utils/unset_atdm_config_vars_environment.sh b/cmake/std/atdm/utils/unset_atdm_config_vars_environment.sh index a0541f7d1aae..551b8ccae4c7 100644 --- a/cmake/std/atdm/utils/unset_atdm_config_vars_environment.sh +++ b/cmake/std/atdm/utils/unset_atdm_config_vars_environment.sh @@ -49,6 +49,7 @@ unset ATDM_CONFIG_MPI_POST_FLAGS unset ATDM_CONFIG_WORKSPACE_BASE_DEFAULT unset ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT unset ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT +unset ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT unset ATDM_CONFIG_SBATCH_DEFAULT_TIMEOUT unset ATDM_CONFIG_SBATCH_DEFAULT_ACCOUNT unset atdm_run_script_on_compute_node @@ -60,3 +61,10 @@ unset ATDM_CONFIG_MPI_EXEC_NUMPROCS_FLAG unset atdm_run_script_on_compute_node unset ATDM_CONFIG_Trilinos_LINK_SEARCH_START_STATIC unset ATDM_CONFIG_SBATCH_EXTRA_ARGS + +# NOTE: Not unsetting the following env vars on purpose because we want users +# to be able to set them before sourcing atdm/load-env.sh : +# +# * ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX +# * ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR +# * ATDM_CONFIG_MAKE_INSTALL_GROUP diff --git a/cmake/std/atdm/van1-tx2/environment.sh b/cmake/std/atdm/van1-tx2/environment.sh index cb149a316c2c..724083887424 100755 --- a/cmake/std/atdm/van1-tx2/environment.sh +++ b/cmake/std/atdm/van1-tx2/environment.sh @@ -147,6 +147,7 @@ export ATDM_CONFIG_WCID_ACCOUNT_DEFAULT=fy150090 # Install related export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs +export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops # # Done diff --git a/cmake/std/atdm/waterman/environment.sh b/cmake/std/atdm/waterman/environment.sh index 61f33977e117..d85cdf617eb2 100755 --- a/cmake/std/atdm/waterman/environment.sh +++ b/cmake/std/atdm/waterman/environment.sh @@ -206,6 +206,7 @@ export ATDM_CONFIG_MPI_POST_FLAGS="-map-by;socket:PE=4" export ATDM_CONFIG_WORKSPACE_BASE_DEFAULT=/home/atdm-devops-admin/jenkins export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/home/atdm-devops-admin/trilinos_installs +export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops export ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT=/home/atdm-devops-admin/tools/run-as-atdm-devops-admin # From 9be15769beb422b99e7527ef0deca5232724c7ca Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 29 Apr 2020 17:59:06 -0600 Subject: [PATCH 3/6] ATDM: Setup for doing installs on 'sems-rhel7' (ATDV-271) I am doing this partially because I want to test these installs on CEE sems-rhel7 machines. But I think it would also be useful to do installs of Trilinos on CEE sems-rhel7 machines (so EMPIRE can test against them). --- cmake/std/atdm/sems-rhel7/environment.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/std/atdm/sems-rhel7/environment.sh b/cmake/std/atdm/sems-rhel7/environment.sh index bdefc2bf0bcc..a8f84438f8b7 100755 --- a/cmake/std/atdm/sems-rhel7/environment.sh +++ b/cmake/std/atdm/sems-rhel7/environment.sh @@ -282,4 +282,9 @@ export MPIF90=`which mpif90` export ATDM_CONFIG_MPI_PRE_FLAGS="--bind-to;none" +# Install-related stuff +export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs +export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops +# NOTE: Above assumes that one is running on a CEE RHE7 machine! + export ATDM_CONFIG_COMPLETED_ENV_SETUP=TRUE From c96bce43be154f2337f7d15ff7f4593d5b8eb33b Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 30 Apr 2020 13:03:15 -0600 Subject: [PATCH 4/6] ATDM: sems-rhel6: Add missing boost module load (#7275) The change the sems-netcdf/4.4.1/exo_parallel module to the sems-netcdf/4.7.3/parallel module in commit 09e765d merged in PR #7179 resulted in the sems-boost/1.59.0/base module no longer being implicilty loaded. This was causing a configure-time failure where boost could not be found. This commit adds a explicit load of sems-boost/1.59.0/base. This allows the configure of Trilinos to work (but I have not tested a full set of builds). --- cmake/std/atdm/sems-rhel6/environment.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/std/atdm/sems-rhel6/environment.sh b/cmake/std/atdm/sems-rhel6/environment.sh index 12a265acad5e..fcb1357879e7 100755 --- a/cmake/std/atdm/sems-rhel6/environment.sh +++ b/cmake/std/atdm/sems-rhel6/environment.sh @@ -169,6 +169,7 @@ else fi module load sems-openmpi/1.10.1 +module load sems-boost/1.59.0/base module load sems-netcdf/4.7.3/parallel module load sems-hdf5/1.10.6/parallel module load sems-zlib/1.2.8/base From 37d444522bfed8c266c4d70d6b558758bb3a385e Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 30 Apr 2020 17:53:55 -0600 Subject: [PATCH 5/6] ATDM: Provide one place for atdm-devops defaults, update docs (ATDV-241) This responds to some good feedback about lots of duplication in setting the group 'wg-run-as-atdm-devops'. I also removed duplication in the near-universal install base dir /projects/atdm_devops/trilinos_installs. (But specific envs can override these in their atdm//environment.sh file.) I also updated the documentation. I tested this manaully on my 'sems-rhel6' machine and it seems to do what it is supposed to do. --- cmake/ctest/drivers/atdm/README.md | 169 ++++++++++++------ cmake/ctest/drivers/atdm/utils/setup_env.sh | 27 ++- .../std/atdm/atdm_devops_install_defaults.sh | 13 ++ cmake/std/atdm/ats1/environment.sh | 4 - cmake/std/atdm/ats2/environment.sh | 4 - cmake/std/atdm/cts1/environment.sh | 3 - cmake/std/atdm/sems-rhel6/environment.sh | 1 - cmake/std/atdm/sems-rhel7/environment.sh | 5 - cmake/std/atdm/van1-tx2/environment.sh | 4 - cmake/std/atdm/waterman/environment.sh | 1 - 10 files changed, 151 insertions(+), 80 deletions(-) create mode 100644 cmake/std/atdm/atdm_devops_install_defaults.sh diff --git a/cmake/ctest/drivers/atdm/README.md b/cmake/ctest/drivers/atdm/README.md index 59767e41f099..142462558766 100644 --- a/cmake/ctest/drivers/atdm/README.md +++ b/cmake/ctest/drivers/atdm/README.md @@ -260,20 +260,118 @@ cores. These scripts support installing Trilinos as a byproduct of running the `ctest -S` driver scripts. These installations are often done as the `jenkins` -entity account from the `jenkins-srn.sandia.gov` site (but other setups are -possible as well). In order to protect installations of Trilinos, a strategy -is implemented that performs the final install using the `atdm-devops-admin` -account using a setuid program called `run-as-atdm-devops-admin` that in -installed on each system. The setup of that program under the -`atdm-devops-admin` user account is described in: +entity account from the `jenkins-srn.sandia.gov` site or as the +'atdm-devops-admin' entity account (e.g. from a cron job). In order to +properly set up installations of Trilinos on all of the supported systems such +that the `atdm-devops-admin` entity account can edit and remote the installs, +some features of TriBITS are used to run `chgrp` and `chmod` on the installed +directories and files. In addition, automatic `/` subdirectories are +created which for each testing day. + +The following (bash) environment variables determine the behavior of the ATDM +`ctest -S` scripts for building and installing Trilinos using this scheme: + +* `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE=`: + Defines the base directory installs of Trilinos under + `//`. This directory + `` must be owned by the user 'atdm-devops-admin', the + group 'wg-run-as-atdm-devops' and it should be world readable and group + read/writable. (If `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE==""` + and `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT!=""` and + `ATDM_CONFIG_USE_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=="1"`, then + `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE` is set to + `${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT}`.) (The var + `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE` is given a default value + in the file `cmake/std/atdm/atdm_devops_install_defaults.sh` if it is not + already set in `cmake/std/atdm//environment.sh`.) + +* `ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=`: + Defines the base directory for setting the group and permissions. If not + set in the env already and if + `${ATDM_CONFIG_USE_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR_DEFAULT}==1`, + then this will bet set to `/`. + +* `ATDM_CONFIG_MAKE_INSTALL_GROUP`: Defines the group that will get set on all + files and dirs under + `${ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}`. If not + already set in the env, then this will be set to + `${ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT}` if + `${ATDM_CONFIG_USE_MAKE_INSTALL_GROUP_DEFAULT}==1`. (The var + `ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT` is given a default value in the + file `cmake/std/atdm/atdm_devops_install_defaults.sh` if it is not already + set in `cmake/std/atdm//environment.sh`.) + +* `ATDM_CONFIG_USE_JENKINS_INSTALL_DEFAULTS=[0|1]`: Set to '1' to use the + defaults for the variables that have defaults (i.e. this sets the + environment variables + `ATDM_CONFIG_USE_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=1`, + `ATDM_CONFIG_USE_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR_DEFAULT=1`, + and `ATDM_CONFIG_USE_MAKE_INSTALL_GROUP_DEFAULT=1`.) + +The defaults for some of these can be set for all systems in the file +`cmake/std/atdm/atdm_devops_install_defaults.sh`. These defaults can then be +overridden in the `cmake/std/atdm//environment.sh` for each +system. + +Then the cron or jenkins driver jobs can activate the usage of these defaults +and perform standard installs as a bi-product of the testing process as +follows: + +``` +export ATDM_CONFIG_USE_JENKINS_INSTALL_DEFAULTS=1 +export CTEST_DO_INSTALL=ON +${WORKSPACE}/Trilinos/cmake/ctest/drivers/atdm/smart-jenkins-driver.sh +``` + +That will result in the install of Trilinos under: + +``` +/// +``` + +where all of the files and directories `/` on down +will be owned by the group `${ATDM_CONFIG_MAKE_INSTALL_GROUP}` and will be +given group read/write and "other" read access. + +NOTE: + +* The `` in the format `YYYY-MM-DD` is automatically determined to + correspond to the CDash `date=` field for the given build of Trilinos + (assuming that `ctest_start()` is called almost immediately which it should + be within a second or less). + +* The build name `` is taken from the full build name + stored in the environment variable `${JOB_NAME}` (with `Trilinos-atdm-` + removed from the beginning of the Jenkins job name). + +Internally, for each build, the environment variable +`ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX` is set to this full install path +(which then gets picked up in the `ATDMDevEnvSettings.cmake` file during the +CMake configure step). + +**WARNING:** Do **NOT** directly set the environment variable +`ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX`. That would result in every Trilinos +build getting installed on top of each other in the same installation +directory! + + +## Installing as the 'atdm-devops-admin' account using the 'jenkins' entity account + +In order to protect the installation Trilinos from other 'jenkins' jobs, a +strategy has been implemented that allows performs the final install using the +`atdm-devops-admin` account using a setuid program called +`run-as-atdm-devops-admin` that in installed on each supported system. The +setup of that program under the `atdm-devops-admin` user account is described +in: * https://gitlab.sandia.gov/atdm-devops-admin/run-as-atdm-devops-admin/blob/master/README.md -This documentation assumes that the program 'run-as-atdm-devops-admin' -correctly installed on each given system. +This documentation below assumes that the program 'run-as-atdm-devops-admin' +is correctly installed on each given system. -The following (bash) environment variables determine the behavior of the ATDM -`ctest -S` scripts for building and installing Trilinos using this scheme: +The following additional (bash) environment variables determine the behavior +of the ATDM `ctest -S` scripts for building and installing Trilinos using this +scheme: * `ATDM_CONFIG_WORKSPACE_BASE=`: Defines a different base workspace directory under which the subdir `SRC_AND_BUILD` is created and @@ -299,36 +397,16 @@ The following (bash) environment variables determine the behavior of the ATDM `ATDM_CONFIG_INSTALL_PBP_RUNNER` is set to `${ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT}`) -* `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE=`: - Defines the base directory installs of Trilinos under - `//`. This directory must be - owned by the 'atdm-devops-admin' user and should be world readable (but not - group or world writable). (If - `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE==""` and - `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT!=""` and - `ATDM_CONFIG_USE_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=="1"`, then - `ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE` is set to - `${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT}`.) - -* `ATDM_CONFIG_USE_JENKINS_INSTALL_DEFAULTS=[0|1]`: Set to '1' to use the - defaults for the above three variables (i.e. this sets the environment variables - `ATDM_CONFIG_USE_WORKSPACE_BASE_DEFAULT=1`, - `ATDM_CONFIG_USE_INSTALL_PBP_RUNNER_DEFAULT=1`, - `ATDM_CONFIG_USE_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=1`). - -The variables `ATDM_CONFIG_WORKSPACE_BASE_DEFAULT`, -`ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT` and -`ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT` are meant to be set -in the `atdm//environment.sh` file as, for example: +The variables `ATDM_CONFIG_WORKSPACE_BASE_DEFAULT` and +`ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT` are meant to be set in the +`atdm//environment.sh` file as, for example: ``` export ATDM_CONFIG_WORKSPACE_BASE_DEFAULT=/home/atdm-devops-admin/jenkins -export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/home/atdm-devops-admin/trilinos_installs export ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT=/home/atdm-devops-admin/tools/run-as-atdm-devops-admin ``` -Then the jenkins driver jobs can activate the usage of these defaults and -perform installs as a bi-product by running: +Running with: ``` export ATDM_CONFIG_USE_JENKINS_INSTALL_DEFAULTS=1 @@ -336,7 +414,7 @@ export CTEST_DO_INSTALL=ON ${WORKSPACE}/Trilinos/cmake/ctest/drivers/atdm/smart-jenkins-driver.sh ``` -This will result in the alternate workspace directory being create as: +will result in the alternate workspace directory being create as: ``` export WORKSPACE=${ATDM_CONFIG_WORKSPACE_BASE}/${ATDM_CONFIG_SYSTEM_NAME}/${JOB_NAME} @@ -352,27 +430,6 @@ under: /// ``` -where: - -* The `` in the format `YYYY-MM-DD` is automatically determined to - correspond to the CDash `date=` field for the given build of Trilinos - (assuming that `ctest_start()` is called almost immediately which it should - be within a second or less). - -* The build name `` is taken from the full build name - stored in the environment variable `${JOB_NAME}` (with `Trilinos-atdm-` - removed from the beginning of the Jenkins job name). - -Internally, for each build, the environment variable -`ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX` is set to this full install path -(which then gets picked up in the `ATDMDevEnvSettings.cmake` file during the -CMake configure step). - -**WARNING:** Do **NOT** directly set the environment variable -`ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX`. That would result in every Trilinos -build getting installed on top of each other in the same installation -directory! - diff --git a/cmake/ctest/drivers/atdm/utils/setup_env.sh b/cmake/ctest/drivers/atdm/utils/setup_env.sh index 34de4cf2dabd..0ad5e8ddda02 100644 --- a/cmake/ctest/drivers/atdm/utils/setup_env.sh +++ b/cmake/ctest/drivers/atdm/utils/setup_env.sh @@ -39,8 +39,13 @@ unset http_proxy # C) Setup install-releated stuff # +source ${ATDM_CONFIG_SCRIPT_DIR}/atdm_devops_install_defaults.sh + echo +# Set up default ATDM_CONFIG_USE_XXX_DEFAULT vars from +# ATDM_CONFIG_USE_JENKINS_INSTALL_DEFAULTS + if [[ "${ATDM_CONFIG_USE_WORKSPACE_BASE_DEFAULT}" == "" ]] \ && [[ "${ATDM_CONFIG_USE_JENKINS_INSTALL_DEFAULTS}" == "1" ]] ; then export ATDM_CONFIG_USE_WORKSPACE_BASE_DEFAULT=1 @@ -53,6 +58,22 @@ if [[ "${ATDM_CONFIG_USE_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT}" == "" ]] fi echo "ATDM_CONFIG_USE_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=${ATDM_CONFIG_USE_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT}" +if [[ "${ATDM_CONFIG_USE_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR_DEFAULT}" == "" ]] \ + && [[ "${ATDM_CONFIG_USE_JENKINS_INSTALL_DEFAULTS}" == "1" ]] ; then + export ATDM_CONFIG_USE_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR_DEFAULT=1 +fi +echo "ATDM_CONFIG_USE_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR_DEFAULT=${ATDM_CONFIG_USE_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR_DEFAULT}" + +if [[ "${ATDM_CONFIG_USE_MAKE_INSTALL_GROUP_DEFAULT}" == "" ]] \ + && [[ "${ATDM_CONFIG_USE_JENKINS_INSTALL_DEFAULTS}" == "1" ]] ; then + export ATDM_CONFIG_USE_MAKE_INSTALL_GROUP_DEFAULT=1 +fi +echo "ATDM_CONFIG_USE_MAKE_INSTALL_GROUP_DEFAULT=${ATDM_CONFIG_USE_MAKE_INSTALL_GROUP_DEFAULT}" + +# Set up the default workspace and base install directory paths + +echo + if [[ "${ATDM_CONFIG_WORKSPACE_BASE}" == "" ]] \ && [[ "${ATDM_CONFIG_WORKSPACE_BASE_DEFAULT}" != "" ]] \ && [[ "${ATDM_CONFIG_USE_WORKSPACE_BASE_DEFAULT}" == "1" ]] ; then @@ -78,7 +99,8 @@ if [ "${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE}" != "" ] ; then # pages where this build will end up. CDASH_TESTING_DATE=`${WORKSPACE}/Trilinos/cmake/ctest/drivers/trilinos_cdash_build_testing_day.sh` - if [[ "${ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" == "" ]] ; then + if [[ "${ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" == "" ]] \ + && [[ "${ATDM_CONFIG_USE_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR_DEFAULT}" == "1" ]] ; then export ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR="${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE}/${CDASH_TESTING_DATE}" fi echo "ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=${ATDM_CONFIG_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR}" @@ -102,7 +124,8 @@ if [ "${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE}" != "" ] ; then fi if [[ "${ATDM_CONFIG_MAKE_INSTALL_GROUP}" == "" ]] \ - && [[ "${ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT}" != "" ]] ; then + && [[ "${ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT}" != "" ]] \ + && [[ "${ATDM_CONFIG_USE_MAKE_INSTALL_GROUP_DEFAULT}" == "1" ]] ; then export ATDM_CONFIG_MAKE_INSTALL_GROUP="${ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT}" fi echo "ATDM_CONFIG_MAKE_INSTALL_GROUP=${ATDM_CONFIG_MAKE_INSTALL_GROUP}" diff --git a/cmake/std/atdm/atdm_devops_install_defaults.sh b/cmake/std/atdm/atdm_devops_install_defaults.sh new file mode 100644 index 000000000000..ba73d5c88191 --- /dev/null +++ b/cmake/std/atdm/atdm_devops_install_defaults.sh @@ -0,0 +1,13 @@ +# These are defaults that work for almost every system where that ATDM DevOps +# effort installs Trilinos as a biproduct of that ATDM Trilinos builds that +# submit to CDash. This assumes that either the 'jenkins' or the +# 'atdm-devops-admin' entity accounts is driving the ctest -S scripts and the +# group 'wg-run-as-atdm-devsops' exists on the machine. + +if [[ "${ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT}" == "" ]] ; then + export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs +fi + +if [[ "${ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT}" == "" ]] ; then + export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops +fi diff --git a/cmake/std/atdm/ats1/environment.sh b/cmake/std/atdm/ats1/environment.sh index 8dadc92c1ca2..ca11f44c70e1 100755 --- a/cmake/std/atdm/ats1/environment.sh +++ b/cmake/std/atdm/ats1/environment.sh @@ -199,8 +199,4 @@ export EUCLID_ROOT=${sparc_tpl_prefix_path}/${system_name}-${node_arch}/euclid-2 # Define and export atdm_run_script_on_compute_node source $ATDM_SCRIPT_DIR/common/define_run_on_slurm_compute_node_func.sh -# Install-related stuff -export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs -export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops - export ATDM_CONFIG_COMPLETED_ENV_SETUP=TRUE diff --git a/cmake/std/atdm/ats2/environment.sh b/cmake/std/atdm/ats2/environment.sh index e3598706ad7d..44e60bce0a28 100644 --- a/cmake/std/atdm/ats2/environment.sh +++ b/cmake/std/atdm/ats2/environment.sh @@ -255,10 +255,6 @@ export F77=mpifort export FC=mpifort export F90=mpifort -# Install-related stuff -export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs/ -export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops - # System-info for what ATS-2 system we are using if [[ "${ATDM_CONFIG_KNOWN_HOSTNAME}" == "vortex" ]] ; then export ATDM_CONFIG_ATS2_LOGIN_NODE=vortex60 diff --git a/cmake/std/atdm/cts1/environment.sh b/cmake/std/atdm/cts1/environment.sh index 9b637657aee6..0300a3386b08 100755 --- a/cmake/std/atdm/cts1/environment.sh +++ b/cmake/std/atdm/cts1/environment.sh @@ -32,7 +32,4 @@ export ATDM_CONFIG_SLURM_DEFAULT_ACCOUNT=fy150090 source $ATDM_SCRIPT_DIR/common/toss3/environment_new.sh -export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs/ -export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops - export ATDM_CONFIG_COMPLETED_ENV_SETUP=TRUE diff --git a/cmake/std/atdm/sems-rhel6/environment.sh b/cmake/std/atdm/sems-rhel6/environment.sh index fcb1357879e7..29d328f8f7dc 100755 --- a/cmake/std/atdm/sems-rhel6/environment.sh +++ b/cmake/std/atdm/sems-rhel6/environment.sh @@ -215,7 +215,6 @@ export ATDM_CONFIG_MPI_PRE_FLAGS="--bind-to;none" export ATDM_CONFIG_WORKSPACE_BASE_DEFAULT=/home/atdm-devops-admin/jenkins export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/home/atdm-devops-admin/trilinos_installs -export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops export ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT=/home/atdm-devops-admin/tools/run-as-atdm-devops-admin # diff --git a/cmake/std/atdm/sems-rhel7/environment.sh b/cmake/std/atdm/sems-rhel7/environment.sh index a8f84438f8b7..bdefc2bf0bcc 100755 --- a/cmake/std/atdm/sems-rhel7/environment.sh +++ b/cmake/std/atdm/sems-rhel7/environment.sh @@ -282,9 +282,4 @@ export MPIF90=`which mpif90` export ATDM_CONFIG_MPI_PRE_FLAGS="--bind-to;none" -# Install-related stuff -export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs -export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops -# NOTE: Above assumes that one is running on a CEE RHE7 machine! - export ATDM_CONFIG_COMPLETED_ENV_SETUP=TRUE diff --git a/cmake/std/atdm/van1-tx2/environment.sh b/cmake/std/atdm/van1-tx2/environment.sh index 724083887424..ed20573a725e 100755 --- a/cmake/std/atdm/van1-tx2/environment.sh +++ b/cmake/std/atdm/van1-tx2/environment.sh @@ -145,10 +145,6 @@ export ATMD_CONFIG_MPI_USE_COMPILER_WRAPPERS=ON export ATDM_CONFIG_WCID_ACCOUNT_DEFAULT=fy150090 -# Install related -export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/projects/atdm_devops/trilinos_installs -export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops - # # Done # diff --git a/cmake/std/atdm/waterman/environment.sh b/cmake/std/atdm/waterman/environment.sh index d85cdf617eb2..61f33977e117 100755 --- a/cmake/std/atdm/waterman/environment.sh +++ b/cmake/std/atdm/waterman/environment.sh @@ -206,7 +206,6 @@ export ATDM_CONFIG_MPI_POST_FLAGS="-map-by;socket:PE=4" export ATDM_CONFIG_WORKSPACE_BASE_DEFAULT=/home/atdm-devops-admin/jenkins export ATDM_CONFIG_TRIL_CMAKE_INSTALL_PREFIX_DATE_BASE_DEFAULT=/home/atdm-devops-admin/trilinos_installs -export ATDM_CONFIG_MAKE_INSTALL_GROUP_DEFAULT=wg-run-as-atdm-devops export ATDM_CONFIG_INSTALL_PBP_RUNNER_DEFAULT=/home/atdm-devops-admin/tools/run-as-atdm-devops-admin # From 21112c29f7fbc2aeda99db012edebfa398700f72 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 30 Apr 2020 18:11:27 -0600 Subject: [PATCH 6/6] Avoid installing *.pyc files for TriBITS Note sure why this file is not installing but we don't want to be installing these *.pyc files. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 520d6ac81d38..6a2eeef5646e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ IF (${PROJECT_NAME}_INSTALL_TriBITS) INSTALL( DIRECTORY "${Trilinos_SOURCE_DIR}/cmake/tribits" DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}/cmake" + PATTERN "*.pyc" EXCLUDE ) ENDIF()