diff options
184 files changed, 2096 insertions, 477 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09afcb3..44ea456 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,7 @@ stages: - build - test - test-ext + - package - upload ################################################################################ @@ -36,6 +37,7 @@ stages: # Job prefixes: # - `b:` build +# - `k:` package # - `l:` lint # - `p:` prep # - `t:` test @@ -530,6 +532,13 @@ t:intel2021.5.0-makefiles: CMAKE_CI_BUILD_NAME: intel2021.5.0_makefiles CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2022.0.2-el8 +t:intel2021.6.0-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2021.6.0_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2022.1.0-el8 + t:oneapi2021.1.1-makefiles: extends: - .cmake_test_linux_inteloneapi_makefiles @@ -572,6 +581,13 @@ t:oneapi2022.0.2-makefiles: CMAKE_CI_BUILD_NAME: oneapi2022.0.2_makefiles CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2022.0.2-el8 +t:oneapi2022.1.0-makefiles: + extends: + - .cmake_test_linux_inteloneapi_makefiles + variables: + CMAKE_CI_BUILD_NAME: oneapi2022.1.0_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2022.1.0-el8 + b:linux-x86_64-package: extends: - .linux_package @@ -969,3 +985,69 @@ t:windows-openwatcom1.9: - t:windows-vs2022-x64-ninja variables: CMAKE_CI_JOB_NIGHTLY: "true" + +b:windows-x86_64-package: + extends: + - .windows_x86_64_package + - .cmake_build_windows + - .cmake_build_package_artifacts + - .windows_tags_nonconcurrent_vs2022 + - .run_only_for_package + dependencies: + - p:doc-package + needs: + - p:doc-package + +k:windows-x86_64-package: + extends: + - .windows_x86_64_package + - .cmake_package_windows + - .cmake_release_artifacts + - .windows_tags_nonconcurrent_vs2022 + - .run_only_for_package + dependencies: + - b:windows-x86_64-package + needs: + - b:windows-x86_64-package + +u:windows-x86_64-package: + extends: + - .rsync_upload_package + - .run_only_for_package + dependencies: + - k:windows-x86_64-package + needs: + - k:windows-x86_64-package + +b:windows-i386-package: + extends: + - .windows_i386_package + - .cmake_build_windows + - .cmake_build_package_artifacts + - .windows_tags_nonconcurrent_vs2022 + - .run_only_for_package + dependencies: + - p:doc-package + needs: + - p:doc-package + +k:windows-i386-package: + extends: + - .windows_i386_package + - .cmake_package_windows + - .cmake_release_artifacts + - .windows_tags_nonconcurrent_vs2022 + - .run_only_for_package + dependencies: + - b:windows-i386-package + needs: + - b:windows-i386-package + +u:windows-i386-package: + extends: + - .rsync_upload_package + - .run_only_for_package + dependencies: + - k:windows-i386-package + needs: + - k:windows-i386-package diff --git a/.gitlab/artifacts.yml b/.gitlab/artifacts.yml index 5472c0a..57ae573 100644 --- a/.gitlab/artifacts.yml +++ b/.gitlab/artifacts.yml @@ -4,13 +4,8 @@ artifacts: expire_in: 1d paths: - # XXX(globbing): Can be simplified with support from - # https://gitlab.com/gitlab-org/gitlab-runner/issues/4840 - - build/CTestTestfile.cmake - - build/*/CTestTestfile.cmake - - build/*/*/CTestTestfile.cmake - - build/*/*/*/CTestTestfile.cmake - - build/*/*/*/*/CTestTestfile.cmake + # Test specifications. + - build/**/CTestTestfile.cmake # Allow CMake to find CMAKE_ROOT. - build/CMakeFiles/CMakeSourceDir.txt @@ -68,6 +63,34 @@ - build/DartConfiguation.tcl - build/CTestCustom.cmake +.cmake_build_package_artifacts: + artifacts: + expire_in: 1d + paths: + # Allow CPack to find CMAKE_ROOT. + - build/CMakeFiles/CMakeSourceDir.txt + + # Install rules. + - build/**/cmake_install.cmake + + # We need the main binaries. + - build/bin/ + + # Pass through the documentation. + - build/install-doc/ + + # CPack configuration. + - build/CPackConfig.cmake + - build/CMakeCPackOptions.cmake + - build/Source/QtDialog/QtDialogCPack.cmake + + # CPack/IFW packaging files. + - build/CMake*.qs + + # CPack/WIX packaging files. + - build/Utilities/Release/WiX/custom_action_dll*.wxs + - build/Utilities/Release/WiX/CustomAction/CMakeWiXCustomActions.* + .cmake_release_artifacts: artifacts: expire_in: 5d @@ -78,6 +101,8 @@ - build/cmake-*-linux-x86_64.* - build/cmake-*-linux-aarch64.* - build/cmake-*-macos*-universal.* + - build/cmake-*-windows-x86_64.* + - build/cmake-*-windows-i386.* # Any source packages made. - build/cmake-*.tar.gz - build/cmake-*.zip diff --git a/.gitlab/ci/configure_windows_i386_package.cmake b/.gitlab/ci/configure_windows_i386_package.cmake new file mode 100644 index 0000000..279f5cf --- /dev/null +++ b/.gitlab/ci/configure_windows_i386_package.cmake @@ -0,0 +1,9 @@ +# CPack package file name component for this platform. +set(CPACK_SYSTEM_NAME "windows-i386" CACHE STRING "") + +# Use APIs from at most Windows 7 +set(CMAKE_C_FLAGS "-D_WIN32_WINNT=0x601 -DNTDDI_VERSION=0x06010000" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-GR -EHsc -D_WIN32_WINNT=0x601 -DNTDDI_VERSION=0x06010000" CACHE STRING "") +set(CMAKE_EXE_LINKER_FLAGS "-machine:x86 -subsystem:console,6.01" CACHE STRING "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_package_common.cmake") diff --git a/.gitlab/ci/configure_windows_package_common.cmake b/.gitlab/ci/configure_windows_package_common.cmake new file mode 100644 index 0000000..cea0ba0 --- /dev/null +++ b/.gitlab/ci/configure_windows_package_common.cmake @@ -0,0 +1,35 @@ +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_DOC_DIR "doc/cmake" CACHE STRING "") + +# Link C/C++ runtime library statically. +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "") + +# Enable cmake-gui with static qt plugins +set(BUILD_QtDialog "TRUE" CACHE BOOL "") +set(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL "3" CACHE STRING "") +set(qt "$ENV{CI_PROJECT_DIR}/.gitlab/qt") +set(CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES + ${qt}/plugins/platforms/qwindows.lib + ${qt}/plugins/styles/qwindowsvistastyle.lib + ${qt}/lib/Qt5EventDispatcherSupport.lib + ${qt}/lib/Qt5FontDatabaseSupport.lib + ${qt}/lib/Qt5ThemeSupport.lib + ${qt}/lib/qtfreetype.lib + ${qt}/lib/qtlibpng.lib + imm32.lib + wtsapi32.lib + CACHE STRING "") +set(CMAKE_PREFIX_PATH "${qt}" CACHE STRING "") + +# Disable ccmake. +set(BUILD_CursesDialog "OFF" CACHE BOOL "") + +set(CMAKE_SKIP_BOOTSTRAP_TEST "TRUE" CACHE STRING "") +set(CMake_TEST_Java OFF CACHE BOOL "") +set(CMake_TEST_Qt5 OFF CACHE BOOL "") +set(CMake_TEST_Qt6 OFF CACHE BOOL "") +set(Python_FIND_REGISTRY NEVER CACHE STRING "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_windows_x86_64_package.cmake b/.gitlab/ci/configure_windows_x86_64_package.cmake new file mode 100644 index 0000000..b7bba85 --- /dev/null +++ b/.gitlab/ci/configure_windows_x86_64_package.cmake @@ -0,0 +1,9 @@ +# CPack package file name component for this platform. +set(CPACK_SYSTEM_NAME "windows-x86_64" CACHE STRING "") + +# Use APIs from at most Windows 7 +set(CMAKE_C_FLAGS "-D_WIN32_WINNT=0x601 -DNTDDI_VERSION=0x06010000" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-GR -EHsc -D_WIN32_WINNT=0x601 -DNTDDI_VERSION=0x06010000" CACHE STRING "") +set(CMAKE_EXE_LINKER_FLAGS "-machine:x64 -subsystem:console,6.01" CACHE STRING "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_package_common.cmake") diff --git a/.gitlab/ci/download_qt.cmake b/.gitlab/ci/download_qt.cmake index 5940a28..90c2187 100644 --- a/.gitlab/ci/download_qt.cmake +++ b/.gitlab/ci/download_qt.cmake @@ -11,7 +11,19 @@ set(qt_version_nodot "${qt_version_major}${qt_version_minor}${qt_version_patch}" # Files needed to download. set(qt_files) -if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "windows") +if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "windows.*package") + if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "windows_x86_64_package") + list(APPEND qt_files "qt-5.12.1-win-x86_64-msvc_v142-1.zip") + set(qt_subdir "qt-5.12.1-win-x86_64-msvc_v142-1") + elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "windows_i386_package") + list(APPEND qt_files "qt-5.12.1-win-i386-msvc_v142-1.zip") + set(qt_subdir "qt-5.12.1-win-i386-msvc_v142-1") + else () + message(FATAL_ERROR "Unknown arch to use for Qt") + endif() + set(qt_url_root "https://cmake.org/files/dependencies") + set(qt_url_path "") +elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "windows") # Determine the ABI to fetch for Qt. if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "vs2015") set(qt_platform "windows_x86") diff --git a/.gitlab/ci/download_qt_hashes.cmake b/.gitlab/ci/download_qt_hashes.cmake index afbc081..d19d284 100644 --- a/.gitlab/ci/download_qt_hashes.cmake +++ b/.gitlab/ci/download_qt_hashes.cmake @@ -12,3 +12,6 @@ set("5.15.1-0-202009071110qtbase-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_6 set("qt-5.9.9-macosx10.10-x86_64-arm64.tar.xz_hash" d4449771afa0bc6a809c14f1e6d939e7732494cf059503ae451e2bfe8fc60cc1) set("qt-5.15.2-macosx10.13-x86_64-arm64.tar.xz_hash" 7b9463a01c8beeee5bf8d01c70deff2d08561cd20aaf6f7a2f41cf8b68ce8a6b) + +set("qt-5.12.1-win-i386-msvc_v142-1.zip_hash" aa78711fdaa5d9b146bf7ddcf15983f9fbb3f995462f2d043f8cca74b40ddd11) +set("qt-5.12.1-win-x86_64-msvc_v142-1.zip_hash" c2fc068b9dac40bb420e28e1ee15ce4f2ccfc866d767f3b99b6bb435b7c4f44b) diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index 3532765..e5febbe 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -35,7 +35,13 @@ variables: VCVARSALL: "${VS170COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat" VCVARSPLATFORM: "x64" - VCVARSVERSION: "14.31.31103" + VCVARSVERSION: "14.32.31326" + +.windows_vcvarsall_vs2022_x86: + variables: + VCVARSALL: "${VS170COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat" + VCVARSPLATFORM: "x86" + VCVARSVERSION: "14.32.31326" .windows_vs2022_x64_ninja: extends: @@ -45,6 +51,30 @@ variables: CMAKE_CONFIGURATION: windows_vs2022_x64_ninja +.windows_package: + extends: + - .windows_build_ninja + + variables: + CMAKE_CI_BUILD_TYPE: Release + CMAKE_CI_NO_INSTALL: 1 + +.windows_x86_64_package: + extends: + - .windows_package + - .windows_vcvarsall_vs2022_x64 + + variables: + CMAKE_CONFIGURATION: windows_x86_64_package + +.windows_i386_package: + extends: + - .windows_package + - .windows_vcvarsall_vs2022_x86 + + variables: + CMAKE_CONFIGURATION: windows_i386_package + ### External testing .windows_vs2022_x64: @@ -54,7 +84,7 @@ CMAKE_CONFIGURATION: windows_vs2022_x64 CMAKE_GENERATOR: "Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM: "x64" - CMAKE_GENERATOR_TOOLSET: "v143,version=14.31.31103" + CMAKE_GENERATOR_TOOLSET: "v143,version=14.32.31326" CMAKE_CI_NIGHTLY_IGNORE_DEPS: "true" .windows_vs2019_x64: @@ -173,7 +203,7 @@ - windows - shell - vs2022 - - msvc-19.31 + - msvc-19.32 - nonconcurrent .windows_tags_concurrent_vs2022: @@ -182,7 +212,7 @@ - windows - shell - vs2022 - - msvc-19.31 + - msvc-19.32 - concurrent .windows_tags_concurrent_vs2019: @@ -236,6 +266,18 @@ interruptible: true +.cmake_package_windows: + stage: package + + script: + - *before_script_windows + - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 + - cd build + - cpack -G ZIP + - cpack -G WIX + + interruptible: true + .cmake_test_windows: stage: test diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml index 8efa304..8fc40a7f 100644 --- a/.gitlab/rules.yml +++ b/.gitlab/rules.yml @@ -70,7 +70,7 @@ when: on_success - if: '$CMAKE_CI_PACKAGE != null && $CI_JOB_STAGE == "prep"' when: manual - - if: '$CMAKE_CI_PACKAGE != null && $CI_JOB_STAGE != "upload"' + - if: '$CMAKE_CI_PACKAGE != null && $CI_JOB_STAGE != "package" && $CI_JOB_STAGE != "upload"' when: on_success - when: never diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in index 81dfeee..f354362 100644 --- a/CMakeCPackOptions.cmake.in +++ b/CMakeCPackOptions.cmake.in @@ -248,6 +248,13 @@ if("${CPACK_GENERATOR}" STREQUAL "WIX") set(CPACK_WIX_LIGHT_EXTRA_FLAGS "-dcl:high") + if(NOT "$ENV{CMAKE_CI_PACKAGE}" STREQUAL "") + # Suppress validation. It does not work without + # an interactive session or an admin account. + # https://github.com/wixtoolset/issues/issues/3968 + list(APPEND CPACK_WIX_LIGHT_EXTRA_FLAGS "-sval") + endif() + set(CPACK_WIX_UI_BANNER "@CMake_SOURCE_DIR@/Utilities/Release/WiX/ui_banner.jpg" ) diff --git a/Copyright.txt b/Copyright.txt index 4b6a7f5..2cf1769 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -78,6 +78,7 @@ The following individuals and institutions are among the Contributors: * Michael Hirsch, Ph.D. <www.scivision.co> * Michael Stürmer * Miguel A. Figueroa-Villanueva +* Mike Durso <rbprogrammer@gmail.com> * Mike Jackson * Mike McQuaid <mike@mikemcquaid.com> * Nicolas Bock <nicolasbock@gmail.com> diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt index ab5f860..6683edb 100644 --- a/Help/command/FIND_XXX.txt +++ b/Help/command/FIND_XXX.txt @@ -54,10 +54,8 @@ Options include: .. versionchanged:: 3.24 On ``Windows`` platform, it is possible to include registry queries as part - of the directories. Such specifications will be ignored on all other - platforms. - - .. include:: FIND_XXX_REGISTRY_QUERY.txt + of the directories, using a :ref:`dedicated syntax <Find Using Windows Registry>`. + Such specifications will be ignored on all other platforms. ``REGISTRY_VIEW`` .. versionadded:: 3.24 diff --git a/Help/command/FIND_XXX_REGISTRY_QUERY.txt b/Help/command/FIND_XXX_REGISTRY_QUERY.txt deleted file mode 100644 index 04a087a..0000000 --- a/Help/command/FIND_XXX_REGISTRY_QUERY.txt +++ /dev/null @@ -1,43 +0,0 @@ -The formal syntax, as specified using -`BNF <https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form>`_ notation with -the regular extensions, for registry query is the following: - -.. parsed-literal:: - - registry_query ::= '[' `sep_definition`_? `root_key`_ - ((`key_separator`_ `sub_key`_)? (`value_separator`_ `value_name`_)?)? ']' - _`sep_definition` ::= '{' `value_separator`_ '}' - _`root_key` ::= 'HKLM' | 'HKEY_LOCAL_MACHINE' | 'HKCU' | 'HKEY_CURRENT_USER' | - 'HKCR' | 'HKEY_CLASSES_ROOT' | 'HKCC' | 'HKEY_CURRENT_CONFIG' | - 'HKU' | 'HKEY_USERS' - _`sub_key` ::= `element`_ (`key_separator`_ `element`_)* - _`key_separator` ::= '/' | '\\' - _`value_separator` ::= `element`_ | ';' - _`value_name` ::= `element`_ | '(default)' - _`element` ::= `character`_\+ - _`character` ::= <any character except `key_separator`_ and `value_separator`_> - -The `sep_definition`_ optional item offers the possibility to specify the -string used to separate the `sub_key`_ from the `value_name`_ item. If -not specified, the character ``;`` is used. - -.. parsed-literal:: - - # example using default separator - |FIND_XXX| (... **PATHS** "/root/[HKLM/Stuff;InstallDir]/lib[HKLM\\\\Stuff;Architecture]") - - # example using different specified separators - |FIND_XXX| (... **HINTS** "/root/[{|}HKCU/Stuff|InstallDir]/lib[{@@}HKCU\\\\Stuff@@Architecture]") - -If the `value_name`_ item is not specified or has the special name -``(default)``, the content of the default value, if any, will be returned. The -supported types for the `value_name`_ are: - -* ``REG_SZ``. -* ``REG_EXPAND_SZ``. The returned data is expanded. -* ``REG_DWORD``. -* ``REG_QWORD``. - -When the registry query failed, typically because the key does not exist or -the data type is not supported, the string ``/REGISTRY-NOTFOUND`` is substituted -to the ``[]`` query expression. diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 8ce6529..a7d7d00 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -309,10 +309,9 @@ that order). .. versionchanged:: 3.24 On ``Windows`` platform, it is possible to include registry queries as part - of the directories specified through ``HINTS`` and ``PATHS`` keywords. Such - specifications will be ignored on all other platforms. - -.. include:: FIND_XXX_REGISTRY_QUERY.txt + of the directories specified through ``HINTS`` and ``PATHS`` keywords, using + a :ref:`dedicated syntax <Find Using Windows Registry>`. Such specifications + will be ignored on all other platforms. .. versionadded:: 3.24 ``REGISTRY_VIEW`` can be specified to manage ``Windows`` registry queries diff --git a/Help/command/install.rst b/Help/command/install.rst index 1a9dfd7..973aa31 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -85,7 +85,7 @@ signatures that specify them. The common options are: ``COMPONENT`` Specify an installation component name with which the install rule - is associated, such as "runtime" or "development". During + is associated, such as ``Runtime`` or ``Development``. During component-specific installation only install rules associated with the given component name will be executed. During a full installation all components are installed unless marked with ``EXCLUDE_FROM_ALL``. diff --git a/Help/command/project.rst b/Help/command/project.rst index 2a9dcfe..8f32fa3 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -123,28 +123,56 @@ The options are: The variables set through the ``VERSION``, ``DESCRIPTION`` and ``HOMEPAGE_URL`` options are intended for use as default values in package metadata and documentation. +.. _`Code Injection`: + Code Injection ^^^^^^^^^^^^^^ -If the :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` or -:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE` variables are set, -the files they point to will be included as the first step of the -``project()`` command. -If both are set, then :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` will be -included before :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE`. - -If the :variable:`CMAKE_PROJECT_INCLUDE` or -:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` variables are set, the files -they point to will be included as the last step of the ``project()`` command. -If both are set, then :variable:`CMAKE_PROJECT_INCLUDE` will be included before -:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`. - -.. versionadded:: 3.15 - Added the ``CMAKE_PROJECT_INCLUDE`` and ``CMAKE_PROJECT_INCLUDE_BEFORE`` - variables. - -.. versionadded:: 3.17 - Added the ``CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE`` variable. +A number of variables can be defined by the user to specify files to include +at different points during the execution of the ``project()`` command. +The following outlines the steps performed during a ``project()`` call: + +* .. versionadded:: 3.15 + For every ``project()`` call regardless of the project + name, include the file named by :variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, + if set. + +* .. versionadded:: 3.17 + If the ``project()`` command specifies ``<PROJECT-NAME>`` as its project + name, include the file named by + :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE`, if set. + +* Set the various project-specific variables detailed in the `Synopsis`_ + and `Options`_ sections above. + +* For the very first ``project()`` call only: + + * If :variable:`CMAKE_TOOLCHAIN_FILE` is set, read it at least once. + It may be read multiple times and it may also be read again when + enabling languages later (see below). + + * Set the variables describing the host and target platforms. + Language-specific variables might or might not be set at this point. + On the first run, the only language-specific variables that might be + defined are those a toolchain file may have set. On subsequent runs, + language-specific variables cached from a previous run may be set. + + * .. versionadded:: 3.24 + Include each file listed in :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES`, + if set. The variable is ignored by CMake thereafter. + +* Enable any languages specified in the call, or the default languages if + none were provided. The toolchain file may be re-read when enabling a + language for the first time. + +* .. versionadded:: 3.15 + For every ``project()`` call regardless of the project + name, include the file named by :variable:`CMAKE_PROJECT_INCLUDE`, + if set. + +* If the ``project()`` command specifies ``<PROJECT-NAME>`` as its project + name, include the file named by + :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`, if set. Usage ^^^^^ diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 4b2a631..806a98d 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -7,6 +7,8 @@ try_compile Try building some code. +.. _`Try Compiling Whole Projects`: + Try Compiling Whole Projects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,6 +27,15 @@ will not be deleted after this command is run. Specify ``<targetName>`` to build a specific target instead of the ``all`` or ``ALL_BUILD`` target. See below for the meaning of other options. +.. versionchanged:: 3.24 + CMake variables describing platform settings, and those listed by the + :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable, are propagated + into the project's build configuration. See policy :policy:`CMP0137`. + Previously this was only done by the + :ref:`source file <Try Compiling Source Files>` signature. + +.. _`Try Compiling Source Files`: + Try Compiling Source Files ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,3 +216,7 @@ a build configuration. .. versionchanged:: 3.14 For the :generator:`Green Hills MULTI` generator the GHS toolset and target system customization cache variables are also propagated into the test project. + +.. versionadded:: 3.24 + The :variable:`CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES` variable may be + set to disable passing platform variables into the test project. diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index fe146de..2c6cd96 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -242,6 +242,69 @@ backwards compatibility for any old names that were actually in use. Make sure you comment them as deprecated, so that no-one starts using them. +.. _`Find Using Windows Registry`: + +Find Using Windows Registry +--------------------------- + +.. versionchanged:: 3.24 + +Options ``HINTS`` and ``PATHS`` of :command:`find_file`, +:command:`find_library`, :command:`find_path`, :command:`find_program`, and +:command:`find_package` commands offer the possibility, on ``Windows`` +platform, to query the registry. + +The formal syntax, as specified using +`BNF <https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form>`_ notation with +the regular extensions, for registry query is the following: + +.. raw:: latex + + \begin{small} + +.. productionlist:: + registry_query: '[' `sep_definition`? `root_key` + : ((`key_separator` `sub_key`)? (`value_separator` `value_name`_)?)? ']' + sep_definition: '{' `value_separator` '}' + root_key: 'HKLM' | 'HKEY_LOCAL_MACHINE' | 'HKCU' | 'HKEY_CURRENT_USER' | + : 'HKCR' | 'HKEY_CLASSES_ROOT' | 'HKCC' | 'HKEY_CURRENT_CONFIG' | + : 'HKU' | 'HKEY_USERS' + sub_key: `element` (`key_separator` `element`)* + key_separator: '/' | '\\' + value_separator: `element` | ';' + value_name: `element` | '(default)' + element: `character`\+ + character: <any character except `key_separator` and `value_separator`> + +.. raw:: latex + + \end{small} + +The :token:`sep_definition` optional item offers the possibility to specify +the string used to separate the :token:`sub_key` from the :token:`value_name` +item. If not specified, the character ``;`` is used. Multiple +:token:`registry_query` items can be specified as part of a path. + +.. code-block:: cmake + + # example using default separator + find_file(... PATHS "/root/[HKLM/Stuff;InstallDir]/lib[HKLM\\\\Stuff;Architecture]") + + # example using different specified separators + find_library(... HINTS "/root/[{|}HKCU/Stuff|InstallDir]/lib[{@@}HKCU\\\\Stuff@@Architecture]") + +If the :token:`value_name` item is not specified or has the special name +``(default)``, the content of the default value, if any, will be returned. The +supported types for the :token:`value_name` are: + +* ``REG_SZ``. +* ``REG_EXPAND_SZ``. The returned data is expanded. +* ``REG_DWORD``. +* ``REG_QWORD``. + +When the registry query failed, typically because the key does not exist or +the data type is not supported, the string ``/REGISTRY-NOTFOUND`` is substituted +to the ``[]`` query expression. A Sample Find Module -------------------- diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 259cebb..788d086 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -58,6 +58,7 @@ Policies Introduced by CMake 3.24 .. toctree:: :maxdepth: 1 + CMP0137: try_compile() passes platform variables in project mode. </policy/CMP0137> CMP0136: Watcom runtime library flags are selected by an abstraction. </policy/CMP0136> CMP0135: ExternalProject ignores timestamps in archives by default for the URL download method. </policy/CMP0135> CMP0134: Fallback to \"HOST\" Windows registry view when \"TARGET\" view is not usable. </policy/CMP0134> diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index c8d24f2..948d87a 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -1068,6 +1068,17 @@ Recognized macros include: A literal dollar sign (``$``). +``${pathListSep}`` + + Native character for separating lists of paths, such as ``:`` or ``;``. + + For example, by setting ``PATH`` to + ``/path/to/ninja/bin${pathListSep}$env{PATH}``, ``${pathListSep}`` will + expand to the underlying operating system's character used for + concatenation in ``PATH``. + + This is allowed in preset files specifying version ``5`` or above. + ``$env{<variable-name>}`` Environment variable with name ``<variable-name>``. The variable name may diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 20b62c5..7935ca3 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -381,7 +381,7 @@ Properties on Targets /prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE /prop_tgt/UNITY_BUILD_MODE /prop_tgt/UNITY_BUILD_UNIQUE_ID - /prop_tgt/VERIFY_HEADER_SETS + /prop_tgt/VERIFY_INTERFACE_HEADER_SETS /prop_tgt/VERSION /prop_tgt/VISIBILITY_INLINES_HIDDEN /prop_tgt/VS_CONFIGURATION_TYPE diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 80160b6..9fbb146 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -243,6 +243,7 @@ Variables that Change Behavior /variable/CMAKE_PROJECT_INCLUDE_BEFORE /variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE /variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE + /variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES /variable/CMAKE_REQUIRE_FIND_PACKAGE_PackageName /variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY /variable/CMAKE_STAGING_PREFIX @@ -502,13 +503,14 @@ Variables that Control the Build /variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG_INIT /variable/CMAKE_STATIC_LINKER_FLAGS_INIT /variable/CMAKE_TRY_COMPILE_CONFIGURATION + /variable/CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES /variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES /variable/CMAKE_TRY_COMPILE_TARGET_TYPE /variable/CMAKE_UNITY_BUILD /variable/CMAKE_UNITY_BUILD_BATCH_SIZE /variable/CMAKE_UNITY_BUILD_UNIQUE_ID /variable/CMAKE_USE_RELATIVE_PATHS - /variable/CMAKE_VERIFY_HEADER_SETS + /variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS /variable/CMAKE_VISIBILITY_INLINES_HIDDEN /variable/CMAKE_VS_GLOBALS /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index e0cb708..38105dd 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -426,6 +426,11 @@ Options in :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR`. This flag tells CMake to warn about other files as well. +``--compile-no-warning-as-error`` + Ignore target property :prop_tgt:`COMPILE_WARNING_AS_ERROR` and variable + :variable:`CMAKE_COMPILE_WARNING_AS_ERROR`, preventing warnings from being + treated as errors on compile. + ``--profiling-output=<path>`` Used in conjunction with ``--profiling-format`` to output to a given path. diff --git a/Help/policy/CMP0137.rst b/Help/policy/CMP0137.rst new file mode 100644 index 0000000..ba3cb9c --- /dev/null +++ b/Help/policy/CMP0137.rst @@ -0,0 +1,33 @@ +CMP0137 +------- + +.. versionadded:: 3.24 + +:command:`try_compile` passes platform variables in project mode. + +The :command:`try_compile` command :ref:`source file <Try Compiling Source +Files>` signature propagates CMake variables containing platform settings, +and those specified by the :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` +variable, into the generated test project. This helps the test project drive +the toolchain the same way the calling project will. In CMake 3.23 and below, +the :ref:`whole-project <Try Compiling Whole Projects>` signature does not +propagate platform variables automatically. CMake 3.24 and above prefer to +propagate platform variables in the :ref:`whole-project <Try Compiling Whole +Projects>` signature. This policy provides compatibility with projects that +have not been updated to expect the behavior. + +The ``OLD`` behavior for this policy is to not pass any additional variables to +the :ref:`whole-project <Try Compiling Whole Projects>` signature. +The ``NEW`` behavior for this policy is to pass the same variables that the +:ref:`source file <Try Compiling Source Files>` signature does. + +Regardless of the policy setting, the +:variable:`CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES` variable may be set +to suppress passing the platform variables through either signature. + +This policy was introduced in CMake version 3.24. Use the +:command:`cmake_policy` command to set this policy to ``OLD`` or ``NEW`` +explicitly. Unlike many policies, CMake version |release| does *not* warn +by default when this policy is not set and simply uses ``OLD`` behavior. + +.. include:: DEPRECATED.txt diff --git a/Help/prop_tgt/VERIFY_HEADER_SETS.rst b/Help/prop_tgt/VERIFY_HEADER_SETS.rst deleted file mode 100644 index e151017..0000000 --- a/Help/prop_tgt/VERIFY_HEADER_SETS.rst +++ /dev/null @@ -1,25 +0,0 @@ -VERIFY_HEADER_SETS ------------------- - -.. versionadded:: 3.24 - -Used to verify that all headers in a target's header sets can be included on -their own. - -When this property is set to true, and the target is an object library, static -library, shared library, or executable with exports enabled, and the target -has one or more ``PUBLIC`` or ``INTERFACE`` header sets, an object library -target named ``<target_name>_verify_header_sets`` is created. This verification -target has one source file per header in the ``PUBLIC`` and ``INTERFACE`` -header sets. Each source file only includes its associated header file. The -verification target links against the original target to get all of its usage -requirements. The verification target has its :prop_tgt:`EXCLUDE_FROM_ALL` and -:prop_tgt:`DISABLE_PRECOMPILE_HEADERS` properties set to true, and its -:prop_tgt:`AUTOMOC`, :prop_tgt:`AUTORCC`, :prop_tgt:`AUTOUIC`, and -:prop_tgt:`UNITY_BUILD` properties set to false. - -If the header's :prop_sf:`LANGUAGE` property is set, the value of that property -is used to determine the language with which to compile the header file. -Otherwise, if the target has any C++ sources, the header is compiled as C++. -Otherwise, if the target has any C sources, the header is compiled as C. -Otherwise, the header file is not compiled. diff --git a/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst b/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst new file mode 100644 index 0000000..d8045c6 --- /dev/null +++ b/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst @@ -0,0 +1,25 @@ +VERIFY_INTERFACE_HEADER_SETS +---------------------------- + +.. versionadded:: 3.24 + +Used to verify that all headers in a target's ``PUBLIC`` and ``INTERFACE`` +header sets can be included on their own. + +When this property is set to true, and the target is an object library, static +library, shared library, or executable with exports enabled, and the target +has one or more ``PUBLIC`` or ``INTERFACE`` header sets, an object library +target named ``<target_name>_verify_interface_header_sets`` is created. This +verification target has one source file per header in the ``PUBLIC`` and +``INTERFACE`` header sets. Each source file only includes its associated +header file. The verification target links against the original target to get +all of its usage requirements. The verification target has its +:prop_tgt:`EXCLUDE_FROM_ALL` and :prop_tgt:`DISABLE_PRECOMPILE_HEADERS` +properties set to true, and its :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTORCC`, +:prop_tgt:`AUTOUIC`, and :prop_tgt:`UNITY_BUILD` properties set to false. + +If the header's :prop_sf:`LANGUAGE` property is set, the value of that property +is used to determine the language with which to compile the header file. +Otherwise, if the target has any C++ sources, the header is compiled as C++. +Otherwise, if the target has any C sources, the header is compiled as C. +Otherwise, the header file is not compiled. diff --git a/Help/release/dev/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.rst b/Help/release/dev/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.rst new file mode 100644 index 0000000..ca2d223 --- /dev/null +++ b/Help/release/dev/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.rst @@ -0,0 +1,6 @@ +CMAKE_PROJECT_TOP_LEVEL_INCLUDES +-------------------------------- + +* The :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variable was added to allow + injecting custom code at the site of the first :command:`project` call, + after the host and target platform details have been determined. diff --git a/Help/release/dev/FindGLUT-remove-undocumented-vars.rst b/Help/release/dev/FindGLUT-remove-undocumented-vars.rst new file mode 100644 index 0000000..6a0c904 --- /dev/null +++ b/Help/release/dev/FindGLUT-remove-undocumented-vars.rst @@ -0,0 +1,5 @@ +FindGLUT-remove-undocumented-vars +--------------------------------- + +* The :module:`FindGLUT` module no longer provides the undocumented + result variables ``GLUT_LIBRARY`` and ``GLUT_INCLUDE_PATH``. diff --git a/Help/release/dev/presets-pathListSep.rst b/Help/release/dev/presets-pathListSep.rst new file mode 100644 index 0000000..84b129f --- /dev/null +++ b/Help/release/dev/presets-pathListSep.rst @@ -0,0 +1,5 @@ +presets-pathListSep +------------------- + +* :manual:`cmake-presets(7)` files now support a ``${pathListSep}`` macro, + which expands to ``:`` or ``;`` based on the platform. diff --git a/Help/release/dev/try_compile-project-platform-vars.rst b/Help/release/dev/try_compile-project-platform-vars.rst new file mode 100644 index 0000000..06596d4 --- /dev/null +++ b/Help/release/dev/try_compile-project-platform-vars.rst @@ -0,0 +1,10 @@ +try_compile-project-platform-vars +--------------------------------- + +* The :command:`try_compile` command + :ref:`whole-project <Try Compiling Whole Projects>` signature + now propagates platform variables. See policy :policy:`CMP0137`. + +* The :variable:`CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES` variable + was added to tell the :command:`try_compile` command not to + pass any platform variables to the test project. diff --git a/Help/release/dev/verify-header-sets.rst b/Help/release/dev/verify-header-sets.rst deleted file mode 100644 index 7676382..0000000 --- a/Help/release/dev/verify-header-sets.rst +++ /dev/null @@ -1,7 +0,0 @@ -verify-header-sets ------------------- - -* A new :prop_tgt:`VERIFY_HEADER_SETS` target property was added, which can be - used to verify that all headers in header sets can be used on their own. -* A new :variable:`CMAKE_VERIFY_HEADER_SETS` variable was added, which is used - to initialize the :prop_tgt:`VERIFY_HEADER_SETS` target property. diff --git a/Help/release/dev/verify-interface-header-sets.rst b/Help/release/dev/verify-interface-header-sets.rst new file mode 100644 index 0000000..fcccb62 --- /dev/null +++ b/Help/release/dev/verify-interface-header-sets.rst @@ -0,0 +1,9 @@ +verify-interface-header-sets +---------------------------- + +* A new :prop_tgt:`VERIFY_INTERFACE_HEADER_SETS` target property was added, + which can be used to verify that all headers in header sets can be used on + their own. +* A new :variable:`CMAKE_VERIFY_INTERFACE_HEADER_SETS` variable was added, + which is used to initialize the :prop_tgt:`VERIFY_INTERFACE_HEADER_SETS` + target property. diff --git a/Help/release/dev/vs-system-include.rst b/Help/release/dev/vs-system-include.rst new file mode 100644 index 0000000..5f42dba --- /dev/null +++ b/Help/release/dev/vs-system-include.rst @@ -0,0 +1,4 @@ +vs-system-include +----------------- + +* :ref:`Visual Studio Generators` now support ``SYSTEM`` headers. diff --git a/Help/release/dev/werror-property.rst b/Help/release/dev/werror-property.rst index c337df7..84c825f 100644 --- a/Help/release/dev/werror-property.rst +++ b/Help/release/dev/werror-property.rst @@ -6,3 +6,8 @@ werror-property Target Property. If :prop_tgt:`COMPILE_WARNING_AS_ERROR` is true, it expands to a different flag depending on the compiler such that any warnings at compile will be treated as errors. + +* :manual:`cmake(1)` gained the command-line option + ``--compile-no-warning-as-error`` which causes the values of + the :prop_tgt:`COMPILE_WARNING_AS_ERROR` target property and + :variable:`CMAKE_COMPILE_WARNING_AS_ERROR` variable to be ignored. diff --git a/Help/variable/CMAKE_PROJECT_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_INCLUDE.rst index 41d9e5d..76b9d92 100644 --- a/Help/variable/CMAKE_PROJECT_INCLUDE.rst +++ b/Help/variable/CMAKE_PROJECT_INCLUDE.rst @@ -5,8 +5,11 @@ CMAKE_PROJECT_INCLUDE A CMake language file or module to be included as the last step of all :command:`project` command calls. This is intended for injecting custom code -into project builds without modifying their source. +into project builds without modifying their source. See :ref:`Code Injection` +for a more detailed discussion of files potentially included during a +:command:`project` call. See also the :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`, -:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE` and -:variable:`CMAKE_PROJECT_INCLUDE_BEFORE` variables. +:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE`, +:variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, and +:variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variables. diff --git a/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst b/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst index c2fd0f8..9a8c4b5 100644 --- a/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst +++ b/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst @@ -5,8 +5,11 @@ CMAKE_PROJECT_INCLUDE_BEFORE A CMake language file or module to be included as the first step of all :command:`project` command calls. This is intended for injecting custom code -into project builds without modifying their source. +into project builds without modifying their source. See :ref:`Code Injection` +for a more detailed discussion of files potentially included during a +:command:`project` call. See also the :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`, -:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE` and -:variable:`CMAKE_PROJECT_INCLUDE` variables. +:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE`, +:variable:`CMAKE_PROJECT_INCLUDE`, and +:variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variables. diff --git a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst index 74247f1..3bb5cd8 100644 --- a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst +++ b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst @@ -4,8 +4,9 @@ CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE A CMake language file or module to be included as the last step of any :command:`project` command calls that specify ``<PROJECT-NAME>`` as the project name. This is intended for injecting custom code into project builds without -modifying their source. +modifying their source. See :ref:`Code Injection` for a more detailed +discussion of files potentially included during a :command:`project` call. See also the :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE`, -:variable:`CMAKE_PROJECT_INCLUDE` and -:variable:`CMAKE_PROJECT_INCLUDE_BEFORE` variables. +:variable:`CMAKE_PROJECT_INCLUDE`, :variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, +and :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variables. diff --git a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst index 39abb12..ca584c1 100644 --- a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst +++ b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst @@ -6,8 +6,9 @@ CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE A CMake language file or module to be included as the first step of any :command:`project` command calls that specify ``<PROJECT-NAME>`` as the project name. This is intended for injecting custom code into project builds without -modifying their source. +modifying their source. See :ref:`Code Injection` for a more detailed +discussion of files potentially included during a :command:`project` call. See also the :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`, -:variable:`CMAKE_PROJECT_INCLUDE` and -:variable:`CMAKE_PROJECT_INCLUDE_BEFORE` variables. +:variable:`CMAKE_PROJECT_INCLUDE`, :variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, +and :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variables. diff --git a/Help/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.rst b/Help/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.rst new file mode 100644 index 0000000..2010b08 --- /dev/null +++ b/Help/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.rst @@ -0,0 +1,27 @@ +CMAKE_PROJECT_TOP_LEVEL_INCLUDES +-------------------------------- + +.. versionadded:: 3.24 + +:ref:`Semicolon-separated list <CMake Language Lists>` of CMake language +files to include as part of the very first :command:`project` call. +The files will be included immediately after the toolchain file has been read +(if one is specified) and platform variables have been set, but before any +languages have been enabled. Therefore, language-specific variables, +including things like :variable:`CMAKE_<LANG>_COMPILER`, might not be set. +See :ref:`Code Injection` for a more detailed discussion of files potentially +included during a :command:`project` call. + +This variable is intended for specifying files that perform one-time setup +for the build. It provides an injection point for things like configuring +package managers, adding logic the user shares between projects (e.g. defining +their own custom build types), and so on. It is primarily for users to add +things specific to their environment, but not for specifying the toolchain +details (use :variable:`CMAKE_TOOLCHAIN_FILE` for that). + +By default, this variable is empty. It is intended to be set by the user. + +See also the :variable:`CMAKE_PROJECT_INCLUDE`, +:variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, +:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`, and +:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE` variables. diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst index ff8d59a..1117c1f 100644 --- a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst +++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst @@ -13,3 +13,6 @@ build directory, and if not found, relative to the source directory. This is initialized by the :envvar:`CMAKE_TOOLCHAIN_FILE` environment variable if it is set when a new build tree is first created. + +See the :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variable for setting +other things not directly related to the toolchain. diff --git a/Help/variable/CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES.rst b/Help/variable/CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES.rst new file mode 100644 index 0000000..944caa5 --- /dev/null +++ b/Help/variable/CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES.rst @@ -0,0 +1,10 @@ +CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES +--------------------------------------- + +Set to a true value to tell the :command:`try_compile` command not +to propagate any platform variables into the test project. + +The :command:`try_compile` command normally passes some CMake variables +that configure the platform and toolchain behavior into test projects. +See policy :policy:`CMP0137`. This variable may be set to disable +that behavior. diff --git a/Help/variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES.rst b/Help/variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES.rst index d178513..6b26d14 100644 --- a/Help/variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES.rst +++ b/Help/variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES.rst @@ -26,3 +26,12 @@ If a user passes ``-DMY_CUSTOM_VARIABLE=SomeValue`` to CMake then this setting will be made visible to the toolchain file both for the main project and for test projects generated by the :command:`try_compile` command source file signature. + +.. versionchanged:: 3.24 + Listed variables are propagated to the :command:`try_compile` + :ref:`whole-project <Try Compiling Whole Projects>` signature too. + See :policy:`CMP0137`. + +.. versionadded:: 3.24 + The :variable:`CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES` variable may be + set to disable passing platform variables into the test project. diff --git a/Help/variable/CMAKE_VERIFY_HEADER_SETS.rst b/Help/variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS.rst index 8bd618a..6f14e6f 100644 --- a/Help/variable/CMAKE_VERIFY_HEADER_SETS.rst +++ b/Help/variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS.rst @@ -1,11 +1,11 @@ -CMAKE_VERIFY_HEADER_SETS ------------------------- +CMAKE_VERIFY_INTERFACE_HEADER_SETS +---------------------------------- .. versionadded:: 3.24 -This variable is used to initialize the :prop_tgt:`VERIFY_HEADER_SETS` -property of targets when they are created. Setting it to true -enables header set verification. +This variable is used to initialize the +:prop_tgt:`VERIFY_INTERFACE_HEADER_SETS` property of targets when they are +created. Setting it to true enables header set verification. Projects should not set this variable, it is intended as a developer control to be set on the :manual:`cmake(1)` command line or other diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst index 84d7212..5c13bb7 100644 --- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst @@ -9,4 +9,4 @@ The :ref:`Visual Studio Generators` for VS 2013 and above support using either the 32-bit or 64-bit host toolchains by specifying a ``host=x86`` or ``host=x64`` value in the :variable:`CMAKE_GENERATOR_TOOLSET` option. CMake provides the selected toolchain architecture preference in this -variable (``x86``, ``x64``, or empty). +variable (``x86``, ``x64``, ``ARM64`` or empty). diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 8c7af06..2c2c2ac 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -128,7 +128,6 @@ if(CMAKE_TOOLCHAIN_FILE) set(CMAKE_TOOLCHAIN_FILE "${_INCLUDED_TOOLCHAIN_FILE}" CACHE FILEPATH "The CMake toolchain file" FORCE) else() message(FATAL_ERROR "Could not find toolchain file: ${CMAKE_TOOLCHAIN_FILE}") - set(CMAKE_TOOLCHAIN_FILE "NOTFOUND" CACHE FILEPATH "The CMake toolchain file" FORCE) endif() endif() diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 5813956..6f5702a 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -177,9 +177,9 @@ macro. packages with no binaries. .. versionadded:: 3.19 - ``COMPATIBILITY_MODE`` ``AnyNewerVersion``, ``SameMajorVersion`` and - ``SameMinorVersion`` handle the version range if any is specified - (see :command:`find_package` command for the details). + The version file generated by ``AnyNewerVersion``, ``SameMajorVersion`` and + ``SameMinorVersion`` arguments of ``COMPATIBILITY`` handle the version range + if any is specified (see :command:`find_package` command for the details). ``ExactVersion`` mode is incompatible with version ranges and will display an author warning if one is specified. diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 5c37be2..707de88 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -2530,6 +2530,12 @@ function(_ep_add_download_command name) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) + get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_DOWNLOAD) + if(uses_terminal) + set(svn_interactive_args "") + else() + set(svn_interactive_args "--non-interactive") + endif() get_filename_component(src_name "${source_dir}" NAME) get_filename_component(work_dir "${source_dir}" PATH) @@ -2545,7 +2551,8 @@ function(_ep_add_download_command name) set(svn_trust_cert_args --trust-server-cert) endif() set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} - --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name}) + ${svn_interactive_args} ${svn_trust_cert_args} ${svn_user_pw_args} + ${src_name}) elseif(git_repository) set(method git) @@ -2934,6 +2941,12 @@ function(_ep_add_update_command name) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) + get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_UPDATE) + if(uses_terminal) + set(svn_interactive_args "") + else() + set(svn_interactive_args "--non-interactive") + endif() set(svn_user_pw_args "") if(DEFINED svn_username) set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}") @@ -2945,7 +2958,7 @@ function(_ep_add_update_command name) set(svn_trust_cert_args --trust-server-cert) endif() set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision} - --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args}) + ${svn_interactive_args} ${svn_trust_cert_args} ${svn_user_pw_args}) set(always 1) elseif(git_repository) # FetchContent gives us these directly, so don't try to recompute them diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index 1b81778..a342aa7 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -1351,6 +1351,14 @@ ExternalProject_Add_Step(${contentName}-populate copyfile list(APPEND subCMakeOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}") endif() + # Override the sub-build's configuration types for multi-config generators. + # This ensures we are not affected by any custom setting from the project + # and can always request a known configuration further below. + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + list(APPEND subCMakeOpts "-DCMAKE_CONFIGURATION_TYPES:STRING=Debug") + endif() + else() # Likely we've been invoked via CMake's script mode where no # generator is set (and hence CMAKE_MAKE_PROGRAM could not be @@ -1395,7 +1403,8 @@ set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION # If we've already previously done these steps, they will not cause # anything to be updated, so extra rebuilds of the project won't occur. # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project - # has this set to something not findable on the PATH. + # has this set to something not findable on the PATH. We also ensured above + # that the Debug config will be defined for multi-config generators. configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/FetchContent/CMakeLists.cmake.in" "${ARG_SUBBUILD_DIR}/CMakeLists.txt") execute_process( @@ -1411,7 +1420,7 @@ set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION message(FATAL_ERROR "CMake step for ${contentName} failed: ${result}") endif() execute_process( - COMMAND ${CMAKE_COMMAND} --build . + COMMAND ${CMAKE_COMMAND} --build . --config Debug RESULT_VARIABLE result ${outputOptions} WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}" diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 43041c5..320ddad 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -96,7 +96,21 @@ endfunction() find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) + # Tell pkg-config not to strip any -I flags to make sure GLUT_INCLUDE_DIRS + # will be defined. + if(DEFINED ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}) + set(_pkgconfig_allow_system_cflags_old "$ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}") + else() + unset(_pkgconfig_allow_system_cflags_old) + endif() + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} 1) pkg_check_modules(GLUT QUIET glut) + if(DEFINED _pkgconfig_allow_system_cflags_old) + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} "${_pkgconfig_allow_system_cflags_old}") + unset(_pkgconfig_allow_system_cflags_old) + else() + unset(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}) + endif() if(NOT GLUT_FOUND) pkg_check_modules(GLUT QUIET freeglut) endif() @@ -261,8 +275,4 @@ if (GLUT_FOUND) PROPERTY INTERFACE_LINK_LIBRARIES GLUT::Cocoa) endif() endif() - - #The following deprecated settings are for backwards compatibility with CMake1.4 - set (GLUT_LIBRARY ${GLUT_LIBRARIES}) - set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIRS}) endif() diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index 1b4662b..5c7aa22 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -45,7 +45,7 @@ function(_FIND_OPENCL_VERSION) set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY}) CMAKE_PUSH_CHECK_STATE() - foreach(VERSION "2_2" "2_1" "2_0" "1_2" "1_1" "1_0") + foreach(VERSION "3_0" "2_2" "2_1" "2_0" "1_2" "1_1" "1_0") set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}") if(APPLE) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 844ea25..854e0e1 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -467,7 +467,7 @@ macro(_pkg_set_path_internal) else() unset(_pkgconfig_allow_system_libs_old) endif() - set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} 0) + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} 1) endmacro() macro(_pkg_restore_path_internal) @@ -478,6 +478,8 @@ macro(_pkg_restore_path_internal) if(DEFINED _pkgconfig_allow_system_libs_old) set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} "${_pkgconfig_allow_system_libs_old}") unset(_pkgconfig_allow_system_libs_old) + else() + unset(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}) endif() unset(_extra_paths) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 6edfbea..cbb6c1c 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -22,7 +22,7 @@ if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) message (FATAL_ERROR "FindPython: INTERNAL ERROR") endif() if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "3") - set(_${_PYTHON_PREFIX}_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) + set(_${_PYTHON_PREFIX}_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "2") set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) else() diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 4fc40c8..7ad3587 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -54,7 +54,7 @@ unset(_Python_NAMES) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonInterp_FIND_VERSION) if(PythonInterp_FIND_VERSION_COUNT GREATER 1) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index c0caf34..43a84dd 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -79,7 +79,7 @@ set(CMAKE_FIND_FRAMEWORK LAST) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonLibs_FIND_VERSION) if(PythonLibs_FIND_VERSION_COUNT GREATER 1) diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index 527ca8b..7a32c2f 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -10,6 +10,15 @@ FindVulkan Find Vulkan, which is a low-overhead, cross-platform 3D graphics and computing API. +Optional COMPONENTS +^^^^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.24 + +This module respects several optional COMPONENTS: ``glslc``, +``glslangValidator``, ``glslang``, ``shaderc_combined`` and ``SPIRV-Tools``. +There are corresponding import targets for each of these flags. + IMPORTED Targets ^^^^^^^^^^^^^^^^ @@ -36,6 +45,24 @@ This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found: The glslangValidator tool, if found. It is used to compile GLSL and HLSL shaders into SPIR-V. +``Vulkan::glslang`` + .. versionadded:: 3.24 + + Defined if SDK has the Khronos-reference front-end shader parser and SPIR-V + generator library (glslang). + +``Vulkan::shaderc_combined`` + .. versionadded:: 3.24 + + Defined if SDK has the Google static library for Vulkan shader compilation + (shaderc_combined). + +``Vulkan::SPIRV-Tools`` + .. versionadded:: 3.24 + + Defined if SDK has the Khronos library to process SPIR-V modules + (SPIRV-Tools). + Result Variables ^^^^^^^^^^^^^^^^ @@ -51,6 +78,26 @@ This module defines the following variables: .. versionadded:: 3.23 value from ``vulkan/vulkan_core.h`` +``Vulkan_glslc_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslc executable. +``Vulkan_glslangValidator_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslangValidator executable. +``Vulkan_glslang_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslang library. +``Vulkan_shaderc_combined_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the shaderc_combined library. +``Vulkan_SPIRV-Tools_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the SPIRV-Tools library. The module will also defines these cache variables: @@ -62,6 +109,18 @@ The module will also defines these cache variables: the path to the GLSL SPIR-V compiler ``Vulkan_GLSLANG_VALIDATOR_EXECUTABLE`` the path to the glslangValidator tool +``Vulkan_glslang_LIBRARY`` + .. versionadded:: 3.24 + + Path to the glslang library. +``Vulkan_shaderc_combined_LIBRARY`` + .. versionadded:: 3.24 + + Path to the shaderc_combined library. +``Vulkan_SPIRV-Tools_LIBRARY`` + .. versionadded:: 3.24 + + Path to the SPIRV-Tools library. Hints ^^^^^ @@ -76,63 +135,258 @@ environment. #]=======================================================================] -if(WIN32) - find_path(Vulkan_INCLUDE_DIR - NAMES vulkan/vulkan.h - HINTS - "$ENV{VULKAN_SDK}/Include" - ) +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) +# For backward compatibility as `FindVulkan` in previous CMake versions allow to retrieve `glslc` +# and `glslangValidator` without requesting the corresponding component. +if(NOT glslc IN_LIST Vulkan_FIND_COMPONENTS) + list(APPEND Vulkan_FIND_COMPONENTS glslc) +endif() +if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS) + list(APPEND Vulkan_FIND_COMPONENTS glslangValidator) +endif() + +if(WIN32) + set(_Vulkan_library_name vulkan-1) + set(_Vulkan_hint_include_search_paths + "$ENV{VULKAN_SDK}/Include" + ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - find_library(Vulkan_LIBRARY - NAMES vulkan-1 - HINTS - "$ENV{VULKAN_SDK}/Lib" - "$ENV{VULKAN_SDK}/Bin" - ) - find_program(Vulkan_GLSLC_EXECUTABLE - NAMES glslc - HINTS - "$ENV{VULKAN_SDK}/Bin" - ) - find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE - NAMES glslangValidator - HINTS - "$ENV{VULKAN_SDK}/Bin" - ) - elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - find_library(Vulkan_LIBRARY - NAMES vulkan-1 - HINTS - "$ENV{VULKAN_SDK}/Lib32" - "$ENV{VULKAN_SDK}/Bin32" - ) - find_program(Vulkan_GLSLC_EXECUTABLE - NAMES glslc - HINTS - "$ENV{VULKAN_SDK}/Bin32" - ) - find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE - NAMES glslangValidator - HINTS - "$ENV{VULKAN_SDK}/Bin32" - ) + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/Bin" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/Lib" + "$ENV{VULKAN_SDK}/Bin" + ) + else() + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/Bin32" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/Lib32" + "$ENV{VULKAN_SDK}/Bin32" + ) endif() else() - find_path(Vulkan_INCLUDE_DIR - NAMES vulkan/vulkan.h - HINTS "$ENV{VULKAN_SDK}/include") - find_library(Vulkan_LIBRARY - NAMES vulkan - HINTS "$ENV{VULKAN_SDK}/lib") + set(_Vulkan_library_name vulkan) + set(_Vulkan_hint_include_search_paths + "$ENV{VULKAN_SDK}/include" + ) + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/bin" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/lib" + ) +endif() + +find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + HINTS + ${_Vulkan_hint_include_search_paths} + ) +mark_as_advanced(Vulkan_INCLUDE_DIR) + +find_library(Vulkan_LIBRARY + NAMES ${_Vulkan_library_name} + HINTS + ${_Vulkan_hint_library_search_paths} + ) +mark_as_advanced(Vulkan_LIBRARY) + +if(glslc IN_LIST Vulkan_FIND_COMPONENTS) find_program(Vulkan_GLSLC_EXECUTABLE NAMES glslc - HINTS "$ENV{VULKAN_SDK}/bin") + HINTS + ${_Vulkan_hint_executable_search_paths} + ) + mark_as_advanced(Vulkan_GLSLC_EXECUTABLE) +endif() +if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS) find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE NAMES glslangValidator - HINTS "$ENV{VULKAN_SDK}/bin") + HINTS + ${_Vulkan_hint_executable_search_paths} + ) + mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) +endif() +if(glslang IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_glslang-spirv_LIBRARY + NAMES SPIRV + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-spirv_LIBRARY) + + find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY + NAMES SPIRVd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-oglcompiler_LIBRARY + NAMES OGLCompiler + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY) + + find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY + NAMES OGLCompilerd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-osdependent_LIBRARY + NAMES OSDependent + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY) + + find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY + NAMES OSDependentd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-machineindependent_LIBRARY + NAMES MachineIndependent + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY) + + find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY + NAMES MachineIndependentd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-genericcodegen_LIBRARY + NAMES GenericCodeGen + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY) + + find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY + NAMES GenericCodeGend + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) + + find_library(Vulkan_glslang_LIBRARY + NAMES glslang + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang_LIBRARY) + + find_library(Vulkan_glslang_DEBUG_LIBRARY + NAMES glslangd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY) +endif() +if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_shaderc_combined_LIBRARY + NAMES shaderc_combined + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_shaderc_combined_LIBRARY) + + find_library(Vulkan_shaderc_combined_DEBUG_LIBRARY + NAMES shaderc_combinedd + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY) +endif() +if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_SPIRV-Tools_LIBRARY + NAMES SPIRV-Tools + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY) + + find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY + NAMES SPIRV-Toolsd + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY) +endif() + +if(Vulkan_GLSLC_EXECUTABLE) + set(Vulkan_glslc_FOUND TRUE) +else() + set(Vulkan_glslc_FOUND FALSE) +endif() + +if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) + set(Vulkan_glslangValidator_FOUND TRUE) +else() + set(Vulkan_glslangValidator_FOUND FALSE) endif() +function(_Vulkan_set_library_component_found component) + cmake_parse_arguments(PARSE_ARGV 1 _ARG + "NO_WARNING" + "" + "DEPENDENT_COMPONENTS") + + set(all_dependent_component_found TRUE) + foreach(dependent_component IN LISTS _ARG_DEPENDENT_COMPONENTS) + if(NOT Vulkan_${dependent_component}_FOUND) + set(all_dependent_component_found FALSE) + break() + endif() + endforeach() + + if(all_dependent_component_found AND (Vulkan_${component}_LIBRARY OR Vulkan_${component}_DEBUG_LIBRARY)) + set(Vulkan_${component}_FOUND TRUE PARENT_SCOPE) + + # For Windows Vulkan SDK, third party tools binaries are provided with different MSVC ABI: + # - Release binaries uses a runtime library + # - Debug binaries uses a debug runtime library + # This lead to incompatibilities in linking for some configuration types due to CMake-default or project-configured selected MSVC ABI. + if(WIN32 AND NOT _ARG_NO_WARNING) + if(NOT Vulkan_${component}_LIBRARY) + message(WARNING +"Library ${component} for Release configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI.") + endif() + if(NOT Vulkan_${component}_DEBUG_LIBRARY) + message(WARNING +"Library ${component} for Debug configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI. Consider re-installing the Vulkan SDK and request debug libraries to fix this warning.") + endif() + endif() + else() + set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE) + endif() +endfunction() + +_Vulkan_set_library_component_found(glslang-spirv NO_WARNING) +_Vulkan_set_library_component_found(glslang-oglcompiler NO_WARNING) +_Vulkan_set_library_component_found(glslang-osdependent NO_WARNING) +_Vulkan_set_library_component_found(glslang-machineindependent NO_WARNING) +_Vulkan_set_library_component_found(glslang-genericcodegen NO_WARNING) +_Vulkan_set_library_component_found(glslang + DEPENDENT_COMPONENTS + glslang-spirv + glslang-oglcompiler + glslang-osdependent + glslang-machineindependent + glslang-genericcodegen) +_Vulkan_set_library_component_found(shaderc_combined) +_Vulkan_set_library_component_found(SPIRV-Tools) + set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR}) @@ -162,11 +416,9 @@ find_package_handle_standard_args(Vulkan Vulkan_INCLUDE_DIR VERSION_VAR Vulkan_VERSION + HANDLE_COMPONENTS ) -mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY Vulkan_GLSLC_EXECUTABLE - Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) - if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) add_library(Vulkan::Vulkan UNKNOWN IMPORTED) set_target_properties(Vulkan::Vulkan PROPERTIES @@ -189,3 +441,217 @@ if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::g add_executable(Vulkan::glslangValidator IMPORTED) set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}") endif() + +if(Vulkan_FOUND) + if((Vulkan_glslang-spirv_LIBRARY OR Vulkan_glslang-spirv_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-spirv) + add_library(Vulkan::glslang-spirv STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-spirv_LIBRARY) + set_property(TARGET Vulkan::glslang-spirv APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}") + endif() + if(Vulkan_glslang-spirv_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-spirv APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-oglcompiler_LIBRARY OR Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-oglcompiler) + add_library(Vulkan::glslang-oglcompiler STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-oglcompiler_LIBRARY) + set_property(TARGET Vulkan::glslang-oglcompiler APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}") + endif() + if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-oglcompiler APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-osdependent_LIBRARY OR Vulkan_glslang-osdependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-osdependent) + add_library(Vulkan::glslang-osdependent STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-osdependent_LIBRARY) + set_property(TARGET Vulkan::glslang-osdependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}") + endif() + if(Vulkan_glslang-osdependent_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-osdependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-machineindependent_LIBRARY OR Vulkan_glslang-machineindependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-machineindependent) + add_library(Vulkan::glslang-machineindependent STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-machineindependent_LIBRARY) + set_property(TARGET Vulkan::glslang-machineindependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}") + endif() + if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-machineindependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-genericcodegen_LIBRARY OR Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-genericcodegen) + add_library(Vulkan::glslang-genericcodegen STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-genericcodegen_LIBRARY) + set_property(TARGET Vulkan::glslang-genericcodegen APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}") + endif() + if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-genericcodegen APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang_LIBRARY OR Vulkan_glslang_DEBUG_LIBRARY) + AND TARGET Vulkan::glslang-spirv + AND TARGET Vulkan::glslang-oglcompiler + AND TARGET Vulkan::glslang-osdependent + AND TARGET Vulkan::glslang-machineindependent + AND TARGET Vulkan::glslang-genericcodegen + AND NOT TARGET Vulkan::glslang) + add_library(Vulkan::glslang STATIC IMPORTED) + set_property(TARGET Vulkan::glslang + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang_LIBRARY) + set_property(TARGET Vulkan::glslang APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}") + endif() + if(Vulkan_glslang_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}") + endif() + target_link_libraries(Vulkan::glslang + INTERFACE + Vulkan::glslang-spirv + Vulkan::glslang-oglcompiler + Vulkan::glslang-osdependent + Vulkan::glslang-machineindependent + Vulkan::glslang-genericcodegen + ) + endif() + + if((Vulkan_shaderc_combined_LIBRARY OR Vulkan_shaderc_combined_DEBUG_LIBRARY) AND NOT TARGET Vulkan::shaderc_combined) + add_library(Vulkan::shaderc_combined STATIC IMPORTED) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_shaderc_combined_LIBRARY) + set_property(TARGET Vulkan::shaderc_combined APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}") + endif() + if(Vulkan_shaderc_combined_DEBUG_LIBRARY) + set_property(TARGET Vulkan::shaderc_combined APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}") + endif() + + if(UNIX) + find_package(Threads REQUIRED) + target_link_libraries(Vulkan::shaderc_combined + INTERFACE + Threads::Threads) + endif() + endif() + + if((Vulkan_SPIRV-Tools_LIBRARY OR Vulkan_SPIRV-Tools_DEBUG_LIBRARY) AND NOT TARGET Vulkan::SPIRV-Tools) + add_library(Vulkan::SPIRV-Tools STATIC IMPORTED) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_SPIRV-Tools_LIBRARY) + set_property(TARGET Vulkan::SPIRV-Tools APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}") + endif() + if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY) + set_property(TARGET Vulkan::SPIRV-Tools APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}") + endif() + endif() +endif() + +unset(_Vulkan_library_name) +unset(_Vulkan_hint_include_search_paths) +unset(_Vulkan_hint_executable_search_paths) +unset(_Vulkan_hint_library_search_paths) + +cmake_policy(POP) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 4af842a..f50116f 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -77,8 +77,13 @@ set(_ZLIB_SEARCH_NORMAL unset(_ZLIB_x86) list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) -set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic zlibstat zlibvc) -set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibstatd zlibvcd) +if(ZLIB_USE_STATIC_LIBS) + set(ZLIB_NAMES zlibstatic zlibstat zlib z) + set(ZLIB_NAMES_DEBUG zlibstaticd zlibstatd zlibd zd) +else() + set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic zlibwapi zlibvc zlibstat) + set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibwapid zlibvcd zlibstatd) +endif() # Try each search configuration. foreach(search ${_ZLIB_SEARCHES}) @@ -87,9 +92,15 @@ endforeach() # Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library if(NOT ZLIB_LIBRARY) + set(_zlib_ORIG_CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES}) + set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + # Prefix/suffix of the win32/Makefile.gcc build + if(WIN32) + list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a") + endif() # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES if(ZLIB_USE_STATIC_LIBS) - set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) if(WIN32) set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) else() @@ -103,9 +114,8 @@ if(NOT ZLIB_LIBRARY) endforeach() # Restore the original find library ordering - if(ZLIB_USE_STATIC_LIBS) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_PREFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(ZLIB) diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index ce0bc10..fb35ff0 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -112,6 +112,9 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 12) target_compile_options(FortranCInterface PRIVATE "-fno-lto") target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects") +endif() +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12) target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects") endif() diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake index fb363f4..056d025 100644 --- a/Modules/Internal/CPack/CPackNuGet.cmake +++ b/Modules/Internal/CPack/CPackNuGet.cmake @@ -332,7 +332,9 @@ endfunction() function(_cpack_nuget_make_files_tag) set(_files) foreach(_comp IN LISTS ARGN) - string(APPEND _files " <file src=\"${_comp}/**\" target=\".\" />\n") + cmake_path(APPEND _comp "**") + cmake_path(NATIVE_PATH _comp _comp) + string(APPEND _files " <file src=\"${_comp}\" target=\".\" />\n") endforeach() set(_CPACK_NUGET_FILES_TAG "<files>\n${_files} </files>" PARENT_SCOPE) endfunction() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 82c4383..3941311 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -191,7 +191,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX") - set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc ") + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc") endmacro() else() cmake_policy(GET CMP0091 __WINDOWS_CLANG_CMP0091) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index db444ba..4df3fe5 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 23) -set(CMake_VERSION_PATCH 20220511) +set(CMake_VERSION_PATCH 20220523) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 11b3b35..8381e86 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -35,11 +35,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args, : Args(std::move(args)) , InitialWidth(initWidth) { - this->HasNonStatusOutputs = false; - this->NumberOfPages = 0; - this->AdvancedMode = false; - this->NumberOfVisibleEntries = 0; - this->OkToGenerate = false; this->HelpMessage.emplace_back( "Welcome to ccmake, curses based user interface for CMake."); this->HelpMessage.emplace_back(); @@ -54,7 +49,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args, cmStrCat(cmSystemTools::GetProgramPath(this->Args[0]), "/cmake"); this->Args[0] = whereCMake; this->CMakeInstance->SetArgs(this->Args); - this->SearchMode = false; } cmCursesMainForm::~cmCursesMainForm() @@ -99,13 +93,14 @@ void cmCursesMainForm::InitializeUI() int entrywidth = this->InitialWidth - 35; - if (count == 0) { - // If cache is empty, display a label saying so and a - // dummy entry widget (does not respond to input) - cmCursesCacheEntryComposite comp("EMPTY CACHE", 30, 30); - comp.Entry = cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1); - newEntries.emplace_back(std::move(comp)); - } else { + // Add a label to display when cache is empty + // dummy entry widget (does not respond to input) + this->EmptyCacheEntry = + cm::make_unique<cmCursesCacheEntryComposite>("EMPTY CACHE", 30, 30); + this->EmptyCacheEntry->Entry = + cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1); + + if (count > 0) { // Create the composites. // First add entries which are new @@ -196,11 +191,11 @@ void cmCursesMainForm::RePost() this->Fields.push_back(entry.Entry->Field); } // if no cache entries there should still be one dummy field - if (this->Fields.empty()) { - const auto& front = this->Entries.front(); - this->Fields.push_back(front.Label->Field); - this->Fields.push_back(front.IsNewLabel->Field); - this->Fields.push_back(front.Entry->Field); + this->IsEmpty = this->Fields.empty(); + if (this->IsEmpty) { + this->Fields.push_back(this->EmptyCacheEntry->Label->Field); + this->Fields.push_back(this->EmptyCacheEntry->IsNewLabel->Field); + this->Fields.push_back(this->EmptyCacheEntry->Entry->Field); this->NumberOfVisibleEntries = 1; } // Has to be null terminated. @@ -875,7 +870,7 @@ void cmCursesMainForm::HandleInput() } } // delete cache entry - else if (key == 'd' && this->NumberOfVisibleEntries) { + else if (key == 'd' && this->NumberOfVisibleEntries && !this->IsEmpty) { this->OkToGenerate = false; FIELD* cur = current_field(this->Form); size_t findex = field_index(cur); diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index c6db66f..112b7e8 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -138,7 +138,7 @@ protected: // Output produced by the last pass std::vector<std::string> Outputs; // Did the last pass produced outputs of interest (errors, warnings, ...) - bool HasNonStatusOutputs; + bool HasNonStatusOutputs = false; // Last progress bar std::string LastProgress; @@ -155,17 +155,19 @@ protected: // Fields displayed. Includes labels, new entry markers, entries std::vector<FIELD*> Fields; // Number of entries shown (depends on mode -normal or advanced-) - size_t NumberOfVisibleEntries; - bool AdvancedMode; + size_t NumberOfVisibleEntries = 0; + bool AdvancedMode = false; // Did the iteration converge (no new entries) ? - bool OkToGenerate; + bool OkToGenerate = false; // Number of pages displayed - int NumberOfPages; + int NumberOfPages = 0; + bool IsEmpty = false; + std::unique_ptr<cmCursesCacheEntryComposite> EmptyCacheEntry; int InitialWidth; std::unique_ptr<cmake> CMakeInstance; std::string SearchString; std::string OldSearchString; - bool SearchMode; + bool SearchMode = false; }; diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx index 478c175..b737c1f 100644 --- a/Source/cmCMakePresetsGraph.cxx +++ b/Source/cmCMakePresetsGraph.cxx @@ -361,6 +361,13 @@ bool ExpandMacros(const cmCMakePresetsGraph& graph, const T& preset, cmSystemTools::GetParentDirectory(preset.OriginFile->Filename); return ExpandMacroResult::Ok; } + if (macroName == "pathListSep") { + if (version < 5) { + return ExpandMacroResult::Error; + } + macroOut += cmSystemTools::GetSystemPathlistSeparator(); + return ExpandMacroResult::Ok; + } } return ExpandMacroResult::Ignore; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 4909948..caa413b 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -872,7 +872,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, } // Forward a set of variables to the inner project cache. - if (this->SrcFileSignature) { + if ((this->SrcFileSignature || + this->Makefile->GetPolicyStatus(cmPolicies::CMP0137) == + cmPolicies::NEW) && + !this->Makefile->IsOn("CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES")) { std::set<std::string> vars; vars.insert(&c_properties[lang_property_start], &c_properties[lang_property_start + lang_property_size]); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d8a7c39..d852b48 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8527,7 +8527,7 @@ cmGeneratorTarget::ManagedType cmGeneratorTarget::GetManagedType( bool cmGeneratorTarget::AddHeaderSetVerification() { - if (!this->GetPropertyAsBool("VERIFY_HEADER_SETS")) { + if (!this->GetPropertyAsBool("VERIFY_INTERFACE_HEADER_SETS")) { return true; } @@ -8601,7 +8601,7 @@ bool cmGeneratorTarget::AddHeaderSetVerification() cmMakefile::PolicyPushPop polScope(this->Makefile); this->Makefile->SetPolicy(cmPolicies::CMP0119, cmPolicies::NEW); verifyTarget = this->Makefile->AddLibrary( - cmStrCat(this->GetName(), "_verify_header_sets"), + cmStrCat(this->GetName(), "_verify_interface_header_sets"), cmStateEnums::OBJECT_LIBRARY, {}, true); } @@ -8682,9 +8682,9 @@ std::string cmGeneratorTarget::GenerateHeaderSetVerificationFile( } headerFilename += source.GetLocation().GetName(); - auto filename = cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), - '/', this->GetName(), "_verify_header_sets/", - headerFilename, extension); + auto filename = cmStrCat( + this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->GetName(), + "_verify_interface_header_sets/", headerFilename, extension); auto* verificationSource = this->Makefile->GetOrCreateSource(filename); verificationSource->SetProperty("LANGUAGE", language); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 09e2abe..3831546 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -688,6 +688,33 @@ void cmGlobalGenerator::EnableLanguage( if (!this->FindMakeProgram(mf)) { return; } + + // One-time includes of user-provided project setup files + std::string includes = + mf->GetSafeDefinition("CMAKE_PROJECT_TOP_LEVEL_INCLUDES"); + std::vector<std::string> includesList = cmExpandedList(includes); + for (std::string const& setupFile : includesList) { + std::string absSetupFile = cmSystemTools::CollapseFullPath( + setupFile, mf->GetCurrentSourceDirectory()); + if (!cmSystemTools::FileExists(absSetupFile)) { + cmSystemTools::Error( + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES file does not exist: " + + setupFile); + return; + } + if (cmSystemTools::FileIsDirectory(absSetupFile)) { + cmSystemTools::Error( + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES file is a directory: " + + setupFile); + return; + } + if (!mf->ReadListFile(absSetupFile)) { + cmSystemTools::Error( + "Failed reading CMAKE_PROJECT_TOP_LEVEL_INCLUDES file: " + + setupFile); + return; + } + } } // Check that the languages are supported by the generator and its diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 12ffa5b..600ee0a 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -138,7 +138,8 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName( bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField( std::string const& key, std::string const& value) { - if (key == "host" && (value == "x64" || value == "x86")) { + if (key == "host" && + (value == "x64" || value == "x86" || value == "ARM64")) { this->GeneratorToolsetHostArchitecture = value; return true; } diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index bc38335..1c05d36 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -27,16 +27,17 @@ #if defined(_M_ARM64) # define HOST_PLATFORM_NAME "ARM64" -# define HOST_TOOLS_ARCH "" +# define HOST_TOOLS_ARCH(v) \ + (v >= cmGlobalVisualStudioGenerator::VSVersion::VS17) ? "ARM64" : "" #elif defined(_M_ARM) # define HOST_PLATFORM_NAME "ARM" -# define HOST_TOOLS_ARCH "" +# define HOST_TOOLS_ARCH(v) "" #elif defined(_M_IA64) # define HOST_PLATFORM_NAME "Itanium" -# define HOST_TOOLS_ARCH "" +# define HOST_TOOLS_ARCH(v) "" #elif defined(_WIN64) # define HOST_PLATFORM_NAME "x64" -# define HOST_TOOLS_ARCH "x64" +# define HOST_TOOLS_ARCH(v) "x64" #else static bool VSIsWow64() { @@ -58,10 +59,12 @@ static std::string VSHostPlatformName() #endif } -static std::string VSHostArchitecture() +static std::string VSHostArchitecture( + cmGlobalVisualStudioGenerator::VSVersion v) { + static_cast<void>(v); #ifdef HOST_TOOLS_ARCH - return HOST_TOOLS_ARCH; + return HOST_TOOLS_ARCH(v); #else if (VSIsWow64()) { return "x64"; @@ -433,7 +436,8 @@ cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator( this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version); if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16) { this->DefaultPlatformName = VSHostPlatformName(); - this->DefaultPlatformToolsetHostArchitecture = VSHostArchitecture(); + this->DefaultPlatformToolsetHostArchitecture = + VSHostArchitecture(this->Version); } if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS17) { // FIXME: Search for an existing framework? Under '%ProgramFiles(x86)%', diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 87110a9..93abd45 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -165,14 +165,22 @@ void cmInstallGenerator::AddInstallRule( } std::string cmInstallGenerator::CreateComponentTest( - const std::string& component, bool exclude_from_all) + const std::string& component, bool exclude_from_all, bool all_components) { + if (all_components) { + if (exclude_from_all) { + return "CMAKE_INSTALL_COMPONENT"; + } + return {}; + } + std::string result = "CMAKE_INSTALL_COMPONENT STREQUAL \""; result += component; result += "\""; if (!exclude_from_all) { result += " OR NOT CMAKE_INSTALL_COMPONENT"; } + return result; } @@ -181,10 +189,11 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Track indentation. Indent indent; + std::string component_test = this->CreateComponentTest( + this->Component, this->ExcludeFromAll, this->AllComponents); + // Begin this block of installation. - if (!this->AllComponents) { - std::string component_test = - this->CreateComponentTest(this->Component, this->ExcludeFromAll); + if (!component_test.empty()) { os << indent << "if(" << component_test << ")\n"; } @@ -193,7 +202,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) this->AllComponents ? indent : indent.Next()); // End this block of installation. - if (!this->AllComponents) { + if (!component_test.empty()) { os << indent << "endif()\n\n"; } } diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index d342c99..9fcd284 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -78,7 +78,8 @@ protected: void GenerateScript(std::ostream& os) override; std::string CreateComponentTest(const std::string& component, - bool exclude_from_all); + bool exclude_from_all, + bool all_components = false); using TweakMethod = std::function<void(std::ostream& os, Indent indent, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e2bcea8..d2c81ae 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1026,11 +1026,13 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags, } // Add Warning as errors flags - const cmValue wError = target->GetProperty("COMPILE_WARNING_AS_ERROR"); - const cmValue wErrorFlag = this->Makefile->GetDefinition( - cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_WARNING_AS_ERROR")); - if (wError.IsOn() && wErrorFlag.IsSet()) { - flags.emplace_back(wErrorFlag); + if (!this->GetCMakeInstance()->GetIgnoreWarningAsError()) { + const cmValue wError = target->GetProperty("COMPILE_WARNING_AS_ERROR"); + const cmValue wErrorFlag = this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_WARNING_AS_ERROR")); + if (wError.IsOn() && wErrorFlag.IsSet()) { + flags.emplace_back(wErrorFlag); + } } // Add compile flag for the MSVC compiler only. diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 4977083..c8b037e 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -411,7 +411,10 @@ class cmMakefile; 3, 24, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0136, \ "Watcom runtime library flags are selected by an abstraction.", 3, \ - 24, 0, cmPolicies::WARN) + 24, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0137, \ + "try_compile() passes platform variables in project mode", 3, 24, 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/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index 26f255d..4dfdfae 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -236,6 +236,7 @@ bool cmRuntimeDependencyArchive::GetGetRuntimeDependenciesCommand( cmGlobalGenerator* gg = this->GetMakefile()->GetGlobalGenerator(); // Add newer Visual Studio paths + AddVisualStudioPath(paths, "Visual Studio 17 ", 17, gg); AddVisualStudioPath(paths, "Visual Studio 16 ", 16, gg); AddVisualStudioPath(paths, "Visual Studio 15 ", 15, gg); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index cb32172..527175d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3429,3 +3429,12 @@ cm::string_view cmSystemTools::GetSystemName() return ""; #endif } + +char cmSystemTools::GetSystemPathlistSeparator() +{ +#if defined(_WIN32) + return ';'; +#else + return ':'; +#endif +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index c17ecbd..4865a4b 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -535,6 +535,9 @@ public: /** Get the system name. */ static cm::string_view GetSystemName(); + /** Get the system path separator character */ + static char GetSystemPathlistSeparator(); + private: static bool s_ForceUnixPaths; static bool s_RunCommandHideConsole; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 80d1940..83dc1c2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -621,7 +621,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } initProp("FOLDER"); - initProp("VERIFY_HEADER_SETS"); + initProp("VERIFY_INTERFACE_HEADER_SETS"); if (this->GetGlobalGenerator()->IsXcode()) { initProp("XCODE_GENERATE_SCHEME"); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1739b5a..60b89df 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3356,6 +3356,43 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } } + // Get includes for this target + if (!this->LangForClCompile.empty()) { + auto includeList = this->GetIncludes(configName, this->LangForClCompile); + + auto sysIncludeFlag = this->Makefile->GetDefinition( + cmStrCat("CMAKE_INCLUDE_SYSTEM_FLAG_", this->LangForClCompile)); + + if (sysIncludeFlag) { + bool gotOneSys = false; + for (auto i : includeList) { + cmSystemTools::ConvertToUnixSlashes(i); + if (this->GeneratorTarget->IsSystemIncludeDirectory( + i, configName, this->LangForClCompile)) { + auto flag = cmTrimWhitespace(*sysIncludeFlag); + if (this->MSTools) { + cmSystemTools::ReplaceString(flag, "-external:I", "/external:I"); + } + clOptions.AppendFlagString("AdditionalOptions", + cmStrCat(flag, " \"", i, '"')); + gotOneSys = true; + } else { + clOptions.AddInclude(i); + } + } + + if (gotOneSys) { + if (auto sysIncludeFlagWarning = this->Makefile->GetDefinition( + cmStrCat("_CMAKE_INCLUDE_SYSTEM_FLAG_", this->LangForClCompile, + "_WARNING"))) { + flags = cmStrCat(flags, ' ', *sysIncludeFlagWarning); + } + } + } else { + clOptions.AddIncludes(includeList); + } + } + clOptions.Parse(flags); clOptions.Parse(defineFlags); std::vector<std::string> targetDefines; @@ -3382,12 +3419,6 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.AppendFlag("DefineConstants", targetDefines); } - // Get includes for this target - if (!this->LangForClCompile.empty()) { - clOptions.AddIncludes( - this->GetIncludes(configName, this->LangForClCompile)); - } - if (this->MSTools) { clOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index d5d08b8..00c65ed 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -171,14 +171,15 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() code.clear(); } - if (arch.empty() && gencode.empty()) { - return; - } - // Create a CodeGeneration field with [arch],[code] syntax in each entry. // CUDA will convert it to `-gencode=arch=[arch],code="[code],[arch]"`. FlagValue& result = this->FlagMap["CodeGeneration"]; + // If there are no flags, leave the CodeGeneration field empty. + if (arch.empty() && gencode.empty()) { + return; + } + // First entries for the -arch=<arch> [-code=<code>,...] pair. if (!arch.empty()) { std::string arch_name = arch[0]; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a8dc963..6d99a3c 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1086,6 +1086,14 @@ void cmake::SetArgs(const std::vector<std::string>& args) << "uninitialized variables.\n"; state->SetCheckSystemVars(true); return true; + } }, + CommandArgument{ + "--compile-no-warning-as-error", CommandArgument::Values::Zero, + [](std::string const&, cmake* state) -> bool { + std::cout << "Ignoring COMPILE_WARNING_AS_ERROR target property and " + << "CMAKE_COMPILE_WARNING_AS_ERROR variable.\n"; + state->SetIgnoreWarningAsError(true); + return true; } } }; diff --git a/Source/cmake.h b/Source/cmake.h index c2bbff7..3c6af17 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -534,6 +534,8 @@ public: void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b; } bool GetCheckSystemVars() const { return this->CheckSystemVars; } void SetCheckSystemVars(bool b) { this->CheckSystemVars = b; } + bool GetIgnoreWarningAsError() const { return this->IgnoreWarningAsError; } + void SetIgnoreWarningAsError(bool b) { this->IgnoreWarningAsError = b; } void MarkCliAsUsed(const std::string& variable); @@ -686,6 +688,7 @@ private: bool WarnUninitialized = false; bool WarnUnusedCli = true; bool CheckSystemVars = false; + bool IgnoreWarningAsError = false; std::map<std::string, bool> UsedCliVariables; std::string CMakeEditCommand; std::string CXXEnvironment; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 41c6c12..19b922b 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -111,6 +111,9 @@ const char* cmDocumentationOptions[][2] = { { "--check-system-vars", "Find problems with variable usage in system " "files." }, + { "--compile-no-warning-as-error", + "Ignore COMPILE_WARNING_AS_ERROR property and " + "CMAKE_COMPILE_WARNING_AS_ERROR variable." }, # if !defined(CMAKE_BOOTSTRAP) { "--profiling-format=<fmt>", "Output data for profiling CMake scripts. Supported formats: " diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9cee144..7fdfaea 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -431,8 +431,10 @@ if(BUILD_TESTING) if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") ADD_TEST_MACRO(CSharpOnly CSharpOnly) - ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx) - ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx) + if(NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") + ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx) + ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx) + endif() ADD_TEST_MACRO(CSharpWin32GenEx CSharpWin32GenEx) set_tests_properties(CSharpWin32GenEx PROPERTIES PASS_REGULAR_EXPRESSION "Target \"CSharpWin32GenEx\" has a generator expression in its\n WIN32_EXECUTABLE property\\. This is not supported on managed executables\\." @@ -2113,6 +2115,7 @@ if(BUILD_TESTING) if(MSVC AND NOT MSVC_VERSION LESS 1310 AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio 9 " OR CMAKE_SIZEOF_VOID_P EQUAL 4) + AND (NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") ) ADD_TEST_MACRO(VSMASM VSMASM) endif() @@ -2123,7 +2126,8 @@ if(BUILD_TESTING) endif() if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio 9 " - AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v90") + AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v90" + AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx) ADD_TEST_MACRO(VSManagedCustomCommand) endif() diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 7490a80..d3b0e9e 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -19,7 +19,7 @@ extern int testStaticLibPlugin(void); #else # define testLib4libcfg testLib4libopt #endif -extern testLib4libcfg(void); +extern int testLib4libcfg(void); int main() { diff --git a/Tests/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt index 7ae8a11..a492daa 100644 --- a/Tests/FindVulkan/Test/CMakeLists.txt +++ b/Tests/FindVulkan/Test/CMakeLists.txt @@ -1,9 +1,13 @@ cmake_minimum_required(VERSION 3.4) +cmake_policy(SET CMP0091 NEW) project(TestFindVulkan C CXX) include(CTest) -SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../) -find_package(Vulkan REQUIRED) +find_package(Vulkan REQUIRED + COMPONENTS + glslang + shaderc_combined + SPIRV-Tools) add_executable(test_tgt main.c) target_link_libraries(test_tgt Vulkan::Vulkan) @@ -23,6 +27,39 @@ target_include_directories(test_var_dl PRIVATE ${Vulkan_INCLUDE_DIRS}) target_link_libraries(test_var_dl ${CMAKE_DL_LIBS}) add_test(NAME test_var_dl COMMAND test_var_dl) +add_executable(test_tgt_glslang main-glslang.cxx) +target_link_libraries(test_tgt_glslang Vulkan::glslang) +add_test(NAME test_tgt_glslang COMMAND test_tgt_glslang) + +get_property(glslang_debug_location TARGET Vulkan::glslang PROPERTY IMPORTED_LOCATION_DEBUG) +if(NOT glslang_debug_location) + set_property(TARGET test_tgt_glslang + PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + +add_executable(test_tgt_shaderc_combined main-shaderc_combined.cxx) +target_link_libraries(test_tgt_shaderc_combined Vulkan::shaderc_combined) +add_test(NAME test_tgt_shaderc_combined COMMAND test_tgt_shaderc_combined) + +get_property(shaderc_combined_debug_location TARGET Vulkan::shaderc_combined PROPERTY IMPORTED_LOCATION_DEBUG) +if(NOT shaderc_combined_debug_location) + set_property(TARGET test_tgt_shaderc_combined + PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + +add_executable(test_tgt_SPIRV-Tools main-SPIRV-Tools.c) +target_link_libraries(test_tgt_SPIRV-Tools Vulkan::SPIRV-Tools) +add_test(NAME test_tgt_SPIRV-Tools COMMAND test_tgt_SPIRV-Tools) + +get_property(SPIRV-Tools_debug_location TARGET Vulkan::SPIRV-Tools PROPERTY IMPORTED_LOCATION_DEBUG) +if(NOT SPIRV-Tools_debug_location) + set_property(TARGET test_tgt_SPIRV-Tools + PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + if(Vulkan_GLSLC_EXECUTABLE) add_test(NAME test_glslc COMMAND ${CMAKE_COMMAND} diff --git a/Tests/FindVulkan/Test/main-SPIRV-Tools.c b/Tests/FindVulkan/Test/main-SPIRV-Tools.c new file mode 100644 index 0000000..097198d --- /dev/null +++ b/Tests/FindVulkan/Test/main-SPIRV-Tools.c @@ -0,0 +1,15 @@ +#include <assert.h> +#include <spirv-tools/libspirv.h> +#include <stdio.h> + +int main() +{ + const char* spv_version = spvSoftwareVersionString(); + const char* spv_details = spvSoftwareVersionDetailsString(); + assert(spv_version); + assert(spv_details); + + printf("SPIRV-Tools version: %s (details: %s)", spv_version, spv_details); + + return 0; +} diff --git a/Tests/FindVulkan/Test/main-glslang.cxx b/Tests/FindVulkan/Test/main-glslang.cxx new file mode 100644 index 0000000..81b18d6 --- /dev/null +++ b/Tests/FindVulkan/Test/main-glslang.cxx @@ -0,0 +1,24 @@ +#include <cassert> +#include <iostream> + +#include <glslang/Public/ShaderLang.h> + +int main() +{ + const glslang::Version glslang_version = glslang::GetVersion(); + const char* glslang_essl_version = glslang::GetEsslVersionString(); + const char* glslang_glsl_version = glslang::GetGlslVersionString(); + const int glslang_khronos_tool_id = glslang::GetKhronosToolId(); + + std::cout << "glslang Version: " << glslang_version.major << '.' + << glslang_version.minor << '.' << glslang_version.patch + << " (glsl version: " << glslang_glsl_version + << ", essl version:" << glslang_essl_version + << ", khronos tool:" << glslang_khronos_tool_id << ')' + << std::endl; + + assert(glslang_essl_version); + assert(glslang_glsl_version); + + return 0; +} diff --git a/Tests/FindVulkan/Test/main-shaderc_combined.cxx b/Tests/FindVulkan/Test/main-shaderc_combined.cxx new file mode 100644 index 0000000..30449fb --- /dev/null +++ b/Tests/FindVulkan/Test/main-shaderc_combined.cxx @@ -0,0 +1,14 @@ +#include <assert.h> +#include <shaderc/shaderc.h> +#include <stdio.h> + +int main() +{ + unsigned int shaderc_version, shaderc_revision; + shaderc_get_spv_version(&shaderc_version, &shaderc_revision); + + printf("shaderc version: %u (revision: %u)", shaderc_version, + shaderc_revision); + + return 0; +} diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 788c5be..bb4b92c 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -11,11 +11,11 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA OR CMAKE_C_COMPILER_ID STREQUAL AppleClang OR CMAKE_C_COMPILER_ID STREQUAL LCC OR ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC" AND - CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29.30036.3" AND - NOT CMAKE_GENERATOR MATCHES "Visual Studio")) # No support for VS generators yet. + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29.30036.3")) AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja" - OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) + OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0) + OR CMAKE_GENERATOR MATCHES "Visual Studio")) if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC") set(run_sys_includes_test 1) else () diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index a746a68..e4973b0 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -23,7 +23,8 @@ target_include_directories(upstream SYSTEM PUBLIC ) add_library(config_specific INTERFACE) -if(CMAKE_GENERATOR STREQUAL "Xcode") +get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(isMultiConfig) # CMAKE_BUILD_TYPE does not work here for multi-config generators target_include_directories(config_specific SYSTEM INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/config_specific" diff --git a/Tests/RunCMake/AutoExportDll/AutoExport.cmake b/Tests/RunCMake/AutoExportDll/AutoExport.cmake index 85eff7e..dbcf4b8 100644 --- a/Tests/RunCMake/AutoExportDll/AutoExport.cmake +++ b/Tests/RunCMake/AutoExportDll/AutoExport.cmake @@ -6,7 +6,8 @@ add_library(objlib OBJECT objlib.c) set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(autoexport SHARED hello.cxx world.cxx foo.c $<TARGET_OBJECTS:objlib>) add_library(autoexport3 SHARED cppCLI.cxx) -if(MSVC AND NOT MSVC_VERSION VERSION_LESS 1600) +if(MSVC AND NOT MSVC_VERSION VERSION_LESS 1600 + AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") set_property(TARGET autoexport3 PROPERTY COMMON_LANGUAGE_RUNTIME "") endif() @@ -15,7 +16,8 @@ if(MSVC) set_target_properties(say PROPERTIES ENABLE_EXPORTS ON) add_library(autoexport_for_exec SHARED hello2.c) target_link_libraries(autoexport_for_exec say) - if(NOT MSVC_VERSION VERSION_LESS 1600) + if(NOT MSVC_VERSION VERSION_LESS 1600 AND + NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") enable_language(ASM_MASM) target_sources(autoexport PRIVATE nop.asm) set_property(SOURCE nop.asm PROPERTY COMPILE_FLAGS /safeseh) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 07b256c..4fe6ac1 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -960,7 +960,9 @@ endif() if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|9[0-9])") add_RunCMake_test(CSharpCustomCommand) - add_RunCMake_test(CSharpReferenceImport) + if(NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") + add_RunCMake_test(CSharpReferenceImport) + endif() endif() add_RunCMake_test("CTestCommandExpandLists") diff --git a/Tests/RunCMake/CMakePresets/PathListSep.cmake b/Tests/RunCMake/CMakePresets/PathListSep.cmake new file mode 100644 index 0000000..52c225b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSep.cmake @@ -0,0 +1,7 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +if(CMAKE_HOST_WIN32) + test_variable(TEST_PATH_LIST_SEP "" "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}") +else() + test_variable(TEST_PATH_LIST_SEP "" "${CMAKE_CURRENT_SOURCE_DIR}:${CMAKE_CURRENT_SOURCE_DIR}") +endif() diff --git a/Tests/RunCMake/CMakePresets/PathListSep.json.in b/Tests/RunCMake/CMakePresets/PathListSep.json.in new file mode 100644 index 0000000..4c25029 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSep.json.in @@ -0,0 +1,13 @@ +{ + "version": 5, + "configurePresets": [ + { + "name": "PathListSep", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_PATH_LIST_SEP": "${sourceDir}${pathListSep}${sourceDir}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt b/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt b/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt new file mode 100644 index 0000000..b961aaf --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/PathListSepFuture: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in b/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in new file mode 100644 index 0000000..2fd6b7e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in @@ -0,0 +1,13 @@ +{ + "version": 4, + "configurePresets": [ + { + "name": "PathListSepFuture", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_PATH_LIST_SEP": "${sourceDir}${pathListSep}${sourceDir}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 5867efd..d097086 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -335,6 +335,12 @@ unset(CMakePresets_EXTRA_FILES) set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/FileDirFuture.json.in") run_cmake_presets(FileDirFuture) +# Test ${pathListSep} macro +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/PathListSep.json.in") +run_cmake_presets(PathListSep) +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/PathListSepFuture.json.in") +run_cmake_presets(PathListSepFuture) + # Test conditions set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Conditions.json.in") run_cmake_presets(ListConditions --list-presets) diff --git a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt index 4dd6be1..a182e1c 100644 --- a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt +++ b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt @@ -1 +1 @@ --- CMAKE_VS_PLATFORM_NAME='(x64|Win32)' +-- CMAKE_VS_PLATFORM_NAME='(x64|Win32|ARM64)' diff --git a/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake b/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake index 059c80f..a532f72 100644 --- a/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake @@ -3,10 +3,11 @@ include(RunCMake) function(run_compile_warn test) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) set(RunCMake_TEST_OUTPUT_MERGE 1) - run_cmake(${test}) + run_cmake_with_options(${test} ${ARGN}) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(${test}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() run_compile_warn(WerrorOn) run_compile_warn(WerrorOff) +run_compile_warn(WerrorOnIgnore "--compile-no-warning-as-error") diff --git a/Tests/RunCMake/CompileWarningAsError/WerrorOnIgnore.cmake b/Tests/RunCMake/CompileWarningAsError/WerrorOnIgnore.cmake new file mode 100644 index 0000000..1f7ccdb --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WerrorOnIgnore.cmake @@ -0,0 +1,8 @@ +enable_language(CXX) + +include(WarningAsErrorOptions.cmake) +get_warning_options(warning_options) + +add_executable(WerrorOn warn.cxx) +target_compile_options(WerrorOn PUBLIC "${warning_options}") +set_target_properties(WerrorOn PROPERTIES COMPILE_WARNING_AS_ERROR ON) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake index 854f3dc..9d5d0b5 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake @@ -1,10 +1,21 @@ message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") +message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR='${CMAKE_HOST_SYSTEM_PROCESSOR}'") if(CMAKE_GENERATOR MATCHES "Visual Studio 1[67]") cmake_host_system_information(RESULT is_64_bit QUERY IS_64BIT) if(is_64_bit) - if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64") + if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "ARM64") + if(CMAKE_GENERATOR STREQUAL "Visual Studio 17 2022") + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "ARM64") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'ARM64' as expected.") + endif() + else() + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not empty as expected.") + endif() + endif() + elseif(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64") message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'x64' as expected.") endif() endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake index 3e418c3..2ba8c3b 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake @@ -17,9 +17,9 @@ set(releaseOK FALSE) file(STRINGS "${csProjectFile}" lines) foreach(line IN LISTS lines) #message(STATUS ${line}) - if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*") + if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64|ARM64).*") set(inDebug TRUE) - elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*") + elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64|ARM64).*") set(inRelease TRUE) elseif(line MATCHES "^ *</PropertyGroup> *$") set(inRelease FALSE) diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake index 631abac..d47bac9 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake @@ -17,9 +17,9 @@ set(releaseOK FALSE) file(STRINGS "${csProjectFile}" lines) foreach(line IN LISTS lines) #message(STATUS ${line}) - if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*") + if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64|ARM64).*") set(inDebug TRUE) - elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*") + elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64|ARM64).*") set(inRelease TRUE) elseif(line MATCHES "^ *</PropertyGroup> *$") set(inRelease FALSE) diff --git a/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake b/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake index 06d48bf..edc655b 100644 --- a/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake +++ b/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake @@ -9,34 +9,34 @@ function(run_cmake_build name target) run_cmake_command(${name}-${target}-${BUILD_CONFIG}-build ${CMAKE_COMMAND} --build . --config ${BUILD_CONFIG} --target ${target}) endfunction() -set(RunCMake_TEST_OPTIONS -DCMAKE_VERIFY_HEADER_SETS=ON) +set(RunCMake_TEST_OPTIONS -DCMAKE_VERIFY_INTERFACE_HEADER_SETS=ON) if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() run_cmake(VerifyHeaderSets) unset(RunCMake_TEST_OPTIONS) -run_cmake_build(VerifyHeaderSets static_verify_header_sets) -run_cmake_build(VerifyHeaderSets shared_verify_header_sets) -run_cmake_build(VerifyHeaderSets object_verify_header_sets) -run_cmake_build(VerifyHeaderSets interface_verify_header_sets) -run_cmake_build(VerifyHeaderSets exe_verify_header_sets) -run_cmake_build(VerifyHeaderSets export_exe_verify_header_sets) -run_cmake_build(VerifyHeaderSets none_verify_header_sets) -run_cmake_build(VerifyHeaderSets property_off_verify_header_sets) -run_cmake_build(VerifyHeaderSets private_verify_header_sets) -run_cmake_build(VerifyHeaderSets a_h_verify_header_sets) -run_cmake_build(VerifyHeaderSets dir_c_h_verify_header_sets) -run_cmake_build(VerifyHeaderSets dir_cxx_h_verify_header_sets) +run_cmake_build(VerifyHeaderSets static_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets shared_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets object_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets interface_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets exe_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets export_exe_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets none_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets property_off_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets private_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets a_h_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets dir_c_h_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets dir_cxx_h_verify_interface_header_sets) if(NOT RunCMake_GENERATOR STREQUAL "Xcode") - run_cmake_build(VerifyHeaderSets config_verify_header_sets) + run_cmake_build(VerifyHeaderSets config_verify_interface_header_sets) if(RunCMake_GENERATOR_IS_MULTI_CONFIG) set(BUILD_CONFIG Release) - run_cmake_build(VerifyHeaderSets config_verify_header_sets) + run_cmake_build(VerifyHeaderSets config_verify_interface_header_sets) unset(BUILD_CONFIG) endif() endif() -run_cmake_build(VerifyHeaderSets lang_test_c_verify_header_sets) -run_cmake_build(VerifyHeaderSets lang_test_cxx_verify_header_sets) +run_cmake_build(VerifyHeaderSets lang_test_c_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets lang_test_cxx_verify_interface_header_sets) diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_interface_header_sets-Debug-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_interface_header_sets-Debug-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_interface_header_sets-Debug-build-stderr.txt index b78bc52..b78bc52 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stdout.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_interface_header_sets-Debug-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_interface_header_sets-Debug-build-stdout.txt index b78bc52..b78bc52 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_interface_header_sets-Debug-build-stdout.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-check.cmake b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-check.cmake index 44e028f..100f482 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-check.cmake +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-check.cmake @@ -1,5 +1,5 @@ function(check_file target filename) - set(full_filename "${RunCMake_TEST_BINARY_DIR}/${target}_verify_header_sets/${filename}") + set(full_filename "${RunCMake_TEST_BINARY_DIR}/${target}_verify_interface_header_sets/${filename}") if(NOT EXISTS "${full_filename}") string(APPEND RunCMake_TEST_FAILED "File ${full_filename} should exist but does not\n") set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Debug-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Debug-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Debug-build-stderr.txt index eaa9a03..eaa9a03 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stdout.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Debug-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Debug-build-stdout.txt index eaa9a03..eaa9a03 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Debug-build-stdout.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Release-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Release-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Release-build-stderr.txt index 25699f9..25699f9 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stdout.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Release-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Release-build-stdout.txt index 25699f9..25699f9 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_interface_header_sets-Release-build-stdout.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_interface_header_sets-Debug-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_interface_header_sets-Debug-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_interface_header_sets-Debug-build-stderr.txt index 27ef042..27ef042 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stdout.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_interface_header_sets-Debug-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_interface_header_sets-Debug-build-stdout.txt index 27ef042..27ef042 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_interface_header_sets-Debug-build-stdout.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_interface_header_sets-Debug-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_interface_header_sets-Debug-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_interface_header_sets-Debug-build-stderr.txt index cd17d11..cd17d11 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stdout.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_interface_header_sets-Debug-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_interface_header_sets-Debug-build-stdout.txt index cd17d11..cd17d11 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_interface_header_sets-Debug-build-stdout.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_interface_header_sets-Debug-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_interface_header_sets-Debug-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_interface_header_sets-Debug-build-stderr.txt index 8d98f9d..8d98f9d 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_interface_header_sets-Debug-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_interface_header_sets-Debug-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_interface_header_sets-Debug-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_interface_header_sets-Debug-build-stderr.txt index 8d98f9d..8d98f9d 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_interface_header_sets-Debug-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_interface_header_sets-Debug-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_interface_header_sets-Debug-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_interface_header_sets-Debug-build-stderr.txt index 8d98f9d..8d98f9d 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_interface_header_sets-Debug-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_interface_header_sets-Debug-build-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-result.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_interface_header_sets-Debug-build-result.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_interface_header_sets-Debug-build-stderr.txt index 8d98f9d..8d98f9d 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-stderr.txt +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_interface_header_sets-Debug-build-stderr.txt diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake index f515031..24298df 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake @@ -27,7 +27,7 @@ add_library(none STATIC lib.c) add_library(property_off STATIC lib.c) target_sources(property_off INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) -set_property(TARGET property_off PROPERTY VERIFY_HEADER_SETS OFF) +set_property(TARGET property_off PROPERTY VERIFY_INTERFACE_HEADER_SETS OFF) add_library(private STATIC lib.c) target_sources(private PRIVATE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake index 48d8e1a..0b5fb8d 100644 --- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake +++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake @@ -1 +1 @@ -check_installed([[^empty1.txt;empty2.txt$]]) +check_installed([[^empty1.txt;empty3.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake index 48d8e1a..88e57e3 100644 --- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake +++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake @@ -1 +1 @@ -check_installed([[^empty1.txt;empty2.txt$]]) +check_installed([[^empty1.txt;empty2.txt;empty3.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake index 48d8e1a..88e57e3 100644 --- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake +++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake @@ -1 +1 @@ -check_installed([[^empty1.txt;empty2.txt$]]) +check_installed([[^empty1.txt;empty2.txt;empty3.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake index aa3f9d1..73c4e35 100644 --- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake +++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake @@ -1,5 +1,16 @@ + install( SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake" + ALL_COMPONENTS +) + +install( CODE "write_empty_file(empty2.txt)" ALL_COMPONENTS - ) + EXCLUDE_FROM_ALL +) + +install( + CODE "write_empty_file(empty3.txt)" + ALL_COMPONENTS +) diff --git a/Tests/RunCMake/project/CodeInjection-stdout.txt b/Tests/RunCMake/project/CodeInjection-stdout.txt new file mode 100644 index 0000000..88ac966 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection-stdout.txt @@ -0,0 +1,10 @@ +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE +(-- )?Included CMAKE_TOOLCHAIN_FILE +.*Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES first file +(-- )?Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES second file +(-- )?Included CMAKE_PROJECT_INCLUDE +(-- )?Calling sub-project +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE +(-- )?Included CMAKE_PROJECT_INCLUDE +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE diff --git a/Tests/RunCMake/project/CodeInjection.cmake b/Tests/RunCMake/project/CodeInjection.cmake new file mode 100644 index 0000000..dcf56a1 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection.cmake @@ -0,0 +1 @@ +add_subdirectory(CodeInjection) diff --git a/Tests/RunCMake/project/CodeInjection/CMakeLists.txt b/Tests/RunCMake/project/CodeInjection/CMakeLists.txt new file mode 100644 index 0000000..8ee99d0 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/CMakeLists.txt @@ -0,0 +1,2 @@ +message(STATUS "Calling sub-project") +project(SubProj LANGUAGES NONE) diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake new file mode 100644 index 0000000..f3f0a7e --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_INCLUDE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake new file mode 100644 index 0000000..01d53c9 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_INCLUDE_BEFORE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake new file mode 100644 index 0000000..d68de6a --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake new file mode 100644 index 0000000..ef3bfc0 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake new file mode 100644 index 0000000..73ad037 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES first file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake new file mode 100644 index 0000000..80f9705 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES second file") diff --git a/Tests/RunCMake/project/CodeInjection/initial_cache.cmake b/Tests/RunCMake/project/CodeInjection/initial_cache.cmake new file mode 100644 index 0000000..6c8995b --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/initial_cache.cmake @@ -0,0 +1,10 @@ +set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/passthrough_toolchain_file.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_include.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_include_before.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_SubProj_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_include.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_SubProj_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_include_before.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_top_level_includes_1.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_top_level_includes_2.cmake" + CACHE STRING "" +) diff --git a/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake b/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake new file mode 100644 index 0000000..d045712 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_TOOLCHAIN_FILE") diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index d7dab12..945d9ed 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -1,5 +1,14 @@ include(RunCMake) +# Use an initial cache file to define the project() variables +# to avoid long command lines. Also see the CMakeOnly test case +# which tests some of the individual variables one at a time. +# Here, we are focused on testing that the variables are all injected +# at the expected points in the expected order. +run_cmake_with_options(CodeInjection + -C "${CMAKE_CURRENT_LIST_DIR}/CodeInjection/initial_cache.cmake" +) + if(CMake_TEST_RESOURCES) run_cmake(ExplicitRC) endif() diff --git a/Tests/RunCMake/try_compile/CMP0137-Common.cmake b/Tests/RunCMake/try_compile/CMP0137-Common.cmake new file mode 100644 index 0000000..2c1bc0d --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-Common.cmake @@ -0,0 +1,16 @@ +set(CMAKE_ENABLE_EXPORTS 1) +set(FOO 2) +set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES FOO) +try_compile(RESULT_VAR + ${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build + ${CMAKE_CURRENT_SOURCE_DIR}/CMP0137 + TestCMP0137) +include(${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build/info.cmake OPTIONAL) + +message(STATUS "Enabling CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES") +set(CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES 1) +try_compile(RESULT_VAR + ${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build2 + ${CMAKE_CURRENT_SOURCE_DIR}/CMP0137 + TestCMP0137) +include(${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build2/info.cmake OPTIONAL) diff --git a/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt b/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt new file mode 100644 index 0000000..abc61dc --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt @@ -0,0 +1,5 @@ +-- CMAKE_ENABLE_EXPORTS='1' +-- FOO='2' +-- Enabling CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES +-- CMAKE_ENABLE_EXPORTS='' +-- FOO='' diff --git a/Tests/RunCMake/try_compile/CMP0137-NEW.cmake b/Tests/RunCMake/try_compile/CMP0137-NEW.cmake new file mode 100644 index 0000000..f7caa50 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0137 NEW) +include(CMP0137-Common.cmake) diff --git a/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt b/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt new file mode 100644 index 0000000..2e4bebe --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt @@ -0,0 +1,5 @@ +-- CMAKE_ENABLE_EXPORTS='' +-- FOO='' +-- Enabling CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES +-- CMAKE_ENABLE_EXPORTS='' +-- FOO='' diff --git a/Tests/RunCMake/try_compile/CMP0137-WARN.cmake b/Tests/RunCMake/try_compile/CMP0137-WARN.cmake new file mode 100644 index 0000000..61b5641 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-WARN.cmake @@ -0,0 +1,2 @@ +# policy CMP0137 not set +include(CMP0137-Common.cmake) diff --git a/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt b/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt new file mode 100644 index 0000000..a3b9fda --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.23) +project(TestCMP0137 NONE) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" " +message(STATUS \"CMAKE_ENABLE_EXPORTS='${CMAKE_ENABLE_EXPORTS}'\") +message(STATUS \"FOO='${FOO}'\") +") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index dcd3799..eca7bf4 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -72,6 +72,8 @@ endif() run_cmake(CMP0056) run_cmake(CMP0066) run_cmake(CMP0067) +run_cmake(CMP0137-WARN) +run_cmake(CMP0137-NEW) if(RunCMake_GENERATOR MATCHES "Make|Ninja") # Use a single build tree for a few tests without cleaning. diff --git a/Tests/TargetName/executables/hello_world.c b/Tests/TargetName/executables/hello_world.c index 5b6eaf8..71d71f5 100644 --- a/Tests/TargetName/executables/hello_world.c +++ b/Tests/TargetName/executables/hello_world.c @@ -1,5 +1,6 @@ #include <stdio.h> -main() +int main(void) { printf("hello, world\n"); + return 0; } diff --git a/Utilities/Release/README.rst b/Utilities/Release/README.rst index dfaf831..770b579 100644 --- a/Utilities/Release/README.rst +++ b/Utilities/Release/README.rst @@ -91,3 +91,9 @@ macOS The ``macos/`` directory contains scripts used to produce dependencies for building CMake binaries on macOS. + +Windows +------- + +The ``win/`` directory contains scripts used to produce dependencies +for building CMake binaries on Windows. diff --git a/Utilities/Release/win/qt-5.12.1-win-x86-msvc-install.patch b/Utilities/Release/win/qt-5.12.1-win-x86-msvc-install.patch new file mode 100644 index 0000000..39a649e --- /dev/null +++ b/Utilities/Release/win/qt-5.12.1-win-x86-msvc-install.patch @@ -0,0 +1,26 @@ +diff --git a/lib/cmake/Qt5Core/Qt5CoreConfig.cmake b/lib/cmake/Qt5Core/Qt5CoreConfig.cmake +index 04ec302..75d5596 100644 +--- a/lib/cmake/Qt5Core/Qt5CoreConfig.cmake ++++ b/lib/cmake/Qt5Core/Qt5CoreConfig.cmake +@@ -118,7 +118,7 @@ if (NOT TARGET Qt5::Core) + list(REMOVE_DUPLICATES Qt5Core_COMPILE_DEFINITIONS) + list(REMOVE_DUPLICATES Qt5Core_EXECUTABLE_COMPILE_FLAGS) + +- set(_Qt5Core_LIB_DEPENDENCIES "") ++ set(_Qt5Core_LIB_DEPENDENCIES "${_qt5Core_install_prefix}/lib/qtpcre2.lib;netapi32.lib;version.lib") + + + add_library(Qt5::Core STATIC IMPORTED) +diff --git a/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake b/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake +index a07b953..2e07371 100644 +--- a/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake ++++ b/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake +@@ -118,7 +118,7 @@ if (NOT TARGET Qt5::Widgets) + list(REMOVE_DUPLICATES Qt5Widgets_COMPILE_DEFINITIONS) + list(REMOVE_DUPLICATES Qt5Widgets_EXECUTABLE_COMPILE_FLAGS) + +- set(_Qt5Widgets_LIB_DEPENDENCIES "Qt5::Gui;Qt5::Core") ++ set(_Qt5Widgets_LIB_DEPENDENCIES "Qt5::Gui;Qt5::Core;dwmapi.lib;uxtheme.lib") + + + add_library(Qt5::Widgets STATIC IMPORTED) diff --git a/Utilities/Release/win/qt-5.12.1-win-x86-msvc.ps1 b/Utilities/Release/win/qt-5.12.1-win-x86-msvc.ps1 new file mode 100755 index 0000000..d9e9617 --- /dev/null +++ b/Utilities/Release/win/qt-5.12.1-win-x86-msvc.ps1 @@ -0,0 +1,118 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Run this script on a Windows host to generate Qt binaries. +# Set the PATH environment variable to contain the locations of cmake and git. + +param ( + [string]$cmake = 'cmake', + [string]$git = 'git', + [switch]$trace +) + +if ($trace -eq $true) { + Set-PSDebug -Trace 1 +} + +$ErrorActionPreference = 'Stop' +$ProgressPreference = 'SilentlyContinue' + +if ($env:VSCMD_ARG_TGT_ARCH -eq "x64") { + $arch = "x86_64"; +} elseif ($env:VSCMD_ARG_TGT_ARCH -eq "x86") { + $arch = "i386"; +} else { + Write-Host "VSCMD_ARG_TGT_ARCH env var not recognized. Run this from a Visual Studio Command Prompt." + exit 1 +} + +if ($env:VCToolsVersion -match '^(?<version>[0-9][0-9]\.[0-9])') { + $toolset = "msvc_v" + $Matches.version -replace '\.', '' +} else { + Write-Host "VCToolsVersion env var not set. Run this from a Visual Studio Command Prompt." +} + +$srcname = "qt-everywhere-src-5.12.1" +$pkgname = "qt-5.12.1-win-$arch-$toolset-1" +$topdir = $pwd.Path +$srcdir = Join-Path $topdir $srcname +$blddir = Join-Path $topdir "$pkgname-build" +$prefix = Join-Path $topdir $pkgname + +# JOM +if ( -not (Test-Path -Path "jom")) { + Invoke-WebRequest -Uri "http://download.qt-project.org/official_releases/jom/unstable-jom.zip" -OutFile jom.zip + if ($(Get-FileHash "jom.zip").Hash -ne '128fdd846fe24f8594eed37d1d8929a0ea78df563537c0c1b1861a635013fff8') { + exit 1 + } + Expand-Archive -Path jom.zip -DestinationPath jom + Remove-Item jom.zip +} +$jom = "$topdir\jom\jom.exe" + +# Qt Source +if ( -not (Test-Path -Path $srcdir)) { + Invoke-WebRequest -Uri "https://download.qt.io/official_releases/qt/5.12/5.12.1/single/qt-everywhere-src-5.12.1.tar.xz" -OutFile qt.tar.xz + if ($(Get-FileHash "qt.tar.xz").Hash -ne 'caffbd625c7bc10ff8c5c7a27dbc7d84fa4de146975c0e1ffe904b514ccd6da4') { + exit 1 + } + & $cmake -E tar xvf qt.tar.xz + Remove-Item qt.tar.xz +} + +# Build Qt +if ( -not (Test-Path -Path $blddir)) { + New-Item -ItemType Directory -Path $blddir + Set-Location -Path "$blddir" + & ..\$srcname\configure.bat ` + -prefix $prefix ` + -static ` + -static-runtime ` + -release ` + -opensource -confirm-license ` + -platform win32-msvc ` + -mp ` + -gui ` + -widgets ` + -qt-pcre ` + -qt-zlib ` + -qt-libpng ` + -qt-libjpeg ` + -no-gif ` + -no-icu ` + -no-pch ` + -no-angle ` + -no-opengl ` + -no-dbus ` + -no-harfbuzz ` + -no-accessibility ` + -skip declarative ` + -skip multimedia ` + -skip qtcanvas3d ` + -skip qtconnectivity ` + -skip qtdeclarative ` + -skip qtlocation ` + -skip qtmultimedia ` + -skip qtsensors ` + -skip qtserialport ` + -skip qtsvg ` + -skip qtwayland ` + -skip qtwebchannel ` + -skip qtwebengine ` + -skip qtwebsockets ` + -skip qtxmlpatterns ` + -nomake examples -nomake tests + & $jom -J $env:NUMBER_OF_PROCESSORS +} + +# Install Qt +if ( -not (Test-Path -Path $prefix)) { + & $jom install + # Patch the installation. + Set-Location -Path $prefix + & $git apply -v (Join-Path $PSScriptRoot qt-5.12.1-win-x86-msvc-install.patch) +} + +# Package Qt +Set-Location -Path $topdir +& $cmake -E tar cf "$pkgname.zip" "--format=zip" "$pkgname" diff --git a/Utilities/Release/win/sign-package.ps1 b/Utilities/Release/win/sign-package.ps1 new file mode 100755 index 0000000..0dbefd2 --- /dev/null +++ b/Utilities/Release/win/sign-package.ps1 @@ -0,0 +1,29 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Run this script on a Windows host in a CMake single-config build tree. + +param ( + [string]$signtool = 'signtool', + [string]$cpack = 'bin\cpack', + [switch]$trace +) + +if ($trace -eq $true) { + Set-PSDebug -Trace 1 +} + +$ErrorActionPreference = 'Stop' + +# Sign binaries with SHA-1 for Windows 7 and below. +& $signtool sign -v -a -t http://timestamp.digicert.com bin\*.exe + +# Sign binaries with SHA-256 for Windows 8 and above. +& $signtool sign -v -a -tr http://timestamp.digicert.com -fd sha256 -td sha256 -as bin\*.exe + +# Create packages. +& $cpack -G ZIP +& $cpack -G WIX + +# Sign installer with SHA-256. +& $signtool sign -v -a -tr http://timestamp.digicert.com -fd sha256 -td sha256 -d "CMake Windows Installer" cmake-*-win*.msi diff --git a/Utilities/Scripts/update-curl.bash b/Utilities/Scripts/update-curl.bash index 64cb659..9715e07 100755 --- a/Utilities/Scripts/update-curl.bash +++ b/Utilities/Scripts/update-curl.bash @@ -8,7 +8,7 @@ readonly name="curl" readonly ownership="Curl Upstream <curl-library@lists.haxx.se>" readonly subtree="Utilities/cmcurl" readonly repo="https://github.com/curl/curl.git" -readonly tag="curl-7_83_0" +readonly tag="curl-7_83_1" readonly shortlog=false readonly paths=" CMake/* diff --git a/Utilities/cmcurl/include/curl/curlver.h b/Utilities/cmcurl/include/curl/curlver.h index 3081115..718d58c 100644 --- a/Utilities/cmcurl/include/curl/curlver.h +++ b/Utilities/cmcurl/include/curl/curlver.h @@ -30,13 +30,13 @@ /* This is the version number of the libcurl package from which this header file origins: */ -#define LIBCURL_VERSION "7.83.0" +#define LIBCURL_VERSION "7.83.1" /* The numeric version number is also available "in parts" by using these defines: */ #define LIBCURL_VERSION_MAJOR 7 #define LIBCURL_VERSION_MINOR 83 -#define LIBCURL_VERSION_PATCH 0 +#define LIBCURL_VERSION_PATCH 1 /* This is the numeric version of the libcurl version number, meant for easier parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will @@ -57,7 +57,7 @@ CURL_VERSION_BITS() macro since curl's own configure script greps for it and needs it to contain the full number. */ -#define LIBCURL_VERSION_NUM 0x075300 +#define LIBCURL_VERSION_NUM 0x075301 /* * This is the date and time when the full source package was created. The diff --git a/Utilities/cmcurl/lib/altsvc.c b/Utilities/cmcurl/lib/altsvc.c index 45929a5..dd2d0eb 100644 --- a/Utilities/cmcurl/lib/altsvc.c +++ b/Utilities/cmcurl/lib/altsvc.c @@ -102,12 +102,17 @@ static struct altsvc *altsvc_createid(const char *srchost, unsigned int dstport) { struct altsvc *as = calloc(sizeof(struct altsvc), 1); + size_t hlen; if(!as) return NULL; - + hlen = strlen(srchost); + DEBUGASSERT(hlen); as->src.host = strdup(srchost); if(!as->src.host) goto error; + if(hlen && (srchost[hlen - 1] == '.')) + /* strip off trailing any dot */ + as->src.host[--hlen] = 0; as->dst.host = strdup(dsthost); if(!as->dst.host) goto error; @@ -398,6 +403,22 @@ static CURLcode getalnum(const char **ptr, char *alpnbuf, size_t buflen) return CURLE_OK; } +/* hostcompare() returns true if 'host' matches 'check'. The first host + * argument may have a trailing dot present that will be ignored. + */ +static bool hostcompare(const char *host, const char *check) +{ + size_t hlen = strlen(host); + size_t clen = strlen(check); + + if(hlen && (host[hlen - 1] == '.')) + hlen--; + if(hlen != clen) + /* they can't match if they have different lengths */ + return FALSE; + return strncasecompare(host, check, hlen); +} + /* altsvc_flush() removes all alternatives for this source origin from the list */ static void altsvc_flush(struct altsvcinfo *asi, enum alpnid srcalpnid, @@ -410,7 +431,7 @@ static void altsvc_flush(struct altsvcinfo *asi, enum alpnid srcalpnid, n = e->next; if((srcalpnid == as->src.alpnid) && (srcport == as->src.port) && - strcasecompare(srchost, as->src.host)) { + hostcompare(srchost, as->src.host)) { Curl_llist_remove(&asi->list, e, NULL); altsvc_free(as); } @@ -635,7 +656,7 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi, continue; } if((as->src.alpnid == srcalpnid) && - strcasecompare(as->src.host, srchost) && + hostcompare(srchost, as->src.host) && (as->src.port == srcport) && (versions & as->dst.alpnid)) { /* match */ diff --git a/Utilities/cmcurl/lib/c-hyper.c b/Utilities/cmcurl/lib/c-hyper.c index de09568..6908298 100644 --- a/Utilities/cmcurl/lib/c-hyper.c +++ b/Utilities/cmcurl/lib/c-hyper.c @@ -439,6 +439,13 @@ CURLcode Curl_hyper_stream(struct Curl_easy *data, reasonp = hyper_response_reason_phrase(resp); reason_len = hyper_response_reason_phrase_len(resp); + if(http_status == 417 && data->state.expect100header) { + infof(data, "Got 417 while waiting for a 100"); + data->state.disableexpect = TRUE; + data->req.newurl = strdup(data->state.url); + Curl_done_sending(data, k); + } + result = status_line(data, conn, http_status, http_version, reasonp, reason_len); if(result) @@ -951,6 +958,11 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) goto error; } } + else { + if(!h2 && !data->state.disableexpect) { + data->state.expect100header = TRUE; + } + } if(hyper_request_set_method(req, (uint8_t *)method, strlen(method))) { failf(data, "error setting method"); diff --git a/Utilities/cmcurl/lib/cookie.c b/Utilities/cmcurl/lib/cookie.c index 451881f..0c2d49b 100644 --- a/Utilities/cmcurl/lib/cookie.c +++ b/Utilities/cmcurl/lib/cookie.c @@ -427,7 +427,15 @@ static void remove_expired(struct CookieInfo *cookies) /* Make sure domain contains a dot or is localhost. */ static bool bad_domain(const char *domain) { - return !strchr(domain, '.') && !strcasecompare(domain, "localhost"); + if(strcasecompare(domain, "localhost")) + return FALSE; + else { + /* there must be a dot present, but that dot must not be a trailing dot */ + char *dot = strchr(domain, '.'); + if(dot) + return dot[1] ? FALSE : TRUE; + } + return TRUE; } /* diff --git a/Utilities/cmcurl/lib/easy.c b/Utilities/cmcurl/lib/easy.c index 65d7464..bd9d695 100644 --- a/Utilities/cmcurl/lib/easy.c +++ b/Utilities/cmcurl/lib/easy.c @@ -1139,7 +1139,7 @@ CURLcode curl_easy_recv(struct Curl_easy *data, void *buffer, size_t buflen, if(!data->conn) /* on first invoke, the transfer has been detached from the connection and needs to be reattached */ - Curl_attach_connnection(data, c); + Curl_attach_connection(data, c); *n = 0; result = Curl_read(data, sfd, buffer, buflen, &n1); @@ -1175,7 +1175,7 @@ CURLcode curl_easy_send(struct Curl_easy *data, const void *buffer, if(!data->conn) /* on first invoke, the transfer has been detached from the connection and needs to be reattached */ - Curl_attach_connnection(data, c); + Curl_attach_connection(data, c); *n = 0; sigpipe_ignore(data, &pipe_st); @@ -1209,12 +1209,12 @@ static int conn_upkeep(struct Curl_easy *data, if(conn->handler->connection_check) { /* briefly attach the connection to this transfer for the purpose of checking it */ - Curl_attach_connnection(data, conn); + Curl_attach_connection(data, conn); /* Do a protocol-specific keepalive check on the connection. */ conn->handler->connection_check(data, conn, CONNCHECK_KEEPALIVE); /* detach the connection again */ - Curl_detach_connnection(data); + Curl_detach_connection(data); } return 0; /* continue iteration */ diff --git a/Utilities/cmcurl/lib/hostip.c b/Utilities/cmcurl/lib/hostip.c index 7f6bbac..7000b85 100644 --- a/Utilities/cmcurl/lib/hostip.c +++ b/Utilities/cmcurl/lib/hostip.c @@ -1268,7 +1268,7 @@ CURLcode Curl_once_resolved(struct Curl_easy *data, bool *protocol_done) result = Curl_setup_conn(data, protocol_done); if(result) { - Curl_detach_connnection(data); + Curl_detach_connection(data); Curl_conncache_remove_conn(data, conn, TRUE); Curl_disconnect(data, conn, TRUE); } diff --git a/Utilities/cmcurl/lib/hsts.c b/Utilities/cmcurl/lib/hsts.c index 03fcc9e..b9fa6f7 100644 --- a/Utilities/cmcurl/lib/hsts.c +++ b/Utilities/cmcurl/lib/hsts.c @@ -114,16 +114,25 @@ static CURLcode hsts_create(struct hsts *h, curl_off_t expires) { struct stsentry *sts = hsts_entry(); + char *duphost; + size_t hlen; if(!sts) return CURLE_OUT_OF_MEMORY; - sts->expires = expires; - sts->includeSubDomains = subdomains; - sts->host = strdup(hostname); - if(!sts->host) { + duphost = strdup(hostname); + if(!duphost) { free(sts); return CURLE_OUT_OF_MEMORY; } + + hlen = strlen(duphost); + if(duphost[hlen - 1] == '.') + /* strip off trailing any dot */ + duphost[--hlen] = 0; + + sts->host = duphost; + sts->expires = expires; + sts->includeSubDomains = subdomains; Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node); return CURLE_OK; } @@ -238,10 +247,21 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname, bool subdomain) { if(h) { + char buffer[MAX_HSTS_HOSTLEN + 1]; time_t now = time(NULL); size_t hlen = strlen(hostname); struct Curl_llist_element *e; struct Curl_llist_element *n; + + if((hlen > MAX_HSTS_HOSTLEN) || !hlen) + return NULL; + memcpy(buffer, hostname, hlen); + if(hostname[hlen-1] == '.') + /* remove the trailing dot */ + --hlen; + buffer[hlen] = 0; + hostname = buffer; + for(e = h->list.head; e; e = n) { struct stsentry *sts = e->ptr; n = e->next; @@ -440,7 +460,7 @@ static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h) CURLSTScode sc; DEBUGASSERT(h); do { - char buffer[257]; + char buffer[MAX_HSTS_HOSTLEN + 1]; struct curl_hstsentry e; e.name = buffer; e.namelen = sizeof(buffer)-1; diff --git a/Utilities/cmcurl/lib/http.c b/Utilities/cmcurl/lib/http.c index 0d5c449..b215307 100644 --- a/Utilities/cmcurl/lib/http.c +++ b/Utilities/cmcurl/lib/http.c @@ -651,6 +651,21 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) return result; } +/* + * Curl_allow_auth_to_host() tells if authentication, cookies or other + * "sensitive data" can (still) be sent to this host. + */ +bool Curl_allow_auth_to_host(struct Curl_easy *data) +{ + struct connectdata *conn = data->conn; + return (!data->state.this_is_a_follow || + data->set.allow_auth_to_other_hosts || + (data->state.first_host && + strcasecompare(data->state.first_host, conn->host.name) && + (data->state.first_remote_port == conn->remote_port) && + (data->state.first_remote_protocol == conn->handler->protocol))); +} + #ifndef CURL_DISABLE_HTTP_AUTH /* * Output the correct authentication header depending on the auth type @@ -775,21 +790,6 @@ output_auth_headers(struct Curl_easy *data, return CURLE_OK; } -/* - * Curl_allow_auth_to_host() tells if authentication, cookies or other - * "sensitive data" can (still) be sent to this host. - */ -bool Curl_allow_auth_to_host(struct Curl_easy *data) -{ - struct connectdata *conn = data->conn; - return (!data->state.this_is_a_follow || - data->set.allow_auth_to_other_hosts || - (data->state.first_host && - strcasecompare(data->state.first_host, conn->host.name) && - (data->state.first_remote_port == conn->remote_port) && - (data->state.first_remote_protocol == conn->handler->protocol))); -} - /** * Curl_http_output_auth() setups the authentication headers for the * host/proxy and the correct authentication diff --git a/Utilities/cmcurl/lib/http_proxy.c b/Utilities/cmcurl/lib/http_proxy.c index 863cbbb..ed08193 100644 --- a/Utilities/cmcurl/lib/http_proxy.c +++ b/Utilities/cmcurl/lib/http_proxy.c @@ -967,6 +967,13 @@ static CURLcode CONNECT(struct Curl_easy *data, break; } + if(conn->bits.close && data->req.newurl) { + /* Connection closed by server. Don't use it anymore */ + Curl_closesocket(data, conn, conn->sock[sockindex]); + conn->sock[sockindex] = CURL_SOCKET_BAD; + break; + } + /* If we are supposed to continue and request a new URL, which basically * means the HTTP authentication is still going on so if the tunnel * is complete we start over in INIT state */ diff --git a/Utilities/cmcurl/lib/multi.c b/Utilities/cmcurl/lib/multi.c index 466425d..8e58d78 100644 --- a/Utilities/cmcurl/lib/multi.c +++ b/Utilities/cmcurl/lib/multi.c @@ -118,7 +118,7 @@ static void init_completed(struct Curl_easy *data) /* Important: reset the conn pointer so that we don't point to memory that could be freed anytime */ - Curl_detach_connnection(data); + Curl_detach_connection(data); Curl_expire_clear(data); /* stop all timers */ } @@ -635,7 +635,7 @@ static CURLcode multi_done(struct Curl_easy *data, process_pending_handles(data->multi); /* connection / multiplex */ CONNCACHE_LOCK(data); - Curl_detach_connnection(data); + Curl_detach_connection(data); if(CONN_INUSE(conn)) { /* Stop if still used. */ CONNCACHE_UNLOCK(data); @@ -824,7 +824,7 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi, that vanish with this handle */ /* Remove the association between the connection and the handle */ - Curl_detach_connnection(data); + Curl_detach_connection(data); if(data->state.lastconnect_id != -1) { /* Mark any connect-only connection for closure */ @@ -899,12 +899,12 @@ bool Curl_multiplex_wanted(const struct Curl_multi *multi) } /* - * Curl_detach_connnection() removes the given transfer from the connection. + * Curl_detach_connection() removes the given transfer from the connection. * * This is the only function that should clear data->conn. This will * occasionally be called with the data->conn pointer already cleared. */ -void Curl_detach_connnection(struct Curl_easy *data) +void Curl_detach_connection(struct Curl_easy *data) { struct connectdata *conn = data->conn; if(conn) { @@ -916,11 +916,11 @@ void Curl_detach_connnection(struct Curl_easy *data) } /* - * Curl_attach_connnection() attaches this transfer to this connection. + * Curl_attach_connection() attaches this transfer to this connection. * * This is the only function that should assign data->conn */ -void Curl_attach_connnection(struct Curl_easy *data, +void Curl_attach_connection(struct Curl_easy *data, struct connectdata *conn) { DEBUGASSERT(!data->conn); @@ -1540,7 +1540,7 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi, /* take this handle to the perform state right away */ multistate(data, MSTATE_PERFORMING); - Curl_attach_connnection(data, conn); + Curl_attach_connection(data, conn); k->keepon |= KEEP_RECV; /* setup to receive! */ } return rc; @@ -2558,7 +2558,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* This is where we make sure that the conn pointer is reset. We don't have to do this in every case block above where a failure is detected */ - Curl_detach_connnection(data); + Curl_detach_connection(data); /* remove connection from cache */ Curl_conncache_remove_conn(data, conn, TRUE); diff --git a/Utilities/cmcurl/lib/multiif.h b/Utilities/cmcurl/lib/multiif.h index f4d0ada..5a8c358 100644 --- a/Utilities/cmcurl/lib/multiif.h +++ b/Utilities/cmcurl/lib/multiif.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,9 +31,9 @@ void Curl_expire(struct Curl_easy *data, timediff_t milli, expire_id); void Curl_expire_clear(struct Curl_easy *data); void Curl_expire_done(struct Curl_easy *data, expire_id id); CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT; -void Curl_attach_connnection(struct Curl_easy *data, +void Curl_attach_connection(struct Curl_easy *data, struct connectdata *conn); -void Curl_detach_connnection(struct Curl_easy *data); +void Curl_detach_connection(struct Curl_easy *data); bool Curl_multiplex_wanted(const struct Curl_multi *multi); void Curl_set_in_callback(struct Curl_easy *data, bool value); bool Curl_is_in_callback(struct Curl_easy *easy); diff --git a/Utilities/cmcurl/lib/setopt.c b/Utilities/cmcurl/lib/setopt.c index 0df1afa..05e1a54 100644 --- a/Utilities/cmcurl/lib/setopt.c +++ b/Utilities/cmcurl/lib/setopt.c @@ -2294,6 +2294,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) case CURLOPT_SSL_OPTIONS: arg = va_arg(param, long); + data->set.ssl.primary.ssl_options = (unsigned char)(arg & 0xff); data->set.ssl.enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST); data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE); data->set.ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN); @@ -2307,6 +2308,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) #ifndef CURL_DISABLE_PROXY case CURLOPT_PROXY_SSL_OPTIONS: arg = va_arg(param, long); + data->set.proxy_ssl.primary.ssl_options = (unsigned char)(arg & 0xff); data->set.proxy_ssl.enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST); data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE); data->set.proxy_ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN); @@ -2745,49 +2747,52 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) case CURLOPT_TLSAUTH_USERNAME: result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME], va_arg(param, char *)); - if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype) - data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */ + if(data->set.str[STRING_TLSAUTH_USERNAME] && + !data->set.ssl.primary.authtype) + data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default to SRP */ break; #ifndef CURL_DISABLE_PROXY case CURLOPT_PROXY_TLSAUTH_USERNAME: result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY], va_arg(param, char *)); if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] && - !data->set.proxy_ssl.authtype) - data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */ + !data->set.proxy_ssl.primary.authtype) + data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default to + SRP */ break; #endif case CURLOPT_TLSAUTH_PASSWORD: result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD], va_arg(param, char *)); - if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype) - data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */ + if(data->set.str[STRING_TLSAUTH_USERNAME] && + !data->set.ssl.primary.authtype) + data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default */ break; #ifndef CURL_DISABLE_PROXY case CURLOPT_PROXY_TLSAUTH_PASSWORD: result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY], va_arg(param, char *)); if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] && - !data->set.proxy_ssl.authtype) - data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */ + !data->set.proxy_ssl.primary.authtype) + data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default */ break; #endif case CURLOPT_TLSAUTH_TYPE: argptr = va_arg(param, char *); if(!argptr || strncasecompare(argptr, "SRP", strlen("SRP"))) - data->set.ssl.authtype = CURL_TLSAUTH_SRP; + data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; else - data->set.ssl.authtype = CURL_TLSAUTH_NONE; + data->set.ssl.primary.authtype = CURL_TLSAUTH_NONE; break; #ifndef CURL_DISABLE_PROXY case CURLOPT_PROXY_TLSAUTH_TYPE: argptr = va_arg(param, char *); if(!argptr || strncasecompare(argptr, "SRP", strlen("SRP"))) - data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; + data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; else - data->set.proxy_ssl.authtype = CURL_TLSAUTH_NONE; + data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_NONE; break; #endif #endif diff --git a/Utilities/cmcurl/lib/url.c b/Utilities/cmcurl/lib/url.c index ef48ed6..6b31d4b 100644 --- a/Utilities/cmcurl/lib/url.c +++ b/Utilities/cmcurl/lib/url.c @@ -372,7 +372,7 @@ CURLcode Curl_close(struct Curl_easy **datap) /* Detach connection if any is left. This should not be normal, but can be the case for example with CONNECT_ONLY + recv/send (test 556) */ - Curl_detach_connnection(data); + Curl_detach_connection(data); m = data->multi; if(m) /* This handle is still part of a multi handle, take care of this first @@ -542,7 +542,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data) set->ssl.primary.verifypeer = TRUE; set->ssl.primary.verifyhost = TRUE; #ifdef USE_TLS_SRP - set->ssl.authtype = CURL_TLSAUTH_NONE; + set->ssl.primary.authtype = CURL_TLSAUTH_NONE; #endif set->ssh_auth_types = CURLSSH_AUTH_DEFAULT; /* defaults to any auth type */ @@ -859,7 +859,7 @@ void Curl_disconnect(struct Curl_easy *data, /* temporarily attach the connection to this transfer handle for the disconnect and shutdown */ - Curl_attach_connnection(data, conn); + Curl_attach_connection(data, conn); if(conn->handler->disconnect) /* This is set if protocol-specific cleanups should be made */ @@ -868,7 +868,7 @@ void Curl_disconnect(struct Curl_easy *data, conn_shutdown(data, conn); /* detach it again */ - Curl_detach_connnection(data); + Curl_detach_connection(data); conn_free(conn); } @@ -1020,12 +1020,12 @@ static bool extract_if_dead(struct connectdata *conn, /* briefly attach the connection to this transfer for the purpose of checking it */ - Curl_attach_connnection(data, conn); + Curl_attach_connection(data, conn); state = conn->handler->connection_check(data, conn, CONNCHECK_ISDEAD); dead = (state & CONNRESULT_DEAD); /* detach the connection again */ - Curl_detach_connnection(data); + Curl_detach_connection(data); } else { @@ -1100,6 +1100,12 @@ static void prune_dead_connections(struct Curl_easy *data) } } +static bool ssh_config_matches(struct connectdata *one, + struct connectdata *two) +{ + return (Curl_safecmp(one->proto.sshc.rsa, two->proto.sshc.rsa) && + Curl_safecmp(one->proto.sshc.rsa_pub, two->proto.sshc.rsa_pub)); +} /* * Given one filled in connection struct (named needle), this function should * detect if there already is one that has all the significant details @@ -1356,6 +1362,11 @@ ConnectionExists(struct Curl_easy *data, (data->state.httpwant < CURL_HTTP_VERSION_2_0)) continue; + if(get_protocol_family(needle->handler) == PROTO_FAMILY_SSH) { + if(!ssh_config_matches(needle, check)) + continue; + } + if((needle->handler->flags&PROTOPT_SSL) #ifndef CURL_DISABLE_PROXY || !needle->bits.httpproxy || needle->bits.tunnel_proxy @@ -1508,7 +1519,7 @@ ConnectionExists(struct Curl_easy *data, if(chosen) { /* mark it as used before releasing the lock */ - Curl_attach_connnection(data, chosen); + Curl_attach_connection(data, chosen); CONNCACHE_UNLOCK(data); *usethis = chosen; return TRUE; /* yes, we found one to use! */ @@ -1758,11 +1769,17 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) conn->ssl_config.verifystatus = data->set.ssl.primary.verifystatus; conn->ssl_config.verifypeer = data->set.ssl.primary.verifypeer; conn->ssl_config.verifyhost = data->set.ssl.primary.verifyhost; + conn->ssl_config.ssl_options = data->set.ssl.primary.ssl_options; +#ifdef USE_TLS_SRP +#endif #ifndef CURL_DISABLE_PROXY conn->proxy_ssl_config.verifystatus = data->set.proxy_ssl.primary.verifystatus; conn->proxy_ssl_config.verifypeer = data->set.proxy_ssl.primary.verifypeer; conn->proxy_ssl_config.verifyhost = data->set.proxy_ssl.primary.verifyhost; + conn->proxy_ssl_config.ssl_options = data->set.proxy_ssl.primary.ssl_options; +#ifdef USE_TLS_SRP +#endif #endif conn->ip_version = data->set.ipver; conn->bits.connect_only = data->set.connect_only; @@ -3779,7 +3796,7 @@ static CURLcode create_conn(struct Curl_easy *data, if(!result) { conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */ - Curl_attach_connnection(data, conn); + Curl_attach_connection(data, conn); result = Curl_conncache_add_conn(data); if(result) goto out; @@ -3848,7 +3865,8 @@ static CURLcode create_conn(struct Curl_easy *data, data->set.str[STRING_SSL_ISSUERCERT_PROXY]; data->set.proxy_ssl.primary.issuercert_blob = data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY]; - data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY]; + data->set.proxy_ssl.primary.CRLfile = + data->set.str[STRING_SSL_CRLFILE_PROXY]; data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY]; data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY]; data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY]; @@ -3856,18 +3874,20 @@ static CURLcode create_conn(struct Curl_easy *data, data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY]; data->set.proxy_ssl.key_blob = data->set.blobs[BLOB_KEY_PROXY]; #endif - data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE]; + data->set.ssl.primary.CRLfile = data->set.str[STRING_SSL_CRLFILE]; data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE]; data->set.ssl.key = data->set.str[STRING_KEY]; data->set.ssl.key_type = data->set.str[STRING_KEY_TYPE]; data->set.ssl.key_passwd = data->set.str[STRING_KEY_PASSWD]; data->set.ssl.primary.clientcert = data->set.str[STRING_CERT]; #ifdef USE_TLS_SRP - data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME]; - data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD]; + data->set.ssl.primary.username = data->set.str[STRING_TLSAUTH_USERNAME]; + data->set.ssl.primary.password = data->set.str[STRING_TLSAUTH_PASSWORD]; #ifndef CURL_DISABLE_PROXY - data->set.proxy_ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY]; - data->set.proxy_ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY]; + data->set.proxy_ssl.primary.username = + data->set.str[STRING_TLSAUTH_USERNAME_PROXY]; + data->set.proxy_ssl.primary.password = + data->set.str[STRING_TLSAUTH_PASSWORD_PROXY]; #endif #endif data->set.ssl.key_blob = data->set.blobs[BLOB_KEY]; @@ -4006,7 +4026,7 @@ static CURLcode create_conn(struct Curl_easy *data, * This is a brand new connection, so let's store it in the connection * cache of ours! */ - Curl_attach_connnection(data, conn); + Curl_attach_connection(data, conn); result = Curl_conncache_add_conn(data); if(result) goto out; @@ -4153,7 +4173,7 @@ CURLcode Curl_connect(struct Curl_easy *data, else if(result && conn) { /* We're not allowed to return failure with memory left allocated in the connectdata struct, free those here */ - Curl_detach_connnection(data); + Curl_detach_connection(data); Curl_conncache_remove_conn(data, conn, TRUE); Curl_disconnect(data, conn, TRUE); } diff --git a/Utilities/cmcurl/lib/urlapi.c b/Utilities/cmcurl/lib/urlapi.c index 99a0f69..2a36de6 100644 --- a/Utilities/cmcurl/lib/urlapi.c +++ b/Utilities/cmcurl/lib/urlapi.c @@ -228,7 +228,7 @@ static void strcpy_url(char *output, const char *url, bool relative) */ bool Curl_is_absolute_url(const char *url, char *buf, size_t buflen) { - size_t i; + int i; DEBUGASSERT(!buf || (buflen > MAX_SCHEME_LEN)); (void)buflen; /* only used in debug-builds */ if(buf) @@ -678,8 +678,8 @@ static CURLUcode hostname_check(struct Curl_URL *u, char *hostname) #endif } else { - /* letters from the second string is not ok */ - len = strcspn(hostname, " \r\n"); + /* letters from the second string are not ok */ + len = strcspn(hostname, " \r\n\t/:#?!@"); if(hlen != len) /* hostname with bad content */ return CURLUE_BAD_HOSTNAME; diff --git a/Utilities/cmcurl/lib/urldata.h b/Utilities/cmcurl/lib/urldata.h index 9c34ec4..584434d 100644 --- a/Utilities/cmcurl/lib/urldata.h +++ b/Utilities/cmcurl/lib/urldata.h @@ -253,10 +253,17 @@ struct ssl_primary_config { char *cipher_list; /* list of ciphers to use */ char *cipher_list13; /* list of TLS 1.3 cipher suites to use */ char *pinned_key; + char *CRLfile; /* CRL to check certificate revocation */ struct curl_blob *cert_blob; struct curl_blob *ca_info_blob; struct curl_blob *issuercert_blob; +#ifdef USE_TLS_SRP + char *username; /* TLS username (for, e.g., SRP) */ + char *password; /* TLS password (for, e.g., SRP) */ + enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */ +#endif char *curves; /* list of curves to use */ + unsigned char ssl_options; /* the CURLOPT_SSL_OPTIONS bitmask */ BIT(verifypeer); /* set TRUE if this is desired */ BIT(verifyhost); /* set TRUE if CN/SAN must match hostname */ BIT(verifystatus); /* set TRUE if certificate status must be checked */ @@ -266,7 +273,6 @@ struct ssl_primary_config { struct ssl_config_data { struct ssl_primary_config primary; long certverifyresult; /* result from the certificate verification */ - char *CRLfile; /* CRL to check certificate revocation */ curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */ void *fsslctxp; /* parameter for call back */ char *cert_type; /* format for certificate (default: PEM)*/ @@ -274,11 +280,6 @@ struct ssl_config_data { struct curl_blob *key_blob; char *key_type; /* format for private key (default: PEM) */ char *key_passwd; /* plain text private key password */ -#ifdef USE_TLS_SRP - char *username; /* TLS username (for, e.g., SRP) */ - char *password; /* TLS password (for, e.g., SRP) */ - enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */ -#endif BIT(certinfo); /* gather lots of certificate info */ BIT(falsestart); BIT(enable_beast); /* allow this flaw for interoperability's sake*/ diff --git a/Utilities/cmcurl/lib/vquic/msh3.c b/Utilities/cmcurl/lib/vquic/msh3.c index be18e6e..f7bd315 100644 --- a/Utilities/cmcurl/lib/vquic/msh3.c +++ b/Utilities/cmcurl/lib/vquic/msh3.c @@ -95,7 +95,9 @@ static const MSH3_REQUEST_IF msh3_request_if = { void Curl_quic_ver(char *p, size_t len) { - (void)msnprintf(p, len, "msh3/%s", "0.0.1"); + uint32_t v[4]; + MsH3Version(v); + (void)msnprintf(p, len, "msh3/%d.%d.%d.%d", v[0], v[1], v[2], v[3]); } CURLcode Curl_quic_connect(struct Curl_easy *data, @@ -121,7 +123,10 @@ CURLcode Curl_quic_connect(struct Curl_easy *data, return CURLE_FAILED_INIT; } - qs->conn = MsH3ConnectionOpen(qs->api, conn->host.name, unsecure); + qs->conn = MsH3ConnectionOpen(qs->api, + conn->host.name, + (uint16_t)conn->remote_port, + unsecure); if(!qs->conn) { failf(data, "can't create msh3 connection"); if(qs->api) { @@ -357,7 +362,7 @@ static void MSH3_CALL msh3_complete(MSH3_REQUEST *Request, void *IfContext, struct HTTP *stream = IfContext; (void)Request; (void)AbortError; - H3BUGF(printf("* msh3_complete, aborted=%hhu\n", Aborted)); + H3BUGF(printf("* msh3_complete, aborted=%s\n", Aborted ? "true" : "false")); msh3_lock_acquire(&stream->recv_lock); if(Aborted) { stream->recv_error = CURLE_HTTP3; /* TODO - how do we pass AbortError? */ diff --git a/Utilities/cmcurl/lib/vquic/ngtcp2.c b/Utilities/cmcurl/lib/vquic/ngtcp2.c index abce631..f1a64ee 100644 --- a/Utilities/cmcurl/lib/vquic/ngtcp2.c +++ b/Utilities/cmcurl/lib/vquic/ngtcp2.c @@ -264,6 +264,7 @@ static SSL_QUIC_METHOD quic_method = {quic_set_encryption_secrets, static SSL_CTX *quic_ssl_ctx(struct Curl_easy *data) { + struct connectdata *conn = data->conn; SSL_CTX *ssl_ctx = SSL_CTX_new(TLS_method()); SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_3_VERSION); @@ -291,12 +292,11 @@ static SSL_CTX *quic_ssl_ctx(struct Curl_easy *data) SSL_CTX_set_keylog_callback(ssl_ctx, keylog_callback); } - { - struct connectdata *conn = data->conn; + if(conn->ssl_config.verifypeer) { const char * const ssl_cafile = conn->ssl_config.CAfile; const char * const ssl_capath = conn->ssl_config.CApath; - if(conn->ssl_config.verifypeer) { + if(ssl_cafile || ssl_capath) { SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL); /* tell OpenSSL where to find CA certificates that are used to verify the server's certificate. */ @@ -311,6 +311,13 @@ static SSL_CTX *quic_ssl_ctx(struct Curl_easy *data) infof(data, " CAfile: %s", ssl_cafile ? ssl_cafile : "none"); infof(data, " CApath: %s", ssl_capath ? ssl_capath : "none"); } +#ifdef CURL_CA_FALLBACK + else { + /* verifying the peer without any CA certificates won't work so + use openssl's built-in default as fallback */ + SSL_CTX_set_default_verify_paths(ssl_ctx); + } +#endif } return ssl_ctx; } diff --git a/Utilities/cmcurl/lib/vssh/ssh.h b/Utilities/cmcurl/lib/vssh/ssh.h index 7972081..30d82e5 100644 --- a/Utilities/cmcurl/lib/vssh/ssh.h +++ b/Utilities/cmcurl/lib/vssh/ssh.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -131,8 +131,8 @@ struct ssh_conn { /* common */ const char *passphrase; /* pass-phrase to use */ - char *rsa_pub; /* path name */ - char *rsa; /* path name */ + char *rsa_pub; /* strdup'ed public key file */ + char *rsa; /* strdup'ed private key file */ bool authed; /* the connection has been authenticated fine */ bool acceptfail; /* used by the SFTP_QUOTE (continue if quote command fails) */ diff --git a/Utilities/cmcurl/lib/vtls/gskit.c b/Utilities/cmcurl/lib/vtls/gskit.c index 9b5fbe4..7a65f92 100644 --- a/Utilities/cmcurl/lib/vtls/gskit.c +++ b/Utilities/cmcurl/lib/vtls/gskit.c @@ -293,27 +293,6 @@ static CURLcode set_numeric(struct Curl_easy *data, } -static CURLcode set_callback(struct Curl_easy *data, - gsk_handle h, GSK_CALLBACK_ID id, void *info) -{ - char buffer[STRERROR_LEN]; - int rc = gsk_attribute_set_callback(h, id, info); - - switch(rc) { - case GSK_OK: - return CURLE_OK; - case GSK_ERROR_IO: - failf(data, "gsk_attribute_set_callback() I/O error: %s", - Curl_strerror(errno, buffer, sizeof(buffer))); - break; - default: - failf(data, "gsk_attribute_set_callback(): %s", gsk_strerror(rc)); - break; - } - return CURLE_SSL_CONNECT_ERROR; -} - - static CURLcode set_ciphers(struct Curl_easy *data, gsk_handle h, unsigned int *protoflags) { @@ -796,13 +775,13 @@ static CURLcode gskit_connect_step1(struct Curl_easy *data, BACKEND->localfd = sockpair[0]; BACKEND->remotefd = sockpair[1]; setsockopt(BACKEND->localfd, SOL_SOCKET, SO_RCVBUF, - (void *) sobufsize, sizeof(sobufsize)); + (void *) &sobufsize, sizeof(sobufsize)); setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_RCVBUF, - (void *) sobufsize, sizeof(sobufsize)); + (void *) &sobufsize, sizeof(sobufsize)); setsockopt(BACKEND->localfd, SOL_SOCKET, SO_SNDBUF, - (void *) sobufsize, sizeof(sobufsize)); + (void *) &sobufsize, sizeof(sobufsize)); setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_SNDBUF, - (void *) sobufsize, sizeof(sobufsize)); + (void *) &sobufsize, sizeof(sobufsize)); curlx_nonblock(BACKEND->localfd, TRUE); curlx_nonblock(BACKEND->remotefd, TRUE); } diff --git a/Utilities/cmcurl/lib/vtls/gtls.c b/Utilities/cmcurl/lib/vtls/gtls.c index 0535011..dd82755 100644 --- a/Utilities/cmcurl/lib/vtls/gtls.c +++ b/Utilities/cmcurl/lib/vtls/gtls.c @@ -445,9 +445,10 @@ gtls_connect_step1(struct Curl_easy *data, } #ifdef USE_GNUTLS_SRP - if((SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP) && + if((SSL_SET_OPTION(primary.authtype) == CURL_TLSAUTH_SRP) && Curl_allow_auth_to_host(data)) { - infof(data, "Using TLS-SRP username: %s", SSL_SET_OPTION(username)); + infof(data, "Using TLS-SRP username: %s", + SSL_SET_OPTION(primary.username)); rc = gnutls_srp_allocate_client_credentials(&backend->srp_client_cred); if(rc != GNUTLS_E_SUCCESS) { @@ -457,8 +458,8 @@ gtls_connect_step1(struct Curl_easy *data, } rc = gnutls_srp_set_client_credentials(backend->srp_client_cred, - SSL_SET_OPTION(username), - SSL_SET_OPTION(password)); + SSL_SET_OPTION(primary.username), + SSL_SET_OPTION(primary.password)); if(rc != GNUTLS_E_SUCCESS) { failf(data, "gnutls_srp_set_client_cred() failed: %s", gnutls_strerror(rc)); @@ -515,19 +516,19 @@ gtls_connect_step1(struct Curl_easy *data, } #endif - if(SSL_SET_OPTION(CRLfile)) { + if(SSL_SET_OPTION(primary.CRLfile)) { /* set the CRL list file */ rc = gnutls_certificate_set_x509_crl_file(backend->cred, - SSL_SET_OPTION(CRLfile), + SSL_SET_OPTION(primary.CRLfile), GNUTLS_X509_FMT_PEM); if(rc < 0) { failf(data, "error reading crl file %s (%s)", - SSL_SET_OPTION(CRLfile), gnutls_strerror(rc)); + SSL_SET_OPTION(primary.CRLfile), gnutls_strerror(rc)); return CURLE_SSL_CRL_BADFILE; } else infof(data, "found %d CRL in %s", - rc, SSL_SET_OPTION(CRLfile)); + rc, SSL_SET_OPTION(primary.CRLfile)); } /* Initialize TLS session as a client */ @@ -598,7 +599,7 @@ gtls_connect_step1(struct Curl_easy *data, #ifdef USE_GNUTLS_SRP /* Only add SRP to the cipher list if SRP is requested. Otherwise * GnuTLS will disable TLS 1.3 support. */ - if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP) { + if(SSL_SET_OPTION(primary.authtype) == CURL_TLSAUTH_SRP) { size_t len = strlen(prioritylist); char *prioritysrp = malloc(len + sizeof(GNUTLS_SRP) + 1); @@ -693,7 +694,7 @@ gtls_connect_step1(struct Curl_easy *data, #ifdef USE_GNUTLS_SRP /* put the credentials to the current session */ - if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP) { + if(SSL_SET_OPTION(primary.authtype) == CURL_TLSAUTH_SRP) { rc = gnutls_credentials_set(session, GNUTLS_CRD_SRP, backend->srp_client_cred); if(rc != GNUTLS_E_SUCCESS) { @@ -875,8 +876,8 @@ Curl_gtls_verifyserver(struct Curl_easy *data, SSL_CONN_CONFIG(verifyhost) || SSL_CONN_CONFIG(issuercert)) { #ifdef USE_GNUTLS_SRP - if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP - && SSL_SET_OPTION(username) != NULL + if(SSL_SET_OPTION(primary.authtype) == CURL_TLSAUTH_SRP + && SSL_SET_OPTION(primary.username) && !SSL_CONN_CONFIG(verifypeer) && gnutls_cipher_get(session)) { /* no peer cert, but auth is ok if we have SRP user and cipher and no @@ -934,7 +935,8 @@ Curl_gtls_verifyserver(struct Curl_easy *data, failf(data, "server certificate verification failed. CAfile: %s " "CRLfile: %s", SSL_CONN_CONFIG(CAfile) ? SSL_CONN_CONFIG(CAfile): "none", - SSL_SET_OPTION(CRLfile)?SSL_SET_OPTION(CRLfile):"none"); + SSL_SET_OPTION(primary.CRLfile) ? + SSL_SET_OPTION(primary.CRLfile) : "none"); return CURLE_PEER_FAILED_VERIFICATION; } else @@ -1564,8 +1566,8 @@ static int gtls_shutdown(struct Curl_easy *data, struct connectdata *conn, gnutls_certificate_free_credentials(backend->cred); #ifdef USE_GNUTLS_SRP - if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP - && SSL_SET_OPTION(username) != NULL) + if(SSL_SET_OPTION(primary.authtype) == CURL_TLSAUTH_SRP + && SSL_SET_OPTION(primary.username) != NULL) gnutls_srp_free_client_credentials(backend->srp_client_cred); #endif diff --git a/Utilities/cmcurl/lib/vtls/mbedtls.c b/Utilities/cmcurl/lib/vtls/mbedtls.c index 64f57c5..b60b9ca 100644 --- a/Utilities/cmcurl/lib/vtls/mbedtls.c +++ b/Utilities/cmcurl/lib/vtls/mbedtls.c @@ -279,7 +279,7 @@ mbed_connect_step1(struct Curl_easy *data, struct connectdata *conn, const char * const ssl_capath = SSL_CONN_CONFIG(CApath); char * const ssl_cert = SSL_SET_OPTION(primary.clientcert); const struct curl_blob *ssl_cert_blob = SSL_SET_OPTION(primary.cert_blob); - const char * const ssl_crlfile = SSL_SET_OPTION(CRLfile); + const char * const ssl_crlfile = SSL_SET_OPTION(primary.CRLfile); const char * const hostname = SSL_HOST_NAME(); #ifndef CURL_DISABLE_VERBOSE_STRINGS const long int port = SSL_HOST_PORT(); @@ -303,8 +303,9 @@ mbed_connect_step1(struct Curl_easy *data, struct connectdata *conn, &ts_entropy, NULL, 0); if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Failed - mbedTLS: ctr_drbg_init returned (-0x%04X) %s", + failf(data, "mbedtls_ctr_drbg_seed returned (-0x%04X) %s", -ret, errorbuf); + return CURLE_FAILED_INIT; } #else mbedtls_entropy_init(&backend->entropy); @@ -314,8 +315,9 @@ mbed_connect_step1(struct Curl_easy *data, struct connectdata *conn, &backend->entropy, NULL, 0); if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Failed - mbedTLS: ctr_drbg_init returned (-0x%04X) %s", + failf(data, "mbedtls_ctr_drbg_seed returned (-0x%04X) %s", -ret, errorbuf); + return CURLE_FAILED_INIT; } #endif /* THREADING_SUPPORT */ @@ -815,8 +817,8 @@ mbed_connect_step2(struct Curl_easy *data, struct connectdata *conn, if(next_protocol) { infof(data, VTLS_INFOF_ALPN_ACCEPTED_1STR, next_protocol); #ifdef USE_HTTP2 - if(!strncmp(next_protocol, ALPN_H2, ALPN_H2_LEN) && - !next_protocol[ALPN_H2_LEN]) { + if(!strncmp(next_protocol, ALPN_H2, ALPN_H2_LENGTH) && + !next_protocol[ALPN_H2_LENGTH]) { conn->negnpn = CURL_HTTP_VERSION_2; } else @@ -1015,7 +1017,7 @@ static CURLcode mbedtls_random(struct Curl_easy *data, if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Failed - mbedTLS: ctr_drbg_seed returned (-0x%04X) %s", + failf(data, "mbedtls_ctr_drbg_seed returned (-0x%04X) %s", -ret, errorbuf); } else { @@ -1023,7 +1025,7 @@ static CURLcode mbedtls_random(struct Curl_easy *data, if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "mbedTLS: ctr_drbg_init returned (-0x%04X) %s", + failf(data, "mbedtls_ctr_drbg_random returned (-0x%04X) %s", -ret, errorbuf); } } diff --git a/Utilities/cmcurl/lib/vtls/nss.c b/Utilities/cmcurl/lib/vtls/nss.c index 5b7de9f..cb0509f 100644 --- a/Utilities/cmcurl/lib/vtls/nss.c +++ b/Utilities/cmcurl/lib/vtls/nss.c @@ -983,6 +983,9 @@ static void display_cert_info(struct Curl_easy *data, PR_Free(common_name); } +/* A number of certs that will never occur in a real server handshake */ +#define TOO_MANY_CERTS 300 + static CURLcode display_conn_info(struct Curl_easy *data, PRFileDesc *sock) { CURLcode result = CURLE_OK; @@ -1018,6 +1021,11 @@ static CURLcode display_conn_info(struct Curl_easy *data, PRFileDesc *sock) cert2 = CERT_FindCertIssuer(cert, now, certUsageSSLCA); while(cert2) { i++; + if(i >= TOO_MANY_CERTS) { + CERT_DestroyCertificate(cert2); + failf(data, "certificate loop"); + return CURLE_SSL_CERTPROBLEM; + } if(cert2->isRoot) { CERT_DestroyCertificate(cert2); break; @@ -2027,13 +2035,13 @@ static CURLcode nss_setup_connect(struct Curl_easy *data, } } - if(SSL_SET_OPTION(CRLfile)) { - const CURLcode rv = nss_load_crl(SSL_SET_OPTION(CRLfile)); + if(SSL_SET_OPTION(primary.CRLfile)) { + const CURLcode rv = nss_load_crl(SSL_SET_OPTION(primary.CRLfile)); if(rv) { result = rv; goto error; } - infof(data, " CRLfile: %s", SSL_SET_OPTION(CRLfile)); + infof(data, " CRLfile: %s", SSL_SET_OPTION(primary.CRLfile)); } if(SSL_SET_OPTION(primary.clientcert)) { diff --git a/Utilities/cmcurl/lib/vtls/openssl.c b/Utilities/cmcurl/lib/vtls/openssl.c index 3722005..635e9c1 100644 --- a/Utilities/cmcurl/lib/vtls/openssl.c +++ b/Utilities/cmcurl/lib/vtls/openssl.c @@ -215,11 +215,10 @@ * OpenSSL: supported since 1.0.2, see * https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set1_groups.html * BoringSSL: supported since 5fd1807d95f7 (committed 2016-09-30) - * LibreSSL: not tested. + * LibreSSL: since 2.5.3 (April 12, 2017) */ -#if ((OPENSSL_VERSION_NUMBER >= 0x10002000L) && \ - !defined(LIBRESSL_VERSION_NUMBER)) || \ - defined(OPENSSL_IS_BORINGSSL) +#if (OPENSSL_VERSION_NUMBER >= 0x10002000L) || \ + defined(OPENSSL_IS_BORINGSSL) #define HAVE_SSL_CTX_SET_EC_CURVES #endif @@ -2663,7 +2662,7 @@ static CURLcode ossl_connect_step1(struct Curl_easy *data, #endif const long int ssl_version = SSL_CONN_CONFIG(version); #ifdef USE_OPENSSL_SRP - const enum CURL_TLSAUTH ssl_authtype = SSL_SET_OPTION(authtype); + const enum CURL_TLSAUTH ssl_authtype = SSL_SET_OPTION(primary.authtype); #endif char * const ssl_cert = SSL_SET_OPTION(primary.clientcert); const struct curl_blob *ssl_cert_blob = SSL_SET_OPTION(primary.cert_blob); @@ -2674,7 +2673,7 @@ static CURLcode ossl_connect_step1(struct Curl_easy *data, (ca_info_blob ? NULL : SSL_CONN_CONFIG(CAfile)); const char * const ssl_capath = SSL_CONN_CONFIG(CApath); const bool verifypeer = SSL_CONN_CONFIG(verifypeer); - const char * const ssl_crlfile = SSL_SET_OPTION(CRLfile); + const char * const ssl_crlfile = SSL_SET_OPTION(primary.CRLfile); char error_buffer[256]; struct ssl_backend_data *backend = connssl->backend; bool imported_native_ca = false; @@ -2926,15 +2925,15 @@ static CURLcode ossl_connect_step1(struct Curl_easy *data, #ifdef USE_OPENSSL_SRP if((ssl_authtype == CURL_TLSAUTH_SRP) && Curl_allow_auth_to_host(data)) { - char * const ssl_username = SSL_SET_OPTION(username); - + char * const ssl_username = SSL_SET_OPTION(primary.username); + char * const ssl_password = SSL_SET_OPTION(primary.password); infof(data, "Using TLS-SRP username: %s", ssl_username); if(!SSL_CTX_set_srp_username(backend->ctx, ssl_username)) { failf(data, "Unable to set SRP user name"); return CURLE_BAD_FUNCTION_ARGUMENT; } - if(!SSL_CTX_set_srp_password(backend->ctx, SSL_SET_OPTION(password))) { + if(!SSL_CTX_set_srp_password(backend->ctx, ssl_password)) { failf(data, "failed setting SRP password"); return CURLE_BAD_FUNCTION_ARGUMENT; } diff --git a/Utilities/cmcurl/lib/vtls/sectransp.c b/Utilities/cmcurl/lib/vtls/sectransp.c index 8ee8fe9..2e57d83 100644 --- a/Utilities/cmcurl/lib/vtls/sectransp.c +++ b/Utilities/cmcurl/lib/vtls/sectransp.c @@ -2045,8 +2045,9 @@ static CURLcode sectransp_connect_step1(struct Curl_easy *data, err = SSLSetPeerDomainName(backend->ssl_ctx, snihost, snilen); if(err != noErr) { - infof(data, "WARNING: SSL: SSLSetPeerDomainName() failed: OSStatus %d", + failf(data, "SSL: SSLSetPeerDomainName() failed: OSStatus %d", err); + return CURLE_SSL_CONNECT_ERROR; } if((Curl_inet_pton(AF_INET, hostname, &addr)) diff --git a/Utilities/cmcurl/lib/vtls/vtls.c b/Utilities/cmcurl/lib/vtls/vtls.c index a40ac06..e2d3438 100644 --- a/Utilities/cmcurl/lib/vtls/vtls.c +++ b/Utilities/cmcurl/lib/vtls/vtls.c @@ -132,6 +132,7 @@ Curl_ssl_config_matches(struct ssl_primary_config *data, { if((data->version == needle->version) && (data->version_max == needle->version_max) && + (data->ssl_options == needle->ssl_options) && (data->verifypeer == needle->verifypeer) && (data->verifyhost == needle->verifyhost) && (data->verifystatus == needle->verifystatus) && @@ -144,9 +145,15 @@ Curl_ssl_config_matches(struct ssl_primary_config *data, Curl_safecmp(data->clientcert, needle->clientcert) && Curl_safecmp(data->random_file, needle->random_file) && Curl_safecmp(data->egdsocket, needle->egdsocket) && +#ifdef USE_TLS_SRP + Curl_safecmp(data->username, needle->username) && + Curl_safecmp(data->password, needle->password) && + (data->authtype == needle->authtype) && +#endif Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list) && Curl_safe_strcasecompare(data->cipher_list13, needle->cipher_list13) && Curl_safe_strcasecompare(data->curves, needle->curves) && + Curl_safe_strcasecompare(data->CRLfile, needle->CRLfile) && Curl_safe_strcasecompare(data->pinned_key, needle->pinned_key)) return TRUE; @@ -163,6 +170,10 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source, dest->verifyhost = source->verifyhost; dest->verifystatus = source->verifystatus; dest->sessionid = source->sessionid; + dest->ssl_options = source->ssl_options; +#ifdef USE_TLS_SRP + dest->authtype = source->authtype; +#endif CLONE_BLOB(cert_blob); CLONE_BLOB(ca_info_blob); @@ -177,6 +188,11 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source, CLONE_STRING(cipher_list13); CLONE_STRING(pinned_key); CLONE_STRING(curves); + CLONE_STRING(CRLfile); +#ifdef USE_TLS_SRP + CLONE_STRING(username); + CLONE_STRING(password); +#endif return TRUE; } @@ -196,6 +212,11 @@ void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc) Curl_safefree(sslc->ca_info_blob); Curl_safefree(sslc->issuercert_blob); Curl_safefree(sslc->curves); + Curl_safefree(sslc->CRLfile); +#ifdef USE_TLS_SRP + Curl_safefree(sslc->username); + Curl_safefree(sslc->password); +#endif } #ifdef USE_SSL diff --git a/Utilities/cmcurl/lib/vtls/x509asn1.c b/Utilities/cmcurl/lib/vtls/x509asn1.c index f64acb8..dfb9386 100644 --- a/Utilities/cmcurl/lib/vtls/x509asn1.c +++ b/Utilities/cmcurl/lib/vtls/x509asn1.c @@ -945,6 +945,24 @@ static int do_pubkey(struct Curl_easy *data, int certnum, /* Generate all information records for the public key. */ + if(strcasecompare(algo, "ecPublicKey")) { + /* + * ECC public key is all the data, a value of type BIT STRING mapped to + * OCTET STRING and should not be parsed as an ASN.1 value. + */ + const unsigned long len = + (unsigned long)((pubkey->end - pubkey->beg - 2) * 4); + if(!certnum) + infof(data, " ECC Public Key (%lu bits)", len); + if(data->set.ssl.certinfo) { + char q[sizeof(len) * 8 / 3 + 1]; + msnprintf(q, sizeof(q), "%lu", len); + if(Curl_ssl_push_certinfo(data, certnum, "ECC Public Key", q)) + return 1; + } + return do_pubkey_field(data, certnum, "ecPublicKey", pubkey); + } + /* Get the public key (single element). */ if(!getASN1Element(&pk, pubkey->beg + 1, pubkey->end)) return 1; @@ -971,14 +989,10 @@ static int do_pubkey(struct Curl_easy *data, int certnum, if(!certnum) infof(data, " RSA Public Key (%lu bits)", len); if(data->set.ssl.certinfo) { - q = curl_maprintf("%lu", len); - if(q) { - CURLcode result = - Curl_ssl_push_certinfo(data, certnum, "RSA Public Key", q); - free((char *) q); - if(result) - return 1; - } + char r[sizeof(len) * 8 / 3 + 1]; + msnprintf(r, sizeof(r), "%lu", len); + if(Curl_ssl_push_certinfo(data, certnum, "RSA Public Key", r)) + return 1; } /* Generate coefficients. */ if(do_pubkey_field(data, certnum, "rsa(n)", &elem)) |