diff options
120 files changed, 2350 insertions, 206 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ec2393b..f8d5292 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,10 +8,15 @@ include: - local: .gitlab/os-macos.yml - local: .gitlab/os-windows.yml + # Post-build steps + - local: .gitlab/upload.yml + stages: - build - test + - package - test-ext + - upload ################################################################################ # Job declarations @@ -52,6 +57,14 @@ build:fedora31-sphinx: - .linux_builder_tags_qt - .run_automatically +build:fedora31-sphinx-package: + extends: + - .fedora31_sphinx_package + - .cmake_build_linux + - .linux_builder_tags_qt + - .cmake_doc_artifacts + - .run_only_for_package + # Linux builds build:centos6-release: @@ -167,6 +180,29 @@ test:macos-xcode: needs: - test:macos-ninja +package:macos: + extends: + - .macos_package + - .cmake_build_macos_package + - .cmake_release_artifacts + - .macos_builder_tags_package + - .run_only_for_package + dependencies: + - build:fedora31-sphinx-package + needs: + - build:fedora31-sphinx-package + +upload:macos: + extends: + - .rsync_upload + - .run_only_for_package + dependencies: + - package:macos + needs: + - package:macos + variables: + RSYNC_DESTINATION: dev + # Windows builds build:windows-vs2019-x64-ninja: diff --git a/.gitlab/artifacts.yml b/.gitlab/artifacts.yml index be10e24..2eadcb1 100644 --- a/.gitlab/artifacts.yml +++ b/.gitlab/artifacts.yml @@ -72,6 +72,7 @@ paths: # Any packages made. - build/cmake-*-Linux-x86_64.* + - build/cmake-*-Darwin-x86_64.* .cmake_test_artifacts: artifacts: @@ -79,3 +80,10 @@ paths: # Take the install tree. - build/install/ + +.cmake_doc_artifacts: + artifacts: + expire_in: 1d + paths: + # Take the install tree. + - build/install-doc/ diff --git a/.gitlab/ci/configure_fedora31_common.cmake b/.gitlab/ci/configure_fedora31_common.cmake index 90b9d90..dc068d5 100644 --- a/.gitlab/ci/configure_fedora31_common.cmake +++ b/.gitlab/ci/configure_fedora31_common.cmake @@ -1,5 +1,4 @@ set(BUILD_CursesDialog ON CACHE BOOL "") set(BUILD_QtDialog ON CACHE BOOL "") - include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_fedora31_sphinx.cmake b/.gitlab/ci/configure_fedora31_sphinx.cmake index dfc9b8c..90d159b 100644 --- a/.gitlab/ci/configure_fedora31_sphinx.cmake +++ b/.gitlab/ci/configure_fedora31_sphinx.cmake @@ -1,8 +1,2 @@ -set(SPHINX_INFO ON CACHE BOOL "") -set(SPHINX_MAN ON CACHE BOOL "") -set(SPHINX_HTML ON CACHE BOOL "") -set(SPHINX_SINGLEHTML ON CACHE BOOL "") -set(SPHINX_QTHELP ON CACHE BOOL "") -set(SPHINX_TEXT ON CACHE BOOL "") - +include("${CMAKE_CURRENT_LIST_DIR}/configure_sphinx.cmake") include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_fedora31_sphinx_package.cmake b/.gitlab/ci/configure_fedora31_sphinx_package.cmake new file mode 100644 index 0000000..e839de8 --- /dev/null +++ b/.gitlab/ci/configure_fedora31_sphinx_package.cmake @@ -0,0 +1,13 @@ +# Disable formats not wanted in the package's documentation. +set(SPHINX_INFO OFF CACHE BOOL "") +set(SPHINX_SINGLEHTML OFF CACHE BOOL "") +set(SPHINX_TEXT OFF CACHE BOOL "") + +# Set the destination directory for docs that packages expect. +set(CMAKE_DOC_DIR "doc/cmake" CACHE STRING "") + +# Use a custom prefix to avoid conflicting with other builds. +set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install-doc" CACHE PATH "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_sphinx.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_macos_package.cmake b/.gitlab/ci/configure_macos_package.cmake new file mode 100644 index 0000000..424bc2b --- /dev/null +++ b/.gitlab/ci/configure_macos_package.cmake @@ -0,0 +1,24 @@ +set(CMake_DOC_ARTIFACT_PREFIX "$ENV{CI_PROJECT_DIR}/build/install-doc" CACHE PATH "") + +# Set up install destinations as expected by the packaging scripts. +set(CMAKE_INSTALL_PREFIX "/" CACHE PATH "") +set(CMAKE_DOC_DIR "doc/cmake" CACHE STRING "") + +# Settings for CMake packages for macOS. +set(CPACK_DMG_FORMAT "UDBZ" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-stdlib=libc++" CACHE STRING "") +set(CMAKE_C_STANDARD "11" CACHE STRING "") +set(CMAKE_CXX_STANDARD "14" CACHE STRING "") +set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "") +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "") +set(CMAKE_SKIP_BOOTSTRAP_TEST "TRUE" CACHE STRING "") +set(CPACK_SYSTEM_NAME "Darwin-x86_64" CACHE STRING "") +set(BUILD_CursesDialog "ON" CACHE BOOL "") +set(BUILD_QtDialog "TRUE" CACHE BOOL "") +set(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL "3" CACHE STRING "") +set(CMake_INSTALL_DEPENDENCIES "ON" CACHE BOOL "") +set(CMAKE_SKIP_RPATH "TRUE" CACHE BOOL "") +set(CMake_TEST_NO_FindPackageModeMakefileTest "TRUE" CACHE BOOL "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_macos_common.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_sphinx.cmake b/.gitlab/ci/configure_sphinx.cmake new file mode 100644 index 0000000..3750309 --- /dev/null +++ b/.gitlab/ci/configure_sphinx.cmake @@ -0,0 +1,6 @@ +set(SPHINX_INFO ON CACHE BOOL "") +set(SPHINX_MAN ON CACHE BOOL "") +set(SPHINX_HTML ON CACHE BOOL "") +set(SPHINX_SINGLEHTML ON CACHE BOOL "") +set(SPHINX_QTHELP ON CACHE BOOL "") +set(SPHINX_TEXT ON CACHE BOOL "") diff --git a/.gitlab/ci/download_qt.cmake b/.gitlab/ci/download_qt.cmake index c392b1c..31ce6c3 100644 --- a/.gitlab/ci/download_qt.cmake +++ b/.gitlab/ci/download_qt.cmake @@ -6,7 +6,11 @@ set(qt_version_minor "15") set(qt_version_patch "0") # This URL is only visible inside of Kitware's network. Please use your own Qt # Account to obtain these files. -set(qt_url_root "https://paraview.org/files/dependencies/internal/qt") +if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "package") + set(qt_url_root "https://cmake.org/files/dependencies") +else () + set(qt_url_root "https://paraview.org/files/dependencies/internal/qt") +endif () # Determine the ABI to fetch for Qt. if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "vs2015") @@ -51,15 +55,21 @@ if (qt_platform STREQUAL "windows_x86") set(qt_subdir "${qt_version}/msvc${msvc_year}_64") elseif (qt_platform STREQUAL "mac_x64") - set(qt_build_stamp "202005140805") - set(qt_file_name_prefix "${qt_version}-0-${qt_build_stamp}") - - foreach (qt_component IN ITEMS qtbase) + if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "package") list(APPEND qt_files - "${qt_file_name_prefix}${qt_component}-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z") - endforeach () + "qt-5.6.2-macosx10.7-x86_64.tar.xz") + set(qt_subdir "qt-5.6.2-macosx10.7-x86_64") + else () + set(qt_build_stamp "202005140805") + set(qt_file_name_prefix "${qt_version}-0-${qt_build_stamp}") + + foreach (qt_component IN ITEMS qtbase) + list(APPEND qt_files + "${qt_file_name_prefix}${qt_component}-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z") + endforeach () - set(qt_subdir "${qt_version}/clang_64") + set(qt_subdir "${qt_version}/clang_64") + endif () else () message(FATAL_ERROR "Unknown files for ${qt_platform}") @@ -72,7 +82,11 @@ if (NOT qt_subdir) endif () # Build up the path to the file to download. -set(qt_url_path "${qt_platform}/desktop/qt5_${qt_version_nodot}/qt.qt5.${qt_version_nodot}.${qt_abi}") +if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "package") + set(qt_url_path "") +else () + set(qt_url_path "${qt_platform}/desktop/qt5_${qt_version_nodot}/qt.qt5.${qt_version_nodot}.${qt_abi}") +endif () set(qt_url_prefix "${qt_url_root}/${qt_url_path}") # Include the file containing the hashes of the files that matter. diff --git a/.gitlab/ci/download_qt_hashes.cmake b/.gitlab/ci/download_qt_hashes.cmake index 59cb597..28837dc 100644 --- a/.gitlab/ci/download_qt_hashes.cmake +++ b/.gitlab/ci/download_qt_hashes.cmake @@ -9,3 +9,5 @@ set("5.15.0-0-202005150700qtbase-Windows-Windows_10-MSVC2015-Windows-Windows_10- set("5.15.0-0-202005150700qtwinextras-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" 4bca3a8d8c7611e211a82d86b3396f8a622abe7859d5052452414642ec191844) set("5.15.0-0-202005140805qtbase-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" 04d867c81d2431f288c42c9752642759460b9468477de349368dcc8de0c8ddc4) + +set("qt-5.6.2-macosx10.7-x86_64.tar.xz_hash" 2b60373ea60037ce356d4c9f5a8c1df9854127a2c55118252e1a2f5a5f4e0010) diff --git a/.gitlab/ci/gitlab_ci.cmake b/.gitlab/ci/gitlab_ci.cmake index 698d5ea..7bd9300 100644 --- a/.gitlab/ci/gitlab_ci.cmake +++ b/.gitlab/ci/gitlab_ci.cmake @@ -5,10 +5,10 @@ endif () # Set up the source and build paths. set(CTEST_SOURCE_DIRECTORY "$ENV{CI_PROJECT_DIR}") +set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build") if (NOT "$ENV{CTEST_SOURCE_SUBDIRECTORY}" STREQUAL "") string(APPEND CTEST_SOURCE_DIRECTORY "/$ENV{CTEST_SOURCE_SUBDIRECTORY}") endif () -set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build") if ("$ENV{CMAKE_CONFIGURATION}" STREQUAL "") message(FATAL_ERROR diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index dfd94f5..1ec5413 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -54,6 +54,13 @@ CTEST_SOURCE_SUBDIRECTORY: "Utilities/Sphinx" CMake_SKIP_INSTALL: 1 +.fedora31_sphinx_package: + extends: .fedora31 + + variables: + CMAKE_CONFIGURATION: fedora31_sphinx_package + CTEST_SOURCE_SUBDIRECTORY: "Utilities/Sphinx" + #### Build and test .fedora31_ninja: diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml index 9d123ec..de1093d 100644 --- a/.gitlab/os-macos.yml +++ b/.gitlab/os-macos.yml @@ -37,6 +37,14 @@ CTEST_NO_WARNINGS_ALLOWED: 1 CMAKE_GENERATOR: "Unix Makefiles" +.macos_package: + extends: .macos_build + + variables: + CMAKE_CONFIGURATION: macos_package + CTEST_NO_WARNINGS_ALLOWED: 1 + CMake_SKIP_INSTALL: 1 + ### External testing .macos_xcode: @@ -56,6 +64,15 @@ - xcode-11.5 - nonconcurrent +.macos_builder_tags_package: + tags: + - cmake # Since this is a bare runner, pin to a project. + - macos + - shell + - xcode-11.5 + - nonconcurrent + - finder + .macos_builder_ext_tags: tags: - cmake # Since this is a bare runner, pin to a project. @@ -91,6 +108,24 @@ interruptible: true +.cmake_build_macos_package: + stage: package + + script: + - *before_script_macos + - .gitlab/ci/sccache.sh + # Allow the server to already be running. + - "sccache --start-server || :" + - sccache --show-stats + - ctest -VV -S .gitlab/ci/ctest_configure.cmake + - ctest -VV -S .gitlab/ci/ctest_build.cmake + - sccache --show-stats + - cd build + - cpack -G TGZ + - cpack -G DragNDrop + + interruptible: true + .cmake_test_macos: stage: test diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml index 3bb8ae4..2bc4496 100644 --- a/.gitlab/rules.yml +++ b/.gitlab/rules.yml @@ -16,3 +16,9 @@ - if: '$CI_PROJECT_PATH == "cmake/cmake"' when: on_success - when: never + +.run_only_for_package: + rules: + - if: '$CMAKE_PACKAGE == "true"' + when: on_success + - when: never diff --git a/.gitlab/upload.yml b/.gitlab/upload.yml new file mode 100644 index 0000000..924e7de --- /dev/null +++ b/.gitlab/upload.yml @@ -0,0 +1,18 @@ +# Steps for uploading artifacts + +.rsync_upload: + image: "fedora:32" + stage: upload + tags: + - docker + - linux + - build + environment: + name: rsync-upload + + script: + - ls build/ + - dnf install -y --setopt=install_weak_deps=False rsync openssh-clients + - chmod 400 $RSYNC_BINARY_KEY + - ssh-keygen -y -f $RSYNC_BINARY_KEY > $RSYNC_BINARY_KEY.pub + - rsync -tv --recursive -e "ssh -i $RSYNC_BINARY_KEY -o StrictHostKeyChecking=no" build/ kitware@public.kitware.com:$RSYNC_DESTINATION/ diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index f3df631..b7dfabc 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -14,7 +14,7 @@ Normal Libraries add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] - [source1] [source2 ...]) + [<source>...]) Adds a library target called ``<name>`` to be built from the source files listed in the command invocation. (The source files can be omitted here @@ -69,7 +69,7 @@ Object Libraries .. code-block:: cmake - add_library(<name> OBJECT <src>...) + add_library(<name> OBJECT [<source>...]) Creates an :ref:`Object Library <Object Libraries>`. An object library compiles source files but does not archive or link their object files into a diff --git a/Help/guide/importing-exporting/Downstream/CMakeLists.txt b/Help/guide/importing-exporting/Downstream/CMakeLists.txt new file mode 100644 index 0000000..381c875 --- /dev/null +++ b/Help/guide/importing-exporting/Downstream/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.15) +project(Downstream) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# find MathFunctions +find_package(MathFunctions 3.4.1 EXACT) + +# create executable +add_executable(myexe main.cc) + +# use MathFunctions library +target_link_libraries(myexe PRIVATE MathFunctions::MathFunctions) diff --git a/Help/guide/importing-exporting/Downstream/main.cc b/Help/guide/importing-exporting/Downstream/main.cc new file mode 100644 index 0000000..8574373 --- /dev/null +++ b/Help/guide/importing-exporting/Downstream/main.cc @@ -0,0 +1,23 @@ +// A simple program that outputs the square root of a number +#include <iostream> +#include <string> + +#include "MathFunctions.h" + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + // convert input to double + const double inputValue = std::stod(argv[1]); + + // calculate square root + const double sqrt = MathFunctions::sqrt(inputValue); + std::cout << "The square root of " << inputValue << " is " << sqrt + << std::endl; + + return 0; +} diff --git a/Help/guide/importing-exporting/DownstreamComponents/CMakeLists.txt b/Help/guide/importing-exporting/DownstreamComponents/CMakeLists.txt new file mode 100644 index 0000000..88b46c8 --- /dev/null +++ b/Help/guide/importing-exporting/DownstreamComponents/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.15) +project(DownstreamComponents) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# find MathFunctions +find_package(MathFunctions 3.4 COMPONENTS Addition SquareRoot) + +# create executable +add_executable(myexe main.cc) + +# use MathFunctions library +target_link_libraries(myexe PRIVATE MathFunctions::Addition MathFunctions::SquareRoot) + +# Workaround for GCC on AIX to avoid -isystem, not needed in general. +set_property(TARGET myexe PROPERTY NO_SYSTEM_FROM_IMPORTED 1) diff --git a/Help/guide/importing-exporting/DownstreamComponents/main.cc b/Help/guide/importing-exporting/DownstreamComponents/main.cc new file mode 100644 index 0000000..f5e8fa6 --- /dev/null +++ b/Help/guide/importing-exporting/DownstreamComponents/main.cc @@ -0,0 +1,28 @@ +// A simple program that outputs the square root of a number +#include <iostream> +#include <string> + +#include "Addition.h" +#include "SquareRoot.h" + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + // convert input to double + const double inputValue = std::stod(argv[1]); + + // calculate square root + const double sqrt = MathFunctions::sqrt(inputValue); + std::cout << "The square root of " << inputValue << " is " << sqrt + << std::endl; + + // calculate sum + const double sum = MathFunctions::add(inputValue, inputValue); + std::cout << inputValue << " + " << inputValue << " = " << sum << std::endl; + + return 0; +} diff --git a/Help/guide/importing-exporting/Importing/CMakeLists.txt b/Help/guide/importing-exporting/Importing/CMakeLists.txt new file mode 100644 index 0000000..fe7d704 --- /dev/null +++ b/Help/guide/importing-exporting/Importing/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.15) +project(Importing) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Add executable +add_executable(myexe IMPORTED) + +# Set imported location +set_property(TARGET myexe PROPERTY + IMPORTED_LOCATION "../InstallMyExe/bin/myexe") + +# Add custom command to create source file +add_custom_command(OUTPUT main.cc COMMAND myexe) + +# Use source file +add_executable(mynewexe main.cc) diff --git a/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt new file mode 100644 index 0000000..13c82dd --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.15) +project(MathFunctions) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# create library +add_library(MathFunctions STATIC MathFunctions.cxx) + +# add include directories +target_include_directories(MathFunctions + PUBLIC + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" + "$<INSTALL_INTERFACE:include>" +) + +# install the target and create export-set +install(TARGETS MathFunctions + EXPORT MathFunctionsTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +# install header file +install(FILES MathFunctions.h DESTINATION include) + +# generate and install export file +install(EXPORT MathFunctionsTargets + FILE MathFunctionsTargets.cmake + NAMESPACE MathFunctions:: + DESTINATION lib/cmake +) + +# include CMakePackageConfigHelpers macro +include(CMakePackageConfigHelpers) + +# set version +set(version 3.4.1) + +set_property(TARGET MathFunctions PROPERTY VERSION ${version}) +set_property(TARGET MathFunctions PROPERTY SOVERSION 3) +set_property(TARGET MathFunctions PROPERTY + INTERFACE_MathFunctions_MAJOR_VERSION 3) +set_property(TARGET MathFunctions APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING MathFunctions_MAJOR_VERSION +) + +# generate the version file for the config file +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" + VERSION "${version}" + COMPATIBILITY AnyNewerVersion +) + +# create config file +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" + INSTALL_DESTINATION lib/cmake +) + +# install config files +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" + DESTINATION lib/cmake +) + +# generate the export targets for the build tree +export(EXPORT MathFunctionsTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/MathFunctionsTargets.cmake" + NAMESPACE MathFunctions:: +) diff --git a/Help/guide/importing-exporting/MathFunctions/Config.cmake.in b/Help/guide/importing-exporting/MathFunctions/Config.cmake.in new file mode 100644 index 0000000..eba1ff6 --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctions/Config.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/MathFunctionsTargets.cmake") + +check_required_components(MathFunctions) diff --git a/Help/guide/importing-exporting/MathFunctions/MathFunctions.cxx b/Help/guide/importing-exporting/MathFunctions/MathFunctions.cxx new file mode 100644 index 0000000..e75fe74 --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctions/MathFunctions.cxx @@ -0,0 +1,10 @@ +#include "MathFunctions.h" + +#include <cmath> + +namespace MathFunctions { +double sqrt(double x) +{ + return std::sqrt(x); +} +} diff --git a/Help/guide/importing-exporting/MathFunctions/MathFunctions.h b/Help/guide/importing-exporting/MathFunctions/MathFunctions.h new file mode 100644 index 0000000..b38596d --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctions/MathFunctions.h @@ -0,0 +1,5 @@ +#pragma once + +namespace MathFunctions { +double sqrt(double x); +} diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/Addition.cxx b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/Addition.cxx new file mode 100644 index 0000000..0a6b98b --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/Addition.cxx @@ -0,0 +1,8 @@ +#include "Addition.h" + +namespace MathFunctions { +double add(double x, double y) +{ + return x + y; +} +} diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/Addition.h b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/Addition.h new file mode 100644 index 0000000..b061d5e --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/Addition.h @@ -0,0 +1,5 @@ +#pragma once + +namespace MathFunctions { +double add(double x, double y); +} diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt new file mode 100644 index 0000000..e3cf711 --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt @@ -0,0 +1,30 @@ +# create library +add_library(Addition STATIC Addition.cxx) + +add_library(MathFunctions::Addition ALIAS Addition) + +# add include directories +target_include_directories(Addition + PUBLIC + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" + $<INSTALL_INTERFACE:include> +) + +# install the target and create export-set +install(TARGETS Addition + EXPORT AdditionTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +# install header file +install(FILES Addition.h DESTINATION include) + +# generate and install export file +install(EXPORT AdditionTargets + FILE MathFunctionsAdditionTargets.cmake + NAMESPACE MathFunctions:: + DESTINATION lib/cmake +) diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt new file mode 100644 index 0000000..4e3496d --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.15) +project(MathFunctionsComponents) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +add_subdirectory(Addition) +add_subdirectory(SquareRoot) + +# include CMakePackageConfigHelpers macro +include(CMakePackageConfigHelpers) + +# set version +set(version 3.4.1) + +# generate the version file for the config file +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" + VERSION "${version}" + COMPATIBILITY AnyNewerVersion +) + +# create config file +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" + INSTALL_DESTINATION lib/cmake + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) + +# install config files +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" + DESTINATION lib/cmake +) diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in b/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in new file mode 100644 index 0000000..09f6c35 --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in @@ -0,0 +1,11 @@ +@PACKAGE_INIT@ + +set(_supported_components Addition SquareRoot) + +foreach(_comp ${MathFunctions_FIND_COMPONENTS}) + if (NOT _comp IN_LIST _supported_components) + set(MathFunctions_FOUND False) + set(MathFunctions_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}") + endif() + include("${CMAKE_CURRENT_LIST_DIR}/MathFunctions${_comp}Targets.cmake") +endforeach() diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/MathFunctions.cxx b/Help/guide/importing-exporting/MathFunctionsComponents/MathFunctions.cxx new file mode 100644 index 0000000..e75fe74 --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/MathFunctions.cxx @@ -0,0 +1,10 @@ +#include "MathFunctions.h" + +#include <cmath> + +namespace MathFunctions { +double sqrt(double x) +{ + return std::sqrt(x); +} +} diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/MathFunctions.h b/Help/guide/importing-exporting/MathFunctionsComponents/MathFunctions.h new file mode 100644 index 0000000..b38596d --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/MathFunctions.h @@ -0,0 +1,5 @@ +#pragma once + +namespace MathFunctions { +double sqrt(double x); +} diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt new file mode 100644 index 0000000..ffa1e3d --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt @@ -0,0 +1,30 @@ +# create library +add_library(SquareRoot STATIC SquareRoot.cxx) + +add_library(MathFunctions::SquareRoot ALIAS SquareRoot) + +# add include directories +target_include_directories(SquareRoot + PUBLIC + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" + "$<INSTALL_INTERFACE:include>" +) + +# install the target and create export-set +install(TARGETS SquareRoot + EXPORT SquareRootTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +# install header file +install(FILES SquareRoot.h DESTINATION include) + +# generate and install export file +install(EXPORT SquareRootTargets + FILE MathFunctionsSquareRootTargets.cmake + NAMESPACE MathFunctions:: + DESTINATION lib/cmake +) diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/SquareRoot.cxx b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/SquareRoot.cxx new file mode 100644 index 0000000..29c0c4a --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/SquareRoot.cxx @@ -0,0 +1,10 @@ +#include "SquareRoot.h" + +#include <cmath> + +namespace MathFunctions { +double sqrt(double x) +{ + return std::sqrt(x); +} +} diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/SquareRoot.h b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/SquareRoot.h new file mode 100644 index 0000000..b38596d --- /dev/null +++ b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/SquareRoot.h @@ -0,0 +1,5 @@ +#pragma once + +namespace MathFunctions { +double sqrt(double x); +} diff --git a/Help/guide/importing-exporting/MyExe/CMakeLists.txt b/Help/guide/importing-exporting/MyExe/CMakeLists.txt new file mode 100644 index 0000000..34e37a4 --- /dev/null +++ b/Help/guide/importing-exporting/MyExe/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.15) +project(MyExe) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Add executable +add_executable(myexe main.cxx) + +# install executable +install(TARGETS myexe) diff --git a/Help/guide/importing-exporting/MyExe/main.cxx b/Help/guide/importing-exporting/MyExe/main.cxx new file mode 100644 index 0000000..35ab2a7 --- /dev/null +++ b/Help/guide/importing-exporting/MyExe/main.cxx @@ -0,0 +1,16 @@ +// A simple program that outputs a file with the given name +#include <fstream> +#include <iostream> + +int main(int argc, char* argv[]) +{ + std::ofstream outfile("main.cc"); + outfile << "int main(int argc, char* argv[])" << std::endl; + outfile << "{" << std::endl; + outfile << " // Your code here" << std::endl; + outfile << " return 0;" << std::endl; + outfile << "}" << std::endl; + outfile.close(); + + return 0; +} diff --git a/Help/guide/importing-exporting/index.rst b/Help/guide/importing-exporting/index.rst new file mode 100644 index 0000000..b0cfb71 --- /dev/null +++ b/Help/guide/importing-exporting/index.rst @@ -0,0 +1,765 @@ +Importing and Exporting Targets +******************************* + +.. only:: html + + .. contents:: + +In this guide, we will present the concept of :prop_tgt:`IMPORTED` targets +and demonstrate how to import existing executable or library files from disk +into a CMake project. We will then show how CMake supports exporting targets +from one CMake-based project and importing them into another. Finally, we +will demonstrate how to package a project with a configuration file to allow +for easy integration into other CMake projects. This guide and the complete +example source code can be found in the ``Help/guide/importing-exporting`` +directory of the CMake source code tree. + + +Importing Targets +================= + +:prop_tgt:`IMPORTED` targets are used to convert files outside of a CMake +project into logical targets inside of the project. :prop_tgt:`IMPORTED` +targets are created using the ``IMPORTED`` option of the +:command:`add_executable` and :command:`add_library` commands. No build +files are generated for :prop_tgt:`IMPORTED` targets. Once imported, +:prop_tgt:`IMPORTED` targets may be referenced like any other target within +the project and provide a convenient, flexible reference to outside +executables and libraries. + +By default, the :prop_tgt:`IMPORTED` target name has scope in the directory in +which it is created and below. We can use the ``GLOBAL`` option to extended +visibility so that the target is accessible globally in the build system. + +Details about the :prop_tgt:`IMPORTED` target are specified by setting +properties whose names begin in ``IMPORTED_`` and ``INTERFACE_``. For example, +:prop_tgt:`IMPORTED_LOCATION` contains the full path to the target on +disk. + +Importing Executables +--------------------- + +To start, we will walk through a simple example that creates an +:prop_tgt:`IMPORTED` executable target and then references it from the +:command:`add_custom_command` command. + +We'll need to do some setup to get started. We want to create an executable +that when run creates a basic ``main.cc`` file in the current directory. The +details of this project are not important. Navigate to +``Help/guide/importing-exporting/MyExe``, create a build directory, run +:manual:`cmake <cmake(1)>` and build and install the project. + +.. code-block:: console + + $ cd Help/guide/importing-exporting/MyExe + $ mkdir build + $ cd build + $ cmake .. + $ cmake --build . + $ cmake --install . --prefix <install location> + $ <install location>/myexe + $ ls + [...] main.cc [...] + +Now we can import this executable into another CMake project. The source code +for this section is available in ``Help/guide/importing-exporting/Importing``. +In the CMakeLists file, use the :command:`add_executable` command to create a +new target called ``myexe``. Use the ``IMPORTED`` option to tell CMake that +this target references an executable file located outside of the project. No +rules will be generated to build it and the :prop_tgt:`IMPORTED` target +property will be set to ``true``. + +.. literalinclude:: Importing/CMakeLists.txt + :language: cmake + :start-after: # Add executable + :end-before: # Set imported location + +Next, set the :prop_tgt:`IMPORTED_LOCATION` property of the target using +the :command:`set_property` command. This will tell CMake the location of the +target on disk. The location may need to be adjusted to the +``<install location>`` specified in the previous step. + +.. literalinclude:: Importing/CMakeLists.txt + :language: cmake + :start-after: # Set imported location + :end-before: # Add custom command + +We can now reference this :prop_tgt:`IMPORTED` target just like any target +built within the project. In this instance, let's imagine that we want to use +the generated source file in our project. Use the :prop_tgt:`IMPORTED` +target in the :command:`add_custom_command` command: + +.. literalinclude:: Importing/CMakeLists.txt + :language: cmake + :start-after: # Add custom command + :end-before: # Use source file + +As ``COMMAND`` specifies an executable target name, it will automatically be +replaced by the location of the executable given by the +:prop_tgt:`IMPORTED_LOCATION` property above. + +Finally, use the output from :command:`add_custom_command`: + +.. literalinclude:: Importing/CMakeLists.txt + :language: cmake + :start-after: # Use source file + +Importing Libraries +------------------- + +In a similar manner, libraries from other projects may be accessed through +:prop_tgt:`IMPORTED` targets. + +Note: The full source code for the examples in this section is not provided +and is left as an exercise for the reader. + +In the CMakeLists file, add an :prop_tgt:`IMPORTED` library and specify its +location on disk: + +.. code-block:: cmake + + add_library(foo STATIC IMPORTED) + set_property(TARGET foo PROPERTY + IMPORTED_LOCATION "/path/to/libfoo.a") + +Then use the :prop_tgt:`IMPORTED` library inside of our project: + +.. code-block:: cmake + + add_executable(myexe src1.c src2.c) + target_link_libraries(myexe PRIVATE foo) + + +On Windows, a .dll and its .lib import library may be imported together: + +.. code-block:: cmake + + add_library(bar SHARED IMPORTED) + set_property(TARGET bar PROPERTY + IMPORTED_LOCATION "c:/path/to/bar.dll") + set_property(TARGET bar PROPERTY + IMPORTED_IMPLIB "c:/path/to/bar.lib") + add_executable(myexe src1.c src2.c) + target_link_libraries(myexe PRIVATE bar) + +A library with multiple configurations may be imported with a single target: + +.. code-block:: cmake + + find_library(math_REL NAMES m) + find_library(math_DBG NAMES md) + add_library(math STATIC IMPORTED GLOBAL) + set_target_properties(math PROPERTIES + IMPORTED_LOCATION "${math_REL}" + IMPORTED_LOCATION_DEBUG "${math_DBG}" + IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" + ) + add_executable(myexe src1.c src2.c) + target_link_libraries(myexe PRIVATE math) + +The generated build system will link ``myexe`` to ``m.lib`` when built in the +release configuration, and ``md.lib`` when built in the debug configuration. + +Exporting Targets +================= + +While :prop_tgt:`IMPORTED` targets on their own are useful, they still +require that the project that imports them knows the locations of the target +files on disk. The real power of :prop_tgt:`IMPORTED` targets is when the +project providing the target files also provides a CMake file to help import +them. A project can be setup to produce the necessary information so that it +can easily be used by other CMake projects be it from a build directory, a +local install or when packaged. + +In the remaining sections, we will walk through a set of example projects +step-by-step. The first project will create and install a library and +corresponding CMake configuration and package files. The second project will +use the generated package. + +Let's start by looking at the ``MathFunctions`` project in the +``Help/guide/importing-exporting/MathFunctions`` directory. Here we have a +header file ``MathFunctions.h`` that declares a ``sqrt`` function: + +.. literalinclude:: MathFunctions/MathFunctions.h + :language: c++ + +And a corresponding source file ``MathFunctions.cxx``: + +.. literalinclude:: MathFunctions/MathFunctions.cxx + :language: c++ + +Don't worry too much about the specifics of the C++ files, they are just meant +to be a simple example that will compile and run on many build systems. + +Now we can create a ``CMakeLists.txt`` file for the ``MathFunctions`` +project. Start by specifying the :command:`cmake_minimum_required` version and +:command:`project` name: + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :end-before: # create library + +Create a library called ``MathFunctions`` with the :command:`add_library` +command: + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # create library + :end-before: # add include directories + +And then use the :command:`target_include_directories` command to specify the +include directories for the target: + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # add include directories + :end-before: # install the target and create export-set + +We need to tell CMake that we want to use different include directories +depending on if we're building the library or using it from an installed +location. If we don't do this, when CMake creates the export information it +will export a path that is specific to the current build directory +and will not be valid for other projects. We can use +:manual:`generator expressions <cmake-generator-expressions(7)>` to specify +that if we're building the library include the current source directory. +Otherwise, when installed, include the ``include`` directory. See the `Creating +Relocatable Packages`_ section for more details. + +The :command:`install(TARGETS)` and :command:`install(EXPORT)` commands +work together to install both targets (a library in our case) and a CMake +file designed to make it easy to import the targets into another CMake project. + +First, in the :command:`install(TARGETS)` command we will specify the target, +the ``EXPORT`` name and the destinations that tell CMake where to install the +targets. + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # install the target and create export-set + :end-before: # install header file + +Here, the ``EXPORT`` option tells CMake to create an export called +``MathFunctionsTargets``. The generated :prop_tgt:`IMPORTED` targets have +appropriate properties set to define their +:ref:`usage requirements <Target Usage Requirements>`, such as +:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`, +:prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` and other relevant built-in +``INTERFACE_`` properties. The ``INTERFACE`` variant of user-defined +properties listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other +:ref:`Compatible Interface Properties` are also propagated to the +generated :prop_tgt:`IMPORTED` targets. For example, in this case, the +:prop_tgt:`IMPORTED` target will have its +:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` property populated with +the directory specified by the ``INCLUDES DESTINATION`` property. As a +relative path was given, it is treated as relative to the +:variable:`CMAKE_INSTALL_PREFIX`. + +Note, we have *not* asked CMake to install the export yet. + +We don't want to forget to install the ``MathFunctions.h`` header file with the +:command:`install(FILES)` command. The header file should be installed to the +``include`` directory, as specified by the +:command:`target_include_directories` command above. + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # install header file + :end-before: # generate and install export file + +Now that the ``MathFunctions`` library and header file are installed, we also +need to explicitly install the ``MathFunctionsTargets`` export details. Use +the :command:`install(EXPORT)` command to export the targets in +``MathFunctionsTargets``, as defined by the :command:`install(TARGETS)` +command. + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # generate and install export file + :end-before: # include CMakePackageConfigHelpers macro + +This command generates the ``MathFunctionsTargets.cmake`` file and arranges +to install it to ``lib/cmake``. The file contains code suitable for +use by downstreams to import all targets listed in the install command from +the installation tree. + +The ``NAMESPACE`` option will prepend ``MathFunctions::`` to the target names +as they are written to the export file. This convention of double-colons +gives CMake a hint that the name is an :prop_tgt:`IMPORTED` target when it +is used by downstream projects. This way, CMake can issue a diagnostic +message if the package providing it was not found. + +The generated export file contains code that creates an :prop_tgt:`IMPORTED` library. + +.. code-block:: cmake + + # Create imported target MathFunctions::MathFunctions + add_library(MathFunctions::MathFunctions STATIC IMPORTED) + + set_target_properties(MathFunctions::MathFunctions PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" + ) + +This code is very similar to the example we created by hand in the +`Importing Libraries`_ section. Note that ``${_IMPORT_PREFIX}`` is computed +relative to the file location. + +An outside project may load this file with the :command:`include` command and +reference the ``MathFunctions`` library from the installation tree as if it +were built in its own tree. For example: + +.. code-block:: cmake + :linenos: + + include(${INSTALL_PREFIX}/lib/cmake/MathFunctionTargets.cmake) + add_executable(myexe src1.c src2.c ) + target_link_libraries(myexe PRIVATE MathFunctions::MathFunctions) + +Line 1 loads the target CMake file. Although we only exported a single +target, this file may import any number of targets. Their locations are +computed relative to the file location so that the install tree may be +easily moved. Line 3 references the imported ``MathFunctions`` library. The +resulting build system will link to the library from its installed location. + +Executables may also be exported and imported using the same process. + +Any number of target installations may be associated with the same +export name. Export names are considered global so any directory may +contribute a target installation. The :command:`install(EXPORT)` command only +needs to be called once to install a file that references all targets. Below +is an example of how multiple exports may be combined into a single +export file, even if they are in different subdirectories of the project. + +.. code-block:: cmake + + # A/CMakeLists.txt + add_executable(myexe src1.c) + install(TARGETS myexe DESTINATION lib/myproj + EXPORT myproj-targets) + + # B/CMakeLists.txt + add_library(foo STATIC foo1.c) + install(TARGETS foo DESTINATION lib EXPORTS myproj-targets) + + # Top CMakeLists.txt + add_subdirectory (A) + add_subdirectory (B) + install(EXPORT myproj-targets DESTINATION lib/myproj) + +Creating Packages +----------------- + +At this point, the ``MathFunctions`` project is exporting the target +information required to be used by other projects. We can make this project +even easier for other projects to use by generating a configuration file so +that the CMake :command:`find_package` command can find our project. + +To start, we will need to make a few additions to the ``CMakeLists.txt`` +file. First, include the :module:`CMakePackageConfigHelpers` module to get +access to some helper functions for creating config files. + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # include CMakePackageConfigHelpers macro + :end-before: # set version + +Then we will create a package configuration file and a package version file. + +Creating a Package Configuration File +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Use the :command:`configure_package_config_file` command provided by the +:module:`CMakePackageConfigHelpers` to generate the package configuration +file. Note that this command should be used instead of the plain +:command:`configure_file` command. It helps to ensure that the resulting +package is relocatable by avoiding hardcoded paths in the installed +configuration file. The path given to ``INSTALL_DESTINATION`` must be the +destination where the ``MathFunctionsConfig.cmake`` file will be installed. +We will examine the contents of the package configuration file in the next +section. + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # create config file + :end-before: # install config files + +Install the generated configuration files with the :command:`INSTALL(files)` +command. Both ``MathFunctionsConfigVersion.cmake`` and +``MathFunctionsConfig.cmake`` are installed to the same location, completing +the package. + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # install config files + :end-before: # generate the export targets for the build tree + +Now we need to create the package configuration file itself. In this case, the +``Config.cmake.in`` file is very simple but sufficient to allow downstreams +to use the :prop_tgt:`IMPORTED` targets. + +.. literalinclude:: MathFunctions/Config.cmake.in + +The first line of the file contains only the string ``@PACKAGE_INIT@``. This +expands when the file is configured and allows the use of relocatable paths +prefixed with ``PACKAGE_``. It also provides the ``set_and_check()`` and +``check_required_components()`` macros. + +The ``check_required_components`` helper macro ensures that all requested, +non-optional components have been found by checking the +``<Package>_<Component>_FOUND`` variables for all required components. This +macro should be called at the end of the package configuration file even if the +package does not have any components. This way, CMake can make sure that the +downstream project hasn't specified any non-existent components. If +``check_required_components`` fails, the ``<Package>_FOUND`` variable is set to +FALSE, and the package is considered to be not found. + +The ``set_and_check()`` macro should be used in configuration files instead +of the normal ``set()`` command for setting directories and file locations. +If a referenced file or directory does not exist, the macro will fail. + +If any macros should be provided by the ``MathFunctions`` package, they should +be in a separate file which is installed to the same location as the +``MathFunctionsConfig.cmake`` file, and included from there. + +**All required dependencies of a package must also be found in the package +configuration file.** Let's imagine that we require the ``Stats`` library in +our project. In the CMakeLists file, we would add: + +.. code-block:: cmake + + find_package(Stats 2.6.4 REQUIRED) + target_link_libraries(MathFunctions PUBLIC Stats::Types) + +As the ``Stats::Types`` target is a ``PUBLIC`` dependency of ``MathFunctions``, +downstreams must also find the ``Stats`` package and link to the +``Stats::Types`` library. The ``Stats`` package should be found in the +configuration file to ensure this. + +.. code-block:: cmake + + include(CMakeFindDependencyMacro) + find_dependency(Stats 2.6.4) + +The ``find_dependency`` macro from the :module:`CMakeFindDependencyMacro` +module helps by propagating whether the package is ``REQUIRED``, or +``QUIET``, etc. The ``find_dependency`` macro also sets +``MathFunctions_FOUND`` to ``False`` if the dependency is not found, along +with a diagnostic that the ``MathFunctions`` package cannot be used without +the ``Stats`` package. + +**Exercise:** Add a required library to the ``MathFunctions`` project. + +Creating a Package Version File +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The :module:`CMakePackageConfigHelpers` module provides the +:command:`write_basic_package_version_file` command for creating a simple +package version file. This file is read by CMake when :command:`find_package` +is called to determine the compatibility with the requested version, and to set +some version-specific variables such as ``<PackageName>_VERSION``, +``<PackageName>_VERSION_MAJOR``, ``<PackageName>_VERSION_MINOR``, etc. See +:manual:`cmake-packages <cmake-packages(7)>` documentation for more details. + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # set version + :end-before: # create config file + +In our example, ``MathFunctions_MAJOR_VERSION`` is defined as a +:prop_tgt:`COMPATIBLE_INTERFACE_STRING` which means that it must be +compatible among the dependencies of any depender. By setting this +custom defined user property in this version and in the next version of +``MathFunctions``, :manual:`cmake <cmake(1)>` will issue a diagnostic if +there is an attempt to use version 3 together with version 4. Packages can +choose to employ such a pattern if different major versions of the package +are designed to be incompatible. + + +Exporting Targets from the Build Tree +------------------------------------- + +Typically, projects are built and installed before being used by an outside +project. However, in some cases, it is desirable to export targets directly +from a build tree. The targets may then be used by an outside project that +references the build tree with no installation involved. The :command:`export` +command is used to generate a file exporting targets from a project build tree. + +If we want our example project to also be used from a build directory we only +have to add the following to ``CMakeLists.txt``: + +.. literalinclude:: MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # generate the export targets for the build tree + +Here we use the :command:`export` command to generate the export targets for +the build tree. In this case, we'll create a file called +``MathFunctionsTargets.cmake`` in the ``cmake`` subdirectory of the build +directory. The generated file contains the required code to import the target +and may be loaded by an outside project that is aware of the project build +tree. This file is specific to the build-tree, and **is not relocatable**. + +It is possible to create a suitable package configuration file and package +version file to define a package for the build tree which may be used without +installation. Consumers of the build tree can simply ensure that the +:variable:`CMAKE_PREFIX_PATH` contains the build directory, or set the +``MathFunctions_DIR`` to ``<build_dir>/MathFunctions`` in the cache. + +An example application of this feature is for building an executable on a host +platform when cross-compiling. The project containing the executable may be +built on the host platform and then the project that is being cross-compiled +for another platform may load it. + +Building and Installing a Package +--------------------------------- + +At this point, we have generated a relocatable CMake configuration for our +project that can be used after the project has been installed. Let's try to +build the ``MathFunctions`` project: + +.. code-block:: console + + mkdir MathFunctions_build + cd MathFunctions_build + cmake ../MathFunctions + cmake --build . + +In the build directory, notice that the file ``MathFunctionsTargets.cmake`` +has been created in the ``cmake`` subdirectory. + +Now install the project: + +.. code-block:: console + + $ cmake --install . --prefix "/home/myuser/installdir" + +Creating Relocatable Packages +============================= + +Packages created by :command:`install(EXPORT)` are designed to be relocatable, +using paths relative to the location of the package itself. They must not +reference absolute paths of files on the machine where the package is built +that will not exist on the machines where the package may be installed. + +When defining the interface of a target for ``EXPORT``, keep in mind that the +include directories should be specified as relative paths to the +:variable:`CMAKE_INSTALL_PREFIX` but should not explicitly include the +:variable:`CMAKE_INSTALL_PREFIX`: + +.. code-block:: cmake + + target_include_directories(tgt INTERFACE + # Wrong, not relocatable: + $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/TgtName> + ) + + target_include_directories(tgt INTERFACE + # Ok, relocatable: + $<INSTALL_INTERFACE:include/TgtName> + ) + +The ``$<INSTALL_PREFIX>`` +:manual:`generator expression <cmake-generator-expressions(7)>` may be used as +a placeholder for the install prefix without resulting in a non-relocatable +package. This is necessary if complex generator expressions are used: + +.. code-block:: cmake + + target_include_directories(tgt INTERFACE + # Ok, relocatable: + $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/TgtName> + ) + +This also applies to paths referencing external dependencies. +It is not advisable to populate any properties which may contain +paths, such as :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` or +:prop_tgt:`INTERFACE_LINK_LIBRARIES`, with paths relevant to dependencies. +For example, this code may not work well for a relocatable package: + +.. code-block:: cmake + + target_link_libraries(MathFunctions INTERFACE + ${Foo_LIBRARIES} ${Bar_LIBRARIES} + ) + target_include_directories(MathFunctions INTERFACE + "$<INSTALL_INTERFACE:${Foo_INCLUDE_DIRS};${Bar_INCLUDE_DIRS}>" + ) + +The referenced variables may contain the absolute paths to libraries +and include directories **as found on the machine the package was made on**. +This would create a package with hard-coded paths to dependencies not +suitable for relocation. + +Ideally such dependencies should be used through their own +:ref:`IMPORTED targets <Imported Targets>` that have their own +:prop_tgt:`IMPORTED_LOCATION` and usage requirement properties +such as :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` populated +appropriately. Those imported targets may then be used with +the :command:`target_link_libraries` command for ``MathFunctions``: + +.. code-block:: cmake + + target_link_libraries(MathFunctions INTERFACE Foo::Foo Bar::Bar) + +With this approach the package references its external dependencies +only through the names of :ref:`IMPORTED targets <Imported Targets>`. +When a consumer uses the installed package, the consumer will run the +appropriate :command:`find_package` commands (via the ``find_dependency`` +macro described above) to find the dependencies and populate the +imported targets with appropriate paths on their own machine. + +Using the Package Configuration File +==================================== + +Now we're ready to create a project to use the installed ``MathFunctions`` +library. In this section we will be using source code from +``Help\guide\importing-exporting\Downstream``. In this directory, there is a +source file called ``main.cc`` that uses the ``MathFunctions`` library to +calculate the square root of a given number and then prints the results: + +.. literalinclude:: Downstream/main.cc + :language: c++ + +As before, we'll start with the :command:`cmake_minimum_required` and +:command:`project` commands in the ``CMakeLists.txt`` file. For this project, +we'll also specify the C++ standard. + +.. literalinclude:: Downstream/CMakeLists.txt + :language: cmake + :end-before: # find MathFunctions + +We can use the :command:`find_package` command: + +.. literalinclude:: Downstream/CMakeLists.txt + :language: cmake + :start-after: # find MathFunctions + :end-before: # create executable + +Create an exectuable: + +.. literalinclude:: Downstream/CMakeLists.txt + :language: cmake + :start-after: # create executable + :end-before: # use MathFunctions library + +And link to the ``MathFunctions`` library: + +.. literalinclude:: Downstream/CMakeLists.txt + :language: cmake + :start-after: # use MathFunctions library + +That's it! Now let's try to build the ``Downstream`` project. + +.. code-block:: console + + mkdir Downstream_build + cd Downstream_build + cmake ../Downstream + cmake --build . + +A warning may have appeared during CMake configuration: + +.. code-block:: console + + CMake Warning at CMakeLists.txt:4 (find_package): + By not providing "FindMathFunctions.cmake" in CMAKE_MODULE_PATH this + project has asked CMake to find a package configuration file provided by + "MathFunctions", but CMake did not find one. + + Could not find a package configuration file provided by "MathFunctions" + with any of the following names: + + MathFunctionsConfig.cmake + mathfunctions-config.cmake + + Add the installation prefix of "MathFunctions" to CMAKE_PREFIX_PATH or set + "MathFunctions_DIR" to a directory containing one of the above files. If + "MathFunctions" provides a separate development package or SDK, be sure it + has been installed. + +Set the ``CMAKE_PREFIX_PATH`` to where MathFunctions was installed previously +and try again. Ensure that the newly created executable runs as expected. + +Adding Components +================= + +Let's edit the ``MathFunctions`` project to use components. The source code for +this section can be found in +``Help\guide\importing-exporting\MathFunctionsComponents``. The CMakeLists file +for this project adds two subdirectories: ``Addition`` and ``SquareRoot``. + +.. literalinclude:: MathFunctionsComponents/CMakeLists.txt + :language: cmake + :end-before: # include CMakePackageConfigHelpers macro + +Generate and install the package configuration and package version files: + +.. literalinclude:: MathFunctionsComponents/CMakeLists.txt + :language: cmake + :start-after: # include CMakePackageConfigHelpers macro + +If ``COMPONENTS`` are specified when the downstream uses +:command:`find_package`, they are listed in the +``<PackageName>_FIND_COMPONENTS`` variable. We can use this variable to verify +that all necessary component targets are included in ``Config.cmake.in``. At +the same time, this function will act as a custom ``check_required_components`` +macro to ensure that the downstream only attempts to use supported components. + +.. literalinclude:: MathFunctionsComponents/Config.cmake.in + +Here, the ``MathFunctions_NOT_FOUND_MESSAGE`` is set to a diagnosis that the +package could not be found because an invalid component was specified. This +message variable can be set for any case where the ``_FOUND`` variable is set +to ``False``, and will be displayed to the user. + +The ``Addition`` and ``SquareRoot`` directories are similar. Let's look at one +of the CMakeLists files: + +.. literalinclude:: MathFunctionsComponents/SquareRoot/CMakeLists.txt + :language: cmake + +Now we can build the project as described in earlier sections. To test using +this package, we can use the project in +``Help\guide\importing-exporting\DownstreamComponents``. There's two +differences from the previous ``Downstream`` project. First, we need to find +the package components. Change the ``find_package`` line from: + +.. literalinclude:: Downstream/CMakeLists.txt + :language: cmake + :start-after: # find MathFunctions + :end-before: # create executable + +To: + +.. literalinclude:: DownstreamComponents/CMakeLists.txt + :language: cmake + :start-after: # find MathFunctions + :end-before: # create executable + +and the ``target_link_libraries`` line from: + +.. literalinclude:: Downstream/CMakeLists.txt + :language: cmake + :start-after: # use MathFunctions library + +To: + +.. literalinclude:: DownstreamComponents/CMakeLists.txt + :language: cmake + :start-after: # use MathFunctions library + :end-before: # Workaround for GCC on AIX to avoid -isystem + +In ``main.cc``, replace ``#include MathFunctions.h`` with: + +.. literalinclude:: DownstreamComponents/main.cc + :language: c + :start-after: #include <string> + :end-before: int main + +Finally, use the ``Addition`` library: + +.. literalinclude:: DownstreamComponents/main.cc + :language: c + :start-after: // calculate sum + :end-before: return 0; + +Build the ``Downstream`` project and confirm that it can find and use the +package components. diff --git a/Help/index.rst b/Help/index.rst index 4d9a9c8..616769e 100644 --- a/Help/index.rst +++ b/Help/index.rst @@ -84,6 +84,7 @@ Reference Manuals /guide/tutorial/index /guide/user-interaction/index /guide/using-dependencies/index + /guide/importing-exporting/index .. only:: html or text diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 3821dc3..0392325 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,6 +57,7 @@ Policies Introduced by CMake 3.19 .. toctree:: :maxdepth: 1 + CMP0114: ExternalProject step targets fully adopt their steps. </policy/CMP0114> CMP0113: Makefile generators do not repeat custom commands from target dependencies. </policy/CMP0113> CMP0112: Target file component generator expressions do not add target dependencies. </policy/CMP0112> CMP0111: An imported target with a missing location fails during generation. </policy/CMP0111> diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 73130b6..cb9579e 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -315,6 +315,7 @@ Properties on Targets /prop_tgt/OUTPUT_NAME_CONFIG /prop_tgt/OUTPUT_NAME /prop_tgt/PCH_WARN_INVALID + /prop_tgt/PCH_INSTANTIATE_TEMPLATES /prop_tgt/PDB_NAME_CONFIG /prop_tgt/PDB_NAME /prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index f776018..d50005c 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -444,6 +444,7 @@ Variables that Control the Build /variable/CMAKE_OSX_DEPLOYMENT_TARGET /variable/CMAKE_OSX_SYSROOT /variable/CMAKE_PCH_WARN_INVALID + /variable/CMAKE_PCH_INSTANTIATE_TEMPLATES /variable/CMAKE_PDB_OUTPUT_DIRECTORY /variable/CMAKE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_POSITION_INDEPENDENT_CODE diff --git a/Help/policy/CMP0114.rst b/Help/policy/CMP0114.rst new file mode 100644 index 0000000..1bc1216 --- /dev/null +++ b/Help/policy/CMP0114.rst @@ -0,0 +1,85 @@ +CMP0114 +------- + +.. versionadded:: 3.19 + +:module:`ExternalProject` step targets fully adopt their steps. + +The :command:`ExternalProject_Add` ``STEP_TARGETS`` option, and the +:command:`ExternalProject_Add_StepTargets` function, can be used to +create build targets for individual steps of an external project. + +In CMake 3.18 and below, step targets have some limitations: + +* Step targets always depend on targets named by the + :command:`ExternalProject_Add` ``DEPENDS`` option even though + not all steps need them. In order to allow step targets to be created + without those dependencies, the :command:`ExternalProject_Add` + ``INDEPENDENT_STEP_TARGETS`` option or the + :command:`ExternalProject_Add_StepTargets` ``NO_DEPENDS`` option may + be used. However, adding such "independent" step targets makes sense + only for specific steps such as ``download``, ``update``, and ``patch`` + because they do not need any of the external project's build dependencies. + Furthermore, it does not make sense to create independent step targets + for steps that depend on non-independent steps. Such rules are not + enforced, and projects that do not follow them can generate build systems + with confusing and generator-specific behavior. + +* Step targets hold copies of the custom commands implementing their + steps that are separate from the copies in the primary target created + by :command:`ExternalProject_Add`, and the primary target does not + depend on the step targets. In parallel builds that drive the primary + target and step targets concurrently, multiple copies of the steps' + commands may run concurrently and race each other. + + Also, prior to policy :policy:`CMP0113`, the step targets generated + by :ref:`Makefile Generators` also contain all the custom commands + on which their step depends. This can lead to repeated execution of + those steps even in serial builds. + +In CMake 3.19 and above, the :module:`ExternalProject` module prefers +a revised design to address these problems: + +* Each step is classified as "independent" if it does not depend + on other targets named by the :command:`ExternalProject_Add` ``DEPENDS``. + The predefined steps are automatically classified by default: + + * The ``download``, ``update``, and ``patch`` steps are independent. + * The ``configure``, ``build``, ``test``, and ``install`` steps are not. + + For custom steps, the :command:`ExternalProject_Add_Step` command provies + an ``INDEPENDENT`` option to mark them as independent. It is an error to + mark a step as independent if it depends on other steps that are not. Note + that this use of the term "independent" refers only to independence from + external targets and is orthogonal to a step's dependencies on other steps. + +* Step targets created by the :command:`ExternalProject_Add` ``STEP_TARGETS`` + option or the :command:`ExternalProject_Add_Step` function are now + independent if and only if their steps are marked as independent. + The :command:`ExternalProject_Add` ``INDEPENDENT_STEP_TARGETS`` option + and :command:`ExternalProject_Add_StepTargets` ``NO_DEPENDS`` option + are no longer allowed. + +* Step targets, when created, are fully responsible for holding the + custom commands implementing their steps. The primary target created + by :command:`ExternalProject_Add` depends on the step targets, and the + step targets depend on each other. The target-level dependencies match + the file-level dependencies used by the custom commands for each step. + + When the :command:`ExternalProject_Add` ``UPDATE_DISCONNECTED`` or + ``TEST_EXCLUDE_FROM_MAIN`` option is used, or the + :command:`ExternalProject_Add_Step` ``EXCLUDE_FROM_MAIN`` option is used + for a custom step, some step targets may be created automatically. + These are needed to hold the steps commonly depended upon by the primary + target and the disconnected step targets. + +Policy ``CMP0114`` provides compatibility for projects that have not been +updated to expect the new behavior. The ``OLD`` behavior for this policy +is to use the above-documented behavior from 3.18 and below. The ``NEW`` +behavior for this policy is to use the above-documented behavior preferred +by 3.19 and above. + +This policy was introduced in CMake version 3.19. CMake version +|release| warns when the policy is not set and uses ``OLD`` behavior. +Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` +explicitly. diff --git a/Help/prop_tgt/PCH_INSTANTIATE_TEMPLATES.rst b/Help/prop_tgt/PCH_INSTANTIATE_TEMPLATES.rst new file mode 100644 index 0000000..7c1af2a --- /dev/null +++ b/Help/prop_tgt/PCH_INSTANTIATE_TEMPLATES.rst @@ -0,0 +1,13 @@ +PCH_INSTANTIATE_TEMPLATES +------------------------- + +.. versionadded:: 3.19 + +When this property is set to true, the precompiled header compiler options +will contain a flag to instantiate templates during the generation of the PCH +if supported. This can significantly improve compile times. Supported in Clang +since version 11. + +This property is initialized by the value of the +:variable:`CMAKE_PCH_INSTANTIATE_TEMPLATES` variable if it is set when a target +is created. If that variable is not set, the property defaults to ``ON``. diff --git a/Help/release/3.16.rst b/Help/release/3.16.rst index f3fdb08..84d96cd 100644 --- a/Help/release/3.16.rst +++ b/Help/release/3.16.rst @@ -178,17 +178,15 @@ Modules Autogen ------- -* When using :prop_tgt:`AUTOMOC`, CMake now generates the ``-p`` path prefix +* When using :prop_tgt:`AUTOMOC`, the new :variable:`CMAKE_AUTOMOC_PATH_PREFIX` + variable or :prop_tgt:`AUTOMOC_PATH_PREFIX` target property may be enabled + to generate the ``-p`` path prefix option for ``moc``. This ensures that ``moc`` output files are identical on different build setups (given, that the headers compiled by ``moc`` are in an :command:`include directory <target_include_directories>`). Also it ensures that ``moc`` output files will compile correctly when the source and/or build directory is a symbolic link. - The ``moc`` path prefix generation behavior can be configured by setting - the new :variable:`CMAKE_AUTOMOC_PATH_PREFIX` variable and/or - :prop_tgt:`AUTOMOC_PATH_PREFIX` target property. - CTest ----- @@ -316,3 +314,11 @@ Changes made since CMake 3.16.0 include the following. :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target properties. Previously they would be places in ``*_CFLAGS_OTHER`` variables and :prop_tgt:`INTERFACE_COMPILE_OPTIONS` target properties. + +3.16.9 +------ + +* The default value of :variable:`CMAKE_AUTOMOC_PATH_PREFIX` was changed to + ``OFF`` because this feature can break existing projects that have + identically named header files in different include directories. + This restores compatibility with behavior of CMake 3.15 and below. diff --git a/Help/release/3.17.rst b/Help/release/3.17.rst index b7c66d8..abd7463 100644 --- a/Help/release/3.17.rst +++ b/Help/release/3.17.rst @@ -346,3 +346,12 @@ Changes made since CMake 3.17.0 include the following. :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target properties. Previously they would be places in ``*_CFLAGS_OTHER`` variables and :prop_tgt:`INTERFACE_COMPILE_OPTIONS` target properties. + +3.17.5 +------ + +* The default value of :variable:`CMAKE_AUTOMOC_PATH_PREFIX` was changed to + ``OFF`` because this feature can break existing projects that have + identically named header files in different include directories. + This restores compatibility with behavior of CMake 3.15 and below. + The default was also changed to ``OFF`` in 3.16.9. diff --git a/Help/release/3.18.rst b/Help/release/3.18.rst index 099e9b5..f97e4df 100644 --- a/Help/release/3.18.rst +++ b/Help/release/3.18.rst @@ -352,6 +352,7 @@ Changes made since CMake 3.18.0 include the following. ``OFF`` because this feature can break existing projects that have identically named header files in different include directories. This restores compatibility with behavior of CMake 3.15 and below. + The default was also changed to ``OFF`` in 3.16.9 and 3.17.5. * The :manual:`Compile Features <cmake-compile-features(7)>` functionality was updated for MSVC 19.27 as mentioned above (``c_restrict``). diff --git a/Help/release/dev/ExternalProject-steps-refinement.rst b/Help/release/dev/ExternalProject-steps-refinement.rst new file mode 100644 index 0000000..9762927 --- /dev/null +++ b/Help/release/dev/ExternalProject-steps-refinement.rst @@ -0,0 +1,5 @@ +ExternalProject-steps-refinement +-------------------------------- + +* The :module:`ExternalProject` module handling of step target dependencies + has been revised. See policy :policy:`CMP0114`. diff --git a/Help/release/dev/PCH_INSTANTIATE_TEMPLATES.rst b/Help/release/dev/PCH_INSTANTIATE_TEMPLATES.rst new file mode 100644 index 0000000..0334204 --- /dev/null +++ b/Help/release/dev/PCH_INSTANTIATE_TEMPLATES.rst @@ -0,0 +1,7 @@ +PCH_INSTANTIATE_TEMPLATES +------------------------- + +* The :prop_tgt:`PCH_INSTANTIATE_TEMPLATES` target property was added to enable + template instantiation in the precompiled header. This is enabled by default + and offers a roughly 20% compile time improvement. Currently only supported + by Clang 11. diff --git a/Help/release/dev/clang-windows-system-includes.rst b/Help/release/dev/clang-windows-system-includes.rst new file mode 100644 index 0000000..d1a3be2 --- /dev/null +++ b/Help/release/dev/clang-windows-system-includes.rst @@ -0,0 +1,5 @@ +clang-windows-system-includes +----------------------------- + +* The ``Clang`` compiler gained support for handling system include directories + when running on Windows. diff --git a/Help/release/dev/cuda-clang-scattered-cross.rst b/Help/release/dev/cuda-clang-scattered-cross.rst new file mode 100644 index 0000000..7278dcb --- /dev/null +++ b/Help/release/dev/cuda-clang-scattered-cross.rst @@ -0,0 +1,5 @@ +cuda-clang-scattered-cross +-------------------------- + +* Scattered toolkit installations are now recognized when crosscompiling + ``CUDA`` using Clang. diff --git a/Help/variable/CMAKE_PCH_INSTANTIATE_TEMPLATES.rst b/Help/variable/CMAKE_PCH_INSTANTIATE_TEMPLATES.rst new file mode 100644 index 0000000..9867f17 --- /dev/null +++ b/Help/variable/CMAKE_PCH_INSTANTIATE_TEMPLATES.rst @@ -0,0 +1,7 @@ +CMAKE_PCH_INSTANTIATE_TEMPLATES +------------------------------- + +.. versionadded:: 3.19 + +This variable is used to initialize the :prop_tgt:`PCH_INSTANTIATE_TEMPLATES` +property of targets when they are created. diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 96f32e5..2f1b0a3 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -88,7 +88,7 @@ else() ) endif() if(CMAKE_C_COMPILER_TARGET) - list(PREPEND CMAKE_C_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_C_COMPILER_TARGET}") + set(CMAKE_C_COMPILER_ID_TEST_FLAGS_FIRST "-c --target=${CMAKE_C_COMPILER_TARGET}") endif() # Build a small source file to identify the compiler. if(NOT CMAKE_C_COMPILER_ID_RUN) diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 6bdd06b..e60a973 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -300,7 +300,7 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang") endforeach() endif() - # Find target directory. Account for crosscompiling. + # Find target directory when crosscompiling. if(CMAKE_CROSSCOMPILING) if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") # Support for NVPACK @@ -320,7 +320,10 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang") if(EXISTS "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/targets/${_CUDA_TARGET_NAME}") set(_CUDA_TARGET_DIR "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/targets/${_CUDA_TARGET_NAME}") endif() - else() + endif() + + # If not already set we can simply use the toolkit root or it's a scattered installation. + if(NOT _CUDA_TARGET_DIR) set(_CUDA_TARGET_DIR "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}") endif() diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 2205c8f..2b27476 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -84,7 +84,7 @@ else() endif() if(CMAKE_CXX_COMPILER_TARGET) - list(PREPEND CMAKE_CXX_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_CXX_COMPILER_TARGET}") + set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS_FIRST "-c --target=${CMAKE_CXX_COMPILER_TARGET}") endif() # Build a small source file to identify the compiler. diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 66adafa..ce8a0f7 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -94,7 +94,11 @@ else() set(_CMAKE_ADDITIONAL_AR_NAMES "llvm-ar") set(_CMAKE_ADDITIONAL_RANLIB_NAMES "llvm-ranlib") set(_CMAKE_ADDITIONAL_STRIP_NAMES "llvm-strip") - set(_CMAKE_ADDITIONAL_LINKER_NAMES "ld.lld") + if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC") + set(_CMAKE_ADDITIONAL_LINKER_NAMES "lld-link") + else() + set(_CMAKE_ADDITIONAL_LINKER_NAMES "ld.lld") + endif() set(_CMAKE_ADDITIONAL_NM_NAMES "llvm-nm") set(_CMAKE_ADDITIONAL_OBJDUMP_NAMES "llvm-objdump") set(_CMAKE_ADDITIONAL_OBJCOPY_NAMES "llvm-objcopy") diff --git a/Modules/CMakeISPCInformation.cmake b/Modules/CMakeISPCInformation.cmake index 46bda5b..5acb682 100644 --- a/Modules/CMakeISPCInformation.cmake +++ b/Modules/CMakeISPCInformation.cmake @@ -1,7 +1,11 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -set(CMAKE_ISPC_OUTPUT_EXTENSION .o) +if(UNIX) + set(CMAKE_ISPC_OUTPUT_EXTENSION .o) +else() + set(CMAKE_ISPC_OUTPUT_EXTENSION .obj) +endif() set(CMAKE_INCLUDE_FLAG_ISPC "-I") # Load compiler-specific information. diff --git a/Modules/Compiler/ARMClang.cmake b/Modules/Compiler/ARMClang.cmake index 70e6ffb..da7a43c 100644 --- a/Modules/Compiler/ARMClang.cmake +++ b/Modules/Compiler/ARMClang.cmake @@ -115,11 +115,12 @@ macro(__compiler_armclang lang) endif() if(__CMAKE_ARMClang_USING_armlink) + unset(CMAKE_${lang}_LINKER_WRAPPER_FLAG) set(__CMAKE_ARMClang_USING_armlink_WRAPPER "") else() - set(__CMAKE_ARMClang_USING_armlink_WRAPPER ${CMAKE_${lang}_LINKER_WRAPPER_FLAG}) + set(__CMAKE_ARMClang_USING_armlink_WRAPPER "-Xlinker") endif() - set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> ${__CMAKE_ARMClang_USING_armlink_WRAPPER} --list <TARGET_BASE>.map") + set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> ${__CMAKE_ARMClang_USING_armlink_WRAPPER} --list=<TARGET_BASE>.map") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "${__CMAKE_ARMClang_USING_armlink_WRAPPER} --via=") diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index f7858d7..27692c2 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -19,6 +19,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "xMSVC") macro(__compiler_clang lang) + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc ") endmacro() else() include(Compiler/GNU) @@ -106,6 +107,9 @@ else() if (NOT CMAKE_GENERATOR MATCHES "Xcode") set(CMAKE_PCH_PROLOGUE "#pragma clang system_header") endif() + if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0.0 AND NOT __is_apple_clang) + set(CMAKE_${lang}_COMPILE_OPTIONS_INSTANTIATE_TEMPLATES_PCH -fpch-instantiate-templates) + endif() set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>) set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}}) endmacro() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 96edbef..b795784 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -398,6 +398,9 @@ External Project Definition project also provides a cache variable or some other convenient method for setting the directory property). + This may cause a step target to be created automatically for the + ``download`` step. See policy :policy:`CMP0114`. + ``PATCH_COMMAND <cmd>...`` Specifies a custom command to patch the sources after an update. By default, no patch command is defined. Note that it can be quite difficult @@ -578,6 +581,8 @@ External Project Definition If enabled, the main build's default ALL target will not depend on the test step. This can be a useful way of ensuring the test step is defined but only gets invoked when manually requested. + This may cause a step target to be created automatically for either + the ``install`` or ``build`` step. See policy :policy:`CMP0114`. **Output Logging Options:** Each of the following ``LOG_...`` options can be used to wrap the relevant @@ -664,19 +669,21 @@ External Project Definition steps need to be triggered manually or if they need to be used as dependencies of other targets. If this option is not specified, the default value is taken from the ``EP_STEP_TARGETS`` directory property. - See :command:`ExternalProject_Add_Step` below for further discussion of - the effects of this option. + See :command:`ExternalProject_Add_StepTargets` below for further + discussion of the effects of this option. ``INDEPENDENT_STEP_TARGETS <step-target>...`` - Generate custom targets for the specified steps and prevent these targets + Deprecated. This is allowed only if policy :policy:`CMP0114` is not set + to ``NEW``. + Generates custom targets for the specified steps and prevent these targets from having the usual dependencies applied to them. If this option is not specified, the default value is taken from the ``EP_INDEPENDENT_STEP_TARGETS`` directory property. This option is mostly useful for allowing individual steps to be driven independently, such as for a CDash setup where each step should be initiated and reported individually rather than as one whole build. See - :command:`ExternalProject_Add_Step` below for further discussion of the - effects of this option. + :command:`ExternalProject_Add_StepTargets` below for further discussion + of the effects of this option. **Miscellaneous Options:** ``LIST_SEPARATOR <sep>`` @@ -772,6 +779,21 @@ control needed to implement such step-level capabilities. ``DEPENDS <file>...`` Files on which this custom step depends. + ``INDEPENDENT <bool>`` + Specifies whether this step is independent of the external dependencies + specified by the :command:`ExternalProject_Add`'s ``DEPENDS`` option. + The default is ``FALSE``. Steps marked as independent may depend only + on other steps marked independent. See policy :policy:`CMP0114`. + + Note that this use of the term "independent" refers only to independence + from external targets specified by the ``DEPENDS`` option and is + orthogonal to a step's dependencies on other steps. + + If a step target is created for an independent step by the + :command:`ExternalProject_Add` ``STEP_TARGETS`` option or by the + :command:`ExternalProject_Add_StepTargets` function, it will not depend + on the external targets, but may depend on targets for other steps. + ``BYPRODUCTS <file>...`` Files that will be generated by this custom step but which might or might not have their modification time updated by subsequent builds. This list of @@ -785,6 +807,8 @@ control needed to implement such step-level capabilities. ``EXCLUDE_FROM_MAIN <bool>`` When enabled, this option specifies that the external project's main target does not depend on the custom step. + This may cause step targets to be created automatically for the steps on + which this step depends. See policy :policy:`CMP0114`. ``WORKING_DIRECTORY <dir>`` Specifies the working directory to set before running the custom step's @@ -815,7 +839,7 @@ control needed to implement such step-level capabilities. .. code-block:: cmake - ExternalProject_Add_StepTargets(<name> [NO_DEPENDS] <step1> [<step2>...]) + ExternalProject_Add_StepTargets(<name> <step1> [<step2>...]) Creating a target for a step allows it to be used as a dependency of another target or to be triggered manually. Having targets for specific steps also @@ -827,37 +851,53 @@ control needed to implement such step-level capabilities. through the step dependency chain, then all the previous steps will also run to ensure everything is up to date. - If the ``NO_DEPENDS`` option is specified, the step target will not depend on - the dependencies of the external project (i.e. on any dependencies of the - ``<name>`` custom target created by :command:`ExternalProject_Add`). This is - usually safe for the ``download``, ``update`` and ``patch`` steps, since they - do not typically require that the dependencies are updated and built. Using - ``NO_DEPENDS`` for any of the other pre-defined steps, however, may break - parallel builds. Only use ``NO_DEPENDS`` where it is certain that the named - steps genuinely do not have dependencies. For custom steps, consider whether - or not the custom commands require the dependencies to be configured, built - and installed. - Internally, :command:`ExternalProject_Add` calls :command:`ExternalProject_Add_Step` to create each step. If any - ``STEP_TARGETS`` or ``INDEPENDENT_STEP_TARGETS`` were specified, then - ``ExternalProject_Add_StepTargets()`` will also be called after - :command:`ExternalProject_Add_Step`. ``INDEPENDENT_STEP_TARGETS`` have the - ``NO_DEPENDS`` option set, whereas ``STEP_TARGETS`` do not. Other than that, - the two options result in ``ExternalProject_Add_StepTargets()`` being called - in the same way. Even if a step is not mentioned in either of those two - options, ``ExternalProject_Add_StepTargets()`` can still be called later to - manually define a target for the step. - - The ``STEP_TARGETS`` and ``INDEPENDENT_STEP_TARGETS`` options for - :command:`ExternalProject_Add` are generally the easiest way to ensure - targets are created for specific steps of interest. For custom steps, - ``ExternalProject_Add_StepTargets()`` must be called explicitly if a target - should also be created for that custom step. An alternative to these two - options is to populate the ``EP_STEP_TARGETS`` and - ``EP_INDEPENDENT_STEP_TARGETS`` directory properties. These act as defaults - for the step target options and can save having to repeatedly specify the - same set of step targets when multiple external projects are being defined. + ``STEP_TARGETS`` were specified, then ``ExternalProject_Add_StepTargets()`` + will also be called after :command:`ExternalProject_Add_Step`. Even if a + step is not mentioned in the ``STEP_TARGETS`` option, + ``ExternalProject_Add_StepTargets()`` can still be called later to manually + define a target for the step. + + The ``STEP_TARGETS`` option for :command:`ExternalProject_Add` is generally + the easiest way to ensure targets are created for specific steps of interest. + For custom steps, ``ExternalProject_Add_StepTargets()`` must be called + explicitly if a target should also be created for that custom step. + An alternative to these two options is to populate the ``EP_STEP_TARGETS`` + directory property. It acts as a default for the step target options and + can save having to repeatedly specify the same set of step targets when + multiple external projects are being defined. + + If :policy:`CMP0114` is set to ``NEW``, step targets are fully responsible + for holding the custom commands implementing their steps. The primary target + created by ``ExternalProject_Add`` depends on the step targets, and the + step targets depend on each other. The target-level dependencies match + the file-level dependencies used by the custom commands for each step. + The targets for steps created with :command:`ExternalProject_Add_Step`'s + ``INDEPENDENT`` option do not depend on the external targets specified + by :command:`ExternalProject_Add`'s ``DEPENDS`` option. The predefined + steps ``mkdir``, ``download``, ``update``, and ``patch`` are independent. + + If :policy:`CMP0114` is not ``NEW``, the following deprecated behavior + is available: + + * A deprecated ``NO_DEPENDS`` option may be specified immediately after the + ``<name>`` and before the first step. + If the ``NO_DEPENDS`` option is specified, the step target will not depend on + the dependencies of the external project (i.e. on any dependencies of the + ``<name>`` custom target created by :command:`ExternalProject_Add`). This is + usually safe for the ``download``, ``update`` and ``patch`` steps, since they + do not typically require that the dependencies are updated and built. Using + ``NO_DEPENDS`` for any of the other pre-defined steps, however, may break + parallel builds. Only use ``NO_DEPENDS`` where it is certain that the named + steps genuinely do not have dependencies. For custom steps, consider whether + or not the custom commands require the dependencies to be configured, built + and installed. + + * The ``INDEPENDENT_STEP_TARGETS`` option for :command:`ExternalProject_Add`, + or the ``EP_INDEPENDENT_STEP_TARGETS`` directory property, tells the + function to call ``ExternalProject_Add_StepTargets()`` internally + using the ``NO_DEPENDS`` option for the specified steps. .. command:: ExternalProject_Add_StepDependencies @@ -1990,41 +2030,138 @@ function(_ep_get_complete_stampfile name stampfile_var) endfunction() +function(_ep_step_add_target name step no_deps) + if(TARGET ${name}-${step}) + return() + endif() + get_property(cmp0114 TARGET ${name} PROPERTY _EP_CMP0114) + _ep_get_step_stampfile(${name} ${step} stamp_file) + cmake_policy(PUSH) + if(cmp0114 STREQUAL "NEW") + # To implement CMP0114 NEW behavior with Makefile generators, + # we need CMP0113 NEW behavior. + cmake_policy(SET CMP0113 NEW) + endif() + add_custom_target(${name}-${step} + DEPENDS ${stamp_file}) + cmake_policy(POP) + set_property(TARGET ${name}-${step} PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP 1) + set_property(TARGET ${name}-${step} PROPERTY LABELS ${name}) + set_property(TARGET ${name}-${step} PROPERTY FOLDER "ExternalProjectTargets/${name}") + + if(cmp0114 STREQUAL "NEW") + # Add target-level dependencies for the step. + get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) + if(NOT exclude_from_main) + add_dependencies(${name} ${name}-${step}) + endif() + _ep_step_add_target_dependencies(${name} ${step} ${step}) + _ep_step_add_target_dependents(${name} ${step} ${step}) + + get_property(independent TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT) + else() + if(no_deps AND "${step}" MATCHES "^(configure|build|install|test)$") + message(AUTHOR_WARNING "Using NO_DEPENDS for \"${step}\" step might break parallel builds") + endif() + set(independent ${no_deps}) + endif() + + # Depend on other external projects (target-level). + if(NOT independent) + get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) + foreach(arg IN LISTS deps) + add_dependencies(${name}-${step} ${arg}) + endforeach() + endif() +endfunction() + + +function(_ep_step_add_target_dependencies name step node) + get_property(dependees TARGET ${name} PROPERTY _EP_${node}_INTERNAL_DEPENDEES) + list(REMOVE_DUPLICATES dependees) + foreach(dependee IN LISTS dependees) + get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) + get_property(dependee_dependers TARGET ${name} PROPERTY _EP_${dependee}_INTERNAL_DEPENDERS) + if(exclude_from_main OR dependee_dependers MATCHES ";") + # The step on which our step target depends itself has + # dependents in multiple targes. It needs a step target too + # so that there is a unique place for its custom command. + _ep_step_add_target("${name}" "${dependee}" "FALSE") + endif() + + if(TARGET ${name}-${dependee}) + add_dependencies(${name}-${step} ${name}-${dependee}) + else() + _ep_step_add_target_dependencies(${name} ${step} ${dependee}) + endif() + endforeach() +endfunction() + + +function(_ep_step_add_target_dependents name step node) + get_property(dependers TARGET ${name} PROPERTY _EP_${node}_INTERNAL_DEPENDERS) + list(REMOVE_DUPLICATES dependers) + foreach(depender IN LISTS dependers) + if(TARGET ${name}-${depender}) + add_dependencies(${name}-${depender} ${name}-${step}) + else() + _ep_step_add_target_dependents(${name} ${step} ${depender}) + endif() + endforeach() +endfunction() + + function(ExternalProject_Add_StepTargets name) + get_property(cmp0114 TARGET ${name} PROPERTY _EP_CMP0114) set(steps ${ARGN}) if(ARGC GREATER 1 AND "${ARGV1}" STREQUAL "NO_DEPENDS") set(no_deps 1) list(REMOVE_AT steps 0) + else() + set(no_deps 0) endif() - foreach(step ${steps}) - if(no_deps AND "${step}" MATCHES "^(configure|build|install|test)$") - message(AUTHOR_WARNING "Using NO_DEPENDS for \"${step}\" step might break parallel builds") + if(cmp0114 STREQUAL "NEW") + if(no_deps) + message(FATAL_ERROR + "The 'NO_DEPENDS' option is no longer allowed. " + "It has been superseded by the per-step 'INDEPENDENT' option. " + "See policy CMP0114." + ) endif() - _ep_get_step_stampfile(${name} ${step} stamp_file) - add_custom_target(${name}-${step} - DEPENDS ${stamp_file}) - set_property(TARGET ${name}-${step} PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP 1) - set_property(TARGET ${name}-${step} PROPERTY LABELS ${name}) - set_property(TARGET ${name}-${step} PROPERTY FOLDER "ExternalProjectTargets/${name}") - - # Depend on other external projects (target-level). - if(NOT no_deps) - get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) - foreach(arg IN LISTS deps) - add_dependencies(${name}-${step} ${arg}) - endforeach() + elseif(cmp0114 STREQUAL "") + cmake_policy(GET_WARNING CMP0114 _cmp0114_warning) + string(APPEND _cmp0114_warning "\n" + "ExternalProject target '${name}' would depend on the targets for " + "step(s) '${steps}' under policy CMP0114, but this is being left out " + "for compatibility since the policy is not set." + ) + if(no_deps) + string(APPEND _cmp0114_warning + " Also, the NO_DEPENDS option is deprecated in favor of policy CMP0114." + ) endif() + message(AUTHOR_WARNING "${_cmp0114_warning}") + endif() + foreach(step ${steps}) + _ep_step_add_target("${name}" "${step}" "${no_deps}") endforeach() endfunction() function(ExternalProject_Add_Step name step) + get_property(cmp0114 TARGET ${name} PROPERTY _EP_CMP0114) _ep_get_complete_stampfile(${name} complete_stamp_file) _ep_get_step_stampfile(${name} ${step} stamp_file) _ep_parse_arguments(ExternalProject_Add_Step ${name} _EP_${step}_ "${ARGN}") + get_property(independent TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT) + if(independent STREQUAL "") + set(independent FALSE) + set_property(TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT "${independent}") + endif() + get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) if(NOT exclude_from_main) add_custom_command(APPEND @@ -2035,12 +2172,21 @@ function(ExternalProject_Add_Step name step) # Steps depending on this step. get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS) + set_property(TARGET ${name} APPEND PROPERTY _EP_${step}_INTERNAL_DEPENDERS ${dependers}) foreach(depender IN LISTS dependers) + set_property(TARGET ${name} APPEND PROPERTY _EP_${depender}_INTERNAL_DEPENDEES ${step}) _ep_get_step_stampfile(${name} ${depender} depender_stamp_file) add_custom_command(APPEND OUTPUT ${depender_stamp_file} DEPENDS ${stamp_file} ) + if(cmp0114 STREQUAL "NEW" AND NOT independent) + get_property(dep_independent TARGET ${name} PROPERTY _EP_${depender}_INDEPENDENT) + if(dep_independent) + message(FATAL_ERROR "ExternalProject '${name}' step '${depender}' is marked INDEPENDENT " + "but depends on step '${step}' that is not marked INDEPENDENT.") + endif() + endif() endforeach() # Dependencies on files. @@ -2051,9 +2197,18 @@ function(ExternalProject_Add_Step name step) # Dependencies on steps. get_property(dependees TARGET ${name} PROPERTY _EP_${step}_DEPENDEES) + set_property(TARGET ${name} APPEND PROPERTY _EP_${step}_INTERNAL_DEPENDEES ${dependees}) foreach(dependee IN LISTS dependees) + set_property(TARGET ${name} APPEND PROPERTY _EP_${dependee}_INTERNAL_DEPENDERS ${step}) _ep_get_step_stampfile(${name} ${dependee} dependee_stamp_file) list(APPEND depends ${dependee_stamp_file}) + if(cmp0114 STREQUAL "NEW" AND independent) + get_property(dep_independent TARGET ${name} PROPERTY _EP_${dependee}_INDEPENDENT) + if(NOT dep_independent) + message(FATAL_ERROR "ExternalProject '${name}' step '${step}' is marked INDEPENDENT " + "but depends on step '${dependee}' that is not marked INDEPENDENT.") + endif() + endif() endforeach() # The command to run. @@ -2148,7 +2303,7 @@ function(ExternalProject_Add_Step name step) endif() foreach(st ${step_targets}) if("${st}" STREQUAL "${step}") - ExternalProject_Add_StepTargets(${name} ${step}) + _ep_step_add_target("${name}" "${step}" "FALSE") break() endif() endforeach() @@ -2157,12 +2312,37 @@ function(ExternalProject_Add_Step name step) if(NOT independent_step_targets) get_property(independent_step_targets DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS) endif() - foreach(st ${independent_step_targets}) - if("${st}" STREQUAL "${step}") - ExternalProject_Add_StepTargets(${name} NO_DEPENDS ${step}) - break() + if(cmp0114 STREQUAL "NEW") + if(independent_step_targets) + message(FATAL_ERROR + "ExternalProject '${name}' option 'INDEPENDENT_STEP_TARGETS' is set to\n" + " ${independent_step_targets}\n" + "but the option is no longer allowed. " + "It has been superseded by the per-step 'INDEPENDENT' option. " + "See policy CMP0114." + ) endif() - endforeach() + else() + if(independent_step_targets AND cmp0114 STREQUAL "") + get_property(warned TARGET ${name} PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS) + if(NOT warned) + set_property(TARGET ${name} PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS 1) + cmake_policy(GET_WARNING CMP0114 _cmp0114_warning) + string(APPEND _cmp0114_warning "\n" + "ExternalProject '${name}' option INDEPENDENT_STEP_TARGETS is set to\n" + " ${independent_step_targets}\n" + "but the option is deprecated in favor of policy CMP0114." + ) + message(AUTHOR_WARNING "${_cmp0114_warning}") + endif() + endif() + foreach(st ${independent_step_targets}) + if("${st}" STREQUAL "${step}") + _ep_step_add_target("${name}" "${step}" "TRUE") + break() + endif() + endforeach() + endif() endfunction() @@ -2225,6 +2405,7 @@ function(_ep_add_mkdir_command name) _ep_get_configuration_subdir_suffix(cfgdir) ExternalProject_Add_Step(${name} mkdir + INDEPENDENT TRUE COMMENT "Creating directories for '${name}'" COMMAND ${CMAKE_COMMAND} -E make_directory ${source_dir} COMMAND ${CMAKE_COMMAND} -E make_directory ${binary_dir} @@ -2600,6 +2781,7 @@ function(_ep_add_download_command name) endforeach() cmake_language(EVAL CODE " ExternalProject_Add_Step(\${name} download + INDEPENDENT TRUE COMMENT \${comment} COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${work_dir} @@ -2763,6 +2945,7 @@ Update to Mercurial >= 2.1.1. endforeach() cmake_language(EVAL CODE " ExternalProject_Add_Step(${name} update + INDEPENDENT TRUE COMMENT \${comment} COMMAND ${__cmdQuoted} ALWAYS \${always} @@ -2809,6 +2992,7 @@ function(_ep_add_patch_command name) endforeach() cmake_language(EVAL CODE " ExternalProject_Add_Step(${name} patch + INDEPENDENT TRUE COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${work_dir} DEPENDEES \${patch_dep} @@ -2973,6 +3157,7 @@ function(_ep_add_configure_command name) endforeach() cmake_language(EVAL CODE " ExternalProject_Add_Step(${name} configure + INDEPENDENT FALSE COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${binary_dir} DEPENDEES patch @@ -3024,6 +3209,7 @@ function(_ep_add_build_command name) endforeach() cmake_language(EVAL CODE " ExternalProject_Add_Step(${name} build + INDEPENDENT FALSE COMMAND ${__cmdQuoted} BYPRODUCTS \${build_byproducts} WORKING_DIRECTORY \${binary_dir} @@ -3067,6 +3253,7 @@ function(_ep_add_install_command name) endforeach() cmake_language(EVAL CODE " ExternalProject_Add_Step(${name} install + INDEPENDENT FALSE COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${binary_dir} DEPENDEES build @@ -3134,6 +3321,7 @@ function(_ep_add_test_command name) endforeach() cmake_language(EVAL CODE " ExternalProject_Add_Step(${name} test + INDEPENDENT FALSE COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${binary_dir} ${dependees_args} @@ -3151,6 +3339,9 @@ function(ExternalProject_Add name) cmake_policy(GET CMP0097 _EP_CMP0097 PARENT_SCOPE # undocumented, do not use outside of CMake ) + cmake_policy(GET CMP0114 cmp0114 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) _ep_get_configuration_subdir_suffix(cfgdir) @@ -3158,14 +3349,23 @@ function(ExternalProject_Add name) set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles) _ep_get_complete_stampfile(${name} complete_stamp_file) + cmake_policy(PUSH) + if(cmp0114 STREQUAL "NEW") + # To implement CMP0114 NEW behavior with Makefile generators, + # we need CMP0113 NEW behavior. + cmake_policy(SET CMP0113 NEW) + endif() # The "ALL" option to add_custom_target just tells it to not set the # EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL # argument was passed, we explicitly set it for the target. add_custom_target(${name} ALL DEPENDS ${complete_stamp_file}) + cmake_policy(POP) set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1) set_property(TARGET ${name} PROPERTY LABELS ${name}) set_property(TARGET ${name} PROPERTY FOLDER "ExternalProjectTargets/${name}") + set_property(TARGET ${name} PROPERTY _EP_CMP0114 "${cmp0114}") + _ep_parse_arguments(ExternalProject_Add ${name} _EP_ "${ARGN}") _ep_set_directories(${name}) _ep_get_step_stampfile(${name} "done" done_stamp_file) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 88a252d..e4353df 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -27,6 +27,7 @@ The following variables may be set to influence this module's behavior: possibilities. List of vendors valid in this module: * ``Goto`` + * ``FlexiBLAS`` * ``OpenBLAS`` * ``FLAME`` * ``ATLAS PhiPACK`` @@ -549,6 +550,22 @@ if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") endif() endif() +# FlexiBLAS? (http://www.mpi-magdeburg.mpg.de/mpcsc/software/FlexiBLAS/) +if(BLA_VENDOR STREQUAL "FlexiBLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "flexiblas" + "" + "" + "" + ) + endif() +endif() + # OpenBLAS? (http://www.openblas.net) if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 184a9a2..81fbbb7 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -709,8 +709,8 @@ if(TARGET Doxygen::doxygen) set(_doxyfile_in "${CMAKE_BINARY_DIR}/CMakeDoxyfile.in") set(_doxyfile_defaults "${CMAKE_BINARY_DIR}/CMakeDoxygenDefaults.cmake") - file(WRITE "${_doxyfile_in}" ${_Doxygen_dne_header}) - file(WRITE "${_doxyfile_defaults}" ${_Doxygen_dne_header}) + set(_doxyfile_in_contents "") + set(_doxyfile_defaults_contents "") # Get strings containing a configuration key from the template Doxyfile # we obtained from this version of Doxygen. Because some options are split @@ -742,19 +742,19 @@ if(TARGET Doxygen::doxygen) if(_Doxygen_param MATCHES "([A-Z][A-Z0-9_]+)( *)=( (.*))?") # Ok, this is a config key with a value if(CMAKE_MATCH_COUNT EQUAL 4) - file(APPEND "${_doxyfile_in}" - "${CMAKE_MATCH_1}${CMAKE_MATCH_2}= @DOXYGEN_${CMAKE_MATCH_1}@\n") + string(APPEND _doxyfile_in_contents + "${CMAKE_MATCH_1}${CMAKE_MATCH_2}= @DOXYGEN_${CMAKE_MATCH_1}@\n") # Remove the backslashes we had to preserve to handle newlines string(REPLACE "\\\n" "\n" _value "${CMAKE_MATCH_4}") - file(APPEND "${_doxyfile_defaults}" + string(APPEND _doxyfile_defaults_contents "if(NOT DEFINED DOXYGEN_${CMAKE_MATCH_1}) set(DOXYGEN_${CMAKE_MATCH_1} ${_value}) endif() ") # Ok, this is a config key with empty default value elseif(CMAKE_MATCH_COUNT EQUAL 2) - file(APPEND "${_doxyfile_in}" - "${CMAKE_MATCH_1}${CMAKE_MATCH_2}= @DOXYGEN_${CMAKE_MATCH_1}@\n") + string(APPEND _doxyfile_in_contents + "${CMAKE_MATCH_1}${CMAKE_MATCH_2}= @DOXYGEN_${CMAKE_MATCH_1}@\n") else() message(AUTHOR_WARNING "Unexpected line format! Code review required!\nFault line: ${_Doxygen_param}") @@ -764,6 +764,10 @@ endif() "Unexpected line format! Code review required!\nFault line: ${_Doxygen_param}") endif() endforeach() + file(WRITE "${_doxyfile_defaults}" "${_Doxygen_dne_header}" + "${_doxyfile_defaults_contents}") + file(WRITE "${_doxyfile_in}" "${_Doxygen_dne_header}" + "${_doxyfile_in_contents}") # Ok, dumped defaults are not needed anymore... file(REMOVE "${_Doxygen_tpl}") diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 438551e..4b71cee 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -26,6 +26,7 @@ The following variables may be set to influence this module's behavior: If set, checks only the specified vendor, if not set checks all the possibilities. List of vendors valid in this module: + * ``FlexiBLAS`` * ``OpenBLAS`` * ``FLAME`` * ``Intel10_32`` (intel mkl v10 32 bit, threaded code) @@ -378,6 +379,22 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) ) endif() + # FlexiBLAS? (http://www.mpi-magdeburg.mpg.de/mpcsc/software/FlexiBLAS/) + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "FlexiBLAS" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "flexiblas" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + # OpenBLAS? (http://www.openblas.net) if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")) diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index f551dfe..0631607 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -67,7 +67,7 @@ if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY) set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES}) endif() -find_library(LIBXML2_LIBRARY NAMES xml2 libxml2 +find_library(LIBXML2_LIBRARY NAMES xml2 libxml2 libxml2_a HINTS ${PC_LIBXML_LIBDIR} ${PC_LIBXML_LIBRARY_DIRS} diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index d89029a..584f64d 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -328,7 +328,7 @@ setting the following variables: ``Python_LIBRARY`` The path to the library. It will be used to compute the - variables ``Python_LIBRARIES``, ``Python_LIBRAY_DIRS`` and + variables ``Python_LIBRARIES``, ``Python_LIBRARY_DIRS`` and ``Python_RUNTIME_LIBRARY_DIRS``. ``Python_INCLUDE_DIR`` diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index f5ad454..1c75011 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -275,7 +275,7 @@ setting the following variables: ``Python2_LIBRARY`` The path to the library. It will be used to compute the - variables ``Python2_LIBRARIES``, ``Python2_LIBRAY_DIRS`` and + variables ``Python2_LIBRARIES``, ``Python2_LIBRARY_DIRS`` and ``Python2_RUNTIME_LIBRARY_DIRS``. ``Python2_INCLUDE_DIR`` diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index bacdc42..e6e9f04 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -325,7 +325,7 @@ setting the following variables: ``Python3_LIBRARY`` The path to the library. It will be used to compute the - variables ``Python3_LIBRARIES``, ``Python3_LIBRAY_DIRS`` and + variables ``Python3_LIBRARIES``, ``Python3_LIBRARY_DIRS`` and ``Python3_RUNTIME_LIBRARY_DIRS``. ``Python3_INCLUDE_DIR`` diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 0d74d30..2261c90 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -163,7 +163,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" include(Platform/Windows-MSVC) # Set the clang option forwarding prefix for clang-cl usage in the llvm-rc processing stage __enable_llvm_rc_preprocessing("-clang:") - macro(__windows_compiler_clang lang) + macro(__windows_compiler_clang_base lang) set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) endmacro() @@ -179,7 +179,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" set(CMAKE_BUILD_TYPE_INIT Debug) __enable_llvm_rc_preprocessing("") - macro(__windows_compiler_clang lang) + macro(__windows_compiler_clang_base lang) __windows_compiler_clang_gnu(${lang}) endmacro() endif() @@ -187,7 +187,16 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" else() include(Platform/Windows-GNU) __enable_llvm_rc_preprocessing("") - macro(__windows_compiler_clang lang) + macro(__windows_compiler_clang_base lang) __windows_compiler_gnu(${lang}) endmacro() endif() + +macro(__windows_compiler_clang lang) + if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0) + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ") + else() + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") + endif() + __windows_compiler_clang_base(${lang}) +endmacro() diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index de31dab..bd08718 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -364,11 +364,6 @@ macro(__windows_compiler_msvc lang) set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) - if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0) - set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ") - else() - set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") - endif() # '-flto=thin' available since Clang 3.9 and Xcode 8 # * http://clang.llvm.org/docs/ThinLTO.html#clang-llvm # * https://trac.macports.org/wiki/XcodeVersionInfo diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 835b785..e6128a6 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 18) -set(CMake_VERSION_PATCH 20200910) +set(CMake_VERSION_PATCH 20200917) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1bb069f..c0f2495 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4134,6 +4134,16 @@ std::string cmGeneratorTarget::GetPchCreateCompileOptions( cmStrCat("CMAKE_", language, "_COMPILE_OPTIONS_INVALID_PCH")); } + if (this->GetPropertyAsBool("PCH_INSTANTIATE_TEMPLATES")) { + std::string varName = cmStrCat( + "CMAKE_", language, "_COMPILE_OPTIONS_INSTANTIATE_TEMPLATES_PCH"); + std::string instantiateOption = + this->Makefile->GetSafeDefinition(varName); + if (!instantiateOption.empty()) { + createOptionList = cmStrCat(createOptionList, ";", instantiateOption); + } + } + const std::string createOptVar = cmStrCat("CMAKE_", language, "_COMPILE_OPTIONS_CREATE_PCH"); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8688b1b..ce1a4ec 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1640,6 +1640,8 @@ bool cmGlobalGenerator::AddAutomaticSources() { for (const auto& lg : this->LocalGenerators) { lg->CreateEvaluationFileOutputs(); + } + for (const auto& lg : this->LocalGenerators) { for (const auto& gt : lg->GetGeneratorTargets()) { if (!gt->CanCompileSources()) { continue; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index f9ec0d6..958d061 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -337,7 +337,10 @@ class cmMakefile; SELECT(POLICY, CMP0113, \ "Makefile generators do not repeat custom commands from target " \ "dependencies.", \ - 3, 19, 0, cmPolicies::WARN) + 3, 19, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0114, \ + "ExternalProject step targets fully adopt their steps.", 3, 19, 0, \ + cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmState.h b/Source/cmState.h index 14870eb..dc3ba65 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -5,10 +5,10 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <functional> -#include <map> #include <memory> #include <set> #include <string> +#include <unordered_map> #include <vector> #include "cmDefinitions.h" @@ -219,8 +219,8 @@ private: cmPropertyDefinitionMap PropertyDefinitions; std::vector<std::string> EnabledLanguages; - std::map<std::string, Command> BuiltinCommands; - std::map<std::string, Command> ScriptedCommands; + std::unordered_map<std::string, Command> BuiltinCommands; + std::unordered_map<std::string, Command> ScriptedCommands; cmPropertyMap GlobalProperties; std::unique_ptr<cmCacheManager> CacheManager; std::unique_ptr<cmGlobVerificationManager> GlobVerificationManager; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ececee7..e076d1e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -381,6 +381,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initPropValue("UNITY_BUILD_BATCH_SIZE", "8"); initPropValue("UNITY_BUILD_MODE", "BATCH"); initPropValue("PCH_WARN_INVALID", "ON"); + initPropValue("PCH_INSTANTIATE_TEMPLATES", "ON"); #ifdef __APPLE__ if (this->GetGlobalGenerator()->IsXcode()) { diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 95162ec..b0cb8d4 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -804,10 +804,6 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif() endmacro() - if(CMake_BUILD_NIGHTLY_RELEASES) - ADD_NIGHTLY_BUILD_TEST(CMakeNightlyOSX - osx_release.cmake) - endif() # add tests with more complex invocations add_test(Framework ${CMAKE_CTEST_COMMAND} @@ -1654,7 +1650,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH set_tests_properties(${tutorial_test_name} PROPERTIES PASS_REGULAR_EXPRESSION ${pass_regex}) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/${tutorial_build_dir}_Build") + list(APPEND TEST_BUILD_DIRS "${tutorial_build_dir}_Build") endfunction() if(NOT CMake_TEST_EXTERNAL_CMAKE) @@ -1674,6 +1670,44 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH add_tutorial_test(Complete FALSE 25 ${pass_regex}) endif() + function(add_importexport_test export_name import_name) + set(install_dir + "${CMake_BINARY_DIR}/Tests/ImportExport/Install${export_name}") + set(export_build_dir "${CMake_BINARY_DIR}/Tests/ImportExport/${export_name}Build") + set(export_test_name "Guide.ImportExport.${export_name}") + add_test(${export_test_name} ${CMAKE_CTEST_COMMAND} + -C "Release" + --build-and-test + "${CMake_SOURCE_DIR}/Help/guide/importing-exporting/${export_name}" + "${export_build_dir}" + ${build_generator_args} + --build-project ${export_name} + --build-target install + --build-options + "-DCMAKE_INSTALL_PREFIX:PATH=${install_dir}") + list(APPEND TEST_BUILD_DIRS "${export_build_dir}") + + set(import_build_dir "${CMake_BINARY_DIR}/Tests/ImportExport/${import_name}Build") + set(import_test_name "Guide.ImportExport.${import_name}") + add_test(${import_test_name} ${CMAKE_CTEST_COMMAND} + -C "Release" + --build-and-test + "${CMake_SOURCE_DIR}/Help/guide/importing-exporting/${import_name}" + "${import_build_dir}" + ${build_generator_args} + --build-project ${import_name} + --build-options + "-DCMAKE_PREFIX_PATH:PATH=${install_dir}/lib/cmake") + set_tests_properties(${import_test_name} PROPERTIES DEPENDS ${export_test_name}) + list(APPEND TEST_BUILD_DIRS "${import_build_dir}") + endfunction() + + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_importexport_test("MyExe" "Importing") + add_importexport_test("MathFunctions" "Downstream") + add_importexport_test("MathFunctionsComponents" "DownstreamComponents") + endif() + add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test "${CMake_SOURCE_DIR}/Tests/Testing" diff --git a/Tests/ISPC/DynamicLibrary/CMakeLists.txt b/Tests/ISPC/DynamicLibrary/CMakeLists.txt index cbfbb3e..4655090 100644 --- a/Tests/ISPC/DynamicLibrary/CMakeLists.txt +++ b/Tests/ISPC/DynamicLibrary/CMakeLists.txt @@ -9,12 +9,14 @@ endif() add_library(ispc_objects1 STATIC extra.ispc extra.cxx) add_library(ispc_objects2 SHARED simple.ispc) +target_sources(ispc_objects2 PRIVATE simple.cxx) set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4") set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4") -target_link_libraries(ispc_objects2 PRIVATE ispc_objects1) +target_link_libraries(ispc_objects2 PUBLIC ispc_objects1) add_executable(ISPCDynamicLibrary main.cxx) target_link_libraries(ISPCDynamicLibrary PUBLIC ispc_objects2) diff --git a/Tests/ISPC/DynamicLibrary/extra.cxx b/Tests/ISPC/DynamicLibrary/extra.cxx index 88ef3a7..b3623d1 100644 --- a/Tests/ISPC/DynamicLibrary/extra.cxx +++ b/Tests/ISPC/DynamicLibrary/extra.cxx @@ -2,7 +2,13 @@ #include "extra.ispc.h" -int extra() +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +EXPORT int extra() { float vin[16], vout[16]; for (int i = 0; i < 16; ++i) diff --git a/Tests/ISPC/DynamicLibrary/main.cxx b/Tests/ISPC/DynamicLibrary/main.cxx index 4f1c9be..f9072c7 100644 --- a/Tests/ISPC/DynamicLibrary/main.cxx +++ b/Tests/ISPC/DynamicLibrary/main.cxx @@ -1,15 +1,17 @@ -#include <stdio.h> -#include "simple.ispc.h" -int main() -{ - float vin[16], vout[16]; - for (int i = 0; i < 16; ++i) - vin[i] = i; +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +#else +# define IMPORT +#endif - ispc::simple(vin, vout, 16); +IMPORT int simple(); +int extra(); - for (int i = 0; i < 16; ++i) - printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +int main() +{ + extra(); + simple(); + return 0; } diff --git a/Tests/ISPC/DynamicLibrary/shim.cxx b/Tests/ISPC/DynamicLibrary/shim.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/shim.cxx diff --git a/Tests/ISPC/DynamicLibrary/simple.cxx b/Tests/ISPC/DynamicLibrary/simple.cxx new file mode 100644 index 0000000..cb5a779 --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/simple.cxx @@ -0,0 +1,23 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +EXPORT int simple() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 7bc0e0f..e586961 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -740,7 +740,9 @@ endif() add_RunCMake_test("CTestCommandExpandLists") -add_RunCMake_test(PrecompileHeaders -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) +add_RunCMake_test(PrecompileHeaders -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}) + add_RunCMake_test("UnityBuild") if(WIN32) diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-common.cmake b/Tests/RunCMake/CompilerLauncher/ISPC-common.cmake index 5beff3d..a6e576e 100644 --- a/Tests/RunCMake/CompilerLauncher/ISPC-common.cmake +++ b/Tests/RunCMake/CompilerLauncher/ISPC-common.cmake @@ -1,4 +1,8 @@ enable_language(ISPC) enable_language(CXX) set(CMAKE_VERBOSE_MAKEFILE TRUE) + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() add_executable(main main.cxx test.ispc) diff --git a/Tests/RunCMake/ExternalProject/Add_StepDependencies-stderr.txt b/Tests/RunCMake/ExternalProject/Add_StepDependencies-stderr.txt new file mode 100644 index 0000000..d0ff15f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Add_StepDependencies-stderr.txt @@ -0,0 +1,12 @@ +^CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set: ExternalProject step targets fully adopt their + steps. Run "cmake --help-policy CMP0114" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + ExternalProject target 'FOO' would depend on the targets for step\(s\) + 'do_something' under policy CMP0114, but this is being left out for + compatibility since the policy is not set. +Call Stack \(most recent call first\): + Add_StepDependencies.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target-stderr.txt b/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target-stderr.txt new file mode 100644 index 0000000..2ae2b53 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target-stderr.txt @@ -0,0 +1,12 @@ +^CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set: ExternalProject step targets fully adopt their + steps. Run "cmake --help-policy CMP0114" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + ExternalProject target 'FOO' would depend on the targets for step\(s\) + 'do_something' under policy CMP0114, but this is being left out for + compatibility since the policy is not set. +Call Stack \(most recent call first\): + Add_StepDependencies_no_target.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep1-result.txt b/Tests/RunCMake/ExternalProject/BadIndependentStep1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep1-stderr.txt b/Tests/RunCMake/ExternalProject/BadIndependentStep1-stderr.txt new file mode 100644 index 0000000..3188910 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep1-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + ExternalProject 'proj' step 'custom' is marked INDEPENDENT but depends on + step 'configure' that is not marked INDEPENDENT. +Call Stack \(most recent call first\): + BadIndependentStep1.cmake:[0-9]+ \(ExternalProject_Add_Step\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep1.cmake b/Tests/RunCMake/ExternalProject/BadIndependentStep1.cmake new file mode 100644 index 0000000..c81eb07 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep1.cmake @@ -0,0 +1,14 @@ +include(ExternalProject) +cmake_policy(SET CMP0114 NEW) + +ExternalProject_Add(proj + SOURCE_DIR "." + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +ExternalProject_Add_Step(proj custom + DEPENDEES configure + INDEPENDENT 1 + ) diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep2-result.txt b/Tests/RunCMake/ExternalProject/BadIndependentStep2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep2-stderr.txt b/Tests/RunCMake/ExternalProject/BadIndependentStep2-stderr.txt new file mode 100644 index 0000000..0b87e5e --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep2-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + ExternalProject 'proj' step 'update' is marked INDEPENDENT but depends on + step 'custom' that is not marked INDEPENDENT. +Call Stack \(most recent call first\): + BadIndependentStep2.cmake:[0-9]+ \(ExternalProject_Add_Step\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep2.cmake b/Tests/RunCMake/ExternalProject/BadIndependentStep2.cmake new file mode 100644 index 0000000..4a530ea --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep2.cmake @@ -0,0 +1,13 @@ +include(ExternalProject) +cmake_policy(SET CMP0114 NEW) + +ExternalProject_Add(proj + SOURCE_DIR "." + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +ExternalProject_Add_Step(proj custom + DEPENDERS update + ) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-Common.cmake index 57626d6..176e28b 100644 --- a/Tests/RunCMake/ExternalProject/NO_DEPENDS.cmake +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-Common.cmake @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8.12) include(ExternalProject RESULT_VARIABLE GOO) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-result.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-stderr.txt new file mode 100644 index 0000000..c6bf767 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + The 'NO_DEPENDS' option is no longer allowed. It has been superseded by + the per-step 'INDEPENDENT' option. See policy CMP0114. +Call Stack \(most recent call first\): + NO_DEPENDS-CMP0114-NEW-Direct.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake new file mode 100644 index 0000000..7ec1a00 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake @@ -0,0 +1,4 @@ +cmake_policy(SET CMP0114 NEW) +include(ExternalProject) +ExternalProject_Add(BAR SOURCE_DIR . TEST_COMMAND echo test) +ExternalProject_Add_StepTargets(BAR NO_DEPENDS test) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-result.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-stderr.txt new file mode 100644 index 0000000..5a5ba89 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-stderr.txt @@ -0,0 +1,16 @@ +^CMake Error at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + ExternalProject 'FOO' option 'INDEPENDENT_STEP_TARGETS' is set to + + download;patch;update;configure;build + + but the option is no longer allowed. It has been superseded by the + per-step 'INDEPENDENT' option. See policy CMP0114. +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_mkdir_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-NEW.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW.cmake new file mode 100644 index 0000000..9622a60 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0114 NEW) +include(NO_DEPENDS-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD-stderr.txt new file mode 100644 index 0000000..2b0feb6 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD-stderr.txt @@ -0,0 +1,61 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "configure" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_configure_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-OLD.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "build" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_build_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-OLD.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "install" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_install_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-OLD.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "test" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + NO_DEPENDS-CMP0114-OLD.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD.cmake new file mode 100644 index 0000000..c20d443 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0114 OLD) +include(NO_DEPENDS-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN-stderr.txt new file mode 100644 index 0000000..bbf7178 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN-stderr.txt @@ -0,0 +1,119 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set: ExternalProject step targets fully adopt their + steps. Run "cmake --help-policy CMP0114" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + ExternalProject 'FOO' option INDEPENDENT_STEP_TARGETS is set to + + download;patch;update;configure;build + + but the option is deprecated in favor of policy CMP0114. +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_mkdir_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "configure" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_configure_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "build" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_build_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set: ExternalProject step targets fully adopt their + steps. Run "cmake --help-policy CMP0114" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + ExternalProject 'BAR' option INDEPENDENT_STEP_TARGETS is set to + + install + + but the option is deprecated in favor of policy CMP0114. +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_mkdir_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "install" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_install_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set: ExternalProject step targets fully adopt their + steps. Run "cmake --help-policy CMP0114" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + ExternalProject target 'BAR' would depend on the targets for step\(s\) + 'test;bar' under policy CMP0114, but this is being left out for + compatibility since the policy is not set. Also, the NO_DEPENDS option is + deprecated in favor of policy CMP0114. +Call Stack \(most recent call first\): + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "test" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN.cmake new file mode 100644 index 0000000..3d9642d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN.cmake @@ -0,0 +1,2 @@ +# Policy CMP0114 not set. +include(NO_DEPENDS-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt deleted file mode 100644 index 928d88a..0000000 --- a/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt +++ /dev/null @@ -1,36 +0,0 @@ -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): - Using NO_DEPENDS for "configure" step might break parallel builds -Call Stack \(most recent call first\): - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_configure_command\) - NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): - Using NO_DEPENDS for "build" step might break parallel builds -Call Stack \(most recent call first\): - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_build_command\) - NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): - Using NO_DEPENDS for "install" step might break parallel builds -Call Stack \(most recent call first\): - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_install_command\) - NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): - Using NO_DEPENDS for "test" step might break parallel builds -Call Stack \(most recent call first\): - NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index c2c77e0..1e88e0b 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -6,6 +6,8 @@ include(RunCMake) unset(ENV{http_proxy}) unset(ENV{https_proxy}) +run_cmake(BadIndependentStep1) +run_cmake(BadIndependentStep2) run_cmake(IncludeScope-Add) run_cmake(IncludeScope-Add_Step) run_cmake(NoOptions) @@ -14,13 +16,46 @@ run_cmake(SourceMissing) run_cmake(CMAKE_CACHE_ARGS) run_cmake(CMAKE_CACHE_DEFAULT_ARGS) run_cmake(CMAKE_CACHE_mix) -run_cmake(NO_DEPENDS) +run_cmake(NO_DEPENDS-CMP0114-WARN) +run_cmake(NO_DEPENDS-CMP0114-OLD) +run_cmake(NO_DEPENDS-CMP0114-NEW) +run_cmake(NO_DEPENDS-CMP0114-NEW-Direct) run_cmake(Add_StepDependencies) run_cmake(Add_StepDependencies_iface) run_cmake(Add_StepDependencies_iface_step) run_cmake(Add_StepDependencies_no_target) run_cmake(UsesTerminal) +macro(check_steps_missing proj) + set(steps "${ARGN}") + foreach(step ${steps}) + if(EXISTS ${RunCMake_TEST_BINARY_DIR}/${proj}-${step}-mark) + string(APPEND RunCMake_TEST_FAILED "${proj} '${step}' step ran but should not have\n") + endif() + endforeach() +endmacro() + +macro(check_steps_present proj) + set(steps "${ARGN}") + foreach(step ${steps}) + if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/${proj}-${step}-mark) + string(APPEND RunCMake_TEST_FAILED "${proj} '${step}' step did not run but should have\n") + endif() + endforeach() +endmacro() + +function(run_steps_CMP0114 val) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Steps-CMP0114-${val}-build) + run_cmake(Steps-CMP0114-${val}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Steps-CMP0114-${val}-build-download ${CMAKE_COMMAND} --build . --target proj1-download) + run_cmake_command(Steps-CMP0114-${val}-build-update ${CMAKE_COMMAND} --build . --target proj1-update) + run_cmake_command(Steps-CMP0114-${val}-build-install ${CMAKE_COMMAND} --build . --target proj1-install) + run_cmake_command(Steps-CMP0114-${val}-build-test ${CMAKE_COMMAND} --build . --target proj1-test) +endfunction() +run_steps_CMP0114(OLD) +run_steps_CMP0114(NEW) + # Run both cmake and build steps. We always do a clean before the # build to ensure that the download step re-runs each time. function(__ep_test_with_build testName) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-Common.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-Common.cmake new file mode 100644 index 0000000..210edb1 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-Common.cmake @@ -0,0 +1,34 @@ +include(ExternalProject) + +ExternalProject_Add(proj0 + SOURCE_DIR "." + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj0-download-mark + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj0-configure-mark + BUILD_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj0-build-mark + INSTALL_COMMAND "" + ) + +cmake_policy(GET CMP0114 cmp0114) +if(cmp0114 STREQUAL "NEW") + set(step_targets "update;test") + set(independent_step_targets "") +else() + set(step_targets "install;test") + set(independent_step_targets "download;update") +endif() + +ExternalProject_Add(proj1 + DEPENDS proj0 + SOURCE_DIR "." + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-download-mark + UPDATE_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-update-mark + PATCH_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-patch-mark + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-configure-mark + BUILD_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-build-mark + INSTALL_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-install-mark + TEST_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-test-mark + TEST_EXCLUDE_FROM_MAIN 1 # Along with 'STEP_TARGETS test', implies 'STEP_TARGETS install' + UPDATE_DISCONNECTED 1 # Along with 'STEP_TARGETS update', implies 'STEP_TARGETS download' + STEP_TARGETS ${step_targets} + INDEPENDENT_STEP_TARGETS ${independent_step_targets} + ) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-download-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-download-check.cmake new file mode 100644 index 0000000..1439f02 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-download-check.cmake @@ -0,0 +1,3 @@ +check_steps_missing(proj0 download configure build) +check_steps_present(proj1 download) +check_steps_missing(proj1 update patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-install-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-install-check.cmake new file mode 100644 index 0000000..c1c9c8f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-install-check.cmake @@ -0,0 +1,3 @@ +check_steps_present(proj0 download configure build) +check_steps_present(proj1 download patch configure build install) +check_steps_missing(proj1 test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-test-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-test-check.cmake new file mode 100644 index 0000000..fe256f2 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-test-check.cmake @@ -0,0 +1,2 @@ +check_steps_present(proj0 download configure build) +check_steps_present(proj1 download patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-update-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-update-check.cmake new file mode 100644 index 0000000..63e2e1d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-update-check.cmake @@ -0,0 +1,3 @@ +check_steps_missing(proj0 download configure build) +check_steps_present(proj1 download update) +check_steps_missing(proj1 patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW.cmake new file mode 100644 index 0000000..9d8e99e --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0114 NEW) +include(Steps-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-download-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-download-check.cmake new file mode 100644 index 0000000..1439f02 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-download-check.cmake @@ -0,0 +1,3 @@ +check_steps_missing(proj0 download configure build) +check_steps_present(proj1 download) +check_steps_missing(proj1 update patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-install-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-install-check.cmake new file mode 100644 index 0000000..c1c9c8f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-install-check.cmake @@ -0,0 +1,3 @@ +check_steps_present(proj0 download configure build) +check_steps_present(proj1 download patch configure build install) +check_steps_missing(proj1 test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-test-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-test-check.cmake new file mode 100644 index 0000000..fe256f2 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-test-check.cmake @@ -0,0 +1,2 @@ +check_steps_present(proj0 download configure build) +check_steps_present(proj1 download patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-update-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-update-check.cmake new file mode 100644 index 0000000..63e2e1d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-update-check.cmake @@ -0,0 +1,3 @@ +check_steps_missing(proj0 download configure build) +check_steps_present(proj1 download update) +check_steps_missing(proj1 patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD.cmake new file mode 100644 index 0000000..0b51ad8 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0114 OLD) +include(Steps-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates-check.cmake new file mode 100644 index 0000000..81449ca --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates-check.cmake @@ -0,0 +1,17 @@ +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/compile_commands.json empty_dir_commands + REGEX "command.*-fpch-instantiate-templates.*empty.dir/cmake_pch[A-Za-z0-9_.]*.h") +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/compile_commands.json foo_dir_commands + REGEX "command.*-fpch-instantiate-templates.*foo.dir/cmake_pch[A-Za-z0-9_.]*.h") + +list(LENGTH empty_dir_commands empty_dir_commands_size) +list(LENGTH foo_dir_commands foo_dir_commands_size) + +if (empty_dir_commands_size EQUAL 0) + set(RunCMake_TEST_FAILED "empty target should have -fpch-instantiate-templates compile option present") + return() +endif() + +if (foo_dir_commands_size GREATER 0) + set(RunCMake_TEST_FAILED "foo target should not have -fpch-instantiate-templates compile option present") + return() +endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates.cmake b/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates.cmake new file mode 100644 index 0000000..3aebbe0 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates.cmake @@ -0,0 +1,16 @@ +enable_language(C) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +add_library(empty empty.c) +target_precompile_headers(empty PUBLIC + <stdio.h> + <string.h> +) + +add_library(foo foo.c) +target_precompile_headers(foo PUBLIC + <stdio.h> + <string.h> +) +set_target_properties(foo PROPERTIES PCH_INSTANTIATE_TEMPLATES OFF) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index 381b800..74670ba 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -20,4 +20,9 @@ run_test(PchReuseFromSubdir) run_cmake(PchMultilanguage) if(RunCMake_GENERATOR MATCHES "Make|Ninja") run_cmake(PchWarnInvalid) + + if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0.0) + run_cmake(PchInstantiateTemplates) + endif() endif() diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 22a3d5a..b739ae2 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -21,6 +21,11 @@ if(CMAKE_DOC_TARBALL) add_custom_target(documentation ALL DEPENDS ${dir}.stamp) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dir}/ DESTINATION . USE_SOURCE_PERMISSIONS) +elseif (CMake_DOC_ARTIFACT_PREFIX) + # Undocumented option for CI usage to reuse already + # built documentation. + install(DIRECTORY ${CMake_DOC_ARTIFACT_PREFIX}/ + DESTINATION . USE_SOURCE_PERMISSIONS) else() # Normal documentation build. add_subdirectory(Sphinx) diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index 88ac826..562df91 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -45,10 +45,8 @@ echo 'Failed to create \${name}.tar.gz' endfunction() write_docs_shell_script("create-${CMAKE_CREATE_VERSION}-docs.sh") -write_rel_shell_script("create-${CMAKE_CREATE_VERSION}-macos.sh" osx_release ) # macOS x86_64 message("Build docs first and then build for each platform: ./create-${CMAKE_CREATE_VERSION}-docs.sh && - ./create-${CMAKE_CREATE_VERSION}-macos.sh && echo done ") diff --git a/Utilities/Release/osx_release.cmake b/Utilities/Release/osx_release.cmake deleted file mode 100644 index 5ef3003..0000000 --- a/Utilities/Release/osx_release.cmake +++ /dev/null @@ -1,34 +0,0 @@ -set(PROCESSORS 4) -set(CMAKE_RELEASE_DIRECTORY /Users/kitware/CMakeReleaseDirectory) -set(BOOTSTRAP_ARGS "--prefix=/ --docdir=doc/cmake") -set(HOST dragnipur) -set(MAKE_PROGRAM "make") -set(MAKE "${MAKE_PROGRAM} -j5") -set(CPACK_BINARY_GENERATORS "DragNDrop TGZ") -set(CPACK_SOURCE_GENERATORS "") -set(CPACK_DMG_FORMAT "UDBZ") #build using bzip2 for smaller package size -set(CC clang) -set(CXX clang++) -set(CFLAGS "") -set(CXXFLAGS "-stdlib=libc++") -set(INITIAL_CACHE " -CMAKE_BUILD_TYPE:STRING=Release -CMAKE_C_STANDARD:STRING=11 -CMAKE_CXX_STANDARD:STRING=14 -CMAKE_OSX_ARCHITECTURES:STRING=x86_64 -CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7 -CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE -CPACK_SYSTEM_NAME:STRING=Darwin-x86_64 -BUILD_CursesDialog:BOOL=ON -BUILD_QtDialog:BOOL=TRUE -CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:STRING=3 -CMake_INSTALL_DEPENDENCIES:BOOL=ON -CMAKE_SKIP_RPATH:BOOL=TRUE -CMake_TEST_NO_FindPackageModeMakefileTest:BOOL=TRUE -") -set(ENV [[ -export CMAKE_PREFIX_PATH='/Users/kitware/SDKs/qt-5.6.2-clang-x64' -]]) -set(SIGN "") -get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) -include(${path}/release_cmake.cmake) |