diff options
471 files changed, 5099 insertions, 1439 deletions
diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index f06f434..dfd94f5 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -99,12 +99,14 @@ .linux_builder_tags: tags: + - cmake - build - docker - linux .linux_builder_tags_qt: tags: + - cmake - build - docker - linux @@ -112,6 +114,7 @@ .linux_builder_tags_cuda: tags: + - cmake - cuda-rt - docker - linux diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index 910a232..63b8758 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -36,7 +36,7 @@ CMAKE_CONFIGURATION: windows_vs2019_x64_ninja VCVARSALL: "${VS160COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat" VCVARSPLATFORM: "x64" - VCVARSVERSION: "14.26" + VCVARSVERSION: "14.27" ### External testing @@ -47,7 +47,7 @@ CMAKE_CONFIGURATION: windows_vs2019_x64 CMAKE_GENERATOR: "Visual Studio 16 2019" CMAKE_GENERATOR_PLATFORM: "x64" - CMAKE_GENERATOR_TOOLSET: "v142,version=14.26" + CMAKE_GENERATOR_TOOLSET: "v142,version=14.27" ## Tags @@ -57,7 +57,7 @@ - windows - shell - vs2019 - - msvc-19.25 + - msvc-19.27 - nonconcurrent .windows_builder_ext_tags: @@ -66,7 +66,7 @@ - windows - shell - vs2019 - - msvc-19.25 + - msvc-19.27 - concurrent ## Windows-specific scripts diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index 52536bb..f3df631 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -118,8 +118,35 @@ target using the commands: and then it is used as an argument to :command:`target_link_libraries` like any other target. -An interface library has no source files itself and is not included -as a target in the generated buildsystem. +An interface library created with the above signature has no source files +itself and is not included as a target in the generated buildsystem. + +Since CMake 3.19, an interface library target may be created with +source files: + +.. code-block:: cmake + + add_library(<name> INTERFACE [<source>...] [EXCLUDE_FROM_ALL]) + +Source files may be listed directly in the ``add_library`` call or added +later by calls to :command:`target_sources` with the ``PRIVATE`` or +``PUBLIC`` keywords. + +If an interface library has source files (i.e. the :prop_tgt:`SOURCES` +target property is set), it will appear in the generated buildsystem +as a build target much like a target defined by the +:command:`add_custom_target` command. It does not compile any sources, +but does contain build rules for custom commands created by the +:command:`add_custom_command` command. + +.. note:: + In most command signatures where the ``INTERFACE`` keyword appears, + the items listed after it only become part of that target's usage + requirements and are not part of the target's own settings. However, + in this signature of ``add_library``, the ``INTERFACE`` keyword refers + to the library type only. Sources listed after it in the ``add_library`` + call are ``PRIVATE`` to the interface library and do not appear in its + :prop_tgt:`INTERFACE_SOURCES` target property. Imported Libraries ^^^^^^^^^^^^^^^^^^ diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst index a77ba37..2b4d082 100644 --- a/Help/command/add_test.rst +++ b/Help/command/add_test.rst @@ -10,8 +10,9 @@ Add a test to the project to be run by :manual:`ctest(1)`. [WORKING_DIRECTORY <dir>] [COMMAND_EXPAND_LISTS]) -Adds a test called ``<name>``. The test name may not contain spaces, -quotes, or other characters special in CMake syntax. The options are: +Adds a test called ``<name>``. The test name may contain arbitrary +characters, expressed as a :ref:`Quoted Argument` or :ref:`Bracket Argument` +if necessary. See policy :policy:`CMP0110`. The options are: ``COMMAND`` Specify the test command-line. If ``<command>`` specifies an diff --git a/Help/command/file.rst b/Help/command/file.rst index 2cf938b..953172b 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -449,7 +449,7 @@ modified. file(GENERATE OUTPUT output-file <INPUT input-file|CONTENT content> - [CONDITION expression]) + [CONDITION expression] [TARGET target]) Generate an output file for each build configuration supported by the current :manual:`CMake Generator <cmake-generators(7)>`. Evaluate @@ -479,6 +479,10 @@ from the input content to produce the output content. The options are: with respect to the value of :variable:`CMAKE_CURRENT_BINARY_DIR`. See policy :policy:`CMP0070`. +``TARGET <target>`` + Specify target which to use when evaluating generator expressions. Enables + use of generator expressions requiring a target. + Exactly one ``CONTENT`` or ``INPUT`` option must be given. A specific ``OUTPUT`` file may be named by at most one invocation of ``file(GENERATE)``. Generated files are modified and their timestamp updated on subsequent cmake diff --git a/Help/cpack_gen/wix.rst b/Help/cpack_gen/wix.rst index 7fb5a12..5b880ba 100644 --- a/Help/cpack_gen/wix.rst +++ b/Help/cpack_gen/wix.rst @@ -286,3 +286,11 @@ Windows using WiX. When unspecified CPack will try to locate a WiX Toolset installation via the ``WIX`` environment variable instead. + +.. variable:: CPACK_WIX_CUSTOM_XMLNS + + This variable provides a list of custom namespace declarations that are necessary + for using WiX extensions. Each declaration should be in the form name=url, where + name is the plain namespace without the usual xmlns: prefix and url is an unquoted + namespace url. A list of commonly known WiX schemata can be found here: + https://wixtoolset.org/documentation/manual/v3/xsd/ diff --git a/Help/dev/review.rst b/Help/dev/review.rst index f2a91c0..8326e70 100644 --- a/Help/dev/review.rst +++ b/Help/dev/review.rst @@ -264,6 +264,7 @@ fixed, it is preferable to link to the issue instead. If relevant, add the first release tag of CMake containing the commit after the ``<date>``, i.e., ``commit <shorthash> (<subject>, <date>, <tag>)``. +Or, use the output of ``git describe --contains <commit>`` as the ``<tag>``. Alternatively, the full commit ``<hash>`` may be used. diff --git a/Help/generator/Visual Studio 14 2015.rst b/Help/generator/Visual Studio 14 2015.rst index 401845d..5b319bb 100644 --- a/Help/generator/Visual Studio 14 2015.rst +++ b/Help/generator/Visual Studio 14 2015.rst @@ -45,3 +45,19 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. By default this generator uses the 32-bit variant even on a 64-bit host. .. include:: VS_TOOLSET_HOST_ARCH.txt + +.. _`Windows 10 SDK Maximum Version for VS 2015`: + +Windows 10 SDK Maximum Version for VS 2015 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Microsoft stated in a "Windows 10 October 2018 Update" blog post that Windows +10 SDK versions (15063, 16299, 17134, 17763) are not supported by VS 2015 and +are only supported by VS 2017 and later. Therefore by default CMake +automatically ignores Windows 10 SDKs beyond ``10.0.14393.0``. + +However, there are other recommendations for certain driver/Win32 builds that +indicate otherwise. A user can override this behavior by either setting the +:variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` to a false value +or setting the :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` to +the string value of the required maximum (e.g. ``10.0.15063.0``). diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index d8142a2..7008383 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -96,6 +96,9 @@ Apple Frameworks A ``SHARED`` library may be marked with the :prop_tgt:`FRAMEWORK` target property to create an macOS or iOS Framework Bundle. +A library with the ``FRAMEWORK`` target property should also set the +:prop_tgt:`FRAMEWORK_VERSION` target property. This property is typically +set to the value of "A" by macOS conventions. The ``MACOSX_FRAMEWORK_IDENTIFIER`` sets ``CFBundleIdentifier`` key and it uniquely identifies the bundle. @@ -104,7 +107,7 @@ and it uniquely identifies the bundle. add_library(MyFramework SHARED MyFramework.cpp) set_target_properties(MyFramework PROPERTIES FRAMEWORK TRUE - FRAMEWORK_VERSION A + FRAMEWORK_VERSION A # Version "A" is macOS convention MACOSX_FRAMEWORK_IDENTIFIER org.cmake.MyFramework ) @@ -115,7 +118,10 @@ Object Libraries The ``OBJECT`` library type defines a non-archival collection of object files resulting from compiling the given source files. The object files collection -may be used as source inputs to other targets: +may be used as source inputs to other targets by using the syntax +``$<TARGET_OBJECTS:name>``. This is a +:manual:`generator expression <cmake-generator-expressions(7)>` that can be +used to supply the ``OBJECT`` library content to other targets: .. code-block:: cmake @@ -373,8 +379,12 @@ position-independent-code, so a diagnostic is issued. The ``lib1`` and ``lib2`` requirements are not "compatible". One of them requires that consumers are built as position-independent-code, while the other requires that consumers are not built as position-independent-code. -Because ``exe2`` links to both and they are in conflict, a diagnostic is -issued. +Because ``exe2`` links to both and they are in conflict, a CMake error message +is issued:: + + CMake Error: The INTERFACE_POSITION_INDEPENDENT_CODE property of "lib2" does + not agree with the value of POSITION_INDEPENDENT_CODE already determined + for "exe2". To be "compatible", the :prop_tgt:`POSITION_INDEPENDENT_CODE` property, if set must be either the same, in a boolean sense, as the @@ -732,7 +742,7 @@ As the value of the :prop_tgt:`POSITION_INDEPENDENT_CODE` property of the ``exe1`` target is dependent on the linked libraries (``lib3``), and the edge of linking ``exe1`` is determined by the same :prop_tgt:`POSITION_INDEPENDENT_CODE` property, the dependency graph above -contains a cycle. :manual:`cmake(1)` issues a diagnostic in this case. +contains a cycle. :manual:`cmake(1)` issues an error message. .. _`Output Artifacts`: @@ -922,8 +932,8 @@ property from it: Interface Libraries ------------------- -An ``INTERFACE`` target has no :prop_tgt:`LOCATION` and is mutable, but is -otherwise similar to an :prop_tgt:`IMPORTED` target. +An ``INTERFACE`` library target does not compile sources and does not +produce a library artifact on disk, so it has no :prop_tgt:`LOCATION`. It may specify usage requirements such as :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`, @@ -937,11 +947,22 @@ Only the ``INTERFACE`` modes of the :command:`target_include_directories`, :command:`target_sources`, and :command:`target_link_libraries` commands may be used with ``INTERFACE`` libraries. +Since CMake 3.19, an ``INTERFACE`` library target may optionally contain +source files. An interface library that contains source files will be +included as a build target in the generated buildsystem. It does not +compile sources, but may contain custom commands to generate other sources. +Additionally, IDEs will show the source files as part of the target for +interactive reading and editing. + A primary use-case for ``INTERFACE`` libraries is header-only libraries. .. code-block:: cmake - add_library(Eigen INTERFACE) + add_library(Eigen INTERFACE + src/eigen.h + src/vector.h + src/matrix.h + ) target_include_directories(Eigen INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> $<INSTALL_INTERFACE:include/Eigen> @@ -975,25 +996,17 @@ This way, the build specification of ``exe1`` is expressed entirely as linked targets, and the complexity of compiler-specific flags is encapsulated in an ``INTERFACE`` library target. -The properties permitted to be set on or read from an ``INTERFACE`` library -are: - -* Properties matching ``INTERFACE_*`` -* Built-in properties matching ``COMPATIBLE_INTERFACE_*`` -* ``EXPORT_NAME`` -* ``EXPORT_PROPERTIES`` -* ``IMPORTED`` -* ``MANUALLY_ADDED_DEPENDENCIES`` -* ``NAME`` -* Properties matching ``IMPORTED_LIBNAME_*`` -* Properties matching ``MAP_IMPORTED_CONFIG_*`` - ``INTERFACE`` libraries may be installed and exported. Any content they refer to must be installed separately: .. code-block:: cmake - add_library(Eigen INTERFACE) + set(Eigen_headers + src/eigen.h + src/vector.h + src/matrix.h + ) + add_library(Eigen INTERFACE ${Eigen_headers}) target_include_directories(Eigen INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> $<INSTALL_INTERFACE:include/Eigen> @@ -1003,9 +1016,6 @@ to must be installed separately: install(EXPORT eigenExport NAMESPACE Upstream:: DESTINATION lib/cmake/Eigen ) - install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/src/eigen.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/vector.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/matrix.h + install(FILES ${Eigen_headers} DESTINATION include/Eigen ) diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index 34edc56..6876e1c 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -650,7 +650,8 @@ with members: ``type`` A string specifying the type of the target. The value is one of ``EXECUTABLE``, ``STATIC_LIBRARY``, ``SHARED_LIBRARY``, - ``MODULE_LIBRARY``, ``OBJECT_LIBRARY``, or ``UTILITY``. + ``MODULE_LIBRARY``, ``OBJECT_LIBRARY``, ``INTERFACE_LIBRARY``, + or ``UTILITY``. ``backtrace`` Optional member that is present when a CMake language backtrace to diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 3ceb1df..ce8969b 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -51,12 +51,14 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used to determine whether to report an error on use of deprecated macros or functions. -Policies Introduced by CMake 3.18 +Policies Introduced by CMake 3.19 ================================= .. toctree:: :maxdepth: 1 + CMP0111: An imported target with a missing location fails during generation. </policy/CMP0111> + CMP0110: add_test() supports arbitrary characters in test names. </policy/CMP0110> CMP0109: find_program() requires permission to execute but not to read. </policy/CMP0109> Policies Introduced by CMake 3.18 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index bdd2333..644e87b 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -308,6 +308,7 @@ Properties on Targets /prop_tgt/OBJCXX_EXTENSIONS /prop_tgt/OBJCXX_STANDARD /prop_tgt/OBJCXX_STANDARD_REQUIRED + /prop_tgt/OPTIMIZE_DEPENDENCIES /prop_tgt/OSX_ARCHITECTURES_CONFIG /prop_tgt/OSX_ARCHITECTURES /prop_tgt/OUTPUT_NAME_CONFIG diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 4515cc3..082e2d5 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -124,6 +124,7 @@ Variables that Provide Information /variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE /variable/CMAKE_VS_PLATFORM_TOOLSET_VERSION /variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION + /variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM /variable/CMAKE_XCODE_GENERATE_SCHEME /variable/CMAKE_XCODE_PLATFORM_TOOLSET /variable/PROJECT-NAME_BINARY_DIR @@ -158,6 +159,7 @@ Variables that Change Behavior /variable/CMAKE_AUTOMOC_RELAXED_MODE /variable/CMAKE_BACKWARDS_COMPATIBILITY /variable/CMAKE_BUILD_TYPE + /variable/CMAKE_CLANG_VFS_OVERLAY /variable/CMAKE_CODEBLOCKS_COMPILER_ID /variable/CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES /variable/CMAKE_CODELITE_USE_TARGETS @@ -436,6 +438,7 @@ Variables that Control the Build /variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX /variable/CMAKE_NO_BUILTIN_CHRPATH /variable/CMAKE_NO_SYSTEM_FROM_IMPORTED + /variable/CMAKE_OPTIMIZE_DEPENDENCIES /variable/CMAKE_OSX_ARCHITECTURES /variable/CMAKE_OSX_DEPLOYMENT_TARGET /variable/CMAKE_OSX_SYSROOT diff --git a/Help/policy/CMP0110.rst b/Help/policy/CMP0110.rst new file mode 100644 index 0000000..bc198aa --- /dev/null +++ b/Help/policy/CMP0110.rst @@ -0,0 +1,24 @@ +CMP0110 +------- + +:command:`add_test` supports arbitrary characters in test names. + +:command:`add_test` can now (officially) create tests with whitespace and +other special characters in its name. Before CMake version 3.19 that was not +allowed, however, it was possible to work around this limitation by explicitly +putting escaped quotes arount the test's name in the ``add_test`` command. + +Although never officially supported several projects in the wild found and +implemented this workaround. However, the new change which officially allows +the ``add_test`` command to support whitespace and other special characters in +test names now breaks that workaround. In order for these projects to work +smoothly with newer CMake versions, this policy was introduced. + +The ``OLD`` behavior of this policy is to still prevent ``add_test`` from +handling whitespace and special characters properly (if not using the +mentioned workaround). The ``NEW`` behavior on the other hand allows names +with whitespace and special characters for tests created by ``add_test``. + +This policy was introduced in CMake version 3.19. CMake version |release| +warns when the policy is not set and uses ``OLD`` behavior. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. diff --git a/Help/policy/CMP0111.rst b/Help/policy/CMP0111.rst new file mode 100644 index 0000000..37e5ad5 --- /dev/null +++ b/Help/policy/CMP0111.rst @@ -0,0 +1,20 @@ +CMP0111 +------- + +.. versionadded:: 3.19 + +An imported target with a missing location fails during generation. + +Prior to this the location would be generated as ``<TARGET_NAME>-NOTFOUND``, +which would result in build failures. + +The ``OLD`` behavior of this policy is to generate the location of an imported +unknown, static or shared library target as ``<TARGET_NAME>-NOTFOUND`` if not +set. +The ``NEW`` behavior is to raise an error. + +This policy was introduced in CMake version 3.19. CMake version |release| +warns when the policy is not set and uses ``OLD`` behavior. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. + +.. include:: DEPRECATED.txt diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst index 9b53282..bac3274 100644 --- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst @@ -13,8 +13,14 @@ The features listed here may be used with the :command:`target_compile_features` command. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. +The features known to this version of CMake are listed below. -The features known to this version of CMake are: +High level meta features indicating C++ standard support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following meta features indicate general support for the associated +language standard. It reflects the language support claimed by the compiler, +but it does not necessarily imply complete conformance to that standard. ``cxx_std_98`` Compiler mode is at least C++ 98. @@ -31,10 +37,29 @@ The features known to this version of CMake are: ``cxx_std_20`` Compiler mode is at least C++ 20. -``cxx_aggregate_default_initializers`` - Aggregate default initializers, as defined in N3605_. - .. _N3605: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3605.html +Low level individual compile features +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For C++ 11 and C++ 14, compilers were sometimes slow to implement certain +language features. CMake provided some individual compile features to help +projects determine whether specific features were available. These individual +features are now less relevant and projects should generally prefer to use the +high level meta features instead. Individual compile features are not provided +for C++ 17 or later. + +See the :manual:`cmake-compile-features(7)` manual for further discussion of +the use of individual compile features. + +Individual features from C++ 98 +""""""""""""""""""""""""""""""" + +``cxx_template_template_parameters`` + Template template parameters, as defined in ``ISO/IEC 14882:1998``. + + +Individual features from C++ 11 +""""""""""""""""""""""""""""""" ``cxx_alias_templates`` Template aliases, as defined in N2258_. @@ -56,30 +81,16 @@ The features known to this version of CMake are: .. _N2761: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf -``cxx_attribute_deprecated`` - ``[[deprecated]]`` attribute, as defined in N3760_. - - .. _N3760: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html - ``cxx_auto_type`` Automatic type deduction, as defined in N1984_. .. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf -``cxx_binary_literals`` - Binary literals, as defined in N3472_. - - .. _N3472: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf - ``cxx_constexpr`` Constant expressions, as defined in N2235_. .. _N2235: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf -``cxx_contextual_conversions`` - Contextual conversions, as defined in N3323_. - - .. _N3323: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3323.pdf ``cxx_decltype_incomplete_return_types`` Decltype on incomplete return types, as defined in N3276_. @@ -91,11 +102,6 @@ The features known to this version of CMake are: .. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf -``cxx_decltype_auto`` - ``decltype(auto)`` semantics, as defined in N3638_. - - .. _N3638: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3638.html - ``cxx_default_function_template_args`` Default template arguments for function templates, as defined in DR226_ @@ -121,11 +127,6 @@ The features known to this version of CMake are: .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm -``cxx_digit_separators`` - Digit separators, as defined in N3781_. - - .. _N3781: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf - ``cxx_enum_forward_declarations`` Enum forward declarations, as defined in N2764_. @@ -163,11 +164,6 @@ The features known to this version of CMake are: .. _N2672: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm -``cxx_generic_lambdas`` - Generic lambdas, as defined in N3649_. - - .. _N3649: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3649.html - ``cxx_inheriting_constructors`` Inheriting constructors, as defined in N2540_. @@ -183,11 +179,6 @@ The features known to this version of CMake are: .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf -``cxx_lambda_init_captures`` - Initialized lambda captures, as defined in N3648_. - - .. _N3648: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3648.html - ``cxx_local_type_template_args`` Local and unnamed types as template arguments, as defined in N2657_. @@ -236,16 +227,6 @@ The features known to this version of CMake are: .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm -``cxx_relaxed_constexpr`` - Relaxed constexpr, as defined in N3652_. - - .. _N3652: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html - -``cxx_return_type_deduction`` - Return type deduction on normal functions, as defined in N3386_. - - .. _N3386: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3386.html - ``cxx_right_angle_brackets`` Right angle bracket parsing, as defined in N1757_. @@ -301,11 +282,6 @@ The features known to this version of CMake are: .. _N2765: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf -``cxx_variable_templates`` - Variable templates, as defined in N3651_. - - .. _N3651: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3651.pdf - ``cxx_variadic_macros`` Variadic macros, as defined in N1653_. @@ -316,5 +292,61 @@ The features known to this version of CMake are: .. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf -``cxx_template_template_parameters`` - Template template parameters, as defined in ``ISO/IEC 14882:1998``. + +Individual features from C++ 14 +""""""""""""""""""""""""""""""" + +``cxx_aggregate_default_initializers`` + Aggregate default initializers, as defined in N3605_. + + .. _N3605: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3605.html + +``cxx_attribute_deprecated`` + ``[[deprecated]]`` attribute, as defined in N3760_. + + .. _N3760: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html + +``cxx_binary_literals`` + Binary literals, as defined in N3472_. + + .. _N3472: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf + +``cxx_contextual_conversions`` + Contextual conversions, as defined in N3323_. + + .. _N3323: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3323.pdf + +``cxx_decltype_auto`` + ``decltype(auto)`` semantics, as defined in N3638_. + + .. _N3638: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3638.html + +``cxx_digit_separators`` + Digit separators, as defined in N3781_. + + .. _N3781: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf + +``cxx_generic_lambdas`` + Generic lambdas, as defined in N3649_. + + .. _N3649: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3649.html + +``cxx_lambda_init_captures`` + Initialized lambda captures, as defined in N3648_. + + .. _N3648: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3648.html + +``cxx_relaxed_constexpr`` + Relaxed constexpr, as defined in N3652_. + + .. _N3652: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html + +``cxx_return_type_deduction`` + Return type deduction on normal functions, as defined in N3386_. + + .. _N3386: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3386.html + +``cxx_variable_templates`` + Variable templates, as defined in N3651_. + + .. _N3651: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3651.pdf diff --git a/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst b/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst index 4f85c16..836d953 100644 --- a/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst +++ b/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst @@ -15,7 +15,7 @@ the ``-p`` path prefix option. ``moc`` usually generates a relative include path in that case. :prop_tgt:`AUTOMOC_PATH_PREFIX` is initialized from the variable -:variable:`CMAKE_AUTOMOC_PATH_PREFIX`, which is ``ON`` by default. +:variable:`CMAKE_AUTOMOC_PATH_PREFIX`, which is ``OFF`` by default. See the :manual:`cmake-qt(7)` manual for more information on using CMake with Qt. @@ -26,8 +26,7 @@ Reproducible builds For reproducible builds it is recommended to keep headers that are ``moc`` compiled in one of the target :command:`include directories <target_include_directories>` and set -:prop_tgt:`AUTOMOC_PATH_PREFIX` to ``ON`` (which is the default). This ensures -that: +:prop_tgt:`AUTOMOC_PATH_PREFIX` to ``ON``. This ensures that: - ``moc`` output files are identical on different build setups, - ``moc`` output files will compile correctly when the source and/or diff --git a/Help/prop_tgt/EXPORT_PROPERTIES.rst b/Help/prop_tgt/EXPORT_PROPERTIES.rst index 34c054f..2d54f8b 100644 --- a/Help/prop_tgt/EXPORT_PROPERTIES.rst +++ b/Help/prop_tgt/EXPORT_PROPERTIES.rst @@ -14,3 +14,11 @@ Properties starting with ``INTERFACE_`` or ``IMPORTED_`` are not allowed as they are reserved for internal CMake use. Properties containing generator expressions are also not allowed. + +.. note:: + + Since CMake 3.19, :ref:`Interface Libraries` may have arbitrary + target properties. If a project exports an interface library + with custom properties, the resulting package may not work with + dependents configured by older versions of CMake that reject the + custom properties. diff --git a/Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst b/Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst index e061863..84029e4 100644 --- a/Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst +++ b/Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst @@ -11,6 +11,14 @@ corresponding to the target's source directory. If the variable :variable:`CMAKE_Fortran_MODULE_DIRECTORY` is set when a target is created its value is used to initialize this property. +When using one of the :ref:`Visual Studio Generators` with the Intel Fortran +plugin installed in Visual Studio, a subdirectory named after the +configuration will be appended to the path where modules are created. +For example, if ``Fortran_MODULE_DIRECTORY`` is set to ``C:/some/path``, +modules will end up in ``C:/some/path/Debug`` (or +``C:/some/path/Release`` etc.) when an Intel Fortran ``.vfproj`` file is +generated, and in ``C:/some/path`` when any other generator is used. + Note that some compilers will automatically search the module output directory for modules USEd during compilation but others will not. If your sources USE modules their location must be specified by diff --git a/Help/prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst b/Help/prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst index dc73807..f7e366a 100644 --- a/Help/prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst +++ b/Help/prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst @@ -1,15 +1,15 @@ IMPLICIT_DEPENDS_INCLUDE_TRANSFORM ---------------------------------- -Specify #include line transforms for dependencies in a target. +Specify ``#include`` line transforms for dependencies in a target. -This property specifies rules to transform macro-like #include lines +This property specifies rules to transform macro-like ``#include`` lines during implicit dependency scanning of C and C++ source files. The list of rules must be semicolon-separated with each entry of the form -"A_MACRO(%)=value-with-%" (the % must be literal). During dependency -scanning occurrences of A_MACRO(...) on #include lines will be +``A_MACRO(%)=value-with-%`` (the ``%`` must be literal). During dependency +scanning occurrences of ``A_MACRO(...)`` on ``#include`` lines will be replaced by the value given with the macro argument substituted for -'%'. For example, the entry +``%``. For example, the entry :: diff --git a/Help/prop_tgt/IOS_INSTALL_COMBINED.rst b/Help/prop_tgt/IOS_INSTALL_COMBINED.rst index 23a86e6..92d60dc 100644 --- a/Help/prop_tgt/IOS_INSTALL_COMBINED.rst +++ b/Help/prop_tgt/IOS_INSTALL_COMBINED.rst @@ -10,4 +10,10 @@ either be built with the device SDK or the simulator SDK depending on the SDK set. But if this property is set to true then the target will at install time also be built for the corresponding SDK and combined into one library. +.. note:: + + If a selected architecture is available for both: device SDK and simulator + SDK it will be built for the SDK selected by :variable:`CMAKE_OSX_SYSROOT` + and removed from the corresponding SDK. + This feature requires at least Xcode version 6. diff --git a/Help/prop_tgt/OPTIMIZE_DEPENDENCIES.rst b/Help/prop_tgt/OPTIMIZE_DEPENDENCIES.rst new file mode 100644 index 0000000..533cf6a --- /dev/null +++ b/Help/prop_tgt/OPTIMIZE_DEPENDENCIES.rst @@ -0,0 +1,38 @@ +OPTIMIZE_DEPENDENCIES +--------------------- + +Activates dependency optimization of static and object libraries. + +When this property is set to true, some dependencies for a static or object +library may be removed at generation time if they are not necessary to build +the library, since static and object libraries don't actually link against +anything. + +If a static or object library has dependency optimization enabled, it first +discards all dependencies. Then, it looks through all of the direct and +indirect dependencies that it initially had, and adds them back if they meet +any of the following criteria: + +* The dependency was added to the library by :command:`add_dependencies`. +* The dependency was added to the library through a source file in the library + generated by a custom command that uses the dependency. +* The dependency has any ``PRE_BUILD``, ``PRE_LINK``, or ``POST_BUILD`` custom + commands associated with it. +* The dependency contains any source files that were generated by a custom + command. +* The dependency contains any languages which produce side effects that are + relevant to the library. Currently, all languages except C, C++, Objective-C, + Objective-C++, assembly, and CUDA are assumed to produce side effects. + However, side effects from one language are assumed not to be relevant to + another (for example, a Fortran library is assumed to not have any side + effects that are relevant for a Swift library.) + +As an example, assume you have a static Fortran library which depends on a +static C library, which in turn depends on a static Fortran library. The +top-level Fortran library has optimization enabled, but the middle C library +does not. If you build the top Fortran library, the bottom Fortran library will +also build, but not the middle C library, since the C library does not have any +side effects that are relevant for the Fortran library. However, if you build +the middle C library, the bottom Fortran library will also build, even though +it does not have any side effects that are relevant to the C library, since the +C library does not have optimization enabled. diff --git a/Help/prop_tgt/WIN32_EXECUTABLE.rst b/Help/prop_tgt/WIN32_EXECUTABLE.rst index 060d166..eac28ae 100644 --- a/Help/prop_tgt/WIN32_EXECUTABLE.rst +++ b/Help/prop_tgt/WIN32_EXECUTABLE.rst @@ -11,3 +11,7 @@ configure use of the Microsoft Foundation Classes (MFC) for WinMain executables. This property is initialized by the value of the :variable:`CMAKE_WIN32_EXECUTABLE` variable if it is set when a target is created. + +This property supports +:manual:`generator expressions <cmake-generator-expressions(7)>`, except if the +target is managed (contains C# code.) diff --git a/Help/release/3.18.rst b/Help/release/3.18.rst index ba80d2b..099e9b5 100644 --- a/Help/release/3.18.rst +++ b/Help/release/3.18.rst @@ -264,6 +264,11 @@ Other * :manual:`ccmake(1)` learned to read a :envvar:`CCMAKE_COLORS` environment variable to customize colors. +* The :manual:`Compile Features <cmake-compile-features(7)>` functionality + is now aware of the availability of C11 features in MSVC 19.27 and 19.28, + including support for the ``c_restrict``, ``c_static_assert`` features and + the ``-std:c11`` flag. + Deprecated and Removed Features =============================== @@ -339,3 +344,20 @@ Changes made since CMake 3.18.0 include the following. that were using manual quoting or escaping to work around the prior limitation. This fix has been reverted in 3.18.1, but may be re-introduced in future versions of CMake with a policy for compatibility. + +3.18.2 +------ + +* The default value of :variable:`CMAKE_AUTOMOC_PATH_PREFIX` was changed to + ``OFF`` because this feature can break existing projects that have + identically named header files in different include directories. + This restores compatibility with behavior of CMake 3.15 and below. + +* The :manual:`Compile Features <cmake-compile-features(7)>` functionality + was updated for MSVC 19.27 as mentioned above (``c_restrict``). + +3.18.3 +------ + +* The :manual:`Compile Features <cmake-compile-features(7)>` functionality + was updated for MSVC 19.28 as mentioned above (``c_static_assert``). diff --git a/Help/release/dev/add_test-special-chars-in-name.rst b/Help/release/dev/add_test-special-chars-in-name.rst new file mode 100644 index 0000000..5bb9a23 --- /dev/null +++ b/Help/release/dev/add_test-special-chars-in-name.rst @@ -0,0 +1,6 @@ +add_test-special-chars-in-name +------------------------------ + +* The :command:`add_test` command now (officially) supports whitespace and + other special characters in the name for the test it creates. + See policy :policy:`CMP0110`. diff --git a/Help/release/dev/asm-osx-architectures.rst b/Help/release/dev/asm-osx-architectures.rst new file mode 100644 index 0000000..d8d0660 --- /dev/null +++ b/Help/release/dev/asm-osx-architectures.rst @@ -0,0 +1,5 @@ +asm-osx-architectures +--------------------- + +* The :prop_tgt:`OSX_ARCHITECTURES` target property is now respected for the + ``ASM`` language. diff --git a/Help/release/dev/build-interface-targets.rst b/Help/release/dev/build-interface-targets.rst new file mode 100644 index 0000000..37bded4 --- /dev/null +++ b/Help/release/dev/build-interface-targets.rst @@ -0,0 +1,6 @@ +build-interface-targets +----------------------- + +* :ref:`Interface Libraries` may now have source files added via + :command:`add_library` or :command:`target_sources`. Those + with sources will be generated as part of the build system. diff --git a/Help/release/dev/clang-cl-vfs.rst b/Help/release/dev/clang-cl-vfs.rst new file mode 100644 index 0000000..40b19ef --- /dev/null +++ b/Help/release/dev/clang-cl-vfs.rst @@ -0,0 +1,6 @@ +clang-cl-vfs +------------ + +* A :variable:`CMAKE_CLANG_VFS_OVERLAY` variable was added to tell + Clang to use a VFS overlay to support the Windows SDK when + cross-compiling from hosts with case-sensitive filesystems. diff --git a/Help/release/dev/cpack-wix-custom-xmlns.rst b/Help/release/dev/cpack-wix-custom-xmlns.rst new file mode 100644 index 0000000..84934cb --- /dev/null +++ b/Help/release/dev/cpack-wix-custom-xmlns.rst @@ -0,0 +1,5 @@ +cpack-wix-custom-xmlns +---------------------- + +* The :cpack_gen:`CPack WIX Generator` gained a + :variable:`CPACK_WIX_CUSTOM_XMLNS` option to specify custom XML namespaces. diff --git a/Help/release/dev/file-generate-target.rst b/Help/release/dev/file-generate-target.rst new file mode 100644 index 0000000..09fb460 --- /dev/null +++ b/Help/release/dev/file-generate-target.rst @@ -0,0 +1,5 @@ +file-generate-target +-------------------- + +* The :command:`file(GENERATE)` command gained a new ``TARGET`` keyword to + support resolving target-dependent generator expressions. diff --git a/Help/release/dev/imported-target-location-required.rst b/Help/release/dev/imported-target-location-required.rst new file mode 100644 index 0000000..3625242 --- /dev/null +++ b/Help/release/dev/imported-target-location-required.rst @@ -0,0 +1,5 @@ +imported-target-location-required +--------------------------------- + +* An imported target with a missing location now fails during generation if the + location is used. See policy :policy:`CMP0111`. diff --git a/Help/release/dev/optimize-link-dependencies.rst b/Help/release/dev/optimize-link-dependencies.rst new file mode 100644 index 0000000..cfda826 --- /dev/null +++ b/Help/release/dev/optimize-link-dependencies.rst @@ -0,0 +1,7 @@ +optimize-link-dependencies +-------------------------- + +* A new target property, :prop_tgt:`OPTIMIZE_DEPENDENCIES`, was added to + avoid unnecessarily building dependencies for a static library. +* A new variable, :variable:`CMAKE_OPTIMIZE_DEPENDENCIES`, was added to + initialize the :prop_tgt:`OPTIMIZE_DEPENDENCIES` target property. diff --git a/Help/release/dev/vs-win-sdk-custom-max.rst b/Help/release/dev/vs-win-sdk-custom-max.rst new file mode 100644 index 0000000..bd19fc8 --- /dev/null +++ b/Help/release/dev/vs-win-sdk-custom-max.rst @@ -0,0 +1,6 @@ +vs-win-sdk-custom-max +--------------------- + +* A :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` variable + was added to tell the :ref:`Visual Studio Generators` what maximumm + version of the Windows SDK to choose. diff --git a/Help/release/dev/win32-executable-genex.rst b/Help/release/dev/win32-executable-genex.rst new file mode 100644 index 0000000..f03203d --- /dev/null +++ b/Help/release/dev/win32-executable-genex.rst @@ -0,0 +1,5 @@ +win32-executable-genex +---------------------- + +* The :prop_tgt:`WIN32_EXECUTABLE` target property now supports + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst b/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst index 07a6cc8..42f48b4 100644 --- a/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst +++ b/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst @@ -10,4 +10,4 @@ This variable is used to initialize the :prop_tgt:`AUTOMOC_PATH_PREFIX` property on all the targets. See that target property for additional information. -The default value is ``ON``. +The default value is ``OFF``. diff --git a/Help/variable/CMAKE_CLANG_VFS_OVERLAY.rst b/Help/variable/CMAKE_CLANG_VFS_OVERLAY.rst new file mode 100644 index 0000000..56ac328 --- /dev/null +++ b/Help/variable/CMAKE_CLANG_VFS_OVERLAY.rst @@ -0,0 +1,9 @@ +CMAKE_CLANG_VFS_OVERLAY +----------------------- + +.. versionadded:: 3.19 + +When cross compiling for windows with clang-cl, this variable can be an +absolute path pointing to a clang virtual file system yaml file, which +will enable clang-cl to resolve windows header names on a case sensitive +file system. diff --git a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst index 07342b5..d5fcb7d 100644 --- a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst +++ b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst @@ -3,9 +3,9 @@ CMAKE_CUDA_HOST_COMPILER .. versionadded:: 3.10 -When :variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>` is set to -NVIDIA ``nvcc``, ``CMAKE_CUDA_HOST_COMPILER`` selects the compiler -executable to use when compiling host code for ``CUDA`` language files. +When :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is +``NVIDIA``, ``CMAKE_CUDA_HOST_COMPILER`` selects the compiler executable to use +when compiling host code for ``CUDA`` language files. This maps to the ``nvcc -ccbin`` option. The ``CMAKE_CUDA_HOST_COMPILER`` variable may be set explicitly before CUDA is @@ -20,6 +20,6 @@ is read-only and changes to it are undefined behavior. .. note:: Since ``CMAKE_CUDA_HOST_COMPILER`` is meaningful only when the - ``CMAKE_CUDA_COMPILER`` is ``nvcc``, it does not make sense to - set ``CMAKE_CUDA_HOST_COMPILER`` explicitly without also setting - ``CMAKE_CUDA_COMPILER`` explicitly to be sure it is ``nvcc``. + :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``, + it does not make sense to set ``CMAKE_CUDA_HOST_COMPILER`` without also + setting ``CMAKE_CUDA_COMPILER`` to NVCC. diff --git a/Help/variable/CMAKE_OPTIMIZE_DEPENDENCIES.rst b/Help/variable/CMAKE_OPTIMIZE_DEPENDENCIES.rst new file mode 100644 index 0000000..eed352a --- /dev/null +++ b/Help/variable/CMAKE_OPTIMIZE_DEPENDENCIES.rst @@ -0,0 +1,4 @@ +CMAKE_OPTIMIZE_DEPENDENCIES +--------------------------- + +Initializes the :prop_tgt:`OPTIMIZE_DEPENDENCIES` target property. diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst index cb55bc2..eb71049 100644 --- a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst +++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst @@ -17,3 +17,5 @@ One may set a ``CMAKE_WINDOWS_KITS_10_DIR`` *environment variable* to an absolute path to tell CMake to look for Windows 10 SDKs in a custom location. The specified directory is expected to contain ``Include/10.0.*`` directories. + +See also :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM`. diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst new file mode 100644 index 0000000..591ea91 --- /dev/null +++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst @@ -0,0 +1,14 @@ +CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM +------------------------------------------------ + +.. versionadded:: 3.19 + +Override the :ref:`Windows 10 SDK Maximum Version for VS 2015`. + +The :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM` variable may +be set to a false value (e.g. ``OFF``, ``FALSE``, or ``0``) or the SDK version +to use as the maximum (e.g. ``10.0.14393.0``). If unset, the default depends +on which version of Visual Studio is targeted by the current generator. + +This can be used in conjunction with :variable:`CMAKE_SYSTEM_VERSION`, which +CMake uses to select :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION`. diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 99d5070..96855d2 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -8,21 +8,34 @@ CMakeDependentOption Macro to provide an option dependent on other options. This macro presents an option to the user only if a set of other -conditions are true. When the option is not presented a default value -is used, but any value set by the user is preserved for when the -option is presented again. Example invocation: +conditions are true. + +Usage: + +.. code-block:: cmake + + cmake_dependent_option(<option> "<help_text>" <value> <depends> <force>) + +Where ``<option>`` is available to the user if ``<depends>`` is true. When +``<option>`` is available, the given ``<help_text>`` and initial ``<value>`` +are used. If the ``<depends>`` condition is not true, ``<option>`` will not be +presented and will always have the value given by ``<force>``. Any value set by +the user is preserved for when the option is presented again. Each element in +the fourth parameter is evaluated as an if-condition, so +:ref:`Condition Syntax` can be used. + +Example invocation: .. code-block:: cmake - CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON + cmake_dependent_option(USE_FOO "Use Foo" ON "USE_BAR;NOT USE_ZOT" OFF) -If USE_BAR is true and USE_ZOT is false, this provides an option -called USE_FOO that defaults to ON. Otherwise, it sets USE_FOO to -OFF. If the status of USE_BAR or USE_ZOT ever changes, any value for -the USE_FOO option is saved so that when the option is re-enabled it -retains its old value. Each element in the fourth parameter is -evaluated as an if-condition, so :ref:`Condition Syntax` can be used. +If ``USE_BAR`` is true and ``USE_ZOT`` is false, this provides an option called +``USE_FOO`` that defaults to ON. Otherwise, it sets ``USE_FOO`` to OFF and +hides the option from the user. If the status of ``USE_BAR`` or ``USE_ZOT`` +ever changes, any value for the ``USE_FOO`` option is saved so that when the +option is re-enabled it retains its old value. #]=======================================================================] macro(CMAKE_DEPENDENT_OPTION option doc default depends force) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 4c2924a..2205c8f 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -84,7 +84,7 @@ else() endif() if(CMAKE_CXX_COMPILER_TARGET) - list(PREPEND CMAKE_CXX_COPMILER_ID_TEST_FLAGS "-c --target=${CMAKE_CXX_COMPILER_TARGET}") + list(PREPEND CMAKE_CXX_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_CXX_COMPILER_TARGET}") endif() # Build a small source file to identify the compiler. diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 3b8d5a1..66adafa 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -103,6 +103,19 @@ else() set(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES "llvm-addr2line") endif() + if(NOT CMAKE_CROSSCOMPILING AND NOT "${_CMAKE_TOOLCHAIN_PREFIX}" STREQUAL "") + list(APPEND _CMAKE_ADDITIONAL_AR_NAMES "ar") + list(APPEND _CMAKE_ADDITIONAL_RANLIB_NAMES "ranlib") + list(APPEND _CMAKE_ADDITIONAL_STRIP_NAMES "strip") + list(APPEND _CMAKE_ADDITIONAL_LINKER_NAMES "ld") + list(APPEND _CMAKE_ADDITIONAL_NM_NAMES "nm") + list(APPEND _CMAKE_ADDITIONAL_OBJDUMP_NAMES "objdump") + list(APPEND _CMAKE_ADDITIONAL_OBJCOPY_NAMES "objcopy") + list(APPEND _CMAKE_ADDITIONAL_READELF_NAMES "readelf") + list(APPEND _CMAKE_ADDITIONAL_DLLTOOL_NAMES "dlltool") + list(APPEND _CMAKE_ADDITIONAL_ADDR2LINE_NAMES "addr2line") + endif() + find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 000fba1..6f665a6 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -26,7 +26,9 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON) set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON) -set(CMAKE_AUTOMOC_PATH_PREFIX ON) +if(NOT DEFINED CMAKE_AUTOMOC_PATH_PREFIX) + set(CMAKE_AUTOMOC_PATH_PREFIX OFF) +endif() set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT") # basically all general purpose OSs support shared libs diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake index 418bafd..44bb622 100644 --- a/Modules/CMakeIOSInstallCombined.cmake +++ b/Modules/CMakeIOSInstallCombined.cmake @@ -80,6 +80,17 @@ function(_ios_install_combined_get_valid_archs sdk resultvar) cmake_policy(POP) endfunction() +# Make both arch lists a disjoint set by preferring the current SDK +# (starting with Xcode 12 arm64 is available as device and simulator arch on iOS) +function(_ios_install_combined_prune_common_archs corr_sdk corr_archs_var this_archs_var) + list(REMOVE_ITEM ${corr_archs_var} ${${this_archs_var}}) + + string(REPLACE ";" " " printable "${${corr_archs_var}}") + _ios_install_combined_message("Architectures (${corr_sdk}) after pruning: ${printable}") + + set("${corr_archs_var}" "${${corr_archs_var}}" PARENT_SCOPE) +endfunction() + # Final target can contain more architectures that specified by SDK. This # function will run 'lipo -info' and parse output. Result will be returned # as a CMake list. @@ -266,8 +277,9 @@ function(ios_install_combined target destination) _ios_install_combined_detect_sdks(this_sdk corr_sdk) # Get architectures of the target - _ios_install_combined_get_valid_archs("${corr_sdk}" corr_valid_archs) _ios_install_combined_get_valid_archs("${this_sdk}" this_valid_archs) + _ios_install_combined_get_valid_archs("${corr_sdk}" corr_valid_archs) + _ios_install_combined_prune_common_archs("${corr_sdk}" corr_valid_archs this_valid_archs) # Return if there are no valid architectures for the SDK. # (note that library already installed) diff --git a/Modules/Compiler/MSVC-C-FeatureTests.cmake b/Modules/Compiler/MSVC-C-FeatureTests.cmake index 3f09be2..4024c12 100644 --- a/Modules/Compiler/MSVC-C-FeatureTests.cmake +++ b/Modules/Compiler/MSVC-C-FeatureTests.cmake @@ -1,8 +1,7 @@ set(_cmake_oldestSupported "_MSC_VER >= 1600") -# Not yet supported: -#set(_cmake_feature_test_c_static_assert "") -#set(_cmake_feature_test_c_restrict "") +set(_cmake_feature_test_c_restrict "_MSC_VER >= 1927") +set(_cmake_feature_test_c_static_assert "_MSC_VER >= 1928") set(_cmake_feature_test_c_variadic_macros "${_cmake_oldestSupported}") set(_cmake_feature_test_c_function_prototypes "${_cmake_oldestSupported}") diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake index bca9764..31ae7fd 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -1,15 +1,31 @@ -# MSVC has no specific options to set C language standards, but set them as -# empty strings anyways so the feature test infrastructure can at least check -# to see if they are defined. -set(CMAKE_C90_STANDARD_COMPILE_OPTION "") -set(CMAKE_C90_EXTENSION_COMPILE_OPTION "") -set(CMAKE_C99_STANDARD_COMPILE_OPTION "") -set(CMAKE_C99_EXTENSION_COMPILE_OPTION "") -set(CMAKE_C11_STANDARD_COMPILE_OPTION "") -set(CMAKE_C11_EXTENSION_COMPILE_OPTION "") +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. -# There is no meaningful default for this -set(CMAKE_C_STANDARD_DEFAULT "") +include(Compiler/CMakeCommonCompilerMacros) + +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) + set(CMAKE_C90_STANDARD_COMPILE_OPTION "") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "") + set(CMAKE_C99_STANDARD_COMPILE_OPTION "") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "") + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std:c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std:c11") + + __compiler_check_default_language_standard(C 19.27 99) +else() + # MSVC has no specific options to set C language standards, but set them as + # empty strings anyways so the feature test infrastructure can at least check + # to see if they are defined. + set(CMAKE_C90_STANDARD_COMPILE_OPTION "") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "") + set(CMAKE_C99_STANDARD_COMPILE_OPTION "") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "") + set(CMAKE_C11_STANDARD_COMPILE_OPTION "") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "") + + # There is no meaningful default for this + set(CMAKE_C_STANDARD_DEFAULT "") +endif() set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") @@ -31,6 +47,14 @@ macro(cmake_record_c_compile_features) list(APPEND CMAKE_C_COMPILE_FEATURES c_variadic_macros) list(APPEND CMAKE_C99_COMPILE_FEATURES c_variadic_macros) endif() + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) + list(APPEND CMAKE_C_COMPILE_FEATURES c_restrict) + list(APPEND CMAKE_C99_COMPILE_FEATURES c_restrict) + endif() + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28) + list(APPEND CMAKE_C_COMPILE_FEATURES c_static_assert) + list(APPEND CMAKE_C11_COMPILE_FEATURES c_static_assert) + endif() set(_result 0) # expected by cmake_determine_compile_features endmacro() diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index feb5ecc..3187294 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -68,20 +68,22 @@ if(UNIX) endif() if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") + # MSVC requires c++14 as the minimum level set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "") set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "") + # MSVC requires c++14 as the minimum level set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "") set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "") if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0) - set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "") - set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "-std=c++14") endif() if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0) - set(CMAKE_CUDA17_STANDARD_COMPILE_OPTION "") - set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CUDA17_STANDARD_COMPILE_OPTION "-std=c++17") + set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17") endif() else() diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in index 99fb917..ff8c659 100644 --- a/Modules/ExternalProject-download.cmake.in +++ b/Modules/ExternalProject-download.cmake.in @@ -105,54 +105,65 @@ set(retry_number 5) message(STATUS "Downloading... dst='@LOCAL@' - timeout='@TIMEOUT_MSG@'" + timeout='@TIMEOUT_MSG@' + inactivity timeout='@INACTIVITY_TIMEOUT_MSG@'" ) - +set(download_retry_codes 7 6 8 15) +set(skip_url_list) +set(status_code) foreach(i RANGE ${retry_number}) - sleep_before_download(${i}) - + if(status_code IN_LIST download_retry_codes) + sleep_before_download(${i}) + endif() foreach(url @REMOTE@) - message(STATUS "Using src='${url}'") + if(NOT url IN_LIST skip_url_list) + message(STATUS "Using src='${url}'") - @TLS_VERIFY_CODE@ - @TLS_CAINFO_CODE@ - @NETRC_CODE@ - @NETRC_FILE_CODE@ + @TLS_VERIFY_CODE@ + @TLS_CAINFO_CODE@ + @NETRC_CODE@ + @NETRC_FILE_CODE@ - file( + file( DOWNLOAD "${url}" "@LOCAL@" @SHOW_PROGRESS@ @TIMEOUT_ARGS@ + @INACTIVITY_TIMEOUT_ARGS@ STATUS status LOG log @USERPWD_ARGS@ @HTTP_HEADERS_ARGS@ - ) - - list(GET status 0 status_code) - list(GET status 1 status_string) - - if(status_code EQUAL 0) - check_file_hash(has_hash hash_is_good) - if(has_hash AND NOT hash_is_good) - message(STATUS "Hash mismatch, removing...") - file(REMOVE "@LOCAL@") + ) + + list(GET status 0 status_code) + list(GET status 1 status_string) + + if(status_code EQUAL 0) + check_file_hash(has_hash hash_is_good) + if(has_hash AND NOT hash_is_good) + message(STATUS "Hash mismatch, removing...") + file(REMOVE "@LOCAL@") + else() + message(STATUS "Downloading... done") + return() + endif() else() - message(STATUS "Downloading... done") - return() + string(APPEND logFailedURLs "error: downloading '${url}' failed + status_code: ${status_code} + status_string: ${status_string} + log: + --- LOG BEGIN --- + ${log} + --- LOG END --- + " + ) + if(NOT status_code IN_LIST download_retry_codes) + list(APPEND skip_url_list "${url}") + break() endif() - else() - string(APPEND logFailedURLs "error: downloading '${url}' failed - status_code: ${status_code} - status_string: ${status_string} - log: - --- LOG BEGIN --- - ${log} - --- LOG END --- - " - ) endif() + endif() endforeach() endforeach() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index aecc00b..96edbef 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -179,6 +179,9 @@ External Project Definition ``TIMEOUT <seconds>`` Maximum time allowed for file download operations. + ``INACTIVITY_TIMEOUT <seconds>`` + Terminate the operation after a period of inactivity. + ``HTTP_USERNAME <username>`` Username for the download operation if authentication is required. @@ -747,7 +750,7 @@ control needed to implement such step-level capabilities. ``<name>`` is the same as the name passed to the original call to :command:`ExternalProject_Add`. The specified ``<step>`` must not be one of - the pre-defined steps (``mkdir``, ``download``, ``update``, ``skip-update``, + the pre-defined steps (``mkdir``, ``download``, ``update``, ``patch``, ``configure``, ``build``, ``install`` or ``test``). The supported options are: @@ -1300,7 +1303,7 @@ function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_r ) endfunction() -function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file) +function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inactivity_timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file) if(timeout) set(TIMEOUT_ARGS TIMEOUT ${timeout}) set(TIMEOUT_MSG "${timeout} seconds") @@ -1308,6 +1311,14 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p set(TIMEOUT_ARGS "# no TIMEOUT") set(TIMEOUT_MSG "none") endif() + if(inactivity_timeout) + set(INACTIVITY_TIMEOUT_ARGS INACTIVITY_TIMEOUT ${inactivity_timeout}) + set(INACTIVITY_TIMEOUT_MSG "${inactivity_timeout} seconds") + else() + set(INACTIVITY_TIMEOUT_ARGS "# no INACTIVITY_TIMEOUT") + set(INACTIVITY_TIMEOUT_MSG "none") + endif() + if(no_progress) set(SHOW_PROGRESS "") @@ -2512,6 +2523,7 @@ function(_ep_add_download_command name) string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) + get_property(inactivity_timeout TARGET ${name} PROPERTY _EP_INACTIVITY_TIMEOUT) get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) @@ -2521,7 +2533,7 @@ function(_ep_add_download_command name) get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER) set(download_script "${stamp_dir}/download-${name}.cmake") - _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${inactivity_timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}") set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) if (no_extract) @@ -2762,21 +2774,6 @@ Update to Mercurial >= 2.1.1. )" ) - if(update_disconnected) - _ep_get_step_stampfile(${name} skip-update skip-update_stamp_file) - string(REPLACE "Performing" "Skipping" comment "${comment}") - ExternalProject_Add_Step(${name} skip-update - COMMENT ${comment} - ALWAYS ${always} - EXCLUDE_FROM_MAIN 1 - WORKING_DIRECTORY ${work_dir} - DEPENDEES download - ${log} - ${uses_terminal} - ) - set_property(SOURCE ${skip-update_stamp_file} PROPERTY SYMBOLIC 1) - endif() - endfunction() @@ -2801,9 +2798,9 @@ function(_ep_add_patch_command name) _ep_get_update_disconnected(update_disconnected ${name}) if(update_disconnected) - set(update_dep skip-update) + set(patch_dep download) else() - set(update_dep update) + set(patch_dep update) endif() set(__cmdQuoted) @@ -2814,7 +2811,7 @@ function(_ep_add_patch_command name) ExternalProject_Add_Step(${name} patch COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${work_dir} - DEPENDEES download \${update_dep} + DEPENDEES \${patch_dep} ${log} )" ) @@ -2970,13 +2967,6 @@ function(_ep_add_configure_command name) set(uses_terminal "") endif() - _ep_get_update_disconnected(update_disconnected ${name}) - if(update_disconnected) - set(update_dep skip-update) - else() - set(update_dep update) - endif() - set(__cmdQuoted) foreach(__item IN LISTS cmd) string(APPEND __cmdQuoted " [==[${__item}]==]") @@ -2985,7 +2975,7 @@ function(_ep_add_configure_command name) ExternalProject_Add_Step(${name} configure COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${binary_dir} - DEPENDEES \${update_dep} patch + DEPENDEES patch DEPENDS \${file_deps} ${log} ${uses_terminal} diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index c85e2d8..acf2a94 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -1038,6 +1038,11 @@ function(FetchContent_Populate contentName) message(FATAL_ERROR "Content ${contentName} already populated in ${${contentNameLower}_SOURCE_DIR}") endif() + __FetchContent_getSavedDetails(${contentName} contentDetails) + if("${contentDetails}" STREQUAL "") + message(FATAL_ERROR "No details have been set for content: ${contentName}") + endif() + string(TOUPPER ${contentName} contentNameUpper) set(FETCHCONTENT_SOURCE_DIR_${contentNameUpper} "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}" @@ -1045,14 +1050,35 @@ function(FetchContent_Populate contentName) if(FETCHCONTENT_SOURCE_DIR_${contentNameUpper}) # The source directory has been explicitly provided in the cache, - # so no population is required + # so no population is required. The build directory may still be specified + # by the declared details though. set(${contentNameLower}_SOURCE_DIR "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}") - set(${contentNameLower}_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build") + + cmake_parse_arguments(savedDetails "" "BINARY_DIR" "" ${contentDetails}) + + if(savedDetails_BINARY_DIR) + set(${contentNameLower}_BINARY_DIR ${savedDetails_BINARY_DIR}) + else() + set(${contentNameLower}_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build") + endif() elseif(FETCHCONTENT_FULLY_DISCONNECTED) - # Bypass population and assume source is already there from a previous run - set(${contentNameLower}_SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src") - set(${contentNameLower}_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build") + # Bypass population and assume source is already there from a previous run. + # Declared details may override the default source or build directories. + + cmake_parse_arguments(savedDetails "" "SOURCE_DIR;BINARY_DIR" "" ${contentDetails}) + + if(savedDetails_SOURCE_DIR) + set(${contentNameLower}_SOURCE_DIR ${savedDetails_SOURCE_DIR}) + else() + set(${contentNameLower}_SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src") + endif() + + if(savedDetails_BINARY_DIR) + set(${contentNameLower}_BINARY_DIR ${savedDetails_BINARY_DIR}) + else() + set(${contentNameLower}_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build") + endif() else() # Support both a global "disconnect all updates" and a per-content @@ -1072,11 +1098,6 @@ function(FetchContent_Populate contentName) unset(quietFlag) endif() - __FetchContent_getSavedDetails(${contentName} contentDetails) - if("${contentDetails}" STREQUAL "") - message(FATAL_ERROR "No details have been set for content: ${contentName}") - endif() - set(__detailsQuoted) foreach(__item IN LISTS contentDetails) string(APPEND __detailsQuoted " [==[${__item}]==]") diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 7a1c252..0a92c71 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -110,6 +110,18 @@ also be defined. With all components enabled, the following variables will be d ``HDF5_DIFF_EXECUTABLE`` path to the HDF5 dataset comparison tool +With all components enabled, the following targets will be defined: + +:: + + ``hdf5::hdf5`` + ``hdf5::hdf5_hl_cpp`` + ``hdf5::hdf5_fortran`` + ``hdf5::hdf5_hl`` + ``hdf5::hdf5_hl_cpp`` + ``hdf5::hdf5_hl_fortran`` + ``hdf5::h5diff`` + Hints ^^^^^ @@ -128,6 +140,11 @@ The following variables can be set to guide the search for HDF5 libraries and in include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +# We haven't found HDF5 yet. Clear its state in case it is set in the parent +# scope somewhere else. We can't rely on it because different components may +# have been requested for this call. +set(HDF5_FOUND OFF) + # List of the valid HDF5 components set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) @@ -195,9 +212,7 @@ macro(_HDF5_remove_duplicates_from_beginning _list_name) endif() endmacro() - # Test first if the current compilers automatically wrap HDF5 - function(_HDF5_test_regular_compiler_C success version is_parallel) set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) @@ -206,7 +221,6 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) set(test_file ${scratch_directory}/cmake_hdf5_test.c) file(WRITE ${test_file} "#include <hdf5.h>\n" - "#include <hdf5_hl.h>\n" "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" "#ifdef H5_HAVE_PARALLEL\n" "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" @@ -972,6 +986,138 @@ if( HDF5_FOUND AND NOT HDF5_DIR) mark_as_advanced(HDF5_DIR) endif() +if (HDF5_FOUND) + if (NOT TARGET HDF5::HDF5) + add_library(HDF5::HDF5 INTERFACE IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_DEFINITIONS}") + set_target_properties(HDF5::HDF5 PROPERTIES + INTERFACE_LINK_LIBRARIES "${HDF5_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + unset(_hdf5_definitions) + endif () + + foreach (hdf5_lang IN LISTS HDF5_LANGUAGE_BINDINGS) + if (hdf5_lang STREQUAL "C") + set(hdf5_target_name "hdf5") + elseif (hdf5_lang STREQUAL "CXX") + set(hdf5_target_name "hdf5_cpp") + elseif (hdf5_lang STREQUAL "Fortran") + set(hdf5_target_name "hdf5_fortran") + else () + continue () + endif () + + if (NOT TARGET "hdf5::${hdf5_target_name}") + if (HDF5_COMPILER_NO_INTERROGATE) + add_library("hdf5::${hdf5_target_name}" INTERFACE IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_DEFINITIONS}") + set_target_properties("hdf5::${hdf5_target_name}" PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_${hdf5_lang}_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + else() + if (DEFINED "HDF5_${hdf5_target_name}_LIBRARY") + set(_hdf5_location "${HDF5_${hdf5_target_name}_LIBRARY}") + elseif (DEFINED "HDF5_${hdf5_lang}_LIBRARY") + set(_hdf5_location "${HDF5_${hdf5_lang}_LIBRARY}") + elseif (DEFINED "HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}") + set(_hdf5_location "${HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}}") + else () + # Error if we still don't have the location. + message(SEND_ERROR + "HDF5 was found, but a different variable was set which contains " + "its location.") + endif () + add_library("hdf5::${hdf5_target_name}" UNKNOWN IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_DEFINITIONS}") + if (NOT HDF5_${hdf5_lang}_INCLUDE_DIRS) + set(HDF5_${hdf5_lang}_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS}) + endif () + set_target_properties("hdf5::${hdf5_target_name}" PROPERTIES + IMPORTED_LOCATION "${_hdf5_location}" + IMPORTED_IMPLIB "${_hdf5_location}" + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_${hdf5_lang}_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + if (_hdf5_libtype STREQUAL "SHARED") + set_property(TARGET "hdf5::${hdf5_target_name}" APPEND + PROPERTY + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB) + elseif (_hdf5_libtype STREQUAL "STATIC") + set_property(TARGET "hdf5::${hdf5_target_name}" APPEND + PROPERTY + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_STATIC_LIB) + endif () + unset(_hdf5_definitions) + unset(_hdf5_libtype) + unset(_hdf5_location) + endif () + endif () + + if (NOT HDF5_FIND_HL) + continue () + endif () + + if (hdf5_lang STREQUAL "C") + set(hdf5_target_name "hdf5_hl") + elseif (hdf5_lang STREQUAL "CXX") + set(hdf5_target_name "hdf5_hl_cpp") + elseif (hdf5_lang STREQUAL "Fortran") + set(hdf5_target_name "hdf5_hl_fortran") + else () + continue () + endif () + + if (NOT TARGET "hdf5::${hdf5_target_name}") + if (HDF5_COMPILER_NO_INTERROGATE) + add_library("hdf5::${hdf5_target_name}" INTERFACE IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_HL_DEFINITIONS}") + set_target_properties("hdf5::${hdf5_target_name}" PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_${hdf5_lang}_HL_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + else() + if (DEFINED "HDF5_${hdf5_target_name}_LIBRARY") + set(_hdf5_location "${HDF5_${hdf5_target_name}_LIBRARY}") + elseif (DEFINED "HDF5_${hdf5_lang}_HL_LIBRARY") + set(_hdf5_location "${HDF5_${hdf5_lang}_HL_LIBRARY}") + elseif (DEFINED "HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}") + set(_hdf5_location "${HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}}") + else () + # Error if we still don't have the location. + message(SEND_ERROR + "HDF5 was found, but a different variable was set which contains " + "its location.") + endif () + add_library("hdf5::${hdf5_target_name}" UNKNOWN IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_HL_DEFINITIONS}") + set_target_properties("hdf5::${hdf5_target_name}" PROPERTIES + IMPORTED_LOCATION "${_hdf5_location}" + IMPORTED_IMPLIB "${_hdf5_location}" + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_${hdf5_lang}_HL_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + if (_hdf5_libtype STREQUAL "SHARED") + set_property(TARGET "hdf5::${hdf5_target_name}" APPEND + PROPERTY + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB) + elseif (_hdf5_libtype STREQUAL "STATIC") + set_property(TARGET "hdf5::${hdf5_target_name}" APPEND + PROPERTY + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_STATIC_LIB) + endif () + unset(_hdf5_definitions) + unset(_hdf5_libtype) + unset(_hdf5_location) + endif () + endif () + endforeach () + unset(hdf5_lang) + + if (HDF5_DIFF_EXECUTABLE AND NOT TARGET hdf5::h5diff) + add_executable(hdf5::h5diff IMPORTED) + set_target_properties(hdf5::h5diff PROPERTIES + IMPORTED_LOCATION "${HDF5_DIFF_EXECUTABLE}") + endif () +endif () + if (HDF5_FIND_DEBUG) message(STATUS "HDF5_DIR: ${HDF5_DIR}") message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}") diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 3a5bd31..eff815d 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -59,6 +59,8 @@ macro(java_append_library_directories _var) endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") set(_java_libarch "i386") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") + set(_java_libarch "arm64") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha") set(_java_libarch "alpha") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index f996d4c..438551e 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -86,42 +86,38 @@ This module defines the following variables: find_package(LAPACK) #]=======================================================================] -# Check the language being used -if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR "FindLAPACK requires Fortran, C, or C++ to be enabled.") - else() - message(STATUS "Looking for LAPACK... - NOT found (Unsupported languages)") - return() - endif() -endif() - if(CMAKE_Fortran_COMPILER_LOADED) include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) else() include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) endif() include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -cmake_push_check_state() -set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) +macro(_lapack_find_library_setup) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) -set(LAPACK_FOUND FALSE) -set(LAPACK95_FOUND FALSE) - -set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) -if(BLA_STATIC) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() -else() - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif() endif() -endif() +endmacro() + +macro(_lapack_find_library_teardown) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + cmake_pop_check_state() +endmacro() # TODO: move this stuff to a separate module @@ -173,6 +169,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a endif() endif() endforeach() + unset(_library) if(_libraries_work) # Test this combination of libraries. @@ -196,187 +193,210 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a else() set(${LIBRARIES} FALSE) endif() + + unset(_extaddlibdir) + unset(_libraries_work) + unset(_combined_name) #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") endmacro() +macro(_lapack_find_dependency dep) + set(_lapack_quiet_arg) + if(LAPACK_FIND_QUIETLY) + set(_lapack_quiet_arg QUIET) + endif() + set(_lapack_required_arg) + if(LAPACK_FIND_REQUIRED) + set(_lapack_required_arg REQUIRED) + endif() + find_package(${dep} ${ARGN} + ${_lapack_quiet_arg} + ${_lapack_required_arg} + ) + if (NOT ${dep}_FOUND) + set(LAPACK_NOT_FOUND_MESSAGE "LAPACK could not be found because dependency ${dep} could not be found.") + endif() + + set(_lapack_required_arg) + set(_lapack_quiet_arg) +endmacro() + +_lapack_find_library_setup() + set(LAPACK_LINKER_FLAGS) set(LAPACK_LIBRARIES) set(LAPACK95_LIBRARIES) -if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_package(BLAS) -else() - find_package(BLAS REQUIRED) +# Check the language being used +if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) + set(LAPACK_NOT_FOUND_MESSAGE + "FindLAPACK requires Fortran, C, or C++ to be enabled.") +endif() + +# Load BLAS +if(NOT LAPACK_NOT_FOUND_MESSAGE) + _lapack_find_dependency(BLAS) endif() -if(BLAS_FOUND) +# Search for different LAPACK distributions if BLAS is found +if(NOT LAPACK_NOT_FOUND_MESSAGE) set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) if(NOT $ENV{BLA_VENDOR} STREQUAL "") set(BLA_VENDOR $ENV{BLA_VENDOR}) - else() - if(NOT BLA_VENDOR) - set(BLA_VENDOR "All") - endif() + elseif(NOT BLA_VENDOR) + set(BLA_VENDOR "All") endif() # LAPACK in the Intel MKL 10+ library? - if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) - # System-specific settings - if(NOT WIN32) - set(LAPACK_mkl_LM "-lm") - set(LAPACK_mkl_LDL "-ldl") - endif() - - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_package(Threads) - else() - find_package(Threads REQUIRED) - endif() - - if(BLA_VENDOR MATCHES "_64ilp") - set(LAPACK_mkl_ILP_MODE "ilp64") - else() - set(LAPACK_mkl_ILP_MODE "lp64") - endif() - - set(LAPACK_SEARCH_LIBS "") - - if(BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") - set(_LIBRARIES LAPACK95_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) - - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_intel_c") - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") - else() - set(LAPACK_mkl_SEARCH_SYMBOL "cheev") - set(_LIBRARIES LAPACK_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - - # old and new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack") - endif() - - # MKL uses a multitude of partially platform-specific subdirectories: - if(BLA_VENDOR STREQUAL "Intel10_32") - set(LAPACK_mkl_ARCH_NAME "ia32") - else() - set(LAPACK_mkl_ARCH_NAME "intel64") - endif() - if(WIN32) - set(LAPACK_mkl_OS_NAME "win") - elseif(APPLE) - set(LAPACK_mkl_OS_NAME "mac") - else() - set(LAPACK_mkl_OS_NAME "lin") - endif() - if(DEFINED ENV{MKLROOT}) - file(TO_CMAKE_PATH "$ENV{MKLROOT}" LAPACK_mkl_MKLROOT) - # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead - # so we can better detect other relevant libraries in 'compiler' or 'tbb': - get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME) - if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") - get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY) - endif() - endif() - set(LAPACK_mkl_LIB_PATH_SUFFIXES - "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" - "compiler/lib/${LAPACK_mkl_ARCH_NAME}" - "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" - "mkl/lib/${LAPACK_mkl_ARCH_NAME}" - "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}") - - # First try empty lapack libs - if(NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "" - "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" - "${LAPACK_mkl_MKLROOT}" - "${LAPACK_mkl_LIB_PATH_SUFFIXES}" - "${_BLAS_LIBRARIES}" - ) - endif() - - # Then try the search libs - foreach(IT ${LAPACK_SEARCH_LIBS}) - string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if(NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "${SEARCH_LIBS}" - "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" - "${LAPACK_mkl_MKLROOT}" - "${LAPACK_mkl_LIB_PATH_SUFFIXES}" - "${_BLAS_LIBRARIES}" - ) - endif() - endforeach() - - unset(LAPACK_mkl_ILP_MODE) - unset(LAPACK_mkl_SEARCH_SYMBOL) - unset(LAPACK_mkl_LM) - unset(LAPACK_mkl_LDL) - unset(LAPACK_mkl_MKLROOT) - unset(LAPACK_mkl_ARCH_NAME) - unset(LAPACK_mkl_OS_NAME) - unset(LAPACK_mkl_LIB_PATH_SUFFIXES) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + AND (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)) + # System-specific settings + if(NOT WIN32) + set(LAPACK_mkl_LM "-lm") + set(LAPACK_mkl_LDL "-ldl") endif() - endif() - # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) - if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) + _lapack_find_dependency(Threads) + + if(BLA_VENDOR MATCHES "_64ilp") + set(LAPACK_mkl_ILP_MODE "ilp64") + else() + set(LAPACK_mkl_ILP_MODE "lp64") + endif() + + set(LAPACK_SEARCH_LIBS "") + + if(BLA_F95) + set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") + set(_LIBRARIES LAPACK95_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) + + # old + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95") + # new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_intel_c") + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") + else() + set(LAPACK_mkl_SEARCH_SYMBOL "cheev") + set(_LIBRARIES LAPACK_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) + + # old and new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack") + endif() + + # MKL uses a multitude of partially platform-specific subdirectories: + if(BLA_VENDOR STREQUAL "Intel10_32") + set(LAPACK_mkl_ARCH_NAME "ia32") + else() + set(LAPACK_mkl_ARCH_NAME "intel64") + endif() + if(WIN32) + set(LAPACK_mkl_OS_NAME "win") + elseif(APPLE) + set(LAPACK_mkl_OS_NAME "mac") + else() + set(LAPACK_mkl_OS_NAME "lin") + endif() + if(DEFINED ENV{MKLROOT}) + file(TO_CMAKE_PATH "$ENV{MKLROOT}" LAPACK_mkl_MKLROOT) + # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead + # so we can better detect other relevant libraries in 'compiler' or 'tbb': + get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME) + if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") + get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY) + endif() + endif() + set(LAPACK_mkl_LIB_PATH_SUFFIXES + "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "compiler/lib/${LAPACK_mkl_ARCH_NAME}" + "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "mkl/lib/${LAPACK_mkl_ARCH_NAME}" + "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}") + + # First try empty lapack libs + if(NOT ${_LIBRARIES}) check_lapack_libraries( - LAPACK_LIBRARIES + ${_LIBRARIES} LAPACK - cheev - "" - "goto2" + ${LAPACK_mkl_SEARCH_SYMBOL} "" "" - "" - "${BLAS_LIBRARIES}" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" + "${_BLAS_LIBRARIES}" ) endif() + + # Then try the search libs + foreach(IT ${LAPACK_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) + if(NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + LAPACK + ${LAPACK_mkl_SEARCH_SYMBOL} + "" + "${SEARCH_LIBS}" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" + "${_BLAS_LIBRARIES}" + ) + endif() + endforeach() + + unset(LAPACK_mkl_ILP_MODE) + unset(LAPACK_mkl_SEARCH_SYMBOL) + unset(LAPACK_mkl_LM) + unset(LAPACK_mkl_LDL) + unset(LAPACK_mkl_MKLROOT) + unset(LAPACK_mkl_ARCH_NAME) + unset(LAPACK_mkl_OS_NAME) + unset(LAPACK_mkl_LIB_PATH_SUFFIXES) + endif() + + # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "goto2" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # OpenBLAS? (http://www.openblas.net) - if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "openblas" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "openblas" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # ArmPL? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries) - if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All") - + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All")) # Check for 64bit Integer support if(BLA_VENDOR MATCHES "_ilp64") set(LAPACK_armpl_LIB "armpl_ilp64") @@ -389,36 +409,33 @@ if(BLAS_FOUND) set(LAPACK_armpl_LIB "${LAPACK_armpl_LIB}_mp") endif() - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "${LAPACK_armpl_LIB}" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "${LAPACK_armpl_LIB}" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # FLAME's blis library? (https://github.com/flame/blis) - if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "flame" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "flame" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # BLAS in acml library? @@ -429,106 +446,70 @@ if(BLAS_FOUND) endif() # Apple LAPACK library? - if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "Accelerate" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "Accelerate" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # Apple NAS (vecLib) library? - if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "vecLib" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "vecLib" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # Generic LAPACK library? - if(BLA_VENDOR STREQUAL "Generic" OR - BLA_VENDOR STREQUAL "ATLAS" OR - BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "lapack" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "Generic" + OR BLA_VENDOR STREQUAL "ATLAS" + OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "lapack" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() -else() - message(STATUS "LAPACK requires BLAS") endif() if(BLA_F95) - if(LAPACK95_LIBRARIES) - set(LAPACK95_FOUND TRUE) - else() - set(LAPACK95_FOUND FALSE) - endif() - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK95_FOUND) - message(STATUS "A library with LAPACK95 API found.") - else() - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with LAPACK95 API not found. Please specify library location." - ) - else() - message(STATUS - "A library with LAPACK95 API not found. Please specify library location." - ) - endif() - endif() - endif() - set(LAPACK_FOUND "${LAPACK95_FOUND}") set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}") -else() - if(LAPACK_LIBRARIES) - set(LAPACK_FOUND TRUE) - else() - set(LAPACK_FOUND FALSE) - endif() +endif() - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_FOUND) - message(STATUS "A library with LAPACK API found.") - else() - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with LAPACK API not found. Please specify library location." - ) - else() - message(STATUS - "A library with LAPACK API not found. Please specify library location." - ) - endif() - endif() - endif() +if(LAPACK_NOT_FOUND_MESSAGE) + set(LAPACK_NOT_FOUND_MESSAGE + REASON_FAILURE_MESSAGE ${LAPACK_NOT_FOUND_MESSAGE}) +endif() +find_package_handle_standard_args(LAPACK REQUIRED_VARS LAPACK_LIBRARIES + ${LAPACK_NOT_FOUND_MESSAGE}) +unset(LAPACK_NOT_FOUND_MESSAGE) + +if(BLA_F95) + set(LAPACK95_FOUND ${LAPACK_FOUND}) endif() # On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines) @@ -537,7 +518,7 @@ if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") set(LAPACK_LIBRARIES "") endif() -if(NOT TARGET LAPACK::LAPACK) +if(LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK) add_library(LAPACK::LAPACK INTERFACE IMPORTED) set(_lapack_libs "${LAPACK_LIBRARIES}") if(_lapack_libs AND TARGET BLAS::BLAS) @@ -554,5 +535,4 @@ if(NOT TARGET LAPACK::LAPACK) unset(_lapack_libs) endif() -cmake_pop_check_state() -set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +_lapack_find_library_teardown() diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index b2526c1..b531e47 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1157,7 +1157,7 @@ macro(_MPI_create_imported_target LANG) string(REPLACE "-pthread" "$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:SHELL:-Xcompiler >-pthread" _MPI_${LANG}_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") string(REPLACE "-fexceptions" "$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:SHELL:-Xcompiler >-fexceptions" - _MPI_${LANG}_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + _MPI_${LANG}_COMPILE_OPTIONS "${_MPI_${LANG}_COMPILE_OPTIONS}") set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${_MPI_${LANG}_COMPILE_OPTIONS}") unset(_MPI_${LANG}_COMPILE_OPTIONS) diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index e1271d4..110e7f9 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -412,8 +412,15 @@ if(OPENGL_EGL_INCLUDE_DIR) endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +if (CMAKE_FIND_PACKAGE_NAME STREQUAL "GLU") + # FindGLU include()'s this module. It's an old pattern, but rather than + # trying to suppress this from outside the module (which is then sensitive to + # the contents, detect the case in this module and suppress it explicitly. + set(FPHSA_NAME_MISMATCHED 1) +endif () FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS} HANDLE_COMPONENTS) +unset(FPHSA_NAME_MISMATCHED) unset(_OpenGL_REQUIRED_VARS) # OpenGL:: targets diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 9196851..91a65fd 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -193,12 +193,18 @@ if(WIN32 AND NOT CYGWIN) endif() if(OPENSSL_USE_STATIC_LIBS) + set(_OPENSSL_STATIC_SUFFIX + "_static" + ) set(_OPENSSL_PATH_SUFFIXES "lib/VC/static" "VC/static" "lib" ) else() + set(_OPENSSL_STATIC_SUFFIX + "" + ) set(_OPENSSL_PATH_SUFFIXES "lib/VC" "VC" @@ -208,6 +214,17 @@ if(WIN32 AND NOT CYGWIN) find_library(LIB_EAY_DEBUG NAMES + # When OpenSSL is built with default options, the static library name is suffixed with "_static". + # Looking the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the + # import library of "libcrypto.dll". + libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libcrypto${_OPENSSL_STATIC_SUFFIX}d + libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libeay32${_OPENSSL_STATIC_SUFFIX}d + crypto${_OPENSSL_STATIC_SUFFIX}d + # When OpenSSL is built with the "-static" option, only the static build is produced, + # and it is not suffixed with "_static". libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d libcrypto${_OPENSSL_MSVC_RT_MODE}d libcryptod @@ -222,6 +239,17 @@ if(WIN32 AND NOT CYGWIN) find_library(LIB_EAY_RELEASE NAMES + # When OpenSSL is built with default options, the static library name is suffixed with "_static". + # Looking the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the + # import library of "libcrypto.dll". + libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libcrypto${_OPENSSL_STATIC_SUFFIX} + libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libeay32${_OPENSSL_STATIC_SUFFIX} + crypto${_OPENSSL_STATIC_SUFFIX} + # When OpenSSL is built with the "-static" option, only the static build is produced, + # and it is not suffixed with "_static". libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} libcrypto${_OPENSSL_MSVC_RT_MODE} libcrypto @@ -236,6 +264,17 @@ if(WIN32 AND NOT CYGWIN) find_library(SSL_EAY_DEBUG NAMES + # When OpenSSL is built with default options, the static library name is suffixed with "_static". + # Looking the "libssl_static.lib" with a higher priority than "libssl.lib" which is the + # import library of "libssl.dll". + libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libssl${_OPENSSL_STATIC_SUFFIX}d + ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + ssleay32${_OPENSSL_STATIC_SUFFIX}d + ssl${_OPENSSL_STATIC_SUFFIX}d + # When OpenSSL is built with the "-static" option, only the static build is produced, + # and it is not suffixed with "_static". libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d libssl${_OPENSSL_MSVC_RT_MODE}d libssld @@ -250,6 +289,17 @@ if(WIN32 AND NOT CYGWIN) find_library(SSL_EAY_RELEASE NAMES + # When OpenSSL is built with default options, the static library name is suffixed with "_static". + # Looking the "libssl_static.lib" with a higher priority than "libssl.lib" which is the + # import library of "libssl.dll". + libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libssl${_OPENSSL_STATIC_SUFFIX} + ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + ssleay32${_OPENSSL_STATIC_SUFFIX} + ssl${_OPENSSL_STATIC_SUFFIX} + # When OpenSSL is built with the "-static" option, only the static build is produced, + # and it is not suffixed with "_static". libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} libssl${_OPENSSL_MSVC_RT_MODE} libssl diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake index fd120bf..c14e059 100644 --- a/Modules/FindPerl.cmake +++ b/Modules/FindPerl.cmake @@ -73,8 +73,15 @@ endif() set(PERL ${PERL_EXECUTABLE}) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +if (CMAKE_FIND_PACKAGE_NAME STREQUAL "PerlLibs") + # FindPerlLibs include()'s this module. It's an old pattern, but rather than + # trying to suppress this from outside the module (which is then sensitive to + # the contents, detect the case in this module and suppress it explicitly. + set(FPHSA_NAME_MISMATCHED 1) +endif () FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl REQUIRED_VARS PERL_EXECUTABLE VERSION_VAR PERL_VERSION_STRING) +unset(FPHSA_NAME_MISMATCHED) mark_as_advanced(PERL_EXECUTABLE) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 1be0625..1d68c44 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -5,17 +5,13 @@ # This file is a "template" file used by various FindPython modules. # -cmake_policy (GET CMP0094 _${_PYTHON_PREFIX}_LOOKUP_POLICY) - -cmake_policy (VERSION 3.7) - -if (_${_PYTHON_PREFIX}_LOOKUP_POLICY) - cmake_policy (SET CMP0094 ${_${_PYTHON_PREFIX}_LOOKUP_POLICY}) -endif() - # # Initial configuration # + +# IN_LIST operator +cmake_policy (SET CMP0057 NEW) + if (NOT DEFINED _PYTHON_PREFIX) message (FATAL_ERROR "FindPython: INTERNAL ERROR") endif() @@ -490,7 +486,7 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) endif() elseif (NAME STREQUAL "SOABI") execute_process (COMMAND ${_${_PYTHON_PREFIX}_INTERPRETER_LAUNCHER} "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c - "import sys\ntry:\n from distutils import sysconfig\n sys.stdout.write(';'.join([sysconfig.get_config_var('SOABI') or '',sysconfig.get_config_var('EXT_SUFFIX') or '']))\nexcept Exception:\n import sysconfig;sys.stdout.write(';'.join([sysconfig.get_config_var('SOABI') or '',sysconfig.get_config_var('EXT_SUFFIX') or '']))" + "import sys\ntry:\n from distutils import sysconfig\n sys.stdout.write(';'.join([sysconfig.get_config_var('SOABI') or '',sysconfig.get_config_var('EXT_SUFFIX') or '',sysconfig.get_config_var('SO') or '']))\nexcept Exception:\n import sysconfig;sys.stdout.write(';'.join([sysconfig.get_config_var('SOABI') or '',sysconfig.get_config_var('EXT_SUFFIX') or '',sysconfig.get_config_var('SO') or '']))" RESULT_VARIABLE _result OUTPUT_VARIABLE _soabi ERROR_QUIET @@ -526,7 +522,7 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) endif() endif() - if (config_flag STREQUAL "ABIFLAGS") + if (NAME STREQUAL "ABIFLAGS" OR NAME STREQUAL "SOABI") set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE) return() endif() @@ -562,18 +558,19 @@ function (_PYTHON_GET_VERSION) if (_PGV_LIBRARY) # retrieve version and abi from library name if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE) + get_filename_component (library_name "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" NAME) # extract version from library name - if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])([0-9]+)") + if (library_name MATCHES "python([23])([0-9]+)") set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE) set (${_PGV_PREFIX}ABI "" PARENT_SCOPE) - elseif (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])\\.([0-9]+)([dmu]*)") + elseif (library_name MATCHES "python([23])\\.([0-9]+)([dmu]*)") set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE) set (${_PGV_PREFIX}ABI "${CMAKE_MATCH_3}" PARENT_SCOPE) - elseif (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "pypy(3)?") + elseif (library_name MATCHES "pypy(3)?-c") set (version "${CMAKE_MATCH_1}") if (version EQUAL "3") set (${_PGV_PREFIX}VERSION_MAJOR "3" PARENT_SCOPE) @@ -1097,6 +1094,7 @@ endif() unset (${_PYTHON_PREFIX}_SOABI) # Define lookup strategy +cmake_policy (GET CMP0094 _${_PYTHON_PREFIX}_LOOKUP_POLICY) if (_${_PYTHON_PREFIX}_LOOKUP_POLICY STREQUAL "NEW") set (_${_PYTHON_PREFIX}_FIND_STRATEGY "LOCATION") else() @@ -1771,9 +1769,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) unset (${_PYTHON_PREFIX}_SITEARCH) endif() - if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL "3") - _python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI) - endif() + _python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI) # store properties in the cache to speed-up future searches set (_${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES @@ -2844,8 +2840,7 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS ${_PYTHON_PREFIX}_PyPy_VERSION "${${_PYTHON_PREFIX}_PyPy_VERSION}") endif() - if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL "3" - AND NOT DEFINED ${_PYTHON_PREFIX}_SOABI) + if (NOT DEFINED ${_PYTHON_PREFIX}_SOABI) _python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI) endif() @@ -3095,11 +3090,6 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") function (__${_PYTHON_PREFIX}_ADD_LIBRARY prefix name) cmake_parse_arguments (PARSE_ARGV 2 PYTHON_ADD_LIBRARY "STATIC;SHARED;MODULE;WITH_SOABI" "" "") - if (prefix STREQUAL "Python2" AND PYTHON_ADD_LIBRARY_WITH_SOABI) - message (AUTHOR_WARNING "FindPython2: Option `WITH_SOABI` is not supported for Python2 and will be ignored.") - unset (PYTHON_ADD_LIBRARY_WITH_SOABI) - endif() - if (PYTHON_ADD_LIBRARY_STATIC) set (type STATIC) elseif (PYTHON_ADD_LIBRARY_SHARED) diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index 563ed46..b5bc8b1 100644 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -201,9 +201,16 @@ endif() # if the include a library are found then we have it include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +if (CMAKE_FIND_PACKAGE_NAME STREQUAL "Qt") + # FindQt include()'s this module. It's an old pattern, but rather than trying + # to suppress this from outside the module (which is then sensitive to the + # contents, detect the case in this module and suppress it explicitly. + set(FPHSA_NAME_MISMATCHED 1) +endif () FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt3 REQUIRED_VARS QT_QT_LIBRARY QT_INCLUDE_DIR QT_MOC_EXECUTABLE VERSION_VAR QT_VERSION_STRING) +unset(FPHSA_NAME_MISMATCHED) set(QT_FOUND ${QT3_FOUND} ) if(QT_FOUND) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 29b1ef8..ec0f453 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1318,10 +1318,18 @@ if (NOT QT_VERSION_MAJOR EQUAL 4) endif() endif() else() + if (CMAKE_FIND_PACKAGE_NAME STREQUAL "Qt") + # FindQt include()'s this module. It's an old pattern, but rather than + # trying to suppress this from outside the module (which is then sensitive + # to the contents, detect the case in this module and suppress it + # explicitly. + set(FPHSA_NAME_MISMATCHED 1) + endif () FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt4 FOUND_VAR Qt4_FOUND REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} VERSION_VAR QTVERSION ) + unset(FPHSA_NAME_MISMATCHED) endif() ####################################### diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 1bdee60..0559a69 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -48,10 +48,21 @@ This module will set the following variables in your project: Ruby patch version. -Also: - -``Ruby_INCLUDE_PATH`` - same as Ruby_INCLUDE_DIRS, only provided for compatibility reasons, don't use it +The following variables are also provided for compatibility reasons, +don't use them in new code: + +``RUBY_EXECUTABLE`` + same as Ruby_EXECUTABLE. +``RUBY_INCLUDE_DIRS`` + same as Ruby_INCLUDE_DIRS. +``RUBY_INCLUDE_PATH`` + same as Ruby_INCLUDE_DIRS. +``RUBY_LIBRARY`` + same as Ruby_LIBRARY. +``RUBY_VERSION`` + same as Ruby_VERSION. +``RUBY_FOUND`` + same as Ruby_FOUND. Hints ^^^^^ @@ -493,7 +504,6 @@ foreach(Camel Ruby_VERSION_MAJOR Ruby_VERSION_MINOR Ruby_VERSION_PATCH - Ruby_INCLUDE_PATH Ruby_ARCH_DIR Ruby_ARCH diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index 960265f..9b771dc 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -223,6 +223,12 @@ find_path(TK_INCLUDE_PATH include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +if (CMAKE_FIND_PACKAGE_NAME STREQUAL "TclStub") + # FindTclStub include()'s this module. It's an old pattern, but rather than + # trying to suppress this from outside the module (which is then sensitive to + # the contents, detect the case in this module and suppress it explicitly. + set(FPHSA_NAME_MISMATCHED 1) +endif () FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH) set(FPHSA_NAME_MISMATCHED 1) set(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED}) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index f306d5b..594d0ec 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -85,8 +85,17 @@ if(TCL_TCLSH) endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +if (CMAKE_FIND_PACKAGE_NAME STREQUAL "TCL" OR + CMAKE_FIND_PACKAGE_NAME STREQUAL "TclStub") + # FindTCL include()'s this module. It's an old pattern, but rather than + # trying to suppress this from outside the module (which is then sensitive to + # the contents, detect the case in this module and suppress it explicitly. + # Transitively, FindTclStub includes FindTCL. + set(FPHSA_NAME_MISMATCHED 1) +endif () FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh REQUIRED_VARS TCL_TCLSH VERSION_VAR TCLSH_VERSION_STRING) +unset(FPHSA_NAME_MISMATCHED) mark_as_advanced(TCL_TCLSH) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 958a22e..a865597 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -28,6 +28,8 @@ and also the following more fine grained variables and targets: X11_xcb_INCLUDE_PATH, X11_xcb_LIB, X11_xcb_FOUND, X11::xcb X11_X11_xcb_INCLUDE_PATH, X11_X11_xcb_LIB, X11_X11_xcb_FOUND, X11::X11_xcb X11_xcb_icccm_INCLUDE_PATH, X11_xcb_icccm_LIB, X11_xcb_icccm_FOUND, X11::xcb_icccm + X11_xcb_util_INCLUDE_PATH, X11_xcb_util_LIB, X11_xcb_util_FOUND, X11::xcb_util + X11_xcb_xfixes_INCLUDE_PATH, X11_xcb_xfixes_LIB, X11_xcb_xfixes_FOUND, X11::xcb_xfixes X11_xcb_xkb_INCLUDE_PATH, X11_xcb_xkb_LIB, X11_xcb_xkb_FOUND, X11::xcb_xkb X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND, X11::Xcomposite X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND, X11::Xcursor @@ -105,6 +107,8 @@ if (UNIX) find_path(X11_xcb_INCLUDE_PATH xcb/xcb.h ${X11_INC_SEARCH_PATH}) find_path(X11_X11_xcb_INCLUDE_PATH X11/Xlib-xcb.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_icccm_INCLUDE_PATH xcb/xcb_icccm.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_util_INCLUDE_PATH xcb/xcb_aux.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xfixes_INCLUDE_PATH xcb/xfixes.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcomposite_INCLUDE_PATH X11/extensions/Xcomposite.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcursor_INCLUDE_PATH X11/Xcursor/Xcursor.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xdamage_INCLUDE_PATH X11/extensions/Xdamage.h ${X11_INC_SEARCH_PATH}) @@ -156,6 +160,8 @@ if (UNIX) find_library(X11_xcb_LIB xcb ${X11_LIB_SEARCH_PATH}) find_library(X11_X11_xcb_LIB X11-xcb ${X11_LIB_SEARCH_PATH}) find_library(X11_xcb_icccm_LIB xcb-icccm ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_util_LIB xcb-util ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xfixes_LIB xcb-xfixes ${X11_LIB_SEARCH_PATH}) find_library(X11_xcb_xkb_LIB xcb-xkb ${X11_LIB_SEARCH_PATH}) find_library(X11_Xcomposite_LIB Xcomposite ${X11_LIB_SEARCH_PATH}) find_library(X11_Xcursor_LIB Xcursor ${X11_LIB_SEARCH_PATH}) @@ -255,6 +261,14 @@ if (UNIX) set(X11_xcb_icccm_FOUND TRUE) endif () + if (X11_xcb_util_LIB AND X11_xcb_util_INCLUDE_PATH) + set(X11_xcb_util_FOUND TRUE) + endif () + + if (X11_xcb_xfixes_LIB) + set(X11_xcb_xfixes_FOUND TRUE) + endif () + if (X11_xcb_xkb_LIB) set(X11_xcb_xkb_FOUND TRUE) endif () @@ -413,9 +427,17 @@ if (UNIX) endif () include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + if (CMAKE_FIND_PACKAGE_NAME STREQUAL "FLTK") + # FindFLTK include()'s this module. It's an old pattern, but rather than + # trying to suppress this from outside the module (which is then sensitive + # to the contents, detect the case in this module and suppress it + # explicitly. + set(FPHSA_NAME_MISMATCHED 1) + endif () find_package_handle_standard_args(X11 REQUIRED_VARS X11_X11_INCLUDE_PATH X11_X11_LIB HANDLE_COMPONENTS) + unset(FPHSA_NAME_MISMATCHED) if(X11_FOUND) include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) @@ -558,6 +580,20 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_util_FOUND AND NOT TARGET X11::xcb_util) + add_library(X11::xcb_util UNKNOWN IMPORTED) + set_target_properties(X11::xcb_util PROPERTIES + IMPORTED_LOCATION "${X11_xcb_util_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_xfixes_FOUND AND NOT TARGET X11::xcb_xfixes) + add_library(X11::xcb_xfixes UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xfixes PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xfixes_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_xkb_FOUND AND NOT TARGET X11::xcb_xkb) add_library(X11::xcb_xkb UNKNOWN IMPORTED) set_target_properties(X11::xcb_xkb PROPERTIES diff --git a/Modules/Internal/CPack/WIX.template.in b/Modules/Internal/CPack/WIX.template.in index c4fc83a..c0bf935 100644 --- a/Modules/Internal/CPack/WIX.template.in +++ b/Modules/Internal/CPack/WIX.template.in @@ -2,7 +2,7 @@ <?include "cpack_variables.wxi"?> -<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" +<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" @CPACK_WIX_CUSTOM_XMLNS_EXPANDED@ RequiredVersion="3.6.3303.0"> <Product Id="$(var.CPACK_WIX_PRODUCT_GUID)" diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index dff8166..c8c91de 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -97,6 +97,27 @@ macro(__windows_compiler_clang_gnu lang) enable_language(RC) endmacro() +macro(__enable_llvm_rc_preprocessing clang_option_prefix) + # Feed the preprocessed rc file to llvm-rc + if(CMAKE_RC_COMPILER_INIT MATCHES "llvm-rc" OR CMAKE_RC_COMPILER MATCHES "llvm-rc") + if(DEFINED CMAKE_C_COMPILER_ID) + set(CMAKE_RC_PREPROCESSOR CMAKE_C_COMPILER) + elseif(DEFINED CMAKE_CXX_COMPILER_ID) + set(CMAKE_RC_PREPROCESSOR CMAKE_CXX_COMPILER) + endif() + if(DEFINED CMAKE_RC_PREPROCESSOR) + set(CMAKE_DEPFILE_FLAGS_RC "${clang_option_prefix}-MD ${clang_option_prefix}-MF ${clang_option_prefix}<DEPFILE>") + set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_COMMAND> -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E -- <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp") + if(CMAKE_GENERATOR MATCHES "Ninja") + set(CMAKE_NINJA_CMCLDEPS_RC 0) + set(CMAKE_NINJA_DEP_TYPE_RC gcc) + endif() + unset(CMAKE_RC_PREPROCESSOR) + endif() + endif() +endmacro() + + if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") @@ -124,7 +145,10 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" if(__RC_COMPILER_PATH) set(CMAKE_RC_COMPILER_INIT rc) else() - set(CMAKE_RC_COMPILER_INIT llvm-rc) + find_program(__RC_COMPILER_PATH NAMES llvm-rc) + if(__RC_COMPILER_PATH) + set(CMAKE_RC_COMPILER_INIT llvm-rc) + endif() endif() unset(__RC_COMPILER_PATH CACHE) @@ -132,25 +156,8 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" ) include(Platform/Windows-MSVC) - - # Feed the preprocessed rc file to llvm-rc - if(CMAKE_RC_COMPILER_INIT MATCHES "llvm-rc") - if(DEFINED CMAKE_C_COMPILER_ID) - set(CMAKE_RC_PREPROCESSOR CMAKE_C_COMPILER) - elseif(DEFINED CMAKE_CXX_COMPILER_ID) - set(CMAKE_RC_PREPROCESSOR CMAKE_CXX_COMPILER) - endif() - if(DEFINED CMAKE_RC_PREPROCESSOR) - set(CMAKE_DEPFILE_FLAGS_RC "-clang:-MD -clang:-MF -clang:<DEPFILE>") - set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_COMMAND} -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E <SOURCE> -- <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp") - if(CMAKE_GENERATOR STREQUAL "Ninja") - set(CMAKE_NINJA_CMCLDEPS_RC 0) - set(CMAKE_NINJA_DEP_TYPE_RC gcc) - endif() - unset(CMAKE_RC_PREPROCESSOR) - endif() - endif() - + # Set the clang option forwarding prefix for clang-cl usage in the llvm-rc processing stage + __enable_llvm_rc_preprocessing("-clang:") macro(__windows_compiler_clang lang) set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) @@ -166,6 +173,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" set(CMAKE_BUILD_TYPE_INIT Debug) + __enable_llvm_rc_preprocessing("") macro(__windows_compiler_clang lang) __windows_compiler_clang_gnu(${lang}) endmacro() @@ -173,6 +181,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" else() include(Platform/Windows-GNU) + __enable_llvm_rc_preprocessing("") macro(__windows_compiler_clang lang) __windows_compiler_gnu(${lang}) endmacro() diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e272da9..de31dab 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -333,6 +333,14 @@ macro(__windows_compiler_msvc lang) set(CMAKE_LINK_PCH ON) if (CMAKE_${lang}_COMPILER_ID STREQUAL "Clang") set(CMAKE_PCH_PROLOGUE "#pragma clang system_header") + + # macOS paths usually start with /Users/*. Unfortunately, clang-cl interprets + # paths starting with /U as macro undefines, so we need to put a -- before the + # input file path to force it to be treated as a path. + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_COMPILE_OBJECT "${CMAKE_${lang}_COMPILE_OBJECT}") + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "${CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE}") + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "${CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE}") + elseif(MSVC_VERSION GREATER_EQUAL 1913) # At least MSVC toolet 14.13 from VS 2017 15.6 set(CMAKE_PCH_PROLOGUE "#pragma system_header") diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index b75eb5e..59a0707 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -496,7 +496,8 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) endif() endif() if (SWIG_MODULE_${name}_LANGUAGE STREQUAL "PYTHON" AND NOT SWIG_MODULE_${name}_NOPROXY) - if(NOT ("-interface" IN_LIST swig_source_file_flags OR "-interface" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS)) + if(SWIG_USE_INTERFACE AND + NOT ("-interface" IN_LIST swig_source_file_flags OR "-interface" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS)) # This makes sure that the name used in the proxy code # matches the library name created by CMake list (APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-interface" "$<TARGET_FILE_PREFIX:${target_name}>$<TARGET_FILE_BASE_NAME:${target_name}>") @@ -724,6 +725,13 @@ function(SWIG_ADD_LIBRARY name) set(swig_generated_sources) set(swig_generated_timestamps) + list(LENGTH swig_dot_i_sources swig_sources_count) + if (swig_sources_count GREATER "1") + # option -interface cannot be used + set(SWIG_USE_INTERFACE FALSE) + else() + set(SWIG_USE_INTERFACE TRUE) + endif() foreach(swig_it IN LISTS swig_dot_i_sources) SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source "${swig_it}") list (APPEND swig_generated_sources "${swig_generated_source}") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b6b868e..af25ce6 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 18) -set(CMake_VERSION_PATCH 20200807) +set(CMake_VERSION_PATCH 20200901) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 72af10b..8b3644f 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -221,6 +221,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() this->LightExtensions.insert("WixUIExtension"); CollectExtensions("CPACK_WIX_EXTENSIONS", this->LightExtensions); CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions); + CollectXmlNamespaces("CPACK_WIX_CUSTOM_XMLNS", this->CustomXmlNamespaces); const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); if (patchFilePath) { @@ -322,6 +323,7 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() cmWIXSourceWriter includeFile(this->Logger, includeFilename, this->ComponentGuidType, cmWIXSourceWriter::INCLUDE_ELEMENT_ROOT); + InjectXmlNamespaces(includeFile); CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID"); CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID"); @@ -345,6 +347,7 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile() cmWIXSourceWriter includeFile(this->Logger, includeFilename, this->ComponentGuidType, cmWIXSourceWriter::INCLUDE_ELEMENT_ROOT); + InjectXmlNamespaces(includeFile); std::string prefix = "CPACK_WIX_PROPERTY_"; std::vector<std::string> options = GetOptions(); @@ -393,6 +396,7 @@ void cmCPackWIXGenerator::CreateWiXProductFragmentIncludeFile() cmWIXSourceWriter includeFile(this->Logger, includeFilename, this->ComponentGuidType, cmWIXSourceWriter::INCLUDE_ELEMENT_ROOT); + InjectXmlNamespaces(includeFile); this->Patch->ApplyFragment("#PRODUCT", includeFile); } @@ -432,6 +436,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() cmWIXDirectoriesSourceWriter directoryDefinitions( this->Logger, directoryDefinitionsFilename, this->ComponentGuidType); + InjectXmlNamespaces(directoryDefinitions); directoryDefinitions.BeginElement("Fragment"); std::string installRoot; @@ -453,6 +458,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() cmWIXFilesSourceWriter fileDefinitions(this->Logger, fileDefinitionsFilename, this->ComponentGuidType); + InjectXmlNamespaces(fileDefinitions); fileDefinitions.BeginElement("Fragment"); @@ -463,6 +469,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() cmWIXFeaturesSourceWriter featureDefinitions( this->Logger, featureDefinitionsFilename, this->ComponentGuidType); + InjectXmlNamespaces(featureDefinitions); featureDefinitions.BeginElement("Fragment"); @@ -1147,6 +1154,35 @@ void cmCPackWIXGenerator::CollectExtensions(std::string const& variableName, extensions.insert(list.begin(), list.end()); } +void cmCPackWIXGenerator::CollectXmlNamespaces(std::string const& variableName, + xmlns_map_t& namespaces) +{ + const char* variableContent = GetOption(variableName.c_str()); + if (!variableContent) { + return; + } + + std::vector<std::string> list = cmExpandedList(variableContent); + for (std::string const& str : list) { + auto pos = str.find('='); + if (pos != std::string::npos) { + auto name = str.substr(0, pos); + auto value = str.substr(pos + 1); + namespaces.emplace(std::make_pair(name, value)); + } else { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Invalid element in CPACK_WIX_CUSTOM_XMLNS ignored: " + << "\"" << str << "\"" << std::endl); + } + } + std::ostringstream oss; + for (auto& ns : namespaces) { + oss << " xmlns:" << ns.first << "=\"" + << cmWIXSourceWriter::EscapeAttributeValue(ns.second) << '"'; + } + SetOption("CPACK_WIX_CUSTOM_XMLNS_EXPANDED", oss.str().c_str()); +} + void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName, std::ostream& stream) { @@ -1172,3 +1208,10 @@ std::string cmCPackWIXGenerator::RelativePathWithoutComponentPrefix( return path.substr(pos + 1); } + +void cmCPackWIXGenerator::InjectXmlNamespaces(cmWIXSourceWriter& sourceWriter) +{ + for (auto& ns : this->CustomXmlNamespaces) { + sourceWriter.AddAttributeUnlessEmpty("xmlns:" + ns.first, ns.second); + } +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index d5a16ec..b9c37e9 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -49,6 +49,7 @@ private: using id_map_t = std::map<std::string, std::string>; using ambiguity_map_t = std::map<std::string, size_t>; using extension_set_t = std::set<std::string>; + using xmlns_map_t = std::map<std::string, std::string>; enum class DefinitionType { @@ -147,16 +148,22 @@ private: void CollectExtensions(std::string const& variableName, extension_set_t& extensions); + void CollectXmlNamespaces(std::string const& variableName, + xmlns_map_t& namespaces); + void AddCustomFlags(std::string const& variableName, std::ostream& stream); std::string RelativePathWithoutComponentPrefix(std::string const& path); + void InjectXmlNamespaces(cmWIXSourceWriter& sourceWriter); + std::vector<std::string> WixSources; id_map_t PathToIdMap; ambiguity_map_t IdAmbiguityCounter; extension_set_t CandleExtensions; extension_set_t LightExtensions; + xmlns_map_t CustomXmlNamespaces; std::string CPackTopLevel; diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 8cc2070..6030ea3 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -50,6 +50,8 @@ public: std::string CreateGuidFromComponentId(std::string const& componentId); + static std::string EscapeAttributeValue(std::string const& value); + protected: cmCPackLog* Logger; @@ -64,8 +66,6 @@ private: void Indent(size_t count); - static std::string EscapeAttributeValue(std::string const& value); - cmsys::ofstream File; State State; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 70e84ee..abd1207 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -819,14 +819,16 @@ void cmCTestTestHandler::CheckLabelFilter(cmCTestTestProperties& it) this->CheckLabelFilterExclude(it); } -void cmCTestTestHandler::ComputeTestList() +bool cmCTestTestHandler::ComputeTestList() { this->TestList.clear(); // clear list of test - this->GetListOfTests(); + if (!this->GetListOfTests()) { + return false; + } if (this->RerunFailed) { this->ComputeTestListForRerunFailed(); - return; + return true; } cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size(); @@ -882,6 +884,7 @@ void cmCTestTestHandler::ComputeTestList() this->TestList = finalList; this->UpdateMaxTestNameWidth(); + return true; } void cmCTestTestHandler::ComputeTestListForRerunFailed() @@ -1260,7 +1263,10 @@ bool cmCTestTestHandler::GetValue(const char* tag, std::string& value, bool cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, std::vector<std::string>& failed) { - this->ComputeTestList(); + if (!this->ComputeTestList()) { + return false; + } + this->StartTest = this->CTest->CurrentTime(); this->StartTestTime = std::chrono::system_clock::now(); auto elapsed_time_start = std::chrono::steady_clock::now(); @@ -1695,7 +1701,7 @@ bool cmCTestTestHandler::ParseResourceGroupsProperty( return lexer.ParseString(val); } -void cmCTestTestHandler::GetListOfTests() +bool cmCTestTestHandler::GetListOfTests() { if (!this->IncludeLabelRegExp.empty()) { this->IncludeLabelRegularExpression.compile( @@ -1748,14 +1754,15 @@ void cmCTestTestHandler::GetListOfTests() // does the DartTestfile.txt exist ? testFilename = "DartTestfile.txt"; } else { - return; + return true; } if (!mf.ReadListFile(testFilename)) { - return; + return false; } if (cmSystemTools::GetErrorOccuredFlag()) { - return; + // SEND_ERROR or FATAL_ERROR in CTestTestfile or TEST_INCLUDE_FILES + return false; } const char* specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE"); if (this->ResourceSpecFile.empty() && specFile) { @@ -1764,6 +1771,7 @@ void cmCTestTestHandler::GetListOfTests() cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Done constructing a list of tests" << std::endl, this->Quiet); + return true; } void cmCTestTestHandler::UseIncludeRegExp() diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index b26f8a6..f9e9391 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -286,10 +286,10 @@ private: /** * Get the list of tests in directory and subdirectories. */ - void GetListOfTests(); + bool GetListOfTests(); // compute the lists of tests that will actually run // based on union regex and -I stuff - void ComputeTestList(); + bool ComputeTestList(); // compute the lists of tests that will actually run // based on LastTestFailed.log diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt index b468f5b..21c499e 100644 --- a/Source/CursesDialog/form/CMakeLists.txt +++ b/Source/CursesDialog/form/CMakeLists.txt @@ -3,6 +3,14 @@ project(CMAKE_FORM) +# Disable warnings to avoid changing 3rd party code. +if(CMAKE_C_COMPILER_ID MATCHES + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") +elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") +endif() + configure_file(cmFormConfigure.h.in "${CMAKE_CURRENT_BINARY_DIR}/cmFormConfigure.h") add_library(cmForm diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 3e5d764..f262fac 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddLibraryCommand.h" -#include <cmext/algorithm> - #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" @@ -111,20 +109,10 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args, "INTERFACE library specified with conflicting ALIAS type."); return false; } - if (excludeFromAll) { - status.SetError( - "INTERFACE library may not be used with EXCLUDE_FROM_ALL."); - return false; - } ++s; type = cmStateEnums::INTERFACE_LIBRARY; haveSpecifiedType = true; } else if (*s == "EXCLUDE_FROM_ALL") { - if (type == cmStateEnums::INTERFACE_LIBRARY) { - status.SetError( - "INTERFACE library may not be used with EXCLUDE_FROM_ALL."); - return false; - } ++s; excludeFromAll = true; } else if (*s == "IMPORTED") { @@ -143,10 +131,6 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args, } if (type == cmStateEnums::INTERFACE_LIBRARY) { - if (s != args.end()) { - status.SetError("INTERFACE library requires no source arguments."); - return false; - } if (importGlobal && !importTarget) { status.SetError( "INTERFACE library specified as GLOBAL, but not as IMPORTED."); @@ -302,8 +286,6 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args, } } - std::vector<std::string> srclists; - if (type == cmStateEnums::INTERFACE_LIBRARY) { if (!cmGeneratorExpression::IsValidTargetName(libName) || libName.find("::") != std::string::npos) { @@ -311,14 +293,10 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args, cmStrCat("Invalid name for INTERFACE library target: ", libName)); return false; } - - mf.AddLibrary(libName, type, srclists, excludeFromAll); - return true; } - cm::append(srclists, s, args.end()); - - mf.AddLibrary(libName, type, srclists, excludeFromAll); + std::vector<std::string> srcs(s, args.end()); + mf.AddLibrary(libName, type, srcs, excludeFromAll); return true; } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index a5fde89..f0ae8de 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -704,8 +704,7 @@ bool cmCTest::UpdateCTestConfiguration() if (!cmSystemTools::FileExists(fileName)) { // No need to exit if we are not producing XML if (this->Impl->ProduceXML) { - cmCTestLog(this, ERROR_MESSAGE, - "Cannot find file: " << fileName << std::endl); + cmCTestLog(this, WARNING, "Cannot find file: " << fileName << std::endl); return false; } } else { diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index e717f71..1f22ce6 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -17,10 +17,12 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetDepend.h" @@ -115,19 +117,32 @@ bool cmComputeTargetDepends::Compute() if (this->DebugMode) { this->DisplayGraph(this->InitialGraph, "initial"); } + cmComputeComponentGraph ccg1(this->InitialGraph); + ccg1.Compute(); + if (!this->CheckComponents(ccg1)) { + return false; + } + + // Compute the intermediate graph. + this->CollectSideEffects(); + this->ComputeIntermediateGraph(); + if (this->DebugMode) { + this->DisplaySideEffects(); + this->DisplayGraph(this->IntermediateGraph, "intermediate"); + } // Identify components. - cmComputeComponentGraph ccg(this->InitialGraph); - ccg.Compute(); + cmComputeComponentGraph ccg2(this->IntermediateGraph); + ccg2.Compute(); if (this->DebugMode) { - this->DisplayComponents(ccg); + this->DisplayComponents(ccg2, "intermediate"); } - if (!this->CheckComponents(ccg)) { + if (!this->CheckComponents(ccg2)) { return false; } // Compute the final dependency graph. - if (!this->ComputeFinalDepends(ccg)) { + if (!this->ComputeFinalDepends(ccg2)) { return false; } if (this->DebugMode) { @@ -382,6 +397,111 @@ void cmComputeTargetDepends::AddTargetDepend( } } +void cmComputeTargetDepends::CollectSideEffects() +{ + this->SideEffects.resize(0); + this->SideEffects.resize(this->InitialGraph.size()); + + int n = static_cast<int>(this->InitialGraph.size()); + std::set<int> visited; + for (int i = 0; i < n; ++i) { + this->CollectSideEffectsForTarget(visited, i); + } +} + +void cmComputeTargetDepends::CollectSideEffectsForTarget( + std::set<int>& visited, int depender_index) +{ + if (!visited.count(depender_index)) { + auto& se = this->SideEffects[depender_index]; + visited.insert(depender_index); + this->Targets[depender_index]->AppendCustomCommandSideEffects( + se.CustomCommandSideEffects); + this->Targets[depender_index]->AppendLanguageSideEffects( + se.LanguageSideEffects); + + for (auto const& edge : this->InitialGraph[depender_index]) { + this->CollectSideEffectsForTarget(visited, edge); + auto const& dse = this->SideEffects[edge]; + se.CustomCommandSideEffects.insert(dse.CustomCommandSideEffects.cbegin(), + dse.CustomCommandSideEffects.cend()); + for (auto const& it : dse.LanguageSideEffects) { + se.LanguageSideEffects[it.first].insert(it.second.cbegin(), + it.second.cend()); + } + } + } +} + +void cmComputeTargetDepends::ComputeIntermediateGraph() +{ + this->IntermediateGraph.resize(0); + this->IntermediateGraph.resize(this->InitialGraph.size()); + + int n = static_cast<int>(this->InitialGraph.size()); + for (int i = 0; i < n; ++i) { + auto const& initialEdges = this->InitialGraph[i]; + auto& intermediateEdges = this->IntermediateGraph[i]; + cmGeneratorTarget const* gt = this->Targets[i]; + if (gt->GetType() != cmStateEnums::STATIC_LIBRARY && + gt->GetType() != cmStateEnums::OBJECT_LIBRARY) { + intermediateEdges = initialEdges; + } else { + if (cmProp optimizeDependencies = + gt->GetProperty("OPTIMIZE_DEPENDENCIES")) { + if (cmIsOn(optimizeDependencies)) { + this->OptimizeLinkDependencies(gt, intermediateEdges, initialEdges); + } else { + intermediateEdges = initialEdges; + } + } else { + intermediateEdges = initialEdges; + } + } + } +} + +void cmComputeTargetDepends::OptimizeLinkDependencies( + cmGeneratorTarget const* gt, cmGraphEdgeList& outputEdges, + cmGraphEdgeList const& inputEdges) +{ + std::set<int> emitted; + for (auto const& edge : inputEdges) { + if (edge.IsStrong()) { + // Preserve strong edges + outputEdges.push_back(edge); + } else { + auto const& dse = this->SideEffects[edge]; + + // Add edges that have custom command side effects + for (cmGeneratorTarget const* dep : dse.CustomCommandSideEffects) { + auto index = this->TargetIndex[dep]; + if (!emitted.count(index)) { + emitted.insert(index); + outputEdges.push_back( + cmGraphEdge(index, false, edge.IsCross(), edge.GetBacktrace())); + } + } + + // Add edges that have language side effects for languages we + // care about + for (auto const& lang : gt->GetAllConfigCompileLanguages()) { + auto it = dse.LanguageSideEffects.find(lang); + if (it != dse.LanguageSideEffects.end()) { + for (cmGeneratorTarget const* dep : it->second) { + auto index = this->TargetIndex[dep]; + if (!emitted.count(index)) { + emitted.insert(index); + outputEdges.push_back(cmGraphEdge(index, false, edge.IsCross(), + edge.GetBacktrace())); + } + } + } + } + } + } +} + void cmComputeTargetDepends::DisplayGraph(Graph const& graph, const std::string& name) { @@ -402,10 +522,39 @@ void cmComputeTargetDepends::DisplayGraph(Graph const& graph, fprintf(stderr, "\n"); } +void cmComputeTargetDepends::DisplaySideEffects() +{ + fprintf(stderr, "The side effects are:\n"); + int n = static_cast<int>(SideEffects.size()); + for (int depender_index = 0; depender_index < n; ++depender_index) { + cmGeneratorTarget const* depender = this->Targets[depender_index]; + fprintf(stderr, "target %d is [%s]\n", depender_index, + depender->GetName().c_str()); + if (!this->SideEffects[depender_index].CustomCommandSideEffects.empty()) { + fprintf(stderr, " custom commands\n"); + for (auto const* gt : + this->SideEffects[depender_index].CustomCommandSideEffects) { + fprintf(stderr, " from target %d [%s]\n", this->TargetIndex[gt], + gt->GetName().c_str()); + } + } + for (auto const& it : + this->SideEffects[depender_index].LanguageSideEffects) { + fprintf(stderr, " language %s\n", it.first.c_str()); + for (auto const* gt : it.second) { + fprintf(stderr, " from target %d [%s]\n", this->TargetIndex[gt], + gt->GetName().c_str()); + } + } + } + fprintf(stderr, "\n"); +} + void cmComputeTargetDepends::DisplayComponents( - cmComputeComponentGraph const& ccg) + cmComputeComponentGraph const& ccg, const std::string& name) { - fprintf(stderr, "The strongly connected components are:\n"); + fprintf(stderr, "The strongly connected components for the %s graph are:\n", + name.c_str()); std::vector<NodeList> const& components = ccg.GetComponents(); int n = static_cast<int>(components.size()); for (int c = 0; c < n; ++c) { diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index e0d625f..277521d 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -42,6 +42,13 @@ public: cmTargetDependSet& deps); private: + struct TargetSideEffects + { + std::set<cmGeneratorTarget const*> CustomCommandSideEffects; + std::map<std::string, std::set<cmGeneratorTarget const*>> + LanguageSideEffects; + }; + void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); @@ -50,6 +57,12 @@ private: void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee, cmListFileBacktrace const& dependee_backtrace, bool linking, bool cross); + void CollectSideEffects(); + void CollectSideEffectsForTarget(std::set<int>& visited, int depender_index); + void ComputeIntermediateGraph(); + void OptimizeLinkDependencies(cmGeneratorTarget const* gt, + cmGraphEdgeList& outputEdges, + cmGraphEdgeList const& inputEdges); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name, const std::string& config, @@ -74,11 +87,15 @@ private: using EdgeList = cmGraphEdgeList; using Graph = cmGraphAdjacencyList; Graph InitialGraph; + Graph IntermediateGraph; Graph FinalGraph; + std::vector<TargetSideEffects> SideEffects; void DisplayGraph(Graph const& graph, const std::string& name); + void DisplaySideEffects(); // Deal with connected components. - void DisplayComponents(cmComputeComponentGraph const& ccg); + void DisplayComponents(cmComputeComponentGraph const& ccg, + const std::string& name); bool CheckComponents(cmComputeComponentGraph const& ccg); void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c, bool strong = false); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 511168b..df68033 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -689,7 +689,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target) { switch (target->GetType()) { case cmStateEnums::EXECUTABLE: - if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) || + if ((target->IsWin32Executable( + target->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"))) || (target->GetPropertyAsBool("MACOSX_BUNDLE"))) { return 0; } diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index e9af208..55fb115 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -625,7 +625,7 @@ Json::Value CodemodelConfig::DumpTargets() for (cmGeneratorTarget* gt : targetList) { if (gt->GetType() == cmStateEnums::GLOBAL_TARGET || - gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + !gt->IsInBuildSystem()) { continue; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 8d20d35..550ad6e 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2240,6 +2240,7 @@ bool HandleUploadCommand(std::vector<std::string> const& args, } void AddEvaluationFile(const std::string& inputName, + const std::string& targetName, const std::string& outputExpr, const std::string& condition, bool inputIsContent, cmExecutionStatus& status) @@ -2255,7 +2256,8 @@ void AddEvaluationFile(const std::string& inputName, conditionGe.Parse(condition); status.GetMakefile().AddEvaluationFile( - inputName, std::move(outputCge), std::move(conditionCge), inputIsContent); + inputName, targetName, std::move(outputCge), std::move(conditionCge), + inputIsContent); } bool HandleGenerateCommand(std::vector<std::string> const& args, @@ -2269,23 +2271,36 @@ bool HandleGenerateCommand(std::vector<std::string> const& args, status.SetError("Incorrect arguments to GENERATE subcommand."); return false; } + std::string condition; - if (args.size() > 5) { - if (args[5] != "CONDITION") { + std::string target; + + for (std::size_t i = 5; i < args.size();) { + const std::string& arg = args[i++]; + + if (args.size() - i == 0) { status.SetError("Incorrect arguments to GENERATE subcommand."); return false; } - if (args.size() != 7) { - status.SetError("Incorrect arguments to GENERATE subcommand."); + + const std::string& value = args[i++]; + + if (value.empty()) { + status.SetError( + arg + " of sub-command GENERATE must not be empty if specified."); return false; } - condition = args[6]; - if (condition.empty()) { - status.SetError("CONDITION of sub-command GENERATE must not be empty if " - "specified."); + + if (arg == "CONDITION") { + condition = value; + } else if (arg == "TARGET") { + target = value; + } else { + status.SetError("Unknown argument to GENERATE subcommand."); return false; } } + std::string output = args[2]; const bool inputIsContent = args[3] != "INPUT"; if (inputIsContent && args[3] != "CONTENT") { @@ -2294,7 +2309,7 @@ bool HandleGenerateCommand(std::vector<std::string> const& args, } std::string input = args[4]; - AddEvaluationFile(input, output, condition, inputIsContent, status); + AddEvaluationFile(input, target, output, condition, inputIsContent, status); return true; } diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 345f0ba..2768547 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -14,10 +14,11 @@ #endif cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding) + : OriginalLocale(getloc()) { #ifndef CMAKE_BOOTSTRAP if (encoding != codecvt::None) { - imbue(std::locale(getloc(), new codecvt(encoding))); + imbue(std::locale(OriginalLocale, new codecvt(encoding))); } #else static_cast<void>(encoding); @@ -228,3 +229,14 @@ void cmGeneratedFileStream::SetTempExt(std::string const& ext) { this->TempExt = ext; } + +void cmGeneratedFileStream::WriteRaw(std::string const& data) +{ +#ifndef CMAKE_BOOTSTRAP + std::locale activeLocale = this->imbue(this->OriginalLocale); + this->write(data.data(), data.size()); + this->imbue(activeLocale); +#else + this->write(data.data(), data.size()); +#endif +} diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index 3dee142..f6da86e 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -147,6 +147,16 @@ public: * This does not work if the file was opened by the constructor. */ void SetTempExt(std::string const& ext); + + /** + * Writes the given string directly to the file without changing the + * encoding. + */ + void WriteRaw(std::string const& data); + +private: + // The original locale of the stream (performs no encoding conversion). + std::locale OriginalLocale; }; #endif diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 1107adb..9e5023d 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -19,11 +19,12 @@ #include "cmSystemTools.h" cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( - std::string input, + std::string input, std::string target, std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr, std::unique_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070) : Input(std::move(input)) + , Target(std::move(target)) , OutputFileExpr(std::move(outputFileExpr)) , Condition(std::move(condition)) , InputIsContent(inputIsContent) @@ -37,9 +38,10 @@ void cmGeneratorExpressionEvaluationFile::Generate( std::map<std::string, std::string>& outputFiles, mode_t perm) { std::string rawCondition = this->Condition->GetInput(); + cmGeneratorTarget* target = lg->FindGeneratorTargetToUse(Target); if (!rawCondition.empty()) { std::string condResult = - this->Condition->Evaluate(lg, config, nullptr, nullptr, nullptr, lang); + this->Condition->Evaluate(lg, config, target, nullptr, nullptr, lang); if (condResult == "0") { return; } @@ -54,16 +56,10 @@ void cmGeneratorExpressionEvaluationFile::Generate( } } - std::string outputFileName = this->OutputFileExpr->Evaluate( - lg, config, nullptr, nullptr, nullptr, lang); + const std::string outputFileName = + this->GetOutputFileName(lg, target, config, lang); const std::string& outputContent = - inputExpression->Evaluate(lg, config, nullptr, nullptr, nullptr, lang); - - if (cmSystemTools::FileIsFullPath(outputFileName)) { - outputFileName = cmSystemTools::CollapseFullPath(outputFileName); - } else { - outputFileName = this->FixRelativePath(outputFileName, PathForOutput, lg); - } + inputExpression->Evaluate(lg, config, target, nullptr, nullptr, lang); auto it = outputFiles.find(outputFileName); @@ -98,11 +94,11 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( { std::vector<std::string> enabledLanguages; cmGlobalGenerator* gg = lg->GetGlobalGenerator(); + cmGeneratorTarget* target = lg->FindGeneratorTargetToUse(Target); gg->GetEnabledLanguages(enabledLanguages); for (std::string const& le : enabledLanguages) { - std::string name = this->OutputFileExpr->Evaluate(lg, config, nullptr, - nullptr, nullptr, le); + std::string const name = this->GetOutputFileName(lg, target, config, le); cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource( name, false, cmSourceFileLocationKind::Known); // Tell TraceDependencies that the file is not expected to exist @@ -125,12 +121,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) if (this->InputIsContent) { inputContent = this->Input; } else { - std::string inputFileName = this->Input; - if (cmSystemTools::FileIsFullPath(inputFileName)) { - inputFileName = cmSystemTools::CollapseFullPath(inputFileName); - } else { - inputFileName = this->FixRelativePath(inputFileName, PathForInput, lg); - } + const std::string inputFileName = this->GetInputFileName(lg); lg->GetMakefile()->AddCMakeDependFile(inputFileName); cmSystemTools::GetPermissions(inputFileName.c_str(), perm); cmsys::ifstream fin(inputFileName.c_str()); @@ -174,6 +165,36 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) } } +std::string cmGeneratorExpressionEvaluationFile::GetInputFileName( + cmLocalGenerator* lg) +{ + std::string inputFileName = this->Input; + + if (cmSystemTools::FileIsFullPath(inputFileName)) { + inputFileName = cmSystemTools::CollapseFullPath(inputFileName); + } else { + inputFileName = this->FixRelativePath(inputFileName, PathForInput, lg); + } + + return inputFileName; +} + +std::string cmGeneratorExpressionEvaluationFile::GetOutputFileName( + cmLocalGenerator* lg, cmGeneratorTarget* target, const std::string& config, + const std::string& lang) +{ + std::string outputFileName = + this->OutputFileExpr->Evaluate(lg, config, target, nullptr, nullptr, lang); + + if (cmSystemTools::FileIsFullPath(outputFileName)) { + outputFileName = cmSystemTools::CollapseFullPath(outputFileName); + } else { + outputFileName = this->FixRelativePath(outputFileName, PathForOutput, lg); + } + + return outputFileName; +} + std::string cmGeneratorExpressionEvaluationFile::FixRelativePath( std::string const& relativePath, PathRole role, cmLocalGenerator* lg) { diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index c3bc4c8..caa8064 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -15,13 +15,14 @@ #include "cmGeneratorExpression.h" #include "cmPolicies.h" +class cmGeneratorTarget; class cmLocalGenerator; class cmGeneratorExpressionEvaluationFile { public: cmGeneratorExpressionEvaluationFile( - std::string input, + std::string input, std::string target, std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr, std::unique_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070); @@ -38,6 +39,11 @@ private: cmCompiledGeneratorExpression* inputExpression, std::map<std::string, std::string>& outputFiles, mode_t perm); + std::string GetInputFileName(cmLocalGenerator* lg); + std::string GetOutputFileName(cmLocalGenerator* lg, + cmGeneratorTarget* target, + const std::string& config, + const std::string& lang); enum PathRole { PathForInput, @@ -48,6 +54,7 @@ private: private: const std::string Input; + const std::string Target; const std::unique_ptr<cmCompiledGeneratorExpression> OutputFileExpr; const std::unique_ptr<cmCompiledGeneratorExpression> Condition; std::vector<std::string> Files; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9f8736a..dc5265f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -380,11 +380,6 @@ std::string cmGeneratorTarget::GetExportName() const cmProp cmGeneratorTarget::GetProperty(const std::string& prop) const { - if (!cmTargetPropertyComputer::PassesWhitelist( - this->GetType(), prop, this->Makefile->GetMessenger(), - this->GetBacktrace())) { - return nullptr; - } if (cmProp result = cmTargetPropertyComputer::GetProperty( this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) { return result; @@ -1089,6 +1084,37 @@ std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPostBuildCommands() return this->Target->GetPostBuildCommands(); } +void cmGeneratorTarget::AppendCustomCommandSideEffects( + std::set<cmGeneratorTarget const*>& sideEffects) const +{ + if (!this->GetPreBuildCommands().empty() || + !this->GetPreLinkCommands().empty() || + !this->GetPostBuildCommands().empty()) { + sideEffects.insert(this); + } else { + for (auto const& source : this->GetAllConfigSources()) { + if (source.Source->GetCustomCommand() != nullptr) { + sideEffects.insert(this); + break; + } + } + } +} + +void cmGeneratorTarget::AppendLanguageSideEffects( + std::map<std::string, std::set<cmGeneratorTarget const*>>& sideEffects) const +{ + static const std::set<cm::string_view> LANGS_WITH_NO_SIDE_EFFECTS = { + "C"_s, "CXX"_s, "OBJC"_s, "OBJCXX"_s, "ASM"_s, "CUDA"_s, + }; + + for (auto const& lang : this->GetAllConfigCompileLanguages()) { + if (!LANGS_WITH_NO_SIDE_EFFECTS.count(lang)) { + sideEffects[lang].insert(this); + } + } +} + bool cmGeneratorTarget::IsInBuildSystem() const { if (this->IsImported()) { @@ -1104,6 +1130,10 @@ bool cmGeneratorTarget::IsInBuildSystem() const case cmStateEnums::GLOBAL_TARGET: return true; case cmStateEnums::INTERFACE_LIBRARY: + // An INTERFACE library is in the build system if it has SOURCES. + if (!this->SourceEntries.empty()) { + return true; + } case cmStateEnums::UNKNOWN_LIBRARY: break; } @@ -1562,7 +1592,6 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths( std::string const& config) const { std::vector<BT<std::string>> files; - assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) { // At configure-time, this method can be called as part of getting the @@ -1754,9 +1783,11 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files, std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); if (sf->GetCustomCommand()) { kind = SourceKindCustomCommand; - // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165 - // NOLINTNEXTLINE(bugprone-branch-clone) - } else if (this->Target->GetType() == cmStateEnums::UTILITY) { + } else if (this->Target->GetType() == cmStateEnums::UTILITY || + this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY + // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165 + // NOLINTNEXTLINE(bugprone-branch-clone) + ) { kind = SourceKindExtra; } else if (this->IsSourceFilePartOfUnityBatch(sf->ResolveFullPath())) { kind = SourceKindUnityBatched; @@ -2249,6 +2280,12 @@ bool cmGeneratorTarget::IsBundleOnApple() const this->IsCFBundleOnApple(); } +bool cmGeneratorTarget::IsWin32Executable(const std::string& config) const +{ + return cmIsOn(cmGeneratorExpression::Evaluate( + this->GetSafeProperty("WIN32_EXECUTABLE"), this->LocalGenerator, config)); +} + std::string cmGeneratorTarget::GetCFBundleDirectory( const std::string& config, BundleDirectoryLevel level) const { @@ -3138,6 +3175,9 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory( void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector<std::string>& archVec) const { + if (!this->Makefile->IsOn("APPLE")) { + return; + } cmProp archs = nullptr; if (!config.empty()) { std::string defVarName = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 680681f..246eede 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -55,6 +55,12 @@ public: std::vector<cmCustomCommand> const& GetPreLinkCommands() const; std::vector<cmCustomCommand> const& GetPostBuildCommands() const; + void AppendCustomCommandSideEffects( + std::set<cmGeneratorTarget const*>& sideEffects) const; + void AppendLanguageSideEffects( + std::map<std::string, std::set<cmGeneratorTarget const*>>& sideEffects) + const; + #define DECLARE_TARGET_POLICY(POLICY) \ cmPolicies::PolicyStatus GetPolicyStatus##POLICY() const \ { \ @@ -278,6 +284,9 @@ public: or CFBundle on Apple. */ bool IsBundleOnApple() const; + /** Return whether this target is a Win32 executable */ + bool IsWin32Executable(const std::string& config) const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config, diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index cba7704..cdfd8c8 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -17,7 +17,6 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include "cmTargetPropertyComputer.h" #include "cmTest.h" #include "cmake.h" @@ -364,12 +363,9 @@ bool HandleTargetMode(cmExecutionStatus& status, const std::string& name, cmProp prop_cstr = nullptr; cmListFileBacktrace bt = status.GetMakefile().GetBacktrace(); cmMessenger* messenger = status.GetMakefile().GetMessenger(); - if (cmTargetPropertyComputer::PassesWhitelist( - target->GetType(), propertyName, messenger, bt)) { - prop_cstr = target->GetComputedProperty(propertyName, messenger, bt); - if (!prop_cstr) { - prop_cstr = target->GetProperty(propertyName); - } + prop_cstr = target->GetComputedProperty(propertyName, messenger, bt); + if (!prop_cstr) { + prop_cstr = target->GetProperty(propertyName); } return StoreResult(infoType, status.GetMakefile(), variable, prop_cstr ? prop_cstr->c_str() : nullptr); diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 8a304be..78a17d2 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -12,7 +12,6 @@ #include "cmPolicies.h" #include "cmProperty.h" #include "cmTarget.h" -#include "cmTargetPropertyComputer.h" class cmMessenger; @@ -46,12 +45,9 @@ bool cmGetTargetPropertyCommand(std::vector<std::string> const& args, cmProp prop_cstr = nullptr; cmListFileBacktrace bt = mf.GetBacktrace(); cmMessenger* messenger = mf.GetMessenger(); - if (cmTargetPropertyComputer::PassesWhitelist(tgt->GetType(), args[2], - messenger, bt)) { - prop_cstr = tgt->GetComputedProperty(args[2], messenger, bt); - if (!prop_cstr) { - prop_cstr = tgt->GetProperty(args[2]); - } + prop_cstr = tgt->GetComputedProperty(args[2], messenger, bt); + if (!prop_cstr) { + prop_cstr = tgt->GetProperty(args[2]); } if (prop_cstr) { prop = *prop_cstr; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 0865432..a550b50 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -335,13 +335,13 @@ bool cmGlobalGenerator::CheckTargetsForType() const bool failed = false; for (const auto& generator : this->LocalGenerators) { for (const auto& target : generator->GetGeneratorTargets()) { - if (target->GetType() == cmStateEnums::EXECUTABLE && - target->GetPropertyAsBool("WIN32_EXECUTABLE")) { + if (target->GetType() == cmStateEnums::EXECUTABLE) { std::vector<std::string> const& configs = target->Makefile->GetGeneratorConfigs( cmMakefile::IncludeEmptyConfig); for (std::string const& config : configs) { - if (target->GetLinkerLanguage(config) == "Swift") { + if (target->IsWin32Executable(config) && + target->GetLinkerLanguage(config) == "Swift") { this->GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, "WIN32_EXECUTABLE property is not supported on Swift " diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9a87e18..ed61021 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1118,6 +1118,7 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( } // FALLTHROUGH case cmStateEnums::GLOBAL_TARGET: + case cmStateEnums::INTERFACE_LIBRARY: case cmStateEnums::UTILITY: { std::string path = cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(), '/', @@ -1130,7 +1131,6 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( break; } - case cmStateEnums::INTERFACE_LIBRARY: case cmStateEnums::UNKNOWN_LIBRARY: break; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ebc90b6..37a77fa 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -387,12 +387,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules( cm::static_reference_cast<cmLocalUnixMakefileGenerator3>(lGenerator); // for all of out targets for (const auto& tgt : lg.GetGeneratorTargets()) { - if ((tgt->GetType() == cmStateEnums::EXECUTABLE) || - (tgt->GetType() == cmStateEnums::STATIC_LIBRARY) || - (tgt->GetType() == cmStateEnums::SHARED_LIBRARY) || - (tgt->GetType() == cmStateEnums::MODULE_LIBRARY) || - (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) || - (tgt->GetType() == cmStateEnums::UTILITY)) { + if (tgt->IsInBuildSystem() && + tgt->GetType() != cmStateEnums::GLOBAL_TARGET) { std::string tname = cmStrCat(lg.GetRelativeTargetDirectory(tgt.get()), "/DependInfo.cmake"); cmSystemTools::ConvertToUnixSlashes(tname); @@ -635,17 +631,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( for (const auto& gtarget : lg.GetGeneratorTargets()) { // Don't emit the same rule twice (e.g. two targets with the same // simple name) - int type = gtarget->GetType(); std::string name = gtarget->GetName(); if (!name.empty() && emitted.insert(name).second && // Handle user targets here. Global targets are handled in // the local generator on a per-directory basis. - ((type == cmStateEnums::EXECUTABLE) || - (type == cmStateEnums::STATIC_LIBRARY) || - (type == cmStateEnums::SHARED_LIBRARY) || - (type == cmStateEnums::MODULE_LIBRARY) || - (type == cmStateEnums::OBJECT_LIBRARY) || - (type == cmStateEnums::UTILITY))) { + (gtarget->IsInBuildSystem() && + gtarget->GetType() != cmStateEnums::GLOBAL_TARGET)) { // Add a rule to build the target by name. lg.WriteDivider(ruleFileStream); ruleFileStream << "# Target rules for targets named " << name @@ -709,15 +700,10 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( // for each target Generate the rule files for each target. for (const auto& gtarget : lg.GetGeneratorTargets()) { - int type = gtarget->GetType(); std::string name = gtarget->GetName(); if (!name.empty() && - ((type == cmStateEnums::EXECUTABLE) || - (type == cmStateEnums::STATIC_LIBRARY) || - (type == cmStateEnums::SHARED_LIBRARY) || - (type == cmStateEnums::MODULE_LIBRARY) || - (type == cmStateEnums::OBJECT_LIBRARY) || - (type == cmStateEnums::UTILITY))) { + (gtarget->IsInBuildSystem() && + gtarget->GetType() != cmStateEnums::GLOBAL_TARGET)) { std::string makefileName; // Add a rule to build the target by name. localName = lg.GetRelativeTargetDirectory(gtarget.get()); @@ -985,7 +971,9 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule( (type == cmStateEnums::STATIC_LIBRARY) || (type == cmStateEnums::SHARED_LIBRARY) || (type == cmStateEnums::MODULE_LIBRARY) || - (type == cmStateEnums::OBJECT_LIBRARY)) { + (type == cmStateEnums::OBJECT_LIBRARY) || + (type == cmStateEnums::INTERFACE_LIBRARY && + target->IsInBuildSystem())) { project_targets.insert(target->GetName()); } else if (type == cmStateEnums::GLOBAL_TARGET) { globals_targets.insert(target->GetName()); diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 451d448..aa1b7ad 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -169,7 +169,8 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, bool required) { // Find the default version of the Windows 10 SDK. - std::string const version = this->GetWindows10SDKVersion(); + std::string const version = this->GetWindows10SDKVersion(mf); + if (required && version.empty()) { std::ostringstream e; e << "Could not find an appropriate version of the Windows 10 SDK" @@ -233,8 +234,25 @@ bool cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const cmSystemTools::KeyWOW64_32); } -std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion() const +std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion( + cmMakefile* mf) const { + // if the given value is set, it can either be OFF/FALSE or a valid SDK + // string + if (std::string const* value = + mf->GetDef("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM")) { + + // If the value is some off/false value, then there is NO maximum set. + if (cmIsOff(value)) { + return std::string(); + } + // If the value is something else, trust that it is a valid SDK value. + else if (value) { + return *value; + } + // If value is an invalid pointer, leave result unchanged. + } + // The last Windows 10 SDK version that VS 2015 can target is 10.0.14393.0. // // "VS 2015 Users: The Windows 10 SDK (15063, 16299, 17134, 17763) is @@ -267,7 +285,8 @@ public: }; #endif -std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() +std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion( + cmMakefile* mf) { #if defined(_WIN32) && !defined(__CYGWIN__) std::vector<std::string> win10Roots; @@ -317,8 +336,10 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() i = cmSystemTools::GetFilenameName(i); } - // Skip SDKs that cannot be used with our toolset. - std::string maxVersion = this->GetWindows10SDKMaxVersion(); + // Skip SDKs that cannot be used with our toolset, unless the user does not + // want to limit the highest supported SDK according to the Microsoft + // documentation. + std::string maxVersion = this->GetWindows10SDKMaxVersion(mf); if (!maxVersion.empty()) { cm::erase_if(sdks, WindowsSDKTooRecent(maxVersion)); } diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 39353f2..2b9a649 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -43,7 +43,7 @@ protected: // Used to make sure that the Windows 10 SDK selected can work with the // version of the toolset. - virtual std::string GetWindows10SDKMaxVersion() const; + virtual std::string GetWindows10SDKMaxVersion(cmMakefile* mf) const; virtual bool SelectWindows10SDK(cmMakefile* mf, bool required); @@ -54,7 +54,7 @@ protected: // installed on the machine. bool IsWindowsDesktopToolsetInstalled() const override; - std::string GetWindows10SDKVersion(); + std::string GetWindows10SDKVersion(cmMakefile* mf); private: class Factory; diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index e2e045c..4b877ce 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -540,8 +540,8 @@ bool cmGlobalVisualStudioVersionedGenerator::IsWin81SDKInstalled() const return false; } -std::string cmGlobalVisualStudioVersionedGenerator::GetWindows10SDKMaxVersion() - const +std::string cmGlobalVisualStudioVersionedGenerator::GetWindows10SDKMaxVersion( + cmMakefile*) const { return std::string(); } diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index d5b8337..289c35c 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -57,7 +57,7 @@ protected: // Check for a Win 8 SDK known to the registry or VS installer tool. bool IsWin81SDKInstalled() const; - std::string GetWindows10SDKMaxVersion() const override; + std::string GetWindows10SDKMaxVersion(cmMakefile*) const override; std::string FindMSBuildCommand() override; std::string FindDevEnvCommand() override; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 574e0f5..793f6f7 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1204,6 +1204,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( } if (gtgt->GetType() == cmStateEnums::UTILITY || + gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY || gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) { cmXCodeObject* t = this->CreateUtilityTarget(gtgt); if (!t) { @@ -2536,7 +2537,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget( this->XCodeObjectMap[gtgt] = target; // Add source files without build rules for editing convenience. - if (gtgt->GetType() == cmStateEnums::UTILITY && + if (gtgt->GetType() != cmStateEnums::GLOBAL_TARGET && gtgt->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { std::vector<cmSourceFile*> sources; if (!gtgt->GetConfigCommonSourceFiles(sources)) { diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 570f4ea..8a7728e 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGraphVizWriter.h" +#include <algorithm> #include <cctype> #include <iostream> #include <memory> @@ -552,16 +553,23 @@ bool cmGraphVizWriter::TargetTypeEnabled( std::string cmGraphVizWriter::ItemNameWithAliases( std::string const& itemName) const { - auto nameWithAliases = itemName; - + std::vector<std::string> items; for (auto const& lg : this->GlobalGenerator->GetLocalGenerators()) { for (auto const& aliasTargets : lg->GetMakefile()->GetAliasTargets()) { if (aliasTargets.second == itemName) { - nameWithAliases += "\\n(" + aliasTargets.first + ")"; + items.push_back(aliasTargets.first); } } } + std::sort(items.begin(), items.end()); + items.erase(std::unique(items.begin(), items.end()), items.end()); + + auto nameWithAliases = itemName; + for(auto const& item : items) { + nameWithAliases += "\\n(" + item + ")"; + } + return nameWithAliases; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9369bd4..300bb26 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1520,7 +1520,7 @@ void cmLocalGenerator::GetTargetFlags( return; } - if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) { + if (target->IsWin32Executable(config)) { exeFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); exeFlags += " "; @@ -1875,8 +1875,9 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, if (this->Makefile->IsOn("APPLE") && this->EmitUniversalBinaryFlags) { std::vector<std::string> archs; target->GetAppleArchs(config, archs); - if (!archs.empty() && !lang.empty() && - (lang[0] == 'C' || lang[0] == 'F' || lang[0] == 'O')) { + if (!archs.empty() && + (lang == "C" || lang == "CXX" || lang == "OBJ" || lang == "OBJCXX" || + cmHasLiteralPrefix(lang, "ASM"))) { for (std::string const& arch : archs) { if (filterArch.empty() || filterArch == arch) { flags += " -arch "; @@ -1938,6 +1939,9 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, this->AddConfigVariableFlags(flags, cmStrCat("CMAKE_", lang, "_FLAGS"), config); + std::string const& compiler = this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_COMPILER_ID")); + if (lang == "Swift") { if (cmProp v = target->GetProperty("Swift_LANGUAGE_VERSION")) { if (cmSystemTools::VersionCompare( @@ -1951,9 +1955,6 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, target->AddCUDAArchitectureFlags(flags); target->AddCUDAToolkitFlags(flags); - std::string const& compiler = - this->Makefile->GetSafeDefinition("CMAKE_CUDA_COMPILER_ID"); - if (compiler == "Clang") { bool separable = target->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION"); @@ -1965,7 +1966,24 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } } } - + // Add VFS Overlay for Clang compiliers + if (compiler == "Clang") { + if (const char* vfsOverlay = + this->Makefile->GetDefinition("CMAKE_CLANG_VFS_OVERLAY")) { + std::string const& compilerSimulateId = + this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_SIMULATE_ID")); + if (compilerSimulateId == "MSVC") { + this->AppendCompileOptions( + flags, + std::vector<std::string>{ "-Xclang", "-ivfsoverlay", "-Xclang", + vfsOverlay }); + } else { + this->AppendCompileOptions( + flags, std::vector<std::string>{ "-ivfsoverlay", vfsOverlay }); + } + } + } // Add MSVC runtime library flags. This is activated by the presence // of a default selection whether or not it is overridden by a property. cmProp msvcRuntimeLibraryDefault = diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index ef34953..eb841d9 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -84,8 +84,26 @@ void cmLocalNinjaGenerator::Generate() if (!showIncludesPrefix.empty()) { cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(), "localized /showIncludes string"); - this->GetRulesFileStream() - << "msvc_deps_prefix = " << showIncludesPrefix << "\n\n"; + this->GetRulesFileStream() << "msvc_deps_prefix = "; +#ifdef WIN32 + // Ninja uses the ANSI Windows APIs, so strings in the rules file + // typically need to be ANSI encoded. However, in this case the compiler + // is being invoked using the UTF-8 codepage so the /showIncludes prefix + // will be UTF-8 encoded on stdout. Ninja can't successfully compare this + // UTF-8 encoded prefix to the ANSI encoded msvc_deps_prefix if it + // contains any non-ASCII characters and dependency checking will fail. + // As a workaround, leave the msvc_deps_prefix UTF-8 encoded even though + // the rest of the file is ANSI encoded. + if (GetConsoleOutputCP() == CP_UTF8 && GetACP() != CP_UTF8) { + this->GetRulesFileStream().WriteRaw(showIncludesPrefix); + } else { + this->GetRulesFileStream() << showIncludesPrefix; + } +#else + // It's safe to use the standard encoding on other platforms. + this->GetRulesFileStream() << showIncludesPrefix; +#endif + this->GetRulesFileStream() << "\n\n"; } } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index fec6a9d..ee7f74c 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -629,9 +629,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( break; case cmStateEnums::UTILITY: case cmStateEnums::GLOBAL_TARGET: + case cmStateEnums::INTERFACE_LIBRARY: configType = "10"; CM_FALLTHROUGH; - default: + case cmStateEnums::UNKNOWN_LIBRARY: targetBuilds = false; break; } @@ -1112,7 +1113,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( cmComputeLinkInformation& cli = *pcli; std::string linkLanguage = cli.GetLinkLanguage(); - bool isWin32Executable = target->GetPropertyAsBool("WIN32_EXECUTABLE"); + bool isWin32Executable = target->IsWin32Executable(configName); // Compute the variable name to lookup standard libraries for this // language. @@ -1638,7 +1639,8 @@ bool cmLocalVisualStudio7Generator::WriteGroup( std::string source = sf->GetFullPath(); if (source != libName || target->GetType() == cmStateEnums::UTILITY || - target->GetType() == cmStateEnums::GLOBAL_TARGET) { + target->GetType() == cmStateEnums::GLOBAL_TARGET || + target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { // Look up the source kind and configs. std::map<cmSourceFile const*, size_t>::const_iterator map_it = sources.Index.find(sf); @@ -1937,6 +1939,7 @@ void cmLocalVisualStudio7Generator::WriteProjectStartFortran( const char* keyword = p ? p->c_str() : "Console Application"; const char* projectType = 0; switch (target->GetType()) { + case cmStateEnums::OBJECT_LIBRARY: case cmStateEnums::STATIC_LIBRARY: projectType = "typeStaticLibrary"; if (keyword) { @@ -1958,7 +1961,8 @@ void cmLocalVisualStudio7Generator::WriteProjectStartFortran( break; case cmStateEnums::UTILITY: case cmStateEnums::GLOBAL_TARGET: - default: + case cmStateEnums::INTERFACE_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: break; } if (projectType) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5e1f070..d9d4ae8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -20,8 +20,10 @@ #include <cmext/algorithm> #include <cmext/string_view> -#include <cm3p/json/value.h> -#include <cm3p/json/writer.h> +#ifndef CMAKE_BOOTSTRAP +# include <cm3p/json/value.h> +# include <cm3p/json/writer.h> +#endif #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" @@ -799,15 +801,15 @@ void cmMakefile::EnforceDirectoryLevelRules() const } void cmMakefile::AddEvaluationFile( - const std::string& inputFile, + const std::string& inputFile, const std::string& targetName, std::unique_ptr<cmCompiledGeneratorExpression> outputName, std::unique_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent) { this->EvaluationFiles.push_back( cm::make_unique<cmGeneratorExpressionEvaluationFile>( - inputFile, std::move(outputName), std::move(condition), inputIsContent, - this->GetPolicyStatus(cmPolicies::CMP0070))); + inputFile, targetName, std::move(outputName), std::move(condition), + inputIsContent, this->GetPolicyStatus(cmPolicies::CMP0070))); } const std::vector<std::unique_ptr<cmGeneratorExpressionEvaluationFile>>& diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 80d80d3..69894b1 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -949,7 +949,7 @@ public: void EnforceDirectoryLevelRules() const; void AddEvaluationFile( - const std::string& inputFile, + const std::string& inputFile, const std::string& targetName, std::unique_ptr<cmCompiledGeneratorExpression> outputName, std::unique_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index bc288ac..9b5c6e6 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -371,7 +371,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->LocalGenerator->AddConfigVariableFlags( linkFlags, "CMAKE_EXE_LINKER_FLAGS", this->GetConfigName()); - if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) { + if (this->GeneratorTarget->IsWin32Executable( + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"))) { this->LocalGenerator->AppendFlags( linkFlags, this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE")); } else { diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 047fee1..afbbbd4 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -71,6 +71,7 @@ std::unique_ptr<cmMakefileTargetGenerator> cmMakefileTargetGenerator::New( case cmStateEnums::OBJECT_LIBRARY: result = cm::make_unique<cmMakefileLibraryTargetGenerator>(tgt); break; + case cmStateEnums::INTERFACE_LIBRARY: case cmStateEnums::UTILITY: result = cm::make_unique<cmMakefileUtilityTargetGenerator>(tgt); break; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 95b8ad7..96e0c69 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -51,6 +51,7 @@ std::unique_ptr<cmNinjaTargetGenerator> cmNinjaTargetGenerator::New( return cm::make_unique<cmNinjaNormalTargetGenerator>(target); case cmStateEnums::UTILITY: + case cmStateEnums::INTERFACE_LIBRARY: case cmStateEnums::GLOBAL_TARGET: return cm::make_unique<cmNinjaUtilityTargetGenerator>(target); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index bba8b03..1a12dab 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -323,7 +323,14 @@ class cmMakefile; 3, 18, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0109, \ "find_program() requires permission to execute but not to read.", 3, \ - 19, 0, cmPolicies::WARN) + 19, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0110, \ + "add_test() supports arbitrary characters in test names.", 3, 19, 0, \ + cmPolicies::WARN) \ + SELECT(POLICY, CMP0111, \ + "An imported target with a missing location fails during " \ + "generation.", \ + 3, 19, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 06957b0..187b256 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1223,9 +1223,13 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() if (this->Moc.ExecutableTarget != nullptr) { dependencies.push_back(this->Moc.ExecutableTarget->Target->GetName()); + } else if (!this->Moc.Executable.empty()) { + dependencies.push_back(this->Moc.Executable); } if (this->Uic.ExecutableTarget != nullptr) { dependencies.push_back(this->Uic.ExecutableTarget->Target->GetName()); + } else if (!this->Uic.Executable.empty()) { + dependencies.push_back(this->Uic.Executable); } // Create the custom command that outputs the timestamp file. @@ -1513,6 +1517,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() info.SetConfig("PARSE_CACHE_FILE", this->AutogenTarget.ParseCacheFile); info.Set("DEP_FILE", this->AutogenTarget.DepFile); info.Set("DEP_FILE_RULE_NAME", this->AutogenTarget.DepFileRuleName); + info.SetArray("CMAKE_LIST_FILES", this->Makefile->GetListFiles()); info.SetArray("HEADER_EXTENSIONS", this->Makefile->GetCMakeInstance()->GetHeaderExtensions()); info.SetArrayArray( diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index f6cccfb..71c288c 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -184,6 +184,7 @@ public: std::string DepFile; std::string DepFileRuleName; std::vector<std::string> HeaderExtensions; + std::vector<std::string> ListFiles; }; /** Shared common variables. */ @@ -2176,7 +2177,7 @@ void cmQtAutoMocUicT::JobDepFilesMergeT::Process() return dependenciesFromDepFile(f.c_str()); }; - std::vector<std::string> dependencies; + std::vector<std::string> dependencies = BaseConst().ListFiles; ParseCacheT& parseCache = BaseEval().ParseCache; auto processMappingEntry = [&](const MappingMapT::value_type& m) { auto cacheEntry = parseCache.GetOrInsert(m.first); @@ -2257,6 +2258,7 @@ bool cmQtAutoMocUicT::InitFromInfo(InfoT const& info) !info.GetString("DEP_FILE_RULE_NAME", BaseConst_.DepFileRuleName, false) || !info.GetStringConfig("SETTINGS_FILE", SettingsFile_, true) || + !info.GetArray("CMAKE_LIST_FILES", BaseConst_.ListFiles, true) || !info.GetArray("HEADER_EXTENSIONS", BaseConst_.HeaderExtensions, true) || !info.GetString("QT_MOC_EXECUTABLE", MocConst_.Executable, false) || !info.GetString("QT_UIC_EXECUTABLE", UicConst_.Executable, false)) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1105f31..a30c9e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -374,6 +374,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("VS_JUST_MY_CODE_DEBUGGING"); initProp("DISABLE_PRECOMPILE_HEADERS"); initProp("UNITY_BUILD"); + initProp("OPTIMIZE_DEPENDENCIES"); initPropValue("UNITY_BUILD_BATCH_SIZE", "8"); initPropValue("UNITY_BUILD_MODE", "BATCH"); initPropValue("PCH_WARN_INVALID", "ON"); @@ -402,12 +403,10 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, #endif } - if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - initProp("FOLDER"); + initProp("FOLDER"); - if (this->GetGlobalGenerator()->IsXcode()) { - initProp("XCODE_GENERATE_SCHEME"); - } + if (this->GetGlobalGenerator()->IsXcode()) { + initProp("XCODE_GENERATE_SCHEME"); } // Setup per-configuration property default values. @@ -522,24 +521,21 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("DOTNET_TARGET_FRAMEWORK_VERSION"); } - if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - - // check for "CMAKE_VS_GLOBALS" variable and set up target properties - // if any - const char* globals = mf->GetDefinition("CMAKE_VS_GLOBALS"); - if (globals) { - const std::string genName = mf->GetGlobalGenerator()->GetName(); - if (cmHasLiteralPrefix(genName, "Visual Studio")) { - std::vector<std::string> props = cmExpandedList(globals); - const std::string vsGlobal = "VS_GLOBAL_"; - for (const std::string& i : props) { - // split NAME=VALUE - const std::string::size_type assignment = i.find('='); - if (assignment != std::string::npos) { - const std::string propName = vsGlobal + i.substr(0, assignment); - const std::string propValue = i.substr(assignment + 1); - initPropValue(propName, propValue.c_str()); - } + // check for "CMAKE_VS_GLOBALS" variable and set up target properties + // if any + const char* globals = mf->GetDefinition("CMAKE_VS_GLOBALS"); + if (globals) { + const std::string genName = mf->GetGlobalGenerator()->GetName(); + if (cmHasLiteralPrefix(genName, "Visual Studio")) { + std::vector<std::string> props = cmExpandedList(globals); + const std::string vsGlobal = "VS_GLOBAL_"; + for (const std::string& i : props) { + // split NAME=VALUE + const std::string::size_type assignment = i.find('='); + if (assignment != std::string::npos) { + const std::string propName = vsGlobal + i.substr(0, assignment); + const std::string propValue = i.substr(assignment + 1); + initPropValue(propName, propValue.c_str()); } } } @@ -1145,11 +1141,6 @@ cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const void cmTarget::SetProperty(const std::string& prop, const char* value) { - if (!cmTargetPropertyComputer::PassesWhitelist( - this->GetType(), prop, impl->Makefile->GetMessenger(), - impl->Makefile->GetBacktrace())) { - return; - } #define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP MAKE_STATIC_PROP(C_STANDARD); MAKE_STATIC_PROP(CXX_STANDARD); @@ -1356,11 +1347,6 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) void cmTarget::AppendProperty(const std::string& prop, const std::string& value, bool asString) { - if (!cmTargetPropertyComputer::PassesWhitelist( - this->GetType(), prop, impl->Makefile->GetMessenger(), - impl->Makefile->GetBacktrace())) { - return; - } if (prop == "NAME") { impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, "NAME property is read-only\n"); @@ -2054,6 +2040,37 @@ std::string cmTarget::ImportedGetFullPath( } if (result.empty()) { + auto message = [&]() -> std::string { + std::string unset; + std::string configuration; + + if (artifact == cmStateEnums::RuntimeBinaryArtifact) { + unset = "IMPORTED_LOCATION"; + } else if (artifact == cmStateEnums::ImportLibraryArtifact) { + unset = "IMPORTED_IMPLIB"; + } + + if (!config.empty()) { + configuration = cmStrCat(" configuration \"", config, "\""); + } + + return cmStrCat(unset, " not set for imported target \"", + this->GetName(), "\"", configuration, "."); + }; + + switch (this->GetPolicyStatus(cmPolicies::CMP0111)) { + case cmPolicies::WARN: + impl->Makefile->IssueMessage( + MessageType::AUTHOR_WARNING, + cmPolicies::GetPolicyWarning(cmPolicies::CMP0111) + "\n" + + message()); + CM_FALLTHROUGH; + case cmPolicies::OLD: + break; + default: + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, message()); + } + result = cmStrCat(this->GetName(), "-NOTFOUND"); } return result; diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index e714720..9e30136 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -123,7 +123,7 @@ bool cmTargetPropCommandBase::ProcessContentArgs( } if (!content.empty()) { if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY && - scope != "INTERFACE") { + scope != "INTERFACE" && this->Property != "SOURCES") { this->SetError("may only set INTERFACE properties on INTERFACE targets"); return false; } diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx index f37995c..b9c9365 100644 --- a/Source/cmTargetPropertyComputer.cxx +++ b/Source/cmTargetPropertyComputer.cxx @@ -3,15 +3,12 @@ #include "cmTargetPropertyComputer.h" -#include <cctype> #include <sstream> -#include <unordered_set> #include "cmMessageType.h" #include "cmMessenger.h" #include "cmPolicies.h" #include "cmStateSnapshot.h" -#include "cmStringAlgorithms.h" bool cmTargetPropertyComputer::HandleLocationPropertyPolicy( std::string const& tgtName, cmMessenger* messenger, @@ -44,69 +41,3 @@ bool cmTargetPropertyComputer::HandleLocationPropertyPolicy( return messageType != MessageType::FATAL_ERROR; } - -bool cmTargetPropertyComputer::WhiteListedInterfaceProperty( - const std::string& prop) -{ - if (cmHasLiteralPrefix(prop, "INTERFACE_")) { - return true; - } - if (cmHasLiteralPrefix(prop, "_")) { - return true; - } - if (std::islower(prop[0])) { - return true; - } - static std::unordered_set<std::string> const builtIns{ - "COMPATIBLE_INTERFACE_BOOL", - "COMPATIBLE_INTERFACE_NUMBER_MAX", - "COMPATIBLE_INTERFACE_NUMBER_MIN", - "COMPATIBLE_INTERFACE_STRING", - "DEPRECATION", - "EXPORT_NAME", - "EXPORT_PROPERTIES", - "IMPORTED", - "IMPORTED_GLOBAL", - "MANUALLY_ADDED_DEPENDENCIES", - "NAME", - "PRIVATE_HEADER", - "PUBLIC_HEADER", - "TYPE" - }; - - if (builtIns.count(prop)) { - return true; - } - - if (prop == "IMPORTED_CONFIGURATIONS" || prop == "IMPORTED_LIBNAME" || - cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME_") || - cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) { - return true; - } - - // This property should not be allowed but was incorrectly added in - // CMake 3.8. We can't remove it from the whitelist without breaking - // projects that try to set it. One day we could warn about this, but - // for now silently accept it. - if (prop == "NO_SYSTEM_FROM_IMPORTED") { - return true; - } - - return false; -} - -bool cmTargetPropertyComputer::PassesWhitelist( - cmStateEnums::TargetType tgtType, std::string const& prop, - cmMessenger* messenger, cmListFileBacktrace const& context) -{ - if (tgtType == cmStateEnums::INTERFACE_LIBRARY && - !WhiteListedInterfaceProperty(prop)) { - std::ostringstream e; - e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " - "The property \"" - << prop << "\" is not allowed."; - messenger->IssueMessage(MessageType::FATAL_ERROR, e.str(), context); - return false; - } - return true; -} diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h index f87b7c2..bafa43b 100644 --- a/Source/cmTargetPropertyComputer.h +++ b/Source/cmTargetPropertyComputer.h @@ -35,12 +35,6 @@ public: return nullptr; } - static bool WhiteListedInterfaceProperty(const std::string& prop); - - static bool PassesWhitelist(cmStateEnums::TargetType tgtType, - std::string const& prop, cmMessenger* messenger, - cmListFileBacktrace const& context); - private: static bool HandleLocationPropertyPolicy(std::string const& tgtName, cmMessenger* messenger, diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 78b230c..da4593f 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -2,8 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTestGenerator.h" +#include <algorithm> +#include <cstddef> // IWYU pragma: keep +#include <iterator> #include <memory> #include <ostream> +#include <string> #include <utility> #include <vector> @@ -11,7 +15,10 @@ #include "cmGeneratorTarget.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmMessageType.h" #include "cmOutputConverter.h" +#include "cmPolicies.h" #include "cmProperty.h" #include "cmPropertyMap.h" #include "cmRange.h" @@ -20,6 +27,52 @@ #include "cmSystemTools.h" #include "cmTest.h" +namespace /* anonymous */ +{ + +bool needToQuoteTestName(const cmMakefile& mf, const std::string& name) +{ + // Determine if policy CMP0110 is set to NEW. + switch (mf.GetPolicyStatus(cmPolicies::CMP0110)) { + case cmPolicies::WARN: + // Only warn if a forbidden character is used in the name. + if (name.find_first_of("$[] #;\t\n\"\\") != std::string::npos) { + mf.IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0110), + "\nThe following name given to add_test() is invalid if " + "CMP0110 is not set or set to OLD:\n `", + name, "´\n")); + } + CM_FALLTHROUGH; + case cmPolicies::OLD: + // OLD behavior is to not quote the test's name. + return false; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + default: + // NEW behavior is to quote the test's name. + return true; + } +} + +std::size_t countMaxConsecutiveEqualSigns(const std::string& name) +{ + std::size_t max = 0; + auto startIt = find(name.begin(), name.end(), '='); + auto endIt = startIt; + for (; startIt != name.end(); startIt = find(endIt, name.end(), '=')) { + endIt = + find_if_not(startIt + 1, name.end(), [](char c) { return c == '='; }); + max = + std::max(max, static_cast<std::size_t>(std::distance(startIt, endIt))); + } + return max; +} + +} // End: anonymous namespace + cmTestGenerator::cmTestGenerator( cmTest* test, std::vector<std::string> const& configurations) : cmScriptGenerator("CTEST_CONFIGURATION_TYPE", configurations) @@ -76,8 +129,21 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Set up generator expression evaluation context. cmGeneratorExpression ge(this->Test->GetBacktrace()); + // Determine if policy CMP0110 is set to NEW. + const bool quote_test_name = + needToQuoteTestName(*this->Test->GetMakefile(), this->Test->GetName()); + // Determine the number of equal-signs needed for quoting test name with + // [==[...]==] syntax. + const std::string equalSigns( + 1 + countMaxConsecutiveEqualSigns(this->Test->GetName()), '='); + // Start the test command. - os << indent << "add_test(" << this->Test->GetName() << " "; + if (quote_test_name) { + os << indent << "add_test([" << equalSigns << "[" << this->Test->GetName() + << "]" << equalSigns << "] "; + } else { + os << indent << "add_test(" << this->Test->GetName() << " "; + } // Evaluate command line arguments std::vector<std::string> argv = @@ -127,8 +193,13 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, os << ")\n"; // Output properties for the test. - os << indent << "set_tests_properties(" << this->Test->GetName() - << " PROPERTIES "; + if (quote_test_name) { + os << indent << "set_tests_properties([" << equalSigns << "[" + << this->Test->GetName() << "]" << equalSigns << "] PROPERTIES "; + } else { + os << indent << "set_tests_properties(" << this->Test->GetName() + << " PROPERTIES "; + } for (auto const& i : this->Test->GetProperties().GetList()) { os << " " << i.first << " " << cmOutputConverter::EscapeForCMake( @@ -140,7 +211,21 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os, Indent indent) { - os << indent << "add_test(" << this->Test->GetName() << " NOT_AVAILABLE)\n"; + // Determine if policy CMP0110 is set to NEW. + const bool quote_test_name = + needToQuoteTestName(*this->Test->GetMakefile(), this->Test->GetName()); + // Determine the number of equal-signs needed for quoting test name with + // [==[...]==] syntax. + const std::string equalSigns( + 1 + countMaxConsecutiveEqualSigns(this->Test->GetName()), '='); + + if (quote_test_name) { + os << indent << "add_test([" << equalSigns << "[" << this->Test->GetName() + << "]" << equalSigns << "] NOT_AVAILABLE)\n"; + } else { + os << indent << "add_test(" << this->Test->GetName() + << " NOT_AVAILABLE)\n"; + } } bool cmTestGenerator::NeedsScriptNoConfig() const @@ -155,14 +240,27 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent) { this->TestGenerated = true; + // Determine if policy CMP0110 is set to NEW. + const bool quote_test_name = + needToQuoteTestName(*this->Test->GetMakefile(), this->Test->GetName()); + // Determine the number of equal-signs needed for quoting test name with + // [==[...]==] syntax. + const std::string equalSigns( + 1 + countMaxConsecutiveEqualSigns(this->Test->GetName()), '='); + // Get the test command line to be executed. std::vector<std::string> const& command = this->Test->GetCommand(); std::string exe = command[0]; cmSystemTools::ConvertToUnixSlashes(exe); - fout << indent; - fout << "add_test("; - fout << this->Test->GetName() << " \"" << exe << "\""; + if (quote_test_name) { + fout << indent << "add_test([" << equalSigns << "[" + << this->Test->GetName() << "]" << equalSigns << "] \"" << exe + << "\""; + } else { + fout << indent << "add_test(" << this->Test->GetName() << " \"" << exe + << "\""; + } for (std::string const& arg : cmMakeRange(command).advance(1)) { // Just double-quote all arguments so they are re-parsed @@ -182,8 +280,13 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent) fout << ")\n"; // Output properties for the test. - fout << indent << "set_tests_properties(" << this->Test->GetName() - << " PROPERTIES "; + if (quote_test_name) { + fout << indent << "set_tests_properties([" << equalSigns << "[" + << this->Test->GetName() << "]" << equalSigns << "] PROPERTIES "; + } else { + fout << indent << "set_tests_properties(" << this->Test->GetName() + << " PROPERTIES "; + } for (auto const& i : this->Test->GetProperties().GetList()) { fout << " " << i.first << " " << cmOutputConverter::EscapeForCMake(i.second); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 6369c1f..fa6ad47 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -315,8 +315,7 @@ std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString( void cmVisualStudio10TargetGenerator::Generate() { // do not generate external ms projects - if (this->GeneratorTarget->GetType() == cmStateEnums::INTERFACE_LIBRARY || - this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) { + if (this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) { return; } const std::string ProjectFileExtension = @@ -437,7 +436,7 @@ void cmVisualStudio10TargetGenerator::Generate() e1.Element("ProjectGuid", "{" + this->GUID + "}"); if ((this->MSTools || this->Android) && - this->GeneratorTarget->GetType() <= cmStateEnums::GLOBAL_TARGET) { + this->GeneratorTarget->IsInBuildSystem()) { this->WriteApplicationTypeSettings(e1); this->VerifyNecessaryFiles(); } @@ -596,20 +595,30 @@ void cmVisualStudio10TargetGenerator::Generate() case cmStateEnums::MODULE_LIBRARY: outputType = "Module"; break; - case cmStateEnums::EXECUTABLE: - if (this->GeneratorTarget->Target->GetPropertyAsBool( - "WIN32_EXECUTABLE")) { + case cmStateEnums::EXECUTABLE: { + auto const win32 = + this->GeneratorTarget->GetSafeProperty("WIN32_EXECUTABLE"); + if (win32.find("$<") != std::string::npos) { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat( + "Target \"", this->GeneratorTarget->GetName(), + "\" has a generator expression in its WIN32_EXECUTABLE " + "property. This is not supported on managed executables.")); + return; + } + if (cmIsOn(win32)) { outputType = "WinExe"; } else { outputType = "Exe"; } - break; + } break; case cmStateEnums::UTILITY: + case cmStateEnums::INTERFACE_LIBRARY: case cmStateEnums::GLOBAL_TARGET: outputType = "Utility"; break; case cmStateEnums::UNKNOWN_LIBRARY: - case cmStateEnums::INTERFACE_LIBRARY: break; } e1.Element("OutputType", outputType); @@ -1157,6 +1166,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0) } break; case cmStateEnums::UTILITY: + case cmStateEnums::INTERFACE_LIBRARY: case cmStateEnums::GLOBAL_TARGET: if (this->NsightTegra) { // Tegra-Android platform does not understand "Utility". @@ -1166,7 +1176,6 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0) } break; case cmStateEnums::UNKNOWN_LIBRARY: - case cmStateEnums::INTERFACE_LIBRARY: break; } } @@ -2152,7 +2161,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2, void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) { - if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::GLOBAL_TARGET) { return; } @@ -3732,7 +3741,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( } if (this->MSTools) { - if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) { + if (this->GeneratorTarget->IsWin32Executable(config)) { if (this->GlobalGenerator->TargetsWindowsCE()) { linkOptions.AddFlag("SubSystem", "WindowsCE"); if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1d4cacc..1bee728 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -93,9 +93,13 @@ #if defined(CMAKE_USE_WMAKE) # include "cmGlobalWatcomWMakeGenerator.h" #endif -#include "cmGlobalUnixMakefileGenerator3.h" #if !defined(CMAKE_BOOTSTRAP) # include "cmGlobalNinjaGenerator.h" +# include "cmGlobalUnixMakefileGenerator3.h" +#elif defined(CMAKE_BOOTSTRAP_MAKEFILES) +# include "cmGlobalUnixMakefileGenerator3.h" +#elif defined(CMAKE_BOOTSTRAP_NINJA) +# include "cmGlobalNinjaGenerator.h" #endif #if !defined(CMAKE_BOOTSTRAP) @@ -1751,6 +1755,9 @@ std::unique_ptr<cmGlobalGenerator> cmake::EvaluateDefaultGlobalGenerator() gen = cm::make_unique<cmGlobalNMakeMakefileGenerator>(this); } return std::unique_ptr<cmGlobalGenerator>(std::move(gen)); +#elif defined(CMAKE_BOOTSTRAP_NINJA) + return std::unique_ptr<cmGlobalGenerator>( + cm::make_unique<cmGlobalNinjaGenerator>(this)); #else return std::unique_ptr<cmGlobalGenerator>( cm::make_unique<cmGlobalUnixMakefileGenerator3>(this)); @@ -2029,13 +2036,17 @@ void cmake::AddDefaultGenerators() this->Generators.push_back(cmGlobalMSYSMakefileGenerator::NewFactory()); this->Generators.push_back(cmGlobalMinGWMakefileGenerator::NewFactory()); #endif - this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory()); #if !defined(CMAKE_BOOTSTRAP) # if defined(__linux__) || defined(_WIN32) this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory()); # endif + this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory()); this->Generators.push_back(cmGlobalNinjaGenerator::NewFactory()); this->Generators.push_back(cmGlobalNinjaMultiGenerator::NewFactory()); +#elif defined(CMAKE_BOOTSTRAP_NINJA) + this->Generators.push_back(cmGlobalNinjaGenerator::NewFactory()); +#elif defined(CMAKE_BOOTSTRAP_MAKEFILES) + this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory()); #endif #if defined(CMAKE_USE_WMAKE) this->Generators.push_back(cmGlobalWatcomWMakeGenerator::NewFactory()); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 1a5fea1..15d2fd1 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1161,7 +1161,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args) return cmcmd::ExecuteLinkScript(args); } -#ifndef CMAKE_BOOTSTRAP +#if !defined(CMAKE_BOOTSTRAP) || defined(CMAKE_BOOTSTRAP_NINJA) // Internal CMake ninja dependency scanning support. if (args[1] == "cmake_ninja_depends") { return cmcmd_cmake_ninja_depends(args.begin() + 2, args.end()); @@ -1772,7 +1772,7 @@ int cmcmd::RunLLVMRC(std::vector<std::string> const& args) // args[2] == source_file_path // args[3] == intermediate_file // args[4..n] == preprocess+args - // args[n+1] == -- + // args[n+1] == ++ // args[n+2...] == llvm-rc+args if (args.size() < 3) { std::cerr << "Invalid cmake_llvm_rc arguments"; @@ -1784,7 +1784,11 @@ int cmcmd::RunLLVMRC(std::vector<std::string> const& args) std::vector<std::string> resource_compile; std::vector<std::string>* pArgTgt = &preprocess; for (std::string const& arg : cmMakeRange(args).advance(4)) { - if (arg == "--") { + // We use ++ as seperator between the preprocessing step definition and the + // rc compilation step becase we need to prepend a -- to seperate the + // source file properly from other options when using clang-cl for + // preprocessing. + if (arg == "++") { pArgTgt = &resource_compile; } else { if (arg.find("SOURCE_DIR") != std::string::npos) { diff --git a/Tests/BootstrapTest.cmake b/Tests/BootstrapTest.cmake index 07a65bf..137de78 100644 --- a/Tests/BootstrapTest.cmake +++ b/Tests/BootstrapTest.cmake @@ -1,12 +1,15 @@ file(MAKE_DIRECTORY "${bin_dir}") include(ProcessorCount) ProcessorCount(nproc) +if(generator MATCHES "Ninja") + set(ninja_arg --generator=Ninja) +endif() if(NOT nproc EQUAL 0) set(parallel_arg --parallel=${nproc}) endif() -message(STATUS "running bootstrap: ${bootstrap} ${parallel_arg}") +message(STATUS "running bootstrap: ${bootstrap} ${ninja_arg} ${parallel_arg}") execute_process( - COMMAND ${bootstrap} ${parallel_arg} + COMMAND ${bootstrap} ${ninja_arg} ${parallel_arg} WORKING_DIRECTORY "${bin_dir}" RESULT_VARIABLE result ) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0daf4ae..95162ec 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -440,6 +440,10 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CSharpOnly CSharpOnly) ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx) ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx) + 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\\." + ) endif() ADD_TEST_MACRO(COnly COnly) @@ -3244,6 +3248,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH COMMAND ${CMAKE_CMAKE_COMMAND} -D "bootstrap=${bootstrap}" -D "bin_dir=${CMake_BINARY_DIR}/Tests/BootstrapTest" + -D "generator=${CMAKE_GENERATOR}" -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest") diff --git a/Tests/CSharpWin32GenEx/CMakeLists.txt b/Tests/CSharpWin32GenEx/CMakeLists.txt new file mode 100644 index 0000000..f4a8d00 --- /dev/null +++ b/Tests/CSharpWin32GenEx/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.18) +project(CSharpWin32GenEx CSharp) + +add_executable(CSharpWin32GenEx csharpwin32genex.cs) +set_property(TARGET CSharpWin32GenEx PROPERTY WIN32_EXECUTABLE $<1:1>) diff --git a/Tests/CSharpWin32GenEx/csharpwin32genex.cs b/Tests/CSharpWin32GenEx/csharpwin32genex.cs new file mode 100644 index 0000000..9892ee0 --- /dev/null +++ b/Tests/CSharpWin32GenEx/csharpwin32genex.cs @@ -0,0 +1,9 @@ +namespace CSharpWin32GenEx +{ + class CSharpWin32GenEx + { + public static void Main(string[] args) + { + } + } +} diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index 43b7217..ba2164b 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -1,11 +1,26 @@ - -add_library(headeronly INTERFACE) +set(headeronly_headers headeronly/headeronly.h) +add_library(headeronly INTERFACE ${headeronly_headers}) set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headeronly>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/headeronly>" ) set_property(TARGET headeronly PROPERTY INTERFACE_COMPILE_DEFINITIONS "HEADERONLY_DEFINE") +add_custom_command(OUTPUT headergen/headergen.h + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/headergen.h.in + ${CMAKE_CURRENT_BINARY_DIR}/headergen/headergen.h + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/headergen.h.in + VERBATIM) + +add_library(headergen INTERFACE headergen/headergen.h) +set_property(TARGET headergen PROPERTY INTERFACE_INCLUDE_DIRECTORIES + "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/headergen>" +) +set_property(TARGET headergen PROPERTY PUBLIC_HEADER + ${CMAKE_CURRENT_BINARY_DIR}/headergen/headergen.h) + add_library(pch_iface INTERFACE) target_precompile_headers(pch_iface INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/pch/pch.h>" @@ -54,6 +69,11 @@ install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_targe pch_iface cmakeonly EXPORT expInterface ) +install(TARGETS headergen + EXPORT expInterface + PUBLIC_HEADER DESTINATION include/headergen + INCLUDES DESTINATION include/headergen +) install(TARGETS sharedlib EXPORT expInterface RUNTIME DESTINATION bin @@ -63,7 +83,7 @@ install(TARGETS sharedlib BUNDLE DESTINATION Applications ) install(FILES - headeronly/headeronly.h + ${headeronly_headers} DESTINATION include/headeronly ) install(FILES diff --git a/Tests/ExportImport/Export/Interface/headergen.h.in b/Tests/ExportImport/Export/Interface/headergen.h.in new file mode 100644 index 0000000..bda2b81 --- /dev/null +++ b/Tests/ExportImport/Export/Interface/headergen.h.in @@ -0,0 +1 @@ +#define HEADERGEN_H diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index ef666b1..202c23e 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -12,6 +12,9 @@ set_property(TARGET define_iface PROPERTY add_executable(headeronlytest_bld headeronlytest.cpp) target_link_libraries(headeronlytest_bld bld::headeronly) +add_executable(headergentest_bld headergentest.cpp) +target_link_libraries(headergentest_bld bld::headergen) + set_property(TARGET bld::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface) add_executable(interfacetest_bld interfacetest.cpp) @@ -93,6 +96,9 @@ target_compile_definitions(source_target_test_exp PRIVATE USE_FROM_INSTALL_DIR) add_executable(headeronlytest_exp headeronlytest.cpp) target_link_libraries(headeronlytest_exp exp::headeronly) +add_executable(headergentest_exp headergentest.cpp) +target_link_libraries(headergentest_exp exp::headergen) + set_property(TARGET exp::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface) add_executable(interfacetest_exp interfacetest.cpp) diff --git a/Tests/ExportImport/Import/Interface/headergentest.cpp b/Tests/ExportImport/Import/Interface/headergentest.cpp new file mode 100644 index 0000000..88ff7f1 --- /dev/null +++ b/Tests/ExportImport/Import/Interface/headergentest.cpp @@ -0,0 +1,11 @@ + +#include "headergen.h" + +#ifndef HEADERGEN_H +# error Expected HEADERGEN_H +#endif + +int main() +{ + return 0; +} diff --git a/Tests/FindPython/FindPythonScript.cmake b/Tests/FindPython/FindPythonScript.cmake index bc7e0d1..808496e 100644 --- a/Tests/FindPython/FindPythonScript.cmake +++ b/Tests/FindPython/FindPythonScript.cmake @@ -1,4 +1,4 @@ - +cmake_minimum_required(VERSION 3.12) if (PYTHON_MUST_NOT_BE_FOUND) find_package(${PYTHON_PACKAGE_NAME} QUIET) if (${PYTHON_PACKAGE_NAME}_FOUND) diff --git a/Tests/FindPython/SOABI/CMakeLists.txt b/Tests/FindPython/SOABI/CMakeLists.txt index 4a6aea3..36daa9f 100644 --- a/Tests/FindPython/SOABI/CMakeLists.txt +++ b/Tests/FindPython/SOABI/CMakeLists.txt @@ -20,3 +20,19 @@ if (Python3_Development_FOUND AND Python3_SOABI) message(FATAL_ERROR "Module suffix do not include Python3_SOABI") endif() endif() + + +find_package(Python2 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) +if(NOT DEFINED Python2_SOABI) + message(FATAL_ERROR "Python2_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") +endif() + +if (Python2_Development_FOUND AND Python2_SOABI) + Python2_add_library (spam2 MODULE WITH_SOABI ../spam.c) + target_compile_definitions (spam2 PRIVATE PYTHON2) + + get_property (suffix TARGET spam2 PROPERTY SUFFIX) + if (NOT suffix MATCHES "^.${Python2_SOABI}") + message(FATAL_ERROR "Module suffix do not include Python2_SOABI") + endif() +endif() diff --git a/Tests/FindX11/Test/CMakeLists.txt b/Tests/FindX11/Test/CMakeLists.txt index 7325b32..5b304d9 100644 --- a/Tests/FindX11/Test/CMakeLists.txt +++ b/Tests/FindX11/Test/CMakeLists.txt @@ -33,6 +33,8 @@ test_x11_component(x11_components Xaw) test_x11_component(x11_components xcb) test_x11_component(x11_components X11_xcb) test_x11_component(x11_components xcb_icccm) +test_x11_component(x11_components xcb_util) +test_x11_component(x11_components xcb_xfixes) test_x11_component(x11_components xcb_xkb) test_x11_component(x11_components Xcomposite) test_x11_component(x11_components Xdamage) @@ -72,6 +74,8 @@ foreach(lib xcb X11_xcb xcb_icccm + xcb_util + xcb_xfixes Xcomposite Xdamage Xdmcp diff --git a/Tests/FindX11/Test/main.c b/Tests/FindX11/Test/main.c index f8c723c..b44ae28 100644 --- a/Tests/FindX11/Test/main.c +++ b/Tests/FindX11/Test/main.c @@ -326,6 +326,44 @@ static void test_Xaw(void) #endif +#ifdef HAVE_xcb +# include <xcb/xcb.h> + +static void test_xcb(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_disconnect(connection); +} + +# ifdef HAVE_xcb_util +# include <xcb/xcb_aux.h> + +static void test_xcb_util(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_screen_t* screen = xcb_aux_get_screen(connection, screen_nbr); + xcb_disconnect(connection); +} + +# endif + +# ifdef HAVE_xcb_xfixes +# include <xcb/xcb_xfixes.h> + +static void test_xcb_xfixes(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_xfixes_query_version(connection, 1, 0); + xcb_disconnect(connection); +} + +# endif + +#endif + #include <stddef.h> int main(int argc, char* argv[]) @@ -413,6 +451,16 @@ int main(int argc, char* argv[]) #ifdef HAVE_X11_Xaw test_Xaw, #endif +#ifdef HAVE_xcb + test_xcb, +#endif +#ifdef HAVE_xcb_util + test_xcb_util, +#endif +#ifdef HAVE_xcb_xfixes + test_xcb_xfixes, +#endif + NULL, }; diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index 311ca2a..ec0a604 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -44,6 +44,7 @@ add_executable(InterfaceLibrary definetestexe.cpp) target_link_libraries(InterfaceLibrary iface_nodepends headeriface + iface_genheader subiface intermediate diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp index 9156426..6c53840 100644 --- a/Tests/InterfaceLibrary/definetestexe.cpp +++ b/Tests/InterfaceLibrary/definetestexe.cpp @@ -15,6 +15,12 @@ # error Expected IFACE_HEADER_BUILDDIR #endif +#include "iface_genheader.h" + +#ifndef IFACE_GENHEADER +# error Expected IFACE_GENHEADER +#endif + extern int obj(); extern int sub(); extern int item(); diff --git a/Tests/InterfaceLibrary/headerdir/CMakeLists.txt b/Tests/InterfaceLibrary/headerdir/CMakeLists.txt index 826a9ed..ae030d7 100644 --- a/Tests/InterfaceLibrary/headerdir/CMakeLists.txt +++ b/Tests/InterfaceLibrary/headerdir/CMakeLists.txt @@ -11,3 +11,12 @@ add_custom_target(headeriface_gen VERBATIM ) add_dependencies(headeriface headeriface_gen) + +add_custom_command(OUTPUT iface_genheader.h + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/iface_genheader.h.in + ${CMAKE_CURRENT_BINARY_DIR}/iface_genheader.h + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/iface_genheader.h.in + VERBATIM) +add_library(iface_genheader INTERFACE iface_genheader.h) diff --git a/Tests/InterfaceLibrary/headerdir/iface_genheader.h.in b/Tests/InterfaceLibrary/headerdir/iface_genheader.h.in new file mode 100644 index 0000000..0a21b62 --- /dev/null +++ b/Tests/InterfaceLibrary/headerdir/iface_genheader.h.in @@ -0,0 +1 @@ +#define IFACE_GENHEADER diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt index 1627b39..8b11b46 100644 --- a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt +++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt @@ -61,6 +61,7 @@ macro(buildMocInclude sourceDir binaryDir) "${sourceDir}" MocInclude CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOMOC_PATH_PREFIX=ON" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output diff --git a/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt b/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt new file mode 100644 index 0000000..2677659 --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt @@ -0,0 +1,96 @@ +# This test checks whether adding a source file to the project triggers an AUTOMOC re-run. + +cmake_minimum_required(VERSION 3.10) +project(RerunMocOnAddFile) +include("../AutogenCoreTest.cmake") + +# Create an executable to generate a clean target +set(main_source "${CMAKE_CURRENT_BINARY_DIR}/generated_main.cpp") +file(WRITE "${main_source}" "int main() {}") +add_executable(exe "${main_source}") + +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") +set(testProjectTemplateDir "${CMAKE_CURRENT_SOURCE_DIR}/MocOnAddFile") +set(testProjectSrc "${CMAKE_CURRENT_BINARY_DIR}/MocOnAddFile") +set(testProjectBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocOnAddFile-build") + +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamp When) + file(TIMESTAMP "${mocBasicBin}" time${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${testProjectBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change) + if (timeAfter VERSION_GREATER timeBefore) + message(STATUS "As expected the file ${mocBasicBin} changed.") + else() + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} did not change!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + endif() +endmacro() + +macro(require_change_not) + if (timeAfter VERSION_GREATER timeBefore) + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} changed!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + else() + message(STATUS "As expected the file ${mocBasicBin} did not change.") + endif() +endmacro() + +# Create the test project from the template +unset(additional_project_sources) +unset(main_cpp_includes) +configure_file("${testProjectTemplateDir}/CMakeLists.txt.in" "${testProjectSrc}/CMakeLists.txt") +configure_file("${testProjectTemplateDir}/main.cpp.in" "${testProjectSrc}/main.cpp") + +# Initial build +try_compile(MOC_RERUN + "${testProjectBinDir}" + "${testProjectSrc}" + MocOnAddFile + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output +) +if (NOT MOC_RERUN) + message(FATAL_ERROR "Initial build of mocOnAddFile failed. Output: ${output}") +endif() + +# Sleep to ensure new timestamps +sleep() + +# Add a QObject class (defined in header) to the project and build +set(additional_project_sources myobject.cpp) +set(main_cpp_includes "#include \"myobject.h\"") +configure_file("${testProjectTemplateDir}/CMakeLists.txt.in" "${testProjectSrc}/CMakeLists.txt" + @ONLY) +configure_file("${testProjectTemplateDir}/main.cpp.in" "${testProjectSrc}/main.cpp" @ONLY) +configure_file("${testProjectTemplateDir}/myobject.h" "${testProjectSrc}/myobject.h" COPYONLY) +configure_file("${testProjectTemplateDir}/myobject.cpp" "${testProjectSrc}/myobject.cpp" COPYONLY) +rebuild(2) + +# Sleep to ensure new timestamps +sleep() + +# Add a QObject class (defined in source) to the project and build +set(additional_project_sources myobject.cpp anotherobject.cpp) +configure_file("${testProjectTemplateDir}/CMakeLists.txt.in" "${testProjectSrc}/CMakeLists.txt" + @ONLY) +configure_file("${testProjectTemplateDir}/anotherobject.cpp" "${testProjectSrc}/anotherobject.cpp" + COPYONLY) +rebuild(3) diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in new file mode 100644 index 0000000..9e5e21c --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) +project(MocOnAddFile) +include("@CMAKE_CURRENT_LIST_DIR@/../AutogenCoreTest.cmake") + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +add_executable(mocOnAddFile main.cpp @additional_project_sources@) +target_link_libraries(mocOnAddFile ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/anotherobject.cpp b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/anotherobject.cpp new file mode 100644 index 0000000..45c5af6 --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/anotherobject.cpp @@ -0,0 +1,15 @@ +#include <qobject.h> + +class AnotherObject : public QObject +{ + Q_OBJECT +public: + AnotherObject() {} +}; + +AnotherObject* createAnotherObject() +{ + return new AnotherObject(); +} + +#include "anotherobject.moc" diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/main.cpp.in b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/main.cpp.in new file mode 100644 index 0000000..f62027a --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/main.cpp.in @@ -0,0 +1,6 @@ +@main_cpp_includes@ + +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.cpp b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.cpp new file mode 100644 index 0000000..7a15300 --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.cpp @@ -0,0 +1,6 @@ +#include "myobject.h" + +MyObject::MyObject(QObject* parent) + : QObject(parent) +{ +} diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.h b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.h new file mode 100644 index 0000000..e373ee8 --- /dev/null +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/myobject.h @@ -0,0 +1,13 @@ +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include <qobject.h> + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject* parent = 0); +}; + +#endif diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index dfa5ea0..0c7bd79 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -20,6 +20,7 @@ ADD_AUTOGEN_TEST(RccOffMocLibrary) ADD_AUTOGEN_TEST(RccOnly rccOnly) ADD_AUTOGEN_TEST(RccSkipSource) ADD_AUTOGEN_TEST(RerunMocBasic) +ADD_AUTOGEN_TEST(RerunMocOnAddFile) ADD_AUTOGEN_TEST(RerunRccConfigChange) ADD_AUTOGEN_TEST(RerunRccDepends) ADD_AUTOGEN_TEST(SameName sameName) diff --git a/Tests/RunCMake/CMP0026/CMP0026-IMPORTED.cmake b/Tests/RunCMake/CMP0026/CMP0026-IMPORTED.cmake index 650c8a5..ae62e79 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-IMPORTED.cmake +++ b/Tests/RunCMake/CMP0026/CMP0026-IMPORTED.cmake @@ -1,6 +1,7 @@ enable_language(CXX) +cmake_policy(SET CMP0111 OLD) add_library(someimportedlib SHARED IMPORTED) get_target_property(_loc someimportedlib LOCATION) diff --git a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake new file mode 100644 index 0000000..564169d --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake @@ -0,0 +1,9 @@ +# Prevent duplicate errors on some platforms. +set(CMAKE_IMPORT_LIBRARY_SUFFIX "placeholder") + +add_library(unknown_lib UNKNOWN IMPORTED) +add_library(static_lib STATIC IMPORTED) +add_library(shared_lib SHARED IMPORTED) + +add_executable(executable main.cpp) +target_link_libraries(executable unknown_lib static_lib shared_lib) diff --git a/Tests/RunCMake/InterfaceLibrary/whitelist-result.txt b/Tests/RunCMake/CMP0111/CMP0111-NEW-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/InterfaceLibrary/whitelist-result.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW-result.txt diff --git a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt new file mode 100644 index 0000000..ba5d936 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt @@ -0,0 +1,7 @@ +CMake Error in CMakeLists.txt: + IMPORTED_LOCATION not set for imported target "static_lib"( configuration + ".+")?. ++ +CMake Error in CMakeLists.txt: + IMPORTED_IMPLIB not set for imported target "shared_lib"( configuration + ".+")?. diff --git a/Tests/RunCMake/CMP0111/CMP0111-NEW.cmake b/Tests/RunCMake/CMP0111/CMP0111-NEW.cmake new file mode 100644 index 0000000..d0c8dd3 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0111 NEW) +include(CMP0111-Common.cmake) diff --git a/Tests/RunCMake/CMP0111/CMP0111-OLD.cmake b/Tests/RunCMake/CMP0111/CMP0111-OLD.cmake new file mode 100644 index 0000000..d00847a --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0111 OLD) +include(CMP0111-Common.cmake) diff --git a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt new file mode 100644 index 0000000..2fe6cc8 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt @@ -0,0 +1,26 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0111 is not set: An imported target with a missing location fails + during generation. Run "cmake --help-policy CMP0111" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. + + IMPORTED_LOCATION not set for imported target "unknown_lib"( configuration + ".+")?. +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0111 is not set: An imported target with a missing location fails + during generation. Run "cmake --help-policy CMP0111" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. + + IMPORTED_LOCATION not set for imported target "static_lib"( configuration + ".+")?. +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0111 is not set: An imported target with a missing location fails + during generation. Run "cmake --help-policy CMP0111" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. + + IMPORTED_IMPLIB not set for imported target "shared_lib"( configuration + ".+")?. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0111/CMP0111-WARN.cmake b/Tests/RunCMake/CMP0111/CMP0111-WARN.cmake new file mode 100644 index 0000000..0efe48c --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-WARN.cmake @@ -0,0 +1 @@ +include(CMP0111-Common.cmake) diff --git a/Tests/RunCMake/CMP0111/CMakeLists.txt b/Tests/RunCMake/CMP0111/CMakeLists.txt new file mode 100644 index 0000000..9f19a75 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.17) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0111/RunCMakeTest.cmake b/Tests/RunCMake/CMP0111/RunCMakeTest.cmake new file mode 100644 index 0000000..02e420a --- /dev/null +++ b/Tests/RunCMake/CMP0111/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0111-OLD) +run_cmake(CMP0111-NEW) +run_cmake(CMP0111-WARN) diff --git a/Tests/RunCMake/CMP0111/main.cpp b/Tests/RunCMake/CMP0111/main.cpp new file mode 100644 index 0000000..5047a34 --- /dev/null +++ b/Tests/RunCMake/CMP0111/main.cpp @@ -0,0 +1,3 @@ +int main() +{ +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e08b30a..65e8b0b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -124,6 +124,7 @@ if(CMake_TEST_CUDA) PROPERTY LABELS "CUDA") endif() add_RunCMake_test(CMP0106) +add_RunCMake_test(CMP0111) # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode @@ -292,6 +293,7 @@ add_RunCMake_test(add_dependencies) add_RunCMake_test(add_executable) add_RunCMake_test(add_library) add_RunCMake_test(add_subdirectory) +add_RunCMake_test(add_test) add_RunCMake_test(build_command) add_executable(exit_code exit_code.c) set(execute_process_ARGS -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>) @@ -365,6 +367,15 @@ function(add_RunCMake_test_try_compile) unset(CMAKE_CXX_STANDARD_DEFAULT) endif() endif() + if(CMAKE_VERSION VERSION_LESS 3.18.20200813 AND "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC") + # Older CMake versions do not know about MSVC language standards. + # Approximate our logic from MSVC-C.cmake. + if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 19.27) + set(CMAKE_C_STANDARD_DEFAULT 99) + else() + set(CMAKE_C_STANDARD_DEFAULT "") + endif() + endif() foreach(var CMAKE_SYSTEM_NAME CMAKE_C_COMPILER_ID @@ -401,6 +412,7 @@ add_RunCMake_test(no_install_prefix) add_RunCMake_test(configure_file) add_RunCMake_test(CTestTimeout -DTIMEOUT=${CTestTestTimeout_TIME}) add_RunCMake_test(CTestTimeoutAfterMatch) +add_RunCMake_test(DependencyGraph -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}) # ctresalloc links against CMakeLib and CTestLib, which means it can't be built # if CMake_TEST_EXTERNAL_CMAKE is activated (the compiler might be different.) @@ -721,3 +733,7 @@ add_RunCMake_test("CTestCommandExpandLists") add_RunCMake_test(PrecompileHeaders -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) add_RunCMake_test("UnityBuild") + +if(WIN32) + add_RunCMake_test(Win32GenEx) +endif() diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake index 761224a..62606f8 100644 --- a/Tests/RunCMake/CTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake @@ -18,3 +18,12 @@ function(run_CMakeCTestArguments) run_cmake_command(CMakeCTestArguments-test ${CMAKE_COMMAND} --build . --config Debug --target "${test}") endfunction() run_CMakeCTestArguments() + +function(run_TestfileErrors) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestfileErrors-build) + run_cmake(TestfileErrors) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(TestfileErrors-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(TestfileErrors-test ${CMAKE_CTEST_COMMAND} -C Debug) +endfunction() +run_TestfileErrors() diff --git a/Tests/RunCMake/CTest/TestfileErrors-Script.cmake b/Tests/RunCMake/CTest/TestfileErrors-Script.cmake new file mode 100644 index 0000000..d9fc7c8 --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-Script.cmake @@ -0,0 +1,4 @@ +message(SEND_ERROR "SEND_ERROR") +message(FATAL_ERROR "FATAL_ERROR") +# This shouldn't get printed because the script aborts on FATAL_ERROR +message(SEND_ERROR "reaching the unreachable") diff --git a/Tests/RunCMake/CTest/TestfileErrors-test-result.txt b/Tests/RunCMake/CTest/TestfileErrors-test-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-test-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt b/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt new file mode 100644 index 0000000..a3a476b --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at [^ +]*/Tests/RunCMake/CTest/TestfileErrors-Script.cmake:1 \(message\): + SEND_ERROR +Call Stack \(most recent call first\): + CTestTestfile.cmake:[0-9]+ \(include\) ++ +CMake Error at [^ +]*/Tests/RunCMake/CTest/TestfileErrors-Script.cmake:2 \(message\): + FATAL_ERROR +Call Stack \(most recent call first\): + CTestTestfile.cmake:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CTest/TestfileErrors.cmake b/Tests/RunCMake/CTest/TestfileErrors.cmake new file mode 100644 index 0000000..676eb47 --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors.cmake @@ -0,0 +1,3 @@ +include(CTest) +add_test(NAME "unreachable" COMMAND ${CMAKE_COMMAND} -E true) +set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/TestfileErrors-Script.cmake) diff --git a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt index d95bb33..97e2a10 100644 --- a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at CTestTestfile.cmake:[0-9]+ \(subdirs\): subdirs called with incorrect number of arguments + -No tests were found!!!$ +Errors while running CTest$ diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt index ba4235d..19310b8 100644 --- a/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt @@ -1 +1,2 @@ +^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputSize/DartConfiguration.tcl Errors while running CTest diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index b20e683..2a5d5d3 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -779,15 +779,15 @@ function(run_llvm_rc) file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake_command(llvm_rc_no_args ${CMAKE_COMMAND} -E cmake_llvm_rc) run_cmake_command(llvm_rc_no_-- ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test") - run_cmake_command(llvm_rc_empty_preprocessor ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp -- ${CMAKE_COMMAND} -E echo "This is a test") - run_cmake_command(llvm_rc_failing_first_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -P FailedProgram.cmake -- ${CMAKE_COMMAND} -E echo "This is a test") - run_cmake_command(llvm_rc_failing_second_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" -- ${CMAKE_COMMAND} -P FailedProgram.cmake ) + run_cmake_command(llvm_rc_empty_preprocessor ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ++ ${CMAKE_COMMAND} -E echo "This is a test") + run_cmake_command(llvm_rc_failing_first_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -P FailedProgram.cmake ++ ${CMAKE_COMMAND} -E echo "This is a test") + run_cmake_command(llvm_rc_failing_second_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" ++ ${CMAKE_COMMAND} -P FailedProgram.cmake ) if(EXISTS ${RunCMake_TEST_BINARY_DIR}/test.tmp) message(SEND_ERROR "${test} - FAILED:\n" "test.tmp was not deleted") endif() file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir") - run_cmake_command(llvm_rc_full_run ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" -- ${CMAKE_COMMAND} -E copy test.tmp SOURCE_DIR/llvmrc.result ) + run_cmake_command(llvm_rc_full_run ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" ++ ${CMAKE_COMMAND} -E copy test.tmp SOURCE_DIR/llvmrc.result ) if(EXISTS ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/test.tmp) message(SEND_ERROR "${test} - FAILED:\n" "test.tmp was not deleted") diff --git a/Tests/RunCMake/DependencyGraph/CMakeLists.txt b/Tests/RunCMake/DependencyGraph/CMakeLists.txt new file mode 100644 index 0000000..b646c4a --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeCommon.cmake b/Tests/RunCMake/DependencyGraph/OptimizeCommon.cmake new file mode 100644 index 0000000..4954bc4 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeCommon.cmake @@ -0,0 +1,40 @@ +enable_language(C) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY out) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY out) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY out) + +add_library(SharedTop SHARED mylib.c) +add_library(StaticTop STATIC mylib.c) +add_library(StaticMiddle STATIC mylib.c) + +add_library(StaticNone STATIC mylib.c) +add_library(StaticPreBuild STATIC mylib.c) +add_library(StaticPreLink STATIC mylib.c) +add_library(StaticPostBuild STATIC mylib.c) +add_library(StaticCc STATIC mylibcc.c) + +add_custom_command(TARGET StaticPreBuild PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E true) +add_custom_command(TARGET StaticPreLink PRE_LINK + COMMAND ${CMAKE_COMMAND} -E true) +add_custom_command(TARGET StaticPostBuild POST_BUILD + COMMAND ${CMAKE_COMMAND} -E true) +add_custom_command(OUTPUT mylibcc.c + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/mylib.c ${CMAKE_BINARY_DIR}/mylibcc.c) + +target_link_libraries(SharedTop PRIVATE StaticMiddle) +target_link_libraries(StaticTop PRIVATE StaticMiddle) +target_link_libraries(StaticMiddle PRIVATE StaticNone StaticPreBuild StaticPreLink StaticPostBuild StaticCc) + +if(OPTIMIZE_TOP) + set_target_properties(SharedTop StaticTop PROPERTIES + OPTIMIZE_DEPENDENCIES TRUE) +endif() +if(OPTIMIZE_MIDDLE) + set_target_properties(StaticMiddle PROPERTIES + OPTIMIZE_DEPENDENCIES TRUE) +endif() + +include(WriteTargets.cmake) +write_targets() diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-check.cmake new file mode 100644 index 0000000..1020cb3 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-check.cmake @@ -0,0 +1,5 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${FortranTop_TARGET_FILE} + ${FortranBottom_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-stderr.txt b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-both.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both.cmake new file mode 100644 index 0000000..581fd46 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both.cmake @@ -0,0 +1 @@ +include(OptimizeFortranCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-check.cmake new file mode 100644 index 0000000..5c7e8cd --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-check.cmake @@ -0,0 +1,6 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${FortranTop_TARGET_FILE} + ${CMiddle_TARGET_FILE} + ${FortranBottom_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-stderr.txt b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle.cmake new file mode 100644 index 0000000..581fd46 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle.cmake @@ -0,0 +1 @@ +include(OptimizeFortranCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-check.cmake new file mode 100644 index 0000000..5c7e8cd --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-check.cmake @@ -0,0 +1,6 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${FortranTop_TARGET_FILE} + ${CMiddle_TARGET_FILE} + ${FortranBottom_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-stderr.txt b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-none.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none.cmake new file mode 100644 index 0000000..581fd46 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none.cmake @@ -0,0 +1 @@ +include(OptimizeFortranCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-check.cmake new file mode 100644 index 0000000..1020cb3 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-check.cmake @@ -0,0 +1,5 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${FortranTop_TARGET_FILE} + ${FortranBottom_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-stderr.txt b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-top.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top.cmake new file mode 100644 index 0000000..581fd46 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top.cmake @@ -0,0 +1 @@ +include(OptimizeFortranCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortranCommon.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortranCommon.cmake new file mode 100644 index 0000000..354d3fc --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortranCommon.cmake @@ -0,0 +1,25 @@ +enable_language(C) +enable_language(Fortran) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY out) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY out) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY out) + +add_library(FortranTop STATIC mylib.f90) +add_library(CMiddle STATIC mylib.c) +add_library(FortranBottom STATIC mylib.f90) + +target_link_libraries(FortranTop PRIVATE CMiddle) +target_link_libraries(CMiddle PRIVATE FortranBottom) + +if(OPTIMIZE_TOP) + set_target_properties(FortranTop PROPERTIES + OPTIMIZE_DEPENDENCIES TRUE) +endif() +if(OPTIMIZE_MIDDLE) + set_target_properties(CMiddle PROPERTIES + OPTIMIZE_DEPENDENCIES TRUE) +endif() + +include(WriteTargets.cmake) +write_targets() diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-both-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-both-build-check.cmake new file mode 100644 index 0000000..312de04 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-both-build-check.cmake @@ -0,0 +1,11 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${SharedTop_TARGET_FILE} + ${SharedTop_TARGET_LINKER_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-both.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-both.cmake new file mode 100644 index 0000000..c150e62 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-both.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-middle-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-middle-build-check.cmake new file mode 100644 index 0000000..312de04 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-middle-build-check.cmake @@ -0,0 +1,11 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${SharedTop_TARGET_FILE} + ${SharedTop_TARGET_LINKER_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-middle.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-middle.cmake new file mode 100644 index 0000000..c150e62 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-middle.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-none-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-none-build-check.cmake new file mode 100644 index 0000000..312de04 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-none-build-check.cmake @@ -0,0 +1,11 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${SharedTop_TARGET_FILE} + ${SharedTop_TARGET_LINKER_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-none.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-none.cmake new file mode 100644 index 0000000..c150e62 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-none.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-top-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-top-build-check.cmake new file mode 100644 index 0000000..312de04 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-top-build-check.cmake @@ -0,0 +1,11 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${SharedTop_TARGET_FILE} + ${SharedTop_TARGET_LINKER_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-top.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-top.cmake new file mode 100644 index 0000000..c150e62 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-top.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-both-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-both-build-check.cmake new file mode 100644 index 0000000..5222ed7 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-both-build-check.cmake @@ -0,0 +1,8 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${StaticTop_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-both.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-both.cmake new file mode 100644 index 0000000..c150e62 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-both.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle-build-check.cmake new file mode 100644 index 0000000..5cba223 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle-build-check.cmake @@ -0,0 +1,10 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${StaticTop_TARGET_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle.cmake new file mode 100644 index 0000000..c150e62 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-none-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-none-build-check.cmake new file mode 100644 index 0000000..5cba223 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-none-build-check.cmake @@ -0,0 +1,10 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${StaticTop_TARGET_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-none.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-none.cmake new file mode 100644 index 0000000..c150e62 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-none.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-top-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-top-build-check.cmake new file mode 100644 index 0000000..5222ed7 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-top-build-check.cmake @@ -0,0 +1,8 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${StaticTop_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-top.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-top.cmake new file mode 100644 index 0000000..c150e62 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-top.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/Property.cmake b/Tests/RunCMake/DependencyGraph/Property.cmake new file mode 100644 index 0000000..08fdd2b --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/Property.cmake @@ -0,0 +1,24 @@ +enable_language(C) + +add_library(Unset STATIC mylib.c) + +set(CMAKE_OPTIMIZE_DEPENDENCIES TRUE) +add_library(SetTrue STATIC mylib.c) + +set(CMAKE_OPTIMIZE_DEPENDENCIES FALSE) +add_library(SetFalse STATIC mylib.c) + +get_property(_set TARGET Unset PROPERTY OPTIMIZE_DEPENDENCIES SET) +if(_set) + message(SEND_ERROR "OPTIMIZE_DEPENDENCIES property should not be set on Unset target") +endif() + +get_property(_true TARGET SetTrue PROPERTY OPTIMIZE_DEPENDENCIES) +if(NOT _true STREQUAL "TRUE") + message(SEND_ERROR "OPTIMIZE_DEPENDENCIES property should be TRUE on SetTrue target") +endif() + +get_property(_false TARGET SetFalse PROPERTY OPTIMIZE_DEPENDENCIES) +if(NOT _false STREQUAL "FALSE") + message(SEND_ERROR "OPTIMIZE_DEPENDENCIES property should be FALSE on SetFalse target") +endif() diff --git a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake new file mode 100644 index 0000000..cb0d541 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake @@ -0,0 +1,60 @@ +include(RunCMake) + +function(check_files dir) + set(expected ${ARGN}) + list(FILTER expected EXCLUDE REGEX "^$") + list(REMOVE_DUPLICATES expected) + list(SORT expected) + + file(GLOB_RECURSE glob "${dir}/*") + set(actual) + foreach(i IN LISTS glob) + if(NOT i MATCHES "(\\.manifest$)|(\\.exp$)|(\\.tds$)") + list(APPEND actual ${i}) + endif() + endforeach() + list(REMOVE_DUPLICATES actual) + list(SORT actual) + + if(NOT "${expected}" STREQUAL "${actual}") + string(REPLACE ";" "\n " expected_formatted "${expected}") + string(REPLACE ";" "\n " actual_formatted "${actual}") + string(APPEND RunCMake_TEST_FAILED "Actual files did not match expected\nExpected:\n ${expected_formatted}\nActual:\n ${actual_formatted}\n") + endif() + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction() + +function(run_cmake_build name) + set(RunCMake_TEST_NO_CLEAN TRUE) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build) + file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}) + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + run_cmake(${name}) + set(RunCMake_TEST_OPTIONS) + run_cmake_command(${name}-build ${CMAKE_COMMAND} + --build ${RunCMake_TEST_BINARY_DIR} + --config Release + --target ${ARGN}) +endfunction() + +function(run_optimize_test name) + set(RunCMake_TEST_OPTIONS) + run_cmake_build(${name}-none ${ARGN}) + set(RunCMake_TEST_OPTIONS -DOPTIMIZE_TOP=TRUE) + run_cmake_build(${name}-top ${ARGN}) + set(RunCMake_TEST_OPTIONS -DOPTIMIZE_MIDDLE=TRUE) + run_cmake_build(${name}-middle ${ARGN}) + set(RunCMake_TEST_OPTIONS -DOPTIMIZE_TOP=TRUE -DOPTIMIZE_MIDDLE=TRUE) + run_cmake_build(${name}-both ${ARGN}) +endfunction() + +run_cmake(Property) + +run_optimize_test(OptimizeShared SharedTop) +run_optimize_test(OptimizeStatic StaticTop) +if(CMAKE_Fortran_COMPILER) + run_optimize_test(OptimizeFortran FortranTop) +endif() diff --git a/Tests/RunCMake/DependencyGraph/WriteTargets.cmake b/Tests/RunCMake/DependencyGraph/WriteTargets.cmake new file mode 100644 index 0000000..e1012c1 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/WriteTargets.cmake @@ -0,0 +1,16 @@ +function(write_targets) + set(_input "") + + get_property(_targets DIRECTORY . PROPERTY BUILDSYSTEM_TARGETS) + foreach(_t IN LISTS _targets) + get_property(_type TARGET "${_t}" PROPERTY TYPE) + if(_type STREQUAL "SHARED_LIBRARY") + string(APPEND _input "set(${_t}_TARGET_FILE [==[$<TARGET_FILE:${_t}>]==])\n") + string(APPEND _input "set(${_t}_TARGET_LINKER_FILE [==[$<TARGET_LINKER_FILE:${_t}>]==])\n") + elseif(_type STREQUAL "STATIC_LIBRARY") + string(APPEND _input "set(${_t}_TARGET_FILE [==[$<TARGET_FILE:${_t}>]==])\n") + endif() + endforeach() + + file(GENERATE OUTPUT target_files.cmake CONTENT "${_input}" CONDITION $<CONFIG:Release>) +endfunction() diff --git a/Tests/RunCMake/DependencyGraph/mylib.c b/Tests/RunCMake/DependencyGraph/mylib.c new file mode 100644 index 0000000..5422fe3 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/mylib.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void mylib(void) +{ +} diff --git a/Tests/RunCMake/DependencyGraph/mylib.f90 b/Tests/RunCMake/DependencyGraph/mylib.f90 new file mode 100644 index 0000000..104768f --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/mylib.f90 @@ -0,0 +1,3 @@ +function mylib_fortran() + mylib_fortran = 42 +end function mylib_fortran diff --git a/Tests/RunCMake/ExternalProject/DownloadInactivityResume.cmake b/Tests/RunCMake/ExternalProject/DownloadInactivityResume.cmake new file mode 100644 index 0000000..d34482d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadInactivityResume.cmake @@ -0,0 +1,5 @@ +include(ExternalProject) +ExternalProject_Add(MyProj URL ${SERVER_URL} INACTIVITY_TIMEOUT 2 DOWNLOAD_NO_EXTRACT TRUE + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "") diff --git a/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-result.txt b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-stdout.txt b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-stdout.txt new file mode 100644 index 0000000..3238147 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-stdout.txt @@ -0,0 +1 @@ +(Timeout was reached)? diff --git a/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout.cmake b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout.cmake new file mode 100644 index 0000000..d34482d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout.cmake @@ -0,0 +1,5 @@ +include(ExternalProject) +ExternalProject_Add(MyProj URL ${SERVER_URL} INACTIVITY_TIMEOUT 2 DOWNLOAD_NO_EXTRACT TRUE + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "") diff --git a/Tests/RunCMake/ExternalProject/DownloadServer.py b/Tests/RunCMake/ExternalProject/DownloadServer.py new file mode 100644 index 0000000..3738317 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadServer.py @@ -0,0 +1,49 @@ +from http.server import HTTPServer, BaseHTTPRequestHandler +import argparse +import time +import subprocess +import sys +import os +import threading +args = None +outerthread = None + +class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.end_headers() + data = b'D' + + if args.speed_limit: + slow_deadline = time.time()+args.limit_duration + + while time.time() < slow_deadline: + self.wfile.write(data) + if args.speed_limit: + time.sleep(1.1) + + data = data * 100 + self.wfile.write(data) + self.close_connection = True + +def runServer(fileName): + httpd = HTTPServer(('localhost', 0), SimpleHTTPRequestHandler) + with open(fileName,"w") as f: + f.write('http://localhost:{}/test'.format(httpd.socket.getsockname()[1])) + httpd.handle_request() + os.remove(fileName) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--speed_limit', help='transfer rate limitation', action='store_true',default=False) + parser.add_argument('--limit_duration', help='duration of the transfer rate limitation',default=1, type=float) + parser.add_argument('--file', help='file to write the url to connect to') + parser.add_argument('--subprocess', action='store_true') + args = parser.parse_args() + if not args.subprocess: + subprocess.Popen([sys.executable]+sys.argv+['--subprocess'],stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL,stdout=subprocess.DEVNULL) + else: + serverThread = threading.Thread(target=runServer,args=(args.file,)) + serverThread.daemon = True + serverThread.start() + serverThread.join(15) diff --git a/Tests/RunCMake/ExternalProject/DownloadTimeout-build-result.txt b/Tests/RunCMake/ExternalProject/DownloadTimeout-build-result.txt new file mode 100644 index 0000000..c20fd86 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadTimeout-build-result.txt @@ -0,0 +1 @@ +^[^0] diff --git a/Tests/RunCMake/ExternalProject/DownloadTimeout-build-stderr.txt b/Tests/RunCMake/ExternalProject/DownloadTimeout-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadTimeout-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/ExternalProject/DownloadTimeout.cmake b/Tests/RunCMake/ExternalProject/DownloadTimeout.cmake new file mode 100644 index 0000000..c90b4ba --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadTimeout.cmake @@ -0,0 +1,5 @@ +include(ExternalProject) +set(source_dir "${CMAKE_CURRENT_BINARY_DIR}/DownloadTimeout") +file(REMOVE_RECURSE "${source_dir}") +file(MAKE_DIRECTORY "${source_dir}") +ExternalProject_Add(MyProj URL "http://cmake.org/invalid_file.tar.gz") diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 0d1da26..c2c77e0 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -1,5 +1,11 @@ +cmake_minimum_required(VERSION 3.12) include(RunCMake) +# We do not contact any remote URLs, but may use a local one. +# Remove any proxy configuration that may change behavior. +unset(ENV{http_proxy}) +unset(ENV{https_proxy}) + run_cmake(IncludeScope-Add) run_cmake(IncludeScope-Add_Step) run_cmake(NoOptions) @@ -27,6 +33,50 @@ function(__ep_test_with_build testName) run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .) endfunction() +find_package(Python3) +function(__ep_test_with_build_with_server testName) + if(NOT Python3_EXECUTABLE) + return() + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_TIMEOUT 20) + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + set(URL_FILE ${RunCMake_BINARY_DIR}/${testName}.url) + if(EXISTS "${URL_FILE}") + file(REMOVE "${URL_FILE}") + endif() + execute_process( + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/DownloadServer.py --file "${URL_FILE}" ${ARGN} + OUTPUT_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt + ERROR_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt + RESULT_VARIABLE result + TIMEOUT 30 + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Failed to start download server:\n ${result}") + endif() + + foreach(i RANGE 1 8) + if(EXISTS ${URL_FILE}) + break() + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${i}) + endforeach() + + if(NOT EXISTS ${URL_FILE}) + message(FATAL_ERROR "Failed to load download server URL from:\n ${URL_FILE}") + endif() + + file(READ ${URL_FILE} SERVER_URL) + message(STATUS "URL : ${URL_FILE} - ${SERVER_URL}") + run_cmake_with_options(${testName} ${CMAKE_COMMAND} -DSERVER_URL=${SERVER_URL} ) + run_cmake_command(${testName}-clean ${CMAKE_COMMAND} --build . --target clean) + run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .) +endfunction() + __ep_test_with_build(MultiCommand) set(RunCMake_TEST_OUTPUT_MERGE 1) @@ -38,6 +88,9 @@ set(RunCMake_TEST_OUTPUT_MERGE 0) if(NOT RunCMake_GENERATOR MATCHES "Visual Studio") __ep_test_with_build(LogOutputOnFailure) __ep_test_with_build(LogOutputOnFailureMerged) + __ep_test_with_build(DownloadTimeout) + __ep_test_with_build_with_server(DownloadInactivityTimeout --speed_limit --limit_duration 40) + __ep_test_with_build_with_server(DownloadInactivityResume --speed_limit --limit_duration 1) endif() # We can't test the substitution when using the old MSYS due to diff --git a/Tests/RunCMake/FetchContent/DirOverrides.cmake b/Tests/RunCMake/FetchContent/DirOverrides.cmake index 50eef16..ad61a00 100644 --- a/Tests/RunCMake/FetchContent/DirOverrides.cmake +++ b/Tests/RunCMake/FetchContent/DirOverrides.cmake @@ -4,18 +4,23 @@ include(FetchContent) FetchContent_Declare( t1 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedSrc - DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR> + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedBin + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR> <BINARY_DIR> ) FetchContent_Populate(t1) if(NOT IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedSrc) message(FATAL_ERROR "Saved details SOURCE_DIR override failed") endif() +if(NOT IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedBin) + message(FATAL_ERROR "Saved details BINARY_DIR override failed") +endif() # Test direct population FetchContent_Populate( t2 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/directSrc - DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR> + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/directBin + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR> <BINARY_DIR> ) if(NOT IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/directSrc) message(FATAL_ERROR "Direct details SOURCE_DIR override failed") @@ -44,3 +49,19 @@ FetchContent_Populate( if(IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedNobuildDir-build) message(FATAL_ERROR "Direct details BINARY_DIR override failed") endif() + +# Test overriding the source directory by reusing the one from t1 +set(FETCHCONTENT_SOURCE_DIR_T5 ${CMAKE_CURRENT_BINARY_DIR}/savedSrc) +FetchContent_Declare( + t5 + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/doesNotExist + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/wontBeCreated + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E false +) +FetchContent_Populate(t5) +if(NOT "${t5_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedSrc") + message(FATAL_ERROR "Wrong SOURCE_DIR returned: ${t5_SOURCE_DIR}") +endif() +if(NOT "${t5_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/wontBeCreated") + message(FATAL_ERROR "Wrong BINARY_DIR returned: ${t5_BINARY_DIR}") +endif() diff --git a/Tests/RunCMake/FetchContent/DirOverridesDisconnected.cmake b/Tests/RunCMake/FetchContent/DirOverridesDisconnected.cmake new file mode 100644 index 0000000..768a82e --- /dev/null +++ b/Tests/RunCMake/FetchContent/DirOverridesDisconnected.cmake @@ -0,0 +1,18 @@ +include(FetchContent) + +# Test using saved details. We are re-using a SOURCE_DIR from a previous test +# so the download command should not be executed. +FetchContent_Declare( + t1 + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedSrc + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedBin + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E false +) +FetchContent_Populate(t1) + +if(NOT "${t1_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedSrc") + message(FATAL_ERROR "Wrong SOURCE_DIR returned: ${t1_SOURCE_DIR}") +endif() +if(NOT "${t1_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedBin") + message(FATAL_ERROR "Wrong BINARY_DIR returned: ${t1_BINARY_DIR}") +endif() diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index f3ed3e2..ad9e48e 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -10,12 +10,25 @@ run_cmake(DownloadFile) run_cmake(SameGenerator) run_cmake(VarDefinitions) run_cmake(GetProperties) -run_cmake(DirOverrides) run_cmake(UsesTerminalOverride) run_cmake(MakeAvailable) run_cmake(MakeAvailableTwice) run_cmake(MakeAvailableUndeclared) +function(run_FetchContent_DirOverrides) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DirOverrides-build) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(DirOverrides) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_with_options(DirOverridesDisconnected + -D FETCHCONTENT_FULLY_DISCONNECTED=YES + ) +endfunction() +run_FetchContent_DirOverrides() + set(RunCMake_TEST_OUTPUT_MERGE 1) run_cmake(PreserveEmptyArgs) set(RunCMake_TEST_OUTPUT_MERGE 0) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index b567bf1..c66757f 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -522,6 +522,7 @@ def gen_check_directories(c, g): read_codemodel_json_data("directories/custom.json"), read_codemodel_json_data("directories/cxx.json"), read_codemodel_json_data("directories/imported.json"), + read_codemodel_json_data("directories/interface.json"), read_codemodel_json_data("directories/object.json"), read_codemodel_json_data("directories/dir.json"), read_codemodel_json_data("directories/dir_dir.json"), @@ -594,6 +595,10 @@ def gen_check_targets(c, g, inSource): read_codemodel_json_data("targets/link_imported_object_exe.json"), read_codemodel_json_data("targets/link_imported_interface_exe.json"), + read_codemodel_json_data("targets/all_build_interface.json"), + read_codemodel_json_data("targets/zero_check_interface.json"), + read_codemodel_json_data("targets/iface_srcs.json"), + read_codemodel_json_data("targets/all_build_custom.json"), read_codemodel_json_data("targets/zero_check_custom.json"), read_codemodel_json_data("targets/custom_tgt.json"), @@ -722,6 +727,7 @@ def gen_check_projects(c, g): read_codemodel_json_data("projects/alias.json"), read_codemodel_json_data("projects/object.json"), read_codemodel_json_data("projects/imported.json"), + read_codemodel_json_data("projects/interface.json"), read_codemodel_json_data("projects/custom.json"), read_codemodel_json_data("projects/external.json"), ] diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json new file mode 100644 index 0000000..b10d496 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json @@ -0,0 +1,14 @@ +{ + "source": "^interface$", + "build": "^interface$", + "parentSource": "^\\.$", + "childSources": null, + "targetIds": [ + "^ALL_BUILD::@25b7fa8ea00134654b85$", + "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "^iface_srcs::@25b7fa8ea00134654b85$" + ], + "projectName": "Interface", + "minimumCMakeVersion": "3.12", + "hasInstallRule": null +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json index c144953..736d1f5 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json @@ -7,6 +7,7 @@ "^custom$", "^cxx$", "^imported$", + "^interface$", "^object$", "^.*/Tests/RunCMake/FileAPIExternalSource$", "^dir$" diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json index f3aac63..4d0cdc0 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json @@ -6,6 +6,7 @@ "Custom", "Cxx", "Imported", + "Interface", "Object", "External" ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/interface.json new file mode 100644 index 0000000..2a22767 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/interface.json @@ -0,0 +1,13 @@ +{ + "name": "Interface", + "parentName": "codemodel-v2", + "childNames": null, + "directorySources": [ + "^interface$" + ], + "targetIds": [ + "^ALL_BUILD::@25b7fa8ea00134654b85$", + "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "^iface_srcs::@25b7fa8ea00134654b85$" + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_interface.json new file mode 100644 index 0000000..fa2a6e5 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_interface.json @@ -0,0 +1,79 @@ +{ + "name": "ALL_BUILD", + "id": "^ALL_BUILD::@25b7fa8ea00134654b85$", + "directorySource": "^interface$", + "projectName": "Interface", + "type": "UTILITY", + "isGeneratorProvided": true, + "sources": [ + { + "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ALL_BUILD$", + "isGenerated": true, + "sourceGroupName": "", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ALL_BUILD\\.rule$", + "isGenerated": true, + "sourceGroupName": "CMake Rules", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "", + "sourcePaths": [ + "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ALL_BUILD$" + ] + }, + { + "name": "CMake Rules", + "sourcePaths": [ + "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ALL_BUILD\\.rule$" + ] + } + ], + "compileGroups": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": null, + "artifacts": null, + "build": "^interface$", + "source": "^interface$", + "install": null, + "link": null, + "archive": null, + "dependencies": [ + { + "id": "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "backtrace": null + }, + { + "id": "^iface_srcs::@25b7fa8ea00134654b85$", + "backtrace": null + } + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json index 59bd750..d023f99 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json @@ -176,6 +176,10 @@ "backtrace": null }, { + "id": "^iface_srcs::@25b7fa8ea00134654b85$", + "backtrace": null + }, + { "id": "^custom_exe::@c11385ffed57b860da63$", "backtrace": null }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json index e7ab55b..c9e652b 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json @@ -119,7 +119,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 37, + "line": 38, "command": "install", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/iface_srcs.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/iface_srcs.json new file mode 100644 index 0000000..97d7ccd --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/iface_srcs.json @@ -0,0 +1,67 @@ +{ + "name": "iface_srcs", + "id": "^iface_srcs::@25b7fa8ea00134654b85$", + "directorySource": "^interface$", + "projectName": "Interface", + "type": "INTERFACE_LIBRARY", + "isGeneratorProvided": null, + "sources": [ + { + "path": "^empty\\.c$", + "isGenerated": null, + "sourceGroupName": "Source Files", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": 3, + "command": "add_library", + "hasParent": true + }, + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "Source Files", + "sourcePaths": [ + "^empty\\.c$" + ] + } + ], + "compileGroups": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": 3, + "command": "add_library", + "hasParent": true + }, + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": null, + "artifacts": null, + "build": "^interface$", + "source": "^interface$", + "install": null, + "link": null, + "archive": null, + "dependencies": [ + { + "id": "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "backtrace": null + } + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_exe.json index 312f4c5..451e8d4 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 5, + "line": 6, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 5, + "line": 6, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_interface_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_interface_exe.json index 7d0e6df..cbd4346 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_interface_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_interface_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 23, + "line": 29, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 23, + "line": 29, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_object_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_object_exe.json index 4aec524..d92a810 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_object_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_object_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 18, + "line": 24, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 18, + "line": 24, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_shared_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_shared_exe.json index f5846ec..1197a73 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_shared_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_shared_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 9, + "line": 14, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 9, + "line": 14, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_static_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_static_exe.json index 29a1695..42564e0 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_static_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_static_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 13, + "line": 19, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 13, + "line": 19, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/zero_check_interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/zero_check_interface.json new file mode 100644 index 0000000..fdd4b2a --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/zero_check_interface.json @@ -0,0 +1,70 @@ +{ + "name": "ZERO_CHECK", + "id": "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "directorySource": "^interface$", + "projectName": "Interface", + "type": "UTILITY", + "isGeneratorProvided": true, + "sources": [ + { + "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ZERO_CHECK$", + "isGenerated": true, + "sourceGroupName": "", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ZERO_CHECK\\.rule$", + "isGenerated": true, + "sourceGroupName": "CMake Rules", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "", + "sourcePaths": [ + "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ZERO_CHECK$" + ] + }, + { + "name": "CMake Rules", + "sourcePaths": [ + "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ZERO_CHECK\\.rule$" + ] + } + ], + "compileGroups": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": null, + "artifacts": null, + "build": "^interface$", + "source": "^interface$", + "install": null, + "link": null, + "archive": null, + "dependencies": null +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake index c98a84c..2405954 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake @@ -18,6 +18,7 @@ add_subdirectory(cxx) add_subdirectory(alias) add_subdirectory(object) add_subdirectory(imported) +add_subdirectory(interface) add_subdirectory(custom) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../FileAPIExternalSource" "${CMAKE_CURRENT_BINARY_DIR}/../FileAPIExternalBuild") add_subdirectory(dir) diff --git a/Tests/RunCMake/FileAPI/imported/CMakeLists.txt b/Tests/RunCMake/FileAPI/imported/CMakeLists.txt index d36d88b..f79d87c 100644 --- a/Tests/RunCMake/FileAPI/imported/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/imported/CMakeLists.txt @@ -1,15 +1,21 @@ project(Imported) add_library(imported_lib UNKNOWN IMPORTED) +set_target_properties(imported_lib PROPERTIES IMPORTED_LOCATION "imported_unk${CMAKE_STATIC_LIBRARY_SUFFIX}") add_executable(imported_exe IMPORTED) add_executable(link_imported_exe ../empty.c) target_link_libraries(link_imported_exe PRIVATE imported_lib) add_library(imported_shared_lib SHARED IMPORTED) +set_target_properties(imported_shared_lib PROPERTIES + IMPORTED_LOCATION "imported_shared${CMAKE_SHARED_LIBRARY_SUFFIX}" + IMPORTED_IMPLIB "imported_shared${CMAKE_IMPORT_LIBRARY_SUFFIX}" +) add_executable(link_imported_shared_exe ../empty.c) target_link_libraries(link_imported_shared_exe PRIVATE imported_shared_lib) add_library(imported_static_lib STATIC IMPORTED) +set_target_properties(imported_static_lib PROPERTIES IMPORTED_LOCATION "imported_static${CMAKE_STATIC_LIBRARY_SUFFIX}") add_executable(link_imported_static_exe ../empty.c) target_link_libraries(link_imported_static_exe PRIVATE imported_static_lib) diff --git a/Tests/RunCMake/FileAPI/interface/CMakeLists.txt b/Tests/RunCMake/FileAPI/interface/CMakeLists.txt new file mode 100644 index 0000000..97948c5 --- /dev/null +++ b/Tests/RunCMake/FileAPI/interface/CMakeLists.txt @@ -0,0 +1,3 @@ +project(Interface) +add_library(iface_none INTERFACE) +add_library(iface_srcs INTERFACE ../empty.c) diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt index dbabaa9..a7a231b 100644 --- a/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt +++ b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt @@ -1,4 +1,18 @@ -^CMake Warning \(dev\) in CMakeLists.txt: +^(CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative + paths. Run "cmake --help-policy CMP0070" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + file\(GENERATE\) given relative OUTPUT path: + + relative-output-WARN.txt + + This is not defined behavior unless CMP0070 is set to NEW. For + compatibility with older versions of CMake, the previous undefined behavior + will be used. +This warning is for project developers. Use -Wno-dev to suppress it. ++)+ +CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative paths. Run "cmake --help-policy CMP0070" for policy details. Use the cmake_policy command to set the policy and suppress this warning. diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index 5987417..48fb71c 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -4,6 +4,10 @@ run_cmake(CMP0070-NEW) run_cmake(CMP0070-OLD) run_cmake(CMP0070-WARN) +run_cmake(SourceProperty) +run_cmake(SourceProperty-CMP0070-NEW) +run_cmake(SourceProperty-CMP0070-OLD) + run_cmake(CommandConflict) if(RunCMake_GENERATOR_IS_MULTI_CONFIG) run_cmake(OutputConflict) @@ -29,6 +33,13 @@ foreach(l CXX C) endif() endforeach() +run_cmake(Target) +file(READ "${RunCMake_BINARY_DIR}/Target-build/sub1/output.txt" sub_1) +file(READ "${RunCMake_BINARY_DIR}/Target-build/sub2/output.txt" sub_2) +if(NOT sub_1 MATCHES "first" OR NOT sub_2 MATCHES "second") + message(SEND_ERROR "Wrong target used by TARGET argument! ${sub_1} ${sub_2}") +endif() + set(timeformat "%Y%j%H%M%S") file(REMOVE "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt") diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-result.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-stderr.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-stderr.txt new file mode 100644 index 0000000..2c385c4 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at SourceProperty-CMP0070-NEW.cmake:[0-9]+ \(add_library\): + Cannot find source file: + +.*\/relative-output-NEW\.c + + Tried extensions \.c \.C.* +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW.cmake b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW.cmake new file mode 100644 index 0000000..d2b3e0c --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW.cmake @@ -0,0 +1,8 @@ +enable_language(C) +add_library(foo) + +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT relative-output-NEW.c CONTENT "") +target_sources(foo PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/relative-output-NEW.c" +) diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-result.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt new file mode 100644 index 0000000..fcb53a7 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt @@ -0,0 +1,23 @@ +^CMake Deprecation Warning at SourceProperty-CMP0070-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0070 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at SourceProperty-CMP0070-OLD.cmake:[0-9]+ \(add_library\): + Cannot find source file: + +.*\/relative-output-OLD\.c + + Tried extensions \.c \.C.* +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD.cmake b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD.cmake new file mode 100644 index 0000000..48eae1e --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD.cmake @@ -0,0 +1,8 @@ +enable_language(C) +add_library(foo) + +cmake_policy(SET CMP0070 OLD) +file(GENERATE OUTPUT relative-output-OLD.c CONTENT "") +target_sources(foo PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/relative-output-OLD.c" +) diff --git a/Tests/RunCMake/File_Generate/SourceProperty-stderr.txt b/Tests/RunCMake/File_Generate/SourceProperty-stderr.txt new file mode 100644 index 0000000..47ec651 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at SourceProperty.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0070 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/File_Generate/SourceProperty.cmake b/Tests/RunCMake/File_Generate/SourceProperty.cmake new file mode 100644 index 0000000..231c670 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty.cmake @@ -0,0 +1,14 @@ +enable_language(C) +add_library(SourceProperty) + +cmake_policy(SET CMP0070 OLD) +file(GENERATE OUTPUT relative-output-OLD.c CONTENT "") +target_sources(SourceProperty PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/relative-output-OLD.c" +) + +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT relative-output-NEW.c CONTENT "") +target_sources(SourceProperty PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/relative-output-NEW.c" +) diff --git a/Tests/RunCMake/File_Generate/Target.cmake b/Tests/RunCMake/File_Generate/Target.cmake new file mode 100644 index 0000000..16e8457 --- /dev/null +++ b/Tests/RunCMake/File_Generate/Target.cmake @@ -0,0 +1,2 @@ +add_subdirectory(sub1) +add_subdirectory(sub2) diff --git a/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt b/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt new file mode 100644 index 0000000..34c51a4 --- /dev/null +++ b/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(library IMPORTED STATIC) +set_property(TARGET library PROPERTY COMPILE_DEFINITIONS "first") + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + CONTENT "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>" + TARGET library +) diff --git a/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt b/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt new file mode 100644 index 0000000..09b81ac --- /dev/null +++ b/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(library IMPORTED STATIC) +set_property(TARGET library PROPERTY COMPILE_DEFINITIONS "second") + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + CONTENT "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>" + TARGET library +) diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index dc77915..4e6eef6 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -1,5 +1,10 @@ include(RunCMake) +# Isolate test cases from caller's environment. +set(ENV{CMAKE_PREFIX_PATH} "") +set(ENV{CMAKE_APPBUNDLE_PATH} "") +set(ENV{CMAKE_FRAMEWORK_PATH} "") + run_cmake(PkgConfigDoesNotExist) run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake b/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake index 4ce6b5c..2c7d5bf 100644 --- a/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake +++ b/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake @@ -60,7 +60,10 @@ target_link_libraries(ConsoleApplication CoreLibrary) # No one will ever notice... add_library(CryptoCurrencyMiningLibrary UNKNOWN IMPORTED) +set_target_properties(CryptoCurrencyMiningLibrary PROPERTIES IMPORTED_LOCATION "cryptomining${CMAKE_STATIC_LIBRARY_SUFFIX}") target_link_libraries(ConsoleApplication CryptoCurrencyMiningLibrary) add_custom_target(GenerateManPage COMMAND ${CMAKE_COMMAND} --version) add_dependencies(ConsoleApplication GenerateManPage) + +add_subdirectory(sub_directory_target) diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot index 31d88df..a9e664a 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot @@ -52,4 +52,5 @@ subgraph clusterLegend { "node12" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node12" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node12" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node13" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot index 26f2f64..06cdb75 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot @@ -50,4 +50,5 @@ subgraph clusterLegend { "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot index 26f2f64..06cdb75 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot @@ -50,4 +50,5 @@ subgraph clusterLegend { "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot index db675a8..490450e 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot @@ -46,4 +46,5 @@ subgraph clusterLegend { "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node10" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot index 234ee39..086c849 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot @@ -35,4 +35,5 @@ subgraph clusterLegend { "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary "node6" [ label = "\"-lm\"", shape = septagon ]; + "node7" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot index 6dea88c..350f0f1 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot @@ -43,4 +43,5 @@ subgraph clusterLegend { "node8" -> "node1" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node9" -> "node1" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node10" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot index df3d10a..fd351d0 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot @@ -44,4 +44,5 @@ subgraph clusterLegend { "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot index 8f832a8..39a2a03 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot @@ -48,4 +48,5 @@ subgraph clusterLegend { "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node11" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot index 26f2f64..06cdb75 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot @@ -50,4 +50,5 @@ subgraph clusterLegend { "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot index e127daa..d949d87 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot @@ -44,4 +44,5 @@ subgraph clusterLegend { "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node11" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot index 81199a2..e9b9570 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot @@ -39,4 +39,5 @@ subgraph clusterLegend { "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot index 4f242bb..7db111c 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot @@ -48,4 +48,5 @@ subgraph clusterLegend { "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node11" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot index c664af8..f664c2e 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot @@ -50,4 +50,5 @@ subgraph clusterLegend { "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot index 5579306..58dda6d 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot @@ -50,4 +50,5 @@ subgraph clusterLegend { "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot index 3bf20ec..8b93f7c 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot @@ -50,4 +50,5 @@ subgraph clusterLegend { "point11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "point11" -> "point0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags "point11" -> "point2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "point12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/sub_directory_target/CMakeLists.txt b/Tests/RunCMake/Graphviz/sub_directory_target/CMakeLists.txt new file mode 100644 index 0000000..d84897b --- /dev/null +++ b/Tests/RunCMake/Graphviz/sub_directory_target/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(SubDirectoryTarget test.c) diff --git a/Tests/RunCMake/Graphviz/sub_directory_target/test.c b/Tests/RunCMake/Graphviz/sub_directory_target/test.c new file mode 100644 index 0000000..d123e09 --- /dev/null +++ b/Tests/RunCMake/Graphviz/sub_directory_target/test.c @@ -0,0 +1,4 @@ +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/RunCMake/InterfaceLibrary/ConfigSources.cmake b/Tests/RunCMake/InterfaceLibrary/ConfigSources.cmake new file mode 100644 index 0000000..631a845 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ConfigSources.cmake @@ -0,0 +1,2 @@ +# Test an interface library added to the build system by a per-config source. +add_library(iface INTERFACE $<$<CONFIG:NotAConfig>:${CMAKE_CURRENT_SOURCE_DIR}/iface.c>) diff --git a/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-result.txt b/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-stdout.txt b/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-stdout.txt new file mode 100644 index 0000000..aac9172 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-stdout.txt @@ -0,0 +1 @@ +iface2|Invalid project diff --git a/Tests/RunCMake/InterfaceLibrary/EmptySources.cmake b/Tests/RunCMake/InterfaceLibrary/EmptySources.cmake new file mode 100644 index 0000000..f452394 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/EmptySources.cmake @@ -0,0 +1,8 @@ +# Test an interface library added to the build system by empty SOURCES. +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY SOURCES "") + +# ...but not added by unset SOURCES. +add_library(iface2 INTERFACE) +set_property(TARGET iface2 PROPERTY SOURCES "") +set_property(TARGET iface2 PROPERTY SOURCES) diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build1-check.cmake b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build1-check.cmake new file mode 100644 index 0000000..6500e48 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build1-check.cmake @@ -0,0 +1,4 @@ +if(EXISTS "${RunCMake_TEST_BINARY_DIR}/iface.txt") + set(RunCMake_TEST_FAILED "iface target built as part of 'all'") + return() +endif() diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build2-check.cmake b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build2-check.cmake new file mode 100644 index 0000000..0977c24 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build2-check.cmake @@ -0,0 +1,4 @@ +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/iface.txt") + set(RunCMake_TEST_FAILED "iface target not built") + return() +endif() diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-result.txt b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-stdout.txt b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-stdout.txt new file mode 100644 index 0000000..aac9172 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-stdout.txt @@ -0,0 +1 @@ +iface2|Invalid project diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll.cmake b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll.cmake new file mode 100644 index 0000000..714161d --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll.cmake @@ -0,0 +1,7 @@ +# Test an interface library with a custom command, but excluded from all. +add_custom_command(OUTPUT iface.txt COMMAND ${CMAKE_COMMAND} -E touch iface.txt) +add_library(iface INTERFACE EXCLUDE_FROM_ALL iface.txt) + +# Test that EXCLUDE_FROM_ALL is allowed even if the interface library has +# no sources, and does not cause it to appear in the build system. +add_library(iface2 INTERFACE EXCLUDE_FROM_ALL) diff --git a/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-result.txt b/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-stdout.txt b/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-stdout.txt new file mode 100644 index 0000000..aac9172 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-stdout.txt @@ -0,0 +1 @@ +iface2|Invalid project diff --git a/Tests/RunCMake/InterfaceLibrary/PublicSources.cmake b/Tests/RunCMake/InterfaceLibrary/PublicSources.cmake new file mode 100644 index 0000000..24785bb --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/PublicSources.cmake @@ -0,0 +1,20 @@ +cmake_policy(SET CMP0076 NEW) +enable_language(C) + +# Test that an interface library can have PUBLIC sources. +# This causes the target to appear in the build system +# *and* causes consumers to use the source. +add_library(iface INTERFACE) +target_sources(iface + PUBLIC iface.c + # Private sources do not compile here or propagate. + PRIVATE iface_broken.c + ) + +# Test that an intermediate interface library does not get the +# sources and does not appear in the build system. +add_library(iface2 INTERFACE) +target_link_libraries(iface2 INTERFACE iface) + +add_executable(use_iface use_iface.c) +target_link_libraries(use_iface PRIVATE iface2) diff --git a/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake index 5a6af1d..834b3c8 100644 --- a/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake @@ -3,7 +3,6 @@ include(RunCMake) run_cmake(invalid_name) run_cmake(target_commands) run_cmake(no_shared_libs) -run_cmake(whitelist) run_cmake(invalid_signature) run_cmake(global-interface) run_cmake(genex_link) @@ -11,3 +10,27 @@ run_cmake(add_custom_command-TARGET) run_cmake(IMPORTED_LIBNAME-bad-value) run_cmake(IMPORTED_LIBNAME-non-iface) run_cmake(IMPORTED_LIBNAME-non-imported) + +function(run_WithSources CASE) + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + run_cmake(${CASE}) + set(RunCMake_TEST_NO_CLEAN 1) + foreach(build IN LISTS ARGN) + if(build MATCHES "^([^:]+)$") + run_cmake_command(${CASE}-${CMAKE_MATCH_1} ${CMAKE_COMMAND} --build . --config Debug) + elseif(build MATCHES "^([^:]+):([^:,]+)(,merge)?$") + if(CMAKE_MATCH_3 STREQUAL ",merge") + set(RunCMake_TEST_OUTPUT_MERGE 1) + endif() + run_cmake_command(${CASE}-${CMAKE_MATCH_1} ${CMAKE_COMMAND} --build . --config Debug --target ${CMAKE_MATCH_2}) + endif() + endforeach() +endfunction() + +run_WithSources(ConfigSources "build1:iface") +run_WithSources(EmptySources "build1:iface" "build2:iface2,merge") +run_WithSources(ExcludeFromAll "build1" "build2:iface" "build3:iface2,merge") +run_WithSources(PublicSources "build1" "build2:iface" "build3:iface2,merge") diff --git a/Tests/RunCMake/InterfaceLibrary/iface.c b/Tests/RunCMake/InterfaceLibrary/iface.c new file mode 100644 index 0000000..c7e7372 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/iface.c @@ -0,0 +1,4 @@ +int iface(void) +{ + return 0; +} diff --git a/Tests/RunCMake/InterfaceLibrary/iface_broken.c b/Tests/RunCMake/InterfaceLibrary/iface_broken.c new file mode 100644 index 0000000..4ff7f31 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/iface_broken.c @@ -0,0 +1 @@ +#error This file should not compile diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt b/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt index 6374b33..763f9f8 100644 --- a/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt @@ -1,8 +1,3 @@ -CMake Error at invalid_signature.cmake:2 \(add_library\): - add_library INTERFACE library requires no source arguments. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ CMake Error at invalid_signature.cmake:3 \(add_library\): add_library INTERFACE library specified with conflicting/multiple types. Call Stack \(most recent call first\): @@ -73,16 +68,6 @@ CMake Error at invalid_signature.cmake:16 \(add_library\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Error at invalid_signature.cmake:17 \(add_library\): - add_library INTERFACE library may not be used with EXCLUDE_FROM_ALL. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ -CMake Error at invalid_signature.cmake:18 \(add_library\): - add_library INTERFACE library may not be used with EXCLUDE_FROM_ALL. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ CMake Error at invalid_signature.cmake:20 \(add_library\): add_library GLOBAL option may only be used with IMPORTED libraries. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake b/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake index 4e53534..2a575b5 100644 --- a/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake +++ b/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake @@ -1,5 +1,5 @@ -add_library(iface1 INTERFACE empty.cpp) + add_library(iface3 STATIC INTERFACE) add_library(iface4 STATIC INTERFACE empty.cpp) add_library(iface5 SHARED INTERFACE) @@ -14,7 +14,7 @@ add_library(iface13 INTERFACE UNKNOWN) add_library(iface14 INTERFACE ALIAS) add_library(iface15 ALIAS INTERFACE) add_library(iface16 INTERFACE INTERFACE) -add_library(iface17 INTERFACE EXCLUDE_FROM_ALL) -add_library(iface18 EXCLUDE_FROM_ALL INTERFACE) + + # add_library(iface19 GLOBAL INTERFACE) Tested separately add_library(iface20 INTERFACE GLOBAL) diff --git a/Tests/RunCMake/InterfaceLibrary/use_iface.c b/Tests/RunCMake/InterfaceLibrary/use_iface.c new file mode 100644 index 0000000..66293e4 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/use_iface.c @@ -0,0 +1,6 @@ +extern int iface(void); + +int main(void) +{ + return iface(); +} diff --git a/Tests/RunCMake/InterfaceLibrary/whitelist-stderr.txt b/Tests/RunCMake/InterfaceLibrary/whitelist-stderr.txt deleted file mode 100644 index 577c0cc..0000000 --- a/Tests/RunCMake/InterfaceLibrary/whitelist-stderr.txt +++ /dev/null @@ -1,19 +0,0 @@ -CMake Error at whitelist.cmake:4 \(set_property\): - INTERFACE_LIBRARY targets may only have whitelisted properties. The - property "OUTPUT_NAME" is not allowed. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) - - -CMake Error at whitelist.cmake:5 \(set_property\): - INTERFACE_LIBRARY targets may only have whitelisted properties. The - property "OUTPUT_NAME" is not allowed. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) - - -CMake Error at whitelist.cmake:6 \(get_target_property\): - INTERFACE_LIBRARY targets may only have whitelisted properties. The - property "OUTPUT_NAME" is not allowed. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/InterfaceLibrary/whitelist.cmake b/Tests/RunCMake/InterfaceLibrary/whitelist.cmake deleted file mode 100644 index 0db6375..0000000 --- a/Tests/RunCMake/InterfaceLibrary/whitelist.cmake +++ /dev/null @@ -1,25 +0,0 @@ - -add_library(iface INTERFACE) - -set_property(TARGET iface PROPERTY OUTPUT_NAME output) -set_property(TARGET iface APPEND PROPERTY OUTPUT_NAME append) -get_target_property(outname iface OUTPUT_NAME) - -# Properties starting with `_` are allowed. -set_property(TARGET iface PROPERTY "_custom_property" output) -set_property(TARGET iface APPEND PROPERTY "_custom_property" append) -get_target_property(outname iface "_custom_property") - -# Properties starting with a lowercase letter are allowed. -set_property(TARGET iface PROPERTY "custom_property" output) -set_property(TARGET iface APPEND PROPERTY "custom_property" append) -get_target_property(outname iface "custom_property") - -# PUBLIC_HEADER / PRIVATE_HEADER properties are allowed -set_property(TARGET iface PROPERTY PUBLIC_HEADER foo.h) -set_property(TARGET iface APPEND PROPERTY PUBLIC_HEADER bar.h) -get_target_property(outname iface PUBLIC_HEADER) - -set_property(TARGET iface PROPERTY PRIVATE_HEADER foo.h) -set_property(TARGET iface APPEND PROPERTY PRIVATE_HEADER bar.h) -get_target_property(outname iface PRIVATE_HEADER) diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake index 6b2721c..32aafca 100644 --- a/Tests/RunCMake/Make/RunCMakeTest.cmake +++ b/Tests/RunCMake/Make/RunCMakeTest.cmake @@ -27,12 +27,15 @@ function(run_VerboseBuild) run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first) unset(RunCMake-stdout-file) set(_backup_lang "$ENV{LANG}") + set(_backup_lc_Messages "$ENV{LC_MESSAGES}") if(MAKE_IS_GNU) set(RunCMake-stdout-file VerboseBuild-nowork-gnu-stdout.txt) set(ENV{LANG} "C") + set(ENV{LC_MESSAGES} "C") endif() run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose) set(ENV{LANG} "${_backup_lang}") + set(ENV{LC_MESSAGES} "${_backup_lc_messages}") endfunction() run_VerboseBuild() diff --git a/Tests/RunCMake/VS10Project/InterfaceLibSources-check.cmake b/Tests/RunCMake/VS10Project/InterfaceLibSources-check.cmake new file mode 100644 index 0000000..bcdc101 --- /dev/null +++ b/Tests/RunCMake/VS10Project/InterfaceLibSources-check.cmake @@ -0,0 +1,25 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/iface.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(found_iface_h 0) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "<([A-Za-z0-9_]+) +Include=.*iface\\.h") + set(rule "${CMAKE_MATCH_1}") + if(NOT rule STREQUAL "None") + set(RunCMake_TEST_FAILED "iface.h referenced as ${rule} instead of None in\n ${vcProjectFile}") + return() + endif() + if(found_iface_h) + set(RunCMake_TEST_FAILED "iface.h referenced multiple times in\n ${vcProjectFile}") + return() + endif() + set(found_iface_h 1) + endif() +endforeach() +if(NOT found_iface_h) + set(RunCMake_TEST_FAILED "iface.h not referenced in\n ${vcProjectFile}") +endif() diff --git a/Tests/RunCMake/VS10Project/InterfaceLibSources.cmake b/Tests/RunCMake/VS10Project/InterfaceLibSources.cmake new file mode 100644 index 0000000..3672be1 --- /dev/null +++ b/Tests/RunCMake/VS10Project/InterfaceLibSources.cmake @@ -0,0 +1 @@ +add_library(iface INTERFACE iface.h) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 93ef603..e9f251a 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -6,6 +6,7 @@ cmake_policy(SET CMP0054 NEW) run_cmake(VsCsharpSourceGroup) run_cmake(VsCSharpCompilerOpts) run_cmake(ExplicitCMakeLists) +run_cmake(InterfaceLibSources) run_cmake(RuntimeLibrary) run_cmake(SourceGroupCMakeLists) run_cmake(SourceGroupTreeCMakeLists) diff --git a/Tests/RunCMake/VS10Project/iface.h b/Tests/RunCMake/VS10Project/iface.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/VS10Project/iface.h diff --git a/Tests/RunCMake/Win32GenEx/CMakeLists.txt b/Tests/RunCMake/Win32GenEx/CMakeLists.txt new file mode 100644 index 0000000..b646c4a --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Win32GenEx/RunCMakeTest.cmake b/Tests/RunCMake/Win32GenEx/RunCMakeTest.cmake new file mode 100644 index 0000000..d5529b0 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/RunCMakeTest.cmake @@ -0,0 +1,28 @@ +include(RunCMake) + +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Win32GenEx-build) + run_cmake(Win32GenEx) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Win32GenEx-debug-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Debug) + run_cmake_command(Win32GenEx-release-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Release) + unset(RunCMake_TEST_NO_CLEAN) +else() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Win32GenEx-debug-build) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + run_cmake(Win32GenEx-debug) + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Win32GenEx-debug-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}) + unset(RunCMake_TEST_NO_CLEAN) + + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Win32GenEx-release-build) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + run_cmake(Win32GenEx-release) + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Win32GenEx-release-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}) + unset(RunCMake_TEST_NO_CLEAN) +endif() diff --git a/Tests/RunCMake/Win32GenEx/Win32GenEx-debug.cmake b/Tests/RunCMake/Win32GenEx/Win32GenEx-debug.cmake new file mode 100644 index 0000000..74c5bd8 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/Win32GenEx-debug.cmake @@ -0,0 +1 @@ +include(Win32GenEx.cmake) diff --git a/Tests/RunCMake/Win32GenEx/Win32GenEx-release.cmake b/Tests/RunCMake/Win32GenEx/Win32GenEx-release.cmake new file mode 100644 index 0000000..74c5bd8 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/Win32GenEx-release.cmake @@ -0,0 +1 @@ +include(Win32GenEx.cmake) diff --git a/Tests/RunCMake/Win32GenEx/Win32GenEx.cmake b/Tests/RunCMake/Win32GenEx/Win32GenEx.cmake new file mode 100644 index 0000000..80f8b80 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/Win32GenEx.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_executable(Win32GenEx main.c) +set_target_properties(Win32GenEx PROPERTIES + WIN32_EXECUTABLE $<CONFIG:Release> + ) +target_compile_definitions(Win32GenEx PRIVATE $<$<CONFIG:Release>:USE_WIN32_MAIN>) diff --git a/Tests/RunCMake/Win32GenEx/main.c b/Tests/RunCMake/Win32GenEx/main.c new file mode 100644 index 0000000..1cf9f81 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/main.c @@ -0,0 +1,14 @@ +#ifdef USE_WIN32_MAIN +# include <windows.h> + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nShowCmd) +{ + return 0; +} +#else +int main(void) +{ + return 0; +} +#endif diff --git a/Tests/RunCMake/XcodeProject/InterfaceLibSources-check.cmake b/Tests/RunCMake/XcodeProject/InterfaceLibSources-check.cmake new file mode 100644 index 0000000..613951a --- /dev/null +++ b/Tests/RunCMake/XcodeProject/InterfaceLibSources-check.cmake @@ -0,0 +1,16 @@ +set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/InterfaceLibSources.xcodeproj/project.pbxproj") +if(NOT EXISTS "${xcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.") + return() +endif() + +set(found_iface_h 0) +file(STRINGS "${xcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "PBXFileReference.*explicitFileType.*sourcecode\\.c\\.h.*iface\\.h") + set(found_iface_h 1) + endif() +endforeach() +if(NOT found_iface_h) + set(RunCMake_TEST_FAILED "iface.h not referenced in\n ${xcProjectFile}") +endif() diff --git a/Tests/RunCMake/XcodeProject/InterfaceLibSources.cmake b/Tests/RunCMake/XcodeProject/InterfaceLibSources.cmake new file mode 100644 index 0000000..3672be1 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/InterfaceLibSources.cmake @@ -0,0 +1 @@ +add_library(iface INTERFACE iface.h) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 342dbbc..ed300bb 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -2,6 +2,7 @@ include(RunCMake) run_cmake(ExplicitCMakeLists) run_cmake(ImplicitCMakeLists) +run_cmake(InterfaceLibSources) run_cmake(XcodeFileType) run_cmake(XcodeAttributeLocation) @@ -309,10 +310,10 @@ endif() if(XCODE_VERSION VERSION_GREATER_EQUAL 8) function(XcodeRemoveExcessiveISystemSDK SDK) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeRemoveExcessiveISystemSDK-${SDK}-build) - set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS") + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_OSX_SYSROOT=${SDK}") run_cmake(XcodeRemoveExcessiveISystem) set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(XcodeRemoveExcessiveISystemSDK-${SDK}-build ${CMAKE_COMMAND} --build . -- -sdk ${SDK}) + run_cmake_command(XcodeRemoveExcessiveISystemSDK-${SDK}-build ${CMAKE_COMMAND} --build .) endfunction() XcodeRemoveExcessiveISystemSDK(iphoneos) diff --git a/Tests/RunCMake/XcodeProject/iface.h b/Tests/RunCMake/XcodeProject/iface.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/iface.h diff --git a/Tests/RunCMake/XcodeProject/main.cpp b/Tests/RunCMake/XcodeProject/main.cpp index c94753f..f8b643a 100644 --- a/Tests/RunCMake/XcodeProject/main.cpp +++ b/Tests/RunCMake/XcodeProject/main.cpp @@ -1,4 +1,4 @@ -int main(int argc, const char* argv[]) +int main() { return 0; } diff --git a/Tests/RunCMake/XcodeProject/main.m b/Tests/RunCMake/XcodeProject/main.m index 6dc190a..3e70e50 100644 --- a/Tests/RunCMake/XcodeProject/main.m +++ b/Tests/RunCMake/XcodeProject/main.m @@ -1,3 +1,3 @@ -int main(int argc, const char * argv[]) { +int main(void) { return 1; } diff --git a/Tests/RunCMake/add_test/CMP0110-Common-AlphaNumeric.cmake b/Tests/RunCMake/add_test/CMP0110-Common-AlphaNumeric.cmake new file mode 100644 index 0000000..c2ab433 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-AlphaNumeric.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "abcdefghijklmnopqrstuvwxyz0123456789") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-BracketArgument.cmake b/Tests/RunCMake/add_test/CMP0110-Common-BracketArgument.cmake new file mode 100644 index 0000000..77cd3eb --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-BracketArgument.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "[=[InBracketBeforeSemi;InBracketAfterSemi]=]") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-EscapedSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-Common-EscapedSpecialChars.cmake new file mode 100644 index 0000000..268b622 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-EscapedSpecialChars.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME \(\)\ \# ) +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-FormerInvalidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-Common-FormerInvalidSpecialChars.cmake new file mode 100644 index 0000000..65bca10 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-FormerInvalidSpecialChars.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "$[] #;\t\n\"\\") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-LeadingAndTrailingWhitespace.cmake b/Tests/RunCMake/add_test/CMP0110-Common-LeadingAndTrailingWhitespace.cmake new file mode 100644 index 0000000..ec90e13 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-LeadingAndTrailingWhitespace.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME " SurroundedByWhitespace ") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-OtherSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-Common-OtherSpecialChars.cmake new file mode 100644 index 0000000..f74c3b5 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-OtherSpecialChars.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "!§%&/ü:*😤~") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-Quote.cmake b/Tests/RunCMake/add_test/CMP0110-Common-Quote.cmake new file mode 100644 index 0000000..a1ddb66 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-Quote.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "BeforeQuote\"\"AfterEscapedQuote") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-Semicolon.cmake b/Tests/RunCMake/add_test/CMP0110-Common-Semicolon.cmake new file mode 100644 index 0000000..11fd4fb --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-Semicolon.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "BeforeSemi;AfterSemi") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-Space.cmake b/Tests/RunCMake/add_test/CMP0110-Common-Space.cmake new file mode 100644 index 0000000..38dd28e --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-Space.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "BeforeSpace AfterSpace") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-ValidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-Common-ValidSpecialChars.cmake new file mode 100644 index 0000000..bfd082b --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-ValidSpecialChars.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "abc_.+-012") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common.cmake b/Tests/RunCMake/add_test/CMP0110-Common.cmake new file mode 100644 index 0000000..915d171 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common.cmake @@ -0,0 +1,9 @@ +include(CTest) +add_test( + NAME "${TEST_NAME}" + COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/CMP0110-Test.cmake" +) +set_property( + TEST "${TEST_NAME}" + PROPERTY ENVIRONMENT CMAKE_add_test_ENVVAR=1 +) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric-ctest-stdout.txt new file mode 100644 index 0000000..ed939bf --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric.cmake new file mode 100644 index 0000000..7ea7042 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-AlphaNumeric.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument-ctest-stdout.txt new file mode 100644 index 0000000..7364d56 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \[=\[InBracketBeforeSemi;InBracketAfterSemi\]=\] \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument.cmake new file mode 100644 index 0000000..baef07c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-BracketArgument.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..80435b6 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \(\) # \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars.cmake new file mode 100644 index 0000000..c9b06bd --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-EscapedSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..5ad8694 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \$\[\] .+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars.cmake new file mode 100644 index 0000000..86ddf14 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-FormerInvalidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialCharsMC.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialCharsMC.cmake new file mode 100644 index 0000000..f9b556a --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialCharsMC.cmake @@ -0,0 +1 @@ +include(CMP0110-NEW-FormerInvalidSpecialChars.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-GeneratorExpressionSyntax.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-GeneratorExpressionSyntax.cmake new file mode 100644 index 0000000..0790536 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-GeneratorExpressionSyntax.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-GeneratorExpressionSyntax.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace-ctest-stdout.txt new file mode 100644 index 0000000..78379cd --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: [ ]SurroundedByWhitespace[ ] \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace.cmake new file mode 100644 index 0000000..2d636a8 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-LeadingAndTrailingWhitespace.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..8ee3ea9 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: !§%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars.cmake new file mode 100644 index 0000000..d77a6ce --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-OtherSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-Quote-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-Quote-ctest-stdout.txt new file mode 100644 index 0000000..23dafd4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-Quote-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeQuote""AfterEscapedQuote \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-Quote.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-Quote.cmake new file mode 100644 index 0000000..2e7a6e1 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-Quote.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-Quote.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-Semicolon.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-Semicolon.cmake new file mode 100644 index 0000000..1c6e1b1 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-Semicolon.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-Semicolon.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-Space.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-Space.cmake new file mode 100644 index 0000000..38afb85 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-Space.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-Space.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..ae1a0b1 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars.cmake new file mode 100644 index 0000000..62bb638 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-ValidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric-ctest-stdout.txt new file mode 100644 index 0000000..ed939bf --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric.cmake new file mode 100644 index 0000000..bf4e82b --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-AlphaNumeric.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument-ctest-stdout.txt new file mode 100644 index 0000000..093f5d4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: InBracketBeforeSemi;InBracketAfterSemi \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument.cmake new file mode 100644 index 0000000..05dfeb4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-BracketArgument.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt new file mode 100644 index 0000000..296e426 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at CTestTestfile.cmake:[0-9]+: + Parse error\. Function missing ending "\)"\. End of file reached\. + + +Errors while running CTest diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars.cmake new file mode 100644 index 0000000..1f0c99f --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-EscapedSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stderr.txt new file mode 100644 index 0000000..c656b4c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..d3b0fac --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \$\[\] \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars.cmake new file mode 100644 index 0000000..883c5b6 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-FormerInvalidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-stderr.txt new file mode 100644 index 0000000..06ad927 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-stderr.txt @@ -0,0 +1,3 @@ +CMake Error at CTestTestfile.cmake:[0-9]+: + Parse error. Function missing ending "\)". Instead found unterminated + string with text "\\ NOT_AVAILABLE\) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC.cmake new file mode 100644 index 0000000..47e03bc --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC.cmake @@ -0,0 +1 @@ +include(CMP0110-OLD-FormerInvalidSpecialChars.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-GeneratorExpressionSyntax.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-GeneratorExpressionSyntax.cmake new file mode 100644 index 0000000..7ee6b50 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-GeneratorExpressionSyntax.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-GeneratorExpressionSyntax.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace-ctest-stdout.txt new file mode 100644 index 0000000..870483e --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: SurroundedByWhitespace \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace.cmake new file mode 100644 index 0000000..a20d211 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-LeadingAndTrailingWhitespace.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..8ee3ea9 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: !§%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars.cmake new file mode 100644 index 0000000..0e88183 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-OtherSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Quote-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Quote-ctest-stdout.txt new file mode 100644 index 0000000..23dafd4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Quote-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeQuote""AfterEscapedQuote \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Quote.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-Quote.cmake new file mode 100644 index 0000000..c910a7c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Quote.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-Quote.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stderr.txt new file mode 100644 index 0000000..0d43768 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: AfterSemi diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stdout.txt new file mode 100644 index 0000000..0a6ebed --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeSemi \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon.cmake new file mode 100644 index 0000000..283aeed --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-Semicolon.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stderr.txt new file mode 100644 index 0000000..2ded1d4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: AfterSpace diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stdout.txt new file mode 100644 index 0000000..059c625 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeSpace \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Space.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-Space.cmake new file mode 100644 index 0000000..46f7c26 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Space.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-Space.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..ae1a0b1 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars.cmake new file mode 100644 index 0000000..ffc6462 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-ValidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Test.cmake b/Tests/RunCMake/add_test/CMP0110-Test.cmake new file mode 100644 index 0000000..3f1dfad --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Test.cmake @@ -0,0 +1,3 @@ +if(NOT DEFINED ENV{CMAKE_add_test_ENVVAR}) + message(FATAL_ERROR "Setting property on test did not succeed!") +endif() diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric-ctest-stdout.txt new file mode 100644 index 0000000..ed939bf --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric.cmake new file mode 100644 index 0000000..d2af2aa --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-AlphaNumeric.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-ctest-stdout.txt new file mode 100644 index 0000000..093f5d4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: InBracketBeforeSemi;InBracketAfterSemi \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-stderr.txt new file mode 100644 index 0000000..19e60c1 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `\[=\[InBracketBeforeSemi;InBracketAfterSemi\]=\]´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument.cmake new file mode 100644 index 0000000..7887658 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-BracketArgument.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt new file mode 100644 index 0000000..296e426 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at CTestTestfile.cmake:[0-9]+: + Parse error\. Function missing ending "\)"\. End of file reached\. + + +Errors while running CTest diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-stderr.txt new file mode 100644 index 0000000..057f2d6 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `\(\) #´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars.cmake new file mode 100644 index 0000000..ca27462 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-EscapedSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stderr.txt new file mode 100644 index 0000000..c656b4c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..d3b0fac --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \$\[\] \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-stderr.txt new file mode 100644 index 0000000..4f20ab9 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `\$\[\] #;[ ] + + "\\´ + +This warning is for project developers\. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars.cmake new file mode 100644 index 0000000..3b689c2 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-FormerInvalidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-stderr.txt new file mode 100644 index 0000000..06ad927 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-stderr.txt @@ -0,0 +1,3 @@ +CMake Error at CTestTestfile.cmake:[0-9]+: + Parse error. Function missing ending "\)". Instead found unterminated + string with text "\\ NOT_AVAILABLE\) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-stderr.txt new file mode 100644 index 0000000..4f20ab9 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `\$\[\] #;[ ] + + "\\´ + +This warning is for project developers\. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC.cmake new file mode 100644 index 0000000..f77ff5c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC.cmake @@ -0,0 +1 @@ +include(CMP0110-WARN-FormerInvalidSpecialChars.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-GeneratorExpressionSyntax.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-GeneratorExpressionSyntax.cmake new file mode 100644 index 0000000..77c9ed2 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-GeneratorExpressionSyntax.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-GeneratorExpressionSyntax.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-ctest-stdout.txt new file mode 100644 index 0000000..870483e --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: SurroundedByWhitespace \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-stderr.txt new file mode 100644 index 0000000..a392fed --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + ` SurroundedByWhitespace ´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace.cmake new file mode 100644 index 0000000..322bb4a --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-LeadingAndTrailingWhitespace.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..8ee3ea9 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: !§%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars.cmake new file mode 100644 index 0000000..19fa6e6 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-OtherSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Quote-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Quote-ctest-stdout.txt new file mode 100644 index 0000000..23dafd4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Quote-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeQuote""AfterEscapedQuote \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Quote-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Quote-stderr.txt new file mode 100644 index 0000000..39f3a92 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Quote-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `BeforeQuote""AfterEscapedQuote´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Quote.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-Quote.cmake new file mode 100644 index 0000000..33aaad0 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Quote.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-Quote.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stderr.txt new file mode 100644 index 0000000..0d43768 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: AfterSemi diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stdout.txt new file mode 100644 index 0000000..0a6ebed --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeSemi \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-stderr.txt new file mode 100644 index 0000000..5101618 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `BeforeSemi;AfterSemi´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon.cmake new file mode 100644 index 0000000..c5da394 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-Semicolon.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stderr.txt new file mode 100644 index 0000000..2ded1d4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: AfterSpace diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stdout.txt new file mode 100644 index 0000000..059c625 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeSpace \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Space-stderr.txt new file mode 100644 index 0000000..862eaa2 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `BeforeSpace AfterSpace´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-Space.cmake new file mode 100644 index 0000000..1f3234c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-Space.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars-ctest-stdout.txt new file mode 100644 index 0000000..ae1a0b1 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars.cmake new file mode 100644 index 0000000..687c899 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-ValidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMakeLists.txt b/Tests/RunCMake/add_test/CMakeLists.txt new file mode 100644 index 0000000..ee8fc29 --- /dev/null +++ b/Tests/RunCMake/add_test/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/add_test/RunCMakeTest.cmake b/Tests/RunCMake/add_test/RunCMakeTest.cmake new file mode 100644 index 0000000..bf6cbff --- /dev/null +++ b/Tests/RunCMake/add_test/RunCMakeTest.cmake @@ -0,0 +1,35 @@ +include(RunCMake) + +set(ENV{CTEST_OUTPUT_ON_FAILURE} 1) + +function(run_case CASE_NAME) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0110-${CASE_NAME}-build) + run_cmake(CMP0110-${CASE_NAME}) + # Run ctest on the generated CTestTestfile.cmake. + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(CMP0110-${CASE_NAME}-ctest ${CMAKE_CTEST_COMMAND} -C Debug) +endfunction() + +set(cases + AlphaNumeric + ValidSpecialChars + OtherSpecialChars + EscapedSpecialChars + Space + LeadingAndTrailingWhitespace + Semicolon + Quote + BracketArgument + ) + +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + list(APPEND cases FormerInvalidSpecialCharsMC) +else() + list(APPEND cases FormerInvalidSpecialChars) +endif() + +foreach(case IN LISTS cases) + run_case(WARN-${case}) + run_case(OLD-${case}) + run_case(NEW-${case}) +endforeach() diff --git a/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake index bab537e..d6ddfae 100644 --- a/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake +++ b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake @@ -3,7 +3,8 @@ set(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1) set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") add_library(imported SHARED IMPORTED) set_target_properties(imported PROPERTIES - IMPORTED_LOCATION "imported" + IMPORTED_LOCATION "imported${CMAKE_SHARED_LIBRARY_SUFFIX}" + IMPORTED_IMPLIB "imported${CMAKE_IMPORT_LIBRARY_SUFFIX}" IMPORTED_LINK_DEPENDENT_LIBRARIES "/path/to/libSharedDep.so" ) add_executable(empty empty.c) diff --git a/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake index f52fa30..608f47b 100644 --- a/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake +++ b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake @@ -1,4 +1,5 @@ enable_language(C) add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL) +set_target_properties(UnknownImportedGlobal PROPERTIES IMPORTED_LOCATION "unknown.${CMAKE_SHARED_LIBRARY_SUFFIX}") add_library(mylib empty.c) target_link_libraries(mylib UnknownImportedGlobal) diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index 7046fab..aee3338 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -101,6 +101,15 @@ add_test(NAME UseSWIG.MultiplePython COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) +add_test(NAME UseSWIG.MultipleFiles COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultipleFiles" + "${CMake_BINARY_DIR}/Tests/UseSWIG/MultipleFiles" + ${build_generator_args} + --build-project TestMultipleFiles + --build-options ${build_options} + ) add_test(NAME UseSWIG.ModuleVersion2 COMMAND diff --git a/Tests/UseSWIG/MultipleFiles/CMakeLists.txt b/Tests/UseSWIG/MultipleFiles/CMakeLists.txt new file mode 100644 index 0000000..bf3d946 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.18) + +project(TestMultipleFiles CXX) + +find_package(SWIG REQUIRED) +include(UseSWIG) + +unset(SWIG_LANG_TYPE) +unset(SWIG_LANG_INCLUDE_DIRECTORIES) +unset(SWIG_LANG_DEFINITIONS) +unset(SWIG_LANG_OPTIONS) +unset(SWIG_LANG_LIBRARIES) + +find_package(Python3 REQUIRED COMPONENTS Development) + +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/add.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/add.i" PROPERTY SWIG_MODULE_NAME _add) +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" PROPERTY SWIG_MODULE_NAME _sub) + + +swig_add_library(example + LANGUAGE python + TYPE MODULE + SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/add.i" + "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" + "${CMAKE_CURRENT_SOURCE_DIR}/add.cxx" + "${CMAKE_CURRENT_SOURCE_DIR}/sub.cxx") +target_include_directories(example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") +target_link_libraries(example PRIVATE Python3::Module) diff --git a/Tests/UseSWIG/MultipleFiles/add.cxx b/Tests/UseSWIG/MultipleFiles/add.cxx new file mode 100644 index 0000000..a4dcca3 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/add.cxx @@ -0,0 +1,6 @@ +#include "add.h" + +int add(int a, int b) +{ + return a + b; +} diff --git a/Tests/UseSWIG/MultipleFiles/add.h b/Tests/UseSWIG/MultipleFiles/add.h new file mode 100644 index 0000000..6295ab9 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/add.h @@ -0,0 +1 @@ +int add(int a, int b); diff --git a/Tests/UseSWIG/MultipleFiles/add.i b/Tests/UseSWIG/MultipleFiles/add.i new file mode 100644 index 0000000..2046397 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/add.i @@ -0,0 +1,4 @@ +%{ +#include "add.h" +%} +%include "add.h" diff --git a/Tests/UseSWIG/MultipleFiles/sub.cxx b/Tests/UseSWIG/MultipleFiles/sub.cxx new file mode 100644 index 0000000..d6874ef --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/sub.cxx @@ -0,0 +1,6 @@ +#include "sub.h" + +int sub(int a, int b) +{ + return a - b; +} diff --git a/Tests/UseSWIG/MultipleFiles/sub.h b/Tests/UseSWIG/MultipleFiles/sub.h new file mode 100644 index 0000000..de77111 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/sub.h @@ -0,0 +1 @@ +int sub(int a, int b); diff --git a/Tests/UseSWIG/MultipleFiles/sub.i b/Tests/UseSWIG/MultipleFiles/sub.i new file mode 100644 index 0000000..fc70f10 --- /dev/null +++ b/Tests/UseSWIG/MultipleFiles/sub.i @@ -0,0 +1,5 @@ +%{ +#include "sub.h" +%} + +%include "sub.h" diff --git a/Utilities/Scripts/update-curl.bash b/Utilities/Scripts/update-curl.bash index 67e2728..94a42e9 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@cool.haxx.se>" readonly subtree="Utilities/cmcurl" readonly repo="https://github.com/curl/curl.git" -readonly tag="curl-7_71_1" +readonly tag="curl-7_72_0" readonly shortlog=false readonly paths=" CMake/* diff --git a/Utilities/cmcurl/CMake/FindZstd.cmake b/Utilities/cmcurl/CMake/FindZstd.cmake new file mode 100644 index 0000000..44c741a --- /dev/null +++ b/Utilities/cmcurl/CMake/FindZstd.cmake @@ -0,0 +1,69 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 1998 - 2020, 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 +# are also available at https://curl.haxx.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +########################################################################### + +#[=======================================================================[.rst: +FindZstd +---------- + +Find the zstd library + +Result Variables +^^^^^^^^^^^^^^^^ + +``Zstd_FOUND`` + System has zstd +``Zstd_INCLUDE_DIRS`` + The zstd include directories. +``Zstd_LIBRARIES`` + The libraries needed to use zstd +#]=======================================================================] + +if(UNIX) + find_package(PkgConfig QUIET) + pkg_search_module(PC_Zstd libzstd) +endif() + +find_path(Zstd_INCLUDE_DIR zstd.h + HINTS + ${PC_Zstd_INCLUDEDIR} + ${PC_Zstd_INCLUDE_DIRS} +) + +find_library(Zstd_LIBRARY NAMES zstd + HINTS + ${PC_Zstd_LIBDIR} + ${PC_Zstd_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Zstd + REQUIRED_VARS + Zstd_LIBRARY + Zstd_INCLUDE_DIR +) + +if(Zstd_FOUND) + set(Zstd_LIBRARIES ${Zstd_LIBRARY}) + set(Zstd_INCLUDE_DIRS ${Zstd_INCLUDE_DIR}) +endif() + +mark_as_advanced(Zstd_INCLUDE_DIRS Zstd_LIBRARIES) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index d327f55..4821656 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -7,6 +7,7 @@ set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi") set(CMAKE_USE_LIBSSH2 OFF CACHE INTERNAL "Disable curl libssh2") set(CMAKE_USE_LIBSSH OFF) set(CMAKE_USE_OPENLDAP OFF CACHE INTERNAL "No curl OpenLDAP") +set(CURL_BROTLI OFF) set(CURL_DISABLE_COOKIES OFF CACHE INTERNAL "Do not disable curl cookie support") set(CURL_DISABLE_CRYPTO_AUTH OFF CACHE INTERNAL "Do not disable curl crypto auth") set(CURL_DISABLE_DICT ON CACHE INTERNAL "Disable curl dict protocol?") @@ -29,6 +30,7 @@ set(CURL_HIDDEN_SYMBOLS OFF CACHE INTERNAL "No curl hidden symbols") set(CURL_LTO OFF CACHE INTERNAL "Turn on compiler Link Time Optimizations") set(CURL_STATIC_CRT OFF CACHE INTERNAL "Set to ON to build libcurl with static CRT on Windows (/MT).") set(CURL_WERROR OFF CACHE INTERNAL "Turn compiler warnings into errors") +set(CURL_ZSTD OFF) set(DISABLED_THREADSAFE OFF CACHE INTERNAL "Curl can use thread-safe functions") set(ENABLE_ARES OFF CACHE INTERNAL "No curl c-ares support") set(ENABLE_ALT_SVC OFF) @@ -47,7 +49,8 @@ set(USE_QUICHE OFF) set(USE_WIN32_LDAP OFF CACHE INTERNAL "No curl Windows LDAP") if(CMAKE_USE_OPENSSL) elseif(WIN32) - set(CMAKE_USE_WINSSL ON CACHE INTERNAL "enable Windows native SSL/TLS") + unset(CMAKE_USE_WINSSL CACHE) + set(CMAKE_USE_SCHANNEL ON) set(CURL_WINDOWS_SSPI ON CACHE INTERNAL "Use windows libraries to allow NTLM authentication without openssl") elseif(APPLE) # Use OS X SSL/TLS native implementation if available on target version. @@ -183,12 +186,15 @@ if(WIN32) set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string") if(CURL_TARGET_WINDOWS_VERSION) add_definitions(-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}) + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}") elseif(ENABLE_INET_PTON) # _WIN32_WINNT_VISTA (0x0600) add_definitions(-D_WIN32_WINNT=0x0600) + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0600") else() # _WIN32_WINNT_WINXP (0x0501) add_definitions(-D_WIN32_WINNT=0x0501) + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0501") endif() endif() endif() @@ -205,7 +211,7 @@ option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OF if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) if(PICKY_COMPILER) - foreach(_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -Wdouble-promotion -Wno-system-headers -Wno-pedantic-ms-format) + foreach(_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion) # surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new # test result in. string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname) @@ -214,6 +220,15 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}") endif() endforeach() + foreach(_CCOPT long-long multichar format-nonliteral sign-conversion system-headers pedantic-ms-format) + # GCC only warns about unknown -Wno- options if there are also other diagnostic messages, + # so test for the positive form instead + string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname) + check_c_compiler_flag("-W${_CCOPT}" ${_optvarname}) + if(${_optvarname}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-${_CCOPT}") + endif() + endforeach() endif() endif() @@ -322,8 +337,10 @@ if(ENABLE_IPV6 AND NOT WIN32) endif() if(0) # This code not needed for building within CMake. -# Required for building manual, docs, tests -curl_nroff_check() +if(USE_MANUAL) + #nroff is currently only used when USE_MANUAL is set, so we can prevent the warning of no *NROFF if USE_MANUAL is OFF (or not defined), by not even looking for NROFF.. + curl_nroff_check() +endif() find_package(Perl) cmake_dependent_option(ENABLE_MANUAL "to provide the built-in manual" @@ -416,14 +433,17 @@ endif() # check SSL libraries # TODO support GnuTLS +if(CMAKE_USE_WINSSL) + message(FATAL_ERROR "The cmake option CMAKE_USE_WINSSL was renamed to CMAKE_USE_SCHANNEL.") +endif() if(APPLE) option(CMAKE_USE_SECTRANSP "enable Apple OS native SSL/TLS" OFF) endif() if(WIN32) - option(CMAKE_USE_WINSSL "enable Windows native SSL/TLS" OFF) + option(CMAKE_USE_SCHANNEL "enable Windows native SSL/TLS" OFF) cmake_dependent_option(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without openssl" ON - CMAKE_USE_WINSSL OFF) + CMAKE_USE_SCHANNEL OFF) endif() option(CMAKE_USE_MBEDTLS "Enable mbedTLS for SSL/TLS" OFF) option(CMAKE_USE_BEARSSL "Enable BearSSL for SSL/TLS" OFF) @@ -431,12 +451,12 @@ option(CMAKE_USE_NSS "Enable NSS for SSL/TLS" OFF) option(CMAKE_USE_WOLFSSL "enable wolfSSL for SSL/TLS" OFF) set(openssl_default ON) -if(WIN32 OR CMAKE_USE_SECTRANSP OR CMAKE_USE_WINSSL OR CMAKE_USE_MBEDTLS OR CMAKE_USE_NSS OR CMAKE_USE_WOLFSSL) +if(WIN32 OR CMAKE_USE_SECTRANSP OR CMAKE_USE_SCHANNEL OR CMAKE_USE_MBEDTLS OR CMAKE_USE_NSS OR CMAKE_USE_WOLFSSL) set(openssl_default OFF) endif() count_true(enabled_ssl_options_count - CMAKE_USE_WINSSL + CMAKE_USE_SCHANNEL CMAKE_USE_SECTRANSP CMAKE_USE_OPENSSL CMAKE_USE_MBEDTLS @@ -448,10 +468,10 @@ if(enabled_ssl_options_count GREATER "1") set(CURL_WITH_MULTI_SSL ON) endif() -if(CMAKE_USE_WINSSL) +if(CMAKE_USE_SCHANNEL) set(SSL_ENABLED ON) set(USE_SCHANNEL ON) # Windows native SSL/TLS support - set(USE_WINDOWS_SSPI ON) # CMAKE_USE_WINSSL implies CURL_WINDOWS_SSPI + set(USE_WINDOWS_SSPI ON) # CMAKE_USE_SCHANNEL implies CURL_WINDOWS_SSPI list(APPEND CURL_LIBS "crypt32") endif() if(CURL_WINDOWS_SSPI) @@ -774,6 +794,22 @@ if(CURL_BROTLI) endif() endif() +option(CURL_ZSTD "Set to ON to enable building curl with zstd support." OFF) +set(HAVE_ZSTD OFF) +if(CURL_ZSTD) + find_package(Zstd REQUIRED) + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${Zstd_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES ${Zstd_LIBRARIES}) + check_symbol_exists(ZSTD_createDStream "zstd.h" HAVE_ZSTD_CREATEDSTREAM) + cmake_pop_check_state() + if(Zstd_FOUND AND HAVE_ZSTD_CREATEDSTREAM) + set(HAVE_ZSTD ON) + list(APPEND CURL_LIBS ${Zstd_LIBRARIES}) + include_directories(${Zstd_INCLUDE_DIRS}) + endif() +endif() + #libSSH2 option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON) mark_as_advanced(CMAKE_USE_LIBSSH2) @@ -1459,11 +1495,13 @@ _add_if("SSL" SSL_ENABLED) _add_if("IPv6" ENABLE_IPV6) _add_if("unix-sockets" USE_UNIX_SOCKETS) _add_if("libz" HAVE_LIBZ) +_add_if("brotli" HAVE_BROTLI) +_add_if("zstd" HAVE_ZSTD) _add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX OR USE_THREADS_WIN32) _add_if("IDN" HAVE_LIBIDN2) _add_if("Largefile" (CURL_SIZEOF_CURL_OFF_T GREATER 4) AND ((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES)) -# TODO SSP1 (WinSSL) check is missing +# TODO SSP1 (Schannel) check is missing _add_if("SSPI" USE_WINDOWS_SSPI) _add_if("GSS-API" HAVE_GSSAPI) _add_if("alt-svc" ENABLE_ALT_SVC) @@ -1525,7 +1563,7 @@ message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}") # Clear list and collect SSL backends set(_items) -_add_if("WinSSL" SSL_ENABLED AND USE_WINDOWS_SSPI) +_add_if("Schannel" SSL_ENABLED AND USE_WINDOWS_SSPI) _add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL) _add_if("Secure Transport" SSL_ENABLED AND USE_SECTRANSP) _add_if("mbedTLS" SSL_ENABLED AND USE_MBEDTLS) diff --git a/Utilities/cmcurl/include/curl/curl.h b/Utilities/cmcurl/include/curl/curl.h index 194b578..e8e3ed1 100644 --- a/Utilities/cmcurl/include/curl/curl.h +++ b/Utilities/cmcurl/include/curl/curl.h @@ -2634,10 +2634,6 @@ typedef enum { CURLINFO_PROXY_SSL_VERIFYRESULT = CURLINFO_LONG + 47, CURLINFO_PROTOCOL = CURLINFO_LONG + 48, CURLINFO_SCHEME = CURLINFO_STRING + 49, - /* Fill in new entries below here! */ - - /* Preferably these would be defined conditionally based on the - sizeof curl_off_t being 64-bits */ CURLINFO_TOTAL_TIME_T = CURLINFO_OFF_T + 50, CURLINFO_NAMELOOKUP_TIME_T = CURLINFO_OFF_T + 51, CURLINFO_CONNECT_TIME_T = CURLINFO_OFF_T + 52, @@ -2646,8 +2642,9 @@ typedef enum { CURLINFO_REDIRECT_TIME_T = CURLINFO_OFF_T + 55, CURLINFO_APPCONNECT_TIME_T = CURLINFO_OFF_T + 56, CURLINFO_RETRY_AFTER = CURLINFO_OFF_T + 57, + CURLINFO_EFFECTIVE_METHOD = CURLINFO_STRING + 58, - CURLINFO_LASTONE = 57 + CURLINFO_LASTONE = 58 } CURLINFO; /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as @@ -2748,6 +2745,7 @@ typedef enum { CURLVERSION_FIFTH, CURLVERSION_SIXTH, CURLVERSION_SEVENTH, + CURLVERSION_EIGHTH, CURLVERSION_LAST /* never actually use this */ } CURLversion; @@ -2756,7 +2754,7 @@ typedef enum { meant to be a built-in version number for what kind of struct the caller expects. If the struct ever changes, we redefine the NOW to another enum from above. */ -#define CURLVERSION_NOW CURLVERSION_SEVENTH +#define CURLVERSION_NOW CURLVERSION_EIGHTH struct curl_version_info_data { CURLversion age; /* age of the returned struct */ @@ -2802,6 +2800,11 @@ struct curl_version_info_data { const char *capath; /* the built-in default CURLOPT_CAPATH, might be NULL */ + /* These fields were added in CURLVERSION_EIGHTH */ + unsigned int zstd_ver_num; /* Numeric Zstd version + (MAJOR << 24) | (MINOR << 12) | PATCH */ + const char *zstd_version; /* human readable string. */ + }; typedef struct curl_version_info_data curl_version_info_data; @@ -2836,6 +2839,8 @@ typedef struct curl_version_info_data curl_version_info_data; #define CURL_VERSION_BROTLI (1<<23) /* Brotli features are present. */ #define CURL_VERSION_ALTSVC (1<<24) /* Alt-Svc handling built-in */ #define CURL_VERSION_HTTP3 (1<<25) /* HTTP3 support built-in */ +#define CURL_VERSION_ZSTD (1<<26) /* zstd features are present */ +#define CURL_VERSION_UNICODE (1<<27) /* Unicode support on Windows */ /* * NAME curl_version_info() diff --git a/Utilities/cmcurl/include/curl/curlver.h b/Utilities/cmcurl/include/curl/curlver.h index 97a8bd8..a881bb7 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.71.1" +#define LIBCURL_VERSION "7.72.0" /* The numeric version number is also available "in parts" by using these defines: */ #define LIBCURL_VERSION_MAJOR 7 -#define LIBCURL_VERSION_MINOR 71 -#define LIBCURL_VERSION_PATCH 1 +#define LIBCURL_VERSION_MINOR 72 +#define LIBCURL_VERSION_PATCH 0 /* 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 0x074701 +#define LIBCURL_VERSION_NUM 0x074800 /* * This is the date and time when the full source package was created. The diff --git a/Utilities/cmcurl/include/curl/multi.h b/Utilities/cmcurl/include/curl/multi.h index 2e6bb72..b911ba9 100644 --- a/Utilities/cmcurl/include/curl/multi.h +++ b/Utilities/cmcurl/include/curl/multi.h @@ -427,12 +427,14 @@ CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, * Name: curl_push_callback * * Desc: This callback gets called when a new stream is being pushed by the - * server. It approves or denies the new stream. + * server. It approves or denies the new stream. It can also decide + * to completely fail the connection. * - * Returns: CURL_PUSH_OK or CURL_PUSH_DENY. + * Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT */ -#define CURL_PUSH_OK 0 -#define CURL_PUSH_DENY 1 +#define CURL_PUSH_OK 0 +#define CURL_PUSH_DENY 1 +#define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */ struct curl_pushheaders; /* forward declaration only */ diff --git a/Utilities/cmcurl/lib/Makefile.inc b/Utilities/cmcurl/lib/Makefile.inc index 723b826..ae3f961 100644 --- a/Utilities/cmcurl/lib/Makefile.inc +++ b/Utilities/cmcurl/lib/Makefile.inc @@ -60,7 +60,8 @@ LIB_CFILES = altsvc.c amigaos.c asyn-ares.c asyn-thread.c base64.c \ sendf.c setopt.c sha256.c share.c slist.c smb.c smtp.c socketpair.c socks.c \ socks_gssapi.c socks_sspi.c speedcheck.c splay.c strcase.c strdup.c \ strerror.c strtok.c strtoofft.c system_win32.c telnet.c tftp.c timeval.c \ - transfer.c urlapi.c version.c warnless.c wildcard.c x509asn1.c dynbuf.c + transfer.c urlapi.c version.c warnless.c wildcard.c x509asn1.c dynbuf.c \ + version_win32.c LIB_HFILES = altsvc.h amigaos.h arpa_telnet.h asyn.h conncache.h connect.h \ content_encoding.h cookie.h curl_addrinfo.h curl_base64.h curl_ctype.h \ @@ -79,7 +80,7 @@ LIB_HFILES = altsvc.h amigaos.h arpa_telnet.h asyn.h conncache.h connect.h \ smb.h smtp.h sockaddr.h socketpair.h socks.h speedcheck.h splay.h strcase.h \ strdup.h strerror.h strtok.h strtoofft.h system_win32.h telnet.h tftp.h \ timeval.h transfer.h urlapi-int.h urldata.h warnless.h wildcard.h \ - x509asn1.h dynbuf.h + x509asn1.h dynbuf.h version_win32.h LIB_RCFILES = libcurl.rc diff --git a/Utilities/cmcurl/lib/asyn-ares.c b/Utilities/cmcurl/lib/asyn-ares.c index ba5160b..e651507 100644 --- a/Utilities/cmcurl/lib/asyn-ares.c +++ b/Utilities/cmcurl/lib/asyn-ares.c @@ -633,7 +633,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, *waitp = 0; /* default to synchronous response */ -#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ +#ifdef ENABLE_IPV6 switch(conn->ip_version) { default: #if ARES_VERSION >= 0x010601 @@ -649,7 +649,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, family = PF_INET6; break; } -#endif /* CURLRES_IPV6 */ +#endif /* ENABLE_IPV6 */ bufp = strdup(hostname); if(bufp) { @@ -670,7 +670,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, /* initial status - failed */ res->last_status = ARES_ENOTFOUND; -#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ +#ifdef ENABLE_IPV6 if(family == PF_UNSPEC) { if(Curl_ipv6works(conn)) { res->num_pending = 2; @@ -690,7 +690,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, } } else -#endif /* CURLRES_IPV6 */ +#endif /* ENABLE_IPV6 */ { res->num_pending = 1; diff --git a/Utilities/cmcurl/lib/asyn.h b/Utilities/cmcurl/lib/asyn.h index be2796c..bd3c3c1 100644 --- a/Utilities/cmcurl/lib/asyn.h +++ b/Utilities/cmcurl/lib/asyn.h @@ -164,7 +164,6 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, #define Curl_resolver_kill(x) Curl_nop_stmt #define Curl_resolver_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST #define Curl_resolver_wait_resolv(x,y) CURLE_COULDNT_RESOLVE_HOST -#define Curl_resolver_getsock(x,y,z) 0 #define Curl_resolver_duphandle(x,y,z) CURLE_OK #define Curl_resolver_init(x,y) CURLE_OK #define Curl_resolver_global_init() CURLE_OK diff --git a/Utilities/cmcurl/lib/connect.c b/Utilities/cmcurl/lib/connect.c index 29293f0..b000b1b 100644 --- a/Utilities/cmcurl/lib/connect.c +++ b/Utilities/cmcurl/lib/connect.c @@ -74,7 +74,7 @@ #include "warnless.h" #include "conncache.h" #include "multihandle.h" -#include "system_win32.h" +#include "version_win32.h" #include "quic.h" #include "socks.h" @@ -934,10 +934,10 @@ CURLcode Curl_is_connected(struct connectdata *conn, return CURLE_OK; } - infof(data, "Connection failed\n"); } - else if(rc & CURL_CSELECT_ERR) + else if(rc & CURL_CSELECT_ERR) { (void)verifyconnect(conn->tempsock[i], &error); + } /* * The connection failed here, we should attempt to connect to the "next @@ -1085,8 +1085,8 @@ void Curl_sndbufset(curl_socket_t sockfd) static int detectOsState = DETECT_OS_NONE; if(detectOsState == DETECT_OS_NONE) { - if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT, - VERSION_GREATER_THAN_EQUAL)) + if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT, + VERSION_GREATER_THAN_EQUAL)) detectOsState = DETECT_OS_VISTA_OR_LATER; else detectOsState = DETECT_OS_PREVISTA; @@ -1363,15 +1363,15 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ } struct connfind { - struct connectdata *tofind; - bool found; + long id_tofind; + struct connectdata *found; }; static int conn_is_conn(struct connectdata *conn, void *param) { struct connfind *f = (struct connfind *)param; - if(conn == f->tofind) { - f->found = TRUE; + if(conn->connection_id == f->id_tofind) { + f->found = conn; return 1; } return 0; @@ -1393,21 +1393,22 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data, * - that is associated with a multi handle, and whose connection * was detached with CURLOPT_CONNECT_ONLY */ - if(data->state.lastconnect && (data->multi_easy || data->multi)) { - struct connectdata *c = data->state.lastconnect; + if((data->state.lastconnect_id != -1) && (data->multi_easy || data->multi)) { + struct connectdata *c; struct connfind find; - find.tofind = data->state.lastconnect; - find.found = FALSE; + find.id_tofind = data->state.lastconnect_id; + find.found = NULL; Curl_conncache_foreach(data, data->multi_easy? &data->multi_easy->conn_cache: &data->multi->conn_cache, &find, conn_is_conn); if(!find.found) { - data->state.lastconnect = NULL; + data->state.lastconnect_id = -1; return CURL_SOCKET_BAD; } + c = find.found; if(connp) { /* only store this if the caller cares for it */ *connp = c; diff --git a/Utilities/cmcurl/lib/content_encoding.c b/Utilities/cmcurl/lib/content_encoding.c index e2e68a1..2fc3d43 100644 --- a/Utilities/cmcurl/lib/content_encoding.c +++ b/Utilities/cmcurl/lib/content_encoding.c @@ -38,6 +38,10 @@ #include <brotli/decode.h> #endif +#ifdef HAVE_ZSTD +#include <zstd.h> +#endif + #include "sendf.h" #include "http.h" #include "content_encoding.h" @@ -710,6 +714,95 @@ static const struct content_encoding brotli_encoding = { #endif +#ifdef HAVE_ZSTD +/* Writer parameters. */ +struct zstd_params { + ZSTD_DStream *zds; /* State structure for zstd. */ + void *decomp; +}; + +static CURLcode zstd_init_writer(struct connectdata *conn, + struct contenc_writer *writer) +{ + struct zstd_params *zp = (struct zstd_params *)&writer->params; + (void)conn; + + if(!writer->downstream) + return CURLE_WRITE_ERROR; + + zp->zds = ZSTD_createDStream(); + zp->decomp = NULL; + return zp->zds ? CURLE_OK : CURLE_OUT_OF_MEMORY; +} + +static CURLcode zstd_unencode_write(struct connectdata *conn, + struct contenc_writer *writer, + const char *buf, size_t nbytes) +{ + CURLcode result = CURLE_OK; + struct zstd_params *zp = (struct zstd_params *)&writer->params; + ZSTD_inBuffer in; + ZSTD_outBuffer out; + size_t errorCode; + + if(!zp->decomp) { + zp->decomp = malloc(DSIZ); + if(!zp->decomp) + return CURLE_OUT_OF_MEMORY; + } + in.pos = 0; + in.src = buf; + in.size = nbytes; + + for(;;) { + out.pos = 0; + out.dst = zp->decomp; + out.size = DSIZ; + + errorCode = ZSTD_decompressStream(zp->zds, &out, &in); + if(ZSTD_isError(errorCode)) { + return CURLE_BAD_CONTENT_ENCODING; + } + if(out.pos > 0) { + result = Curl_unencode_write(conn, writer->downstream, + zp->decomp, out.pos); + if(result) + break; + } + if((in.pos == nbytes) && (out.pos < out.size)) + break; + } + + return result; +} + +static void zstd_close_writer(struct connectdata *conn, + struct contenc_writer *writer) +{ + struct zstd_params *zp = (struct zstd_params *)&writer->params; + (void)conn; + + if(zp->decomp) { + free(zp->decomp); + zp->decomp = NULL; + } + if(zp->zds) { + ZSTD_freeDStream(zp->zds); + zp->zds = NULL; + } +} + +static const struct content_encoding zstd_encoding = { + "zstd", + NULL, + zstd_init_writer, + zstd_unencode_write, + zstd_close_writer, + sizeof(struct zstd_params) +}; +#endif + + /* Identity handler. */ static CURLcode identity_init_writer(struct connectdata *conn, struct contenc_writer *writer) @@ -752,6 +845,9 @@ static const struct content_encoding * const encodings[] = { #ifdef HAVE_BROTLI &brotli_encoding, #endif +#ifdef HAVE_ZSTD + &zstd_encoding, +#endif NULL }; diff --git a/Utilities/cmcurl/lib/curl_config.h.cmake b/Utilities/cmcurl/lib/curl_config.h.cmake index 00ae658..d5bf4fe 100644 --- a/Utilities/cmcurl/lib/curl_config.h.cmake +++ b/Utilities/cmcurl/lib/curl_config.h.cmake @@ -430,6 +430,9 @@ /* if brotli is available */ #cmakedefine HAVE_BROTLI 1 +/* if zstd is available */ +#cmakedefine HAVE_ZSTD 1 + /* Define to 1 if you have the <locale.h> header file. */ #cmakedefine HAVE_LOCALE_H 1 diff --git a/Utilities/cmcurl/lib/curl_setup.h b/Utilities/cmcurl/lib/curl_setup.h index dadfff9..45a093f 100644 --- a/Utilities/cmcurl/lib/curl_setup.h +++ b/Utilities/cmcurl/lib/curl_setup.h @@ -656,7 +656,7 @@ int netware_init(void); defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_SECTRANSP) || \ defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \ defined(USE_MBEDTLS) || \ - (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_SET_ODD_PARITY)) + (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT)) #define USE_NTLM diff --git a/Utilities/cmcurl/lib/curl_sspi.c b/Utilities/cmcurl/lib/curl_sspi.c index 83ece9a..512ce24 100644 --- a/Utilities/cmcurl/lib/curl_sspi.c +++ b/Utilities/cmcurl/lib/curl_sspi.c @@ -28,6 +28,7 @@ #include "curl_sspi.h" #include "curl_multibyte.h" #include "system_win32.h" +#include "version_win32.h" #include "warnless.h" /* The last #include files should be: */ @@ -82,7 +83,7 @@ CURLcode Curl_sspi_global_init(void) * have both these DLLs (security.dll forwards calls to secur32.dll) */ /* Load SSPI dll into the address space of the calling process */ - if(Curl_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL)) + if(curlx_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL)) s_hSecDll = Curl_load_library(TEXT("security.dll")); else s_hSecDll = Curl_load_library(TEXT("secur32.dll")); diff --git a/Utilities/cmcurl/lib/curlx.h b/Utilities/cmcurl/lib/curlx.h index a8bae14..98e51bf 100644 --- a/Utilities/cmcurl/lib/curlx.h +++ b/Utilities/cmcurl/lib/curlx.h @@ -63,6 +63,9 @@ curlx_unicodefree() */ +#include "version_win32.h" +/* "version_win32.h" provides curlx_verify_windows_version() */ + /* Now setup curlx_ * names for the functions that are to become curlx_ and be removed from a future libcurl official API: curlx_getenv diff --git a/Utilities/cmcurl/lib/doh.c b/Utilities/cmcurl/lib/doh.c index ebb2c24..8bc3428 100644 --- a/Utilities/cmcurl/lib/doh.c +++ b/Utilities/cmcurl/lib/doh.c @@ -858,7 +858,7 @@ doh2ai(const struct dohentry *de, const char *hostname, int port) addr = (void *)ai->ai_addr; /* storage area for this info */ DEBUGASSERT(sizeof(struct in_addr) == sizeof(de->addr[i].ip.v4)); memcpy(&addr->sin_addr, &de->addr[i].ip.v4, sizeof(struct in_addr)); - addr->sin_family = (CURL_SA_FAMILY_T)addrtype; + addr->sin_family = addrtype; addr->sin_port = htons((unsigned short)port); break; @@ -867,7 +867,7 @@ doh2ai(const struct dohentry *de, const char *hostname, int port) addr6 = (void *)ai->ai_addr; /* storage area for this info */ DEBUGASSERT(sizeof(struct in6_addr) == sizeof(de->addr[i].ip.v6)); memcpy(&addr6->sin6_addr, &de->addr[i].ip.v6, sizeof(struct in6_addr)); - addr6->sin6_family = (CURL_SA_FAMILY_T)addrtype; + addr6->sin6_family = addrtype; addr6->sin6_port = htons((unsigned short)port); break; #endif diff --git a/Utilities/cmcurl/lib/dynbuf.h b/Utilities/cmcurl/lib/dynbuf.h index c80239e..ecc9957 100644 --- a/Utilities/cmcurl/lib/dynbuf.h +++ b/Utilities/cmcurl/lib/dynbuf.h @@ -53,11 +53,11 @@ size_t Curl_dyn_len(const struct dynbuf *s); #define DYN_HAXPROXY 2048 #define DYN_HTTP_REQUEST (128*1024) #define DYN_H2_HEADERS (128*1024) -#define DYN_H2_TRAILER 4096 +#define DYN_H2_TRAILERS (128*1024) #define DYN_APRINTF 8000000 #define DYN_RTSP_REQ_HEADER (64*1024) #define DYN_TRAILERS (64*1024) #define DYN_PROXY_CONNECT_HEADERS 16384 #define DYN_QLOG_NAME 1024 -#define DYN_H1_TRAILER DYN_H2_TRAILER +#define DYN_H1_TRAILER 4096 #endif diff --git a/Utilities/cmcurl/lib/easy.c b/Utilities/cmcurl/lib/easy.c index 292cca7..a69eb9e 100644 --- a/Utilities/cmcurl/lib/easy.c +++ b/Utilities/cmcurl/lib/easy.c @@ -838,8 +838,7 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data) /* the connection cache is setup on demand */ outcurl->state.conn_cache = NULL; - - outcurl->state.lastconnect = NULL; + outcurl->state.lastconnect_id = -1; outcurl->progress.flags = data->progress.flags; outcurl->progress.callback = data->progress.callback; diff --git a/Utilities/cmcurl/lib/ftp.c b/Utilities/cmcurl/lib/ftp.c index cfd70a6..7d805fa 100644 --- a/Utilities/cmcurl/lib/ftp.c +++ b/Utilities/cmcurl/lib/ftp.c @@ -3251,9 +3251,9 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status, } if(conn->ssl[SECONDARYSOCKET].use) { - /* The secondary socket used SSL so we must close down that part first - before we close the socket for real */ - result = Curl_ssl_shutdown(conn, SECONDARYSOCKET); + /* The secondary socket is using SSL so we must close down that part + first before we close the socket for real */ + Curl_ssl_close(conn, SECONDARYSOCKET); /* Note that we keep "use" set to TRUE since that (next) connection is still requested to use SSL */ diff --git a/Utilities/cmcurl/lib/getinfo.c b/Utilities/cmcurl/lib/getinfo.c index 6d5bd5f..82691dc 100644 --- a/Utilities/cmcurl/lib/getinfo.c +++ b/Utilities/cmcurl/lib/getinfo.c @@ -78,6 +78,7 @@ CURLcode Curl_initinfo(struct Curl_easy *data) info->conn_local_ip[0] = '\0'; info->conn_primary_port = 0; info->conn_local_port = 0; + info->retry_after = 0; info->conn_scheme = 0; info->conn_protocol = 0; @@ -95,6 +96,34 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info, case CURLINFO_EFFECTIVE_URL: *param_charp = data->change.url?data->change.url:(char *)""; break; + case CURLINFO_EFFECTIVE_METHOD: { + const char *m = data->set.str[STRING_CUSTOMREQUEST]; + if(!m) { + if(data->set.opt_no_body) + m = "HEAD"; + else { + switch(data->state.httpreq) { + case HTTPREQ_POST: + case HTTPREQ_POST_FORM: + case HTTPREQ_POST_MIME: + m = "POST"; + break; + case HTTPREQ_PUT: + m = "PUT"; + break; + default: /* this should never happen */ + case HTTPREQ_GET: + m = "GET"; + break; + case HTTPREQ_HEAD: + m = "HEAD"; + break; + } + } + } + *param_charp = m; + } + break; case CURLINFO_CONTENT_TYPE: *param_charp = data->info.contenttype; break; diff --git a/Utilities/cmcurl/lib/http.c b/Utilities/cmcurl/lib/http.c index 28d66c2..8fcdd43 100644 --- a/Utilities/cmcurl/lib/http.c +++ b/Utilities/cmcurl/lib/http.c @@ -2014,9 +2014,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) case HTTPREQ_PUT: request = "PUT"; break; - case HTTPREQ_OPTIONS: - request = "OPTIONS"; - break; default: /* this should never happen */ case HTTPREQ_GET: request = "GET"; diff --git a/Utilities/cmcurl/lib/http.h b/Utilities/cmcurl/lib/http.h index 641bc0b..9ea3eb2 100644 --- a/Utilities/cmcurl/lib/http.h +++ b/Utilities/cmcurl/lib/http.h @@ -148,6 +148,7 @@ struct HTTP { struct dynbuf header_recvbuf; size_t nread_header_recvbuf; /* number of bytes in header_recvbuf fed into upper layer */ + struct dynbuf trailer_recvbuf; int status_code; /* HTTP status code */ const uint8_t *pausedata; /* pointer to data received in on_data_chunk */ size_t pauselen; /* the number of bytes left in data */ diff --git a/Utilities/cmcurl/lib/http2.c b/Utilities/cmcurl/lib/http2.c index 6cf651f..d316da8 100644 --- a/Utilities/cmcurl/lib/http2.c +++ b/Utilities/cmcurl/lib/http2.c @@ -514,7 +514,7 @@ static int push_promise(struct Curl_easy *data, struct connectdata *conn, const nghttp2_push_promise *frame) { - int rv; + int rv; /* one of the CURL_PUSH_* defines */ H2BUGF(infof(data, "PUSH_PROMISE received, stream %u!\n", frame->promised_stream_id)); if(data->multi->push_cb) { @@ -528,7 +528,7 @@ static int push_promise(struct Curl_easy *data, struct Curl_easy *newhandle = duphandle(data); if(!newhandle) { infof(data, "failed to duplicate handle\n"); - rv = 1; /* FAIL HARD */ + rv = CURL_PUSH_DENY; /* FAIL HARD */ goto fail; } @@ -541,13 +541,15 @@ static int push_promise(struct Curl_easy *data, if(!stream) { failf(data, "Internal NULL stream!\n"); (void)Curl_close(&newhandle); - rv = 1; + rv = CURL_PUSH_DENY; goto fail; } rv = set_transfer_url(newhandle, &heads); - if(rv) + if(rv) { + rv = CURL_PUSH_DENY; goto fail; + } Curl_set_in_callback(data, true); rv = data->multi->push_cb(data, newhandle, @@ -563,6 +565,7 @@ static int push_promise(struct Curl_easy *data, stream->push_headers_used = 0; if(rv) { + DEBUGASSERT((rv > CURL_PUSH_OK) && (rv <= CURL_PUSH_ERROROUT)); /* denied, kill off the new handle again */ http2_stream_free(newhandle->req.protop); newhandle->req.protop = NULL; @@ -583,7 +586,7 @@ static int push_promise(struct Curl_easy *data, http2_stream_free(newhandle->req.protop); newhandle->req.protop = NULL; Curl_close(&newhandle); - rv = 1; + rv = CURL_PUSH_DENY; goto fail; } @@ -595,12 +598,13 @@ static int push_promise(struct Curl_easy *data, infof(data, "failed to set user_data for stream %d\n", frame->promised_stream_id); DEBUGASSERT(0); + rv = CURL_PUSH_DENY; goto fail; } } else { H2BUGF(infof(data, "Got PUSH_PROMISE, ignore it!\n")); - rv = 1; + rv = CURL_PUSH_DENY; } fail: return rv; @@ -737,11 +741,16 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, case NGHTTP2_PUSH_PROMISE: rv = push_promise(data_s, conn, &frame->push_promise); if(rv) { /* deny! */ - rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, + int h2; + DEBUGASSERT((rv > CURL_PUSH_OK) && (rv <= CURL_PUSH_ERROROUT)); + h2 = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, frame->push_promise.promised_stream_id, NGHTTP2_CANCEL); - if(nghttp2_is_fatal(rv)) { - return rv; + if(nghttp2_is_fatal(h2)) + return NGHTTP2_ERR_CALLBACK_FAILURE; + else if(rv == CURL_PUSH_ERROROUT) { + DEBUGF(infof(data_s, "Fail the parent stream (too)\n")); + return NGHTTP2_ERR_CALLBACK_FAILURE; } } break; @@ -839,7 +848,7 @@ static int on_stream_close(nghttp2_session *session, int32_t stream_id, return 0; } H2BUGF(infof(data_s, "on_stream_close(), %s (err %d), stream %u\n", - nghttp2_strerror(error_code), error_code, stream_id)); + nghttp2_http2_strerror(error_code), error_code, stream_id)); stream = data_s->req.protop; if(!stream) return NGHTTP2_ERR_CALLBACK_FAILURE; @@ -1006,18 +1015,11 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame, if(stream->bodystarted) { /* This is a trailer */ - struct dynbuf trail; H2BUGF(infof(data_s, "h2 trailer: %.*s: %.*s\n", namelen, name, valuelen, value)); - Curl_dyn_init(&trail, DYN_H2_TRAILER); - result = Curl_dyn_addf(&trail, + result = Curl_dyn_addf(&stream->trailer_recvbuf, "%.*s: %.*s\r\n", namelen, name, valuelen, value); - if(!result) - result = Curl_client_write(conn, CLIENTWRITE_HEADER, - Curl_dyn_ptr(&trail), - Curl_dyn_len(&trail)); - Curl_dyn_free(&trail); if(result) return NGHTTP2_ERR_CALLBACK_FAILURE; @@ -1165,6 +1167,7 @@ void Curl_http2_done(struct Curl_easy *data, bool premature) /* there might be allocated resources done before this got the 'h2' pointer setup */ Curl_dyn_free(&http->header_recvbuf); + Curl_dyn_free(&http->trailer_recvbuf); if(http->push_headers) { /* if they weren't used and then freed before */ for(; http->push_headers_used > 0; --http->push_headers_used) { @@ -1174,7 +1177,8 @@ void Curl_http2_done(struct Curl_easy *data, bool premature) http->push_headers = NULL; } - if(!httpc->h2) /* not HTTP/2 ? */ + if(!(data->conn->handler->protocol&PROTO_FAMILY_HTTP) || + !httpc->h2) /* not HTTP/2 ? */ return; if(premature) { @@ -1203,6 +1207,13 @@ void Curl_http2_done(struct Curl_easy *data, bool premature) } http->stream_id = 0; } + + if(0 == nghttp2_session_check_request_allowed(httpc->h2)) { + /* No more requests are allowed in the current session, so the connection + may not be reused. This is set when a GOAWAY frame has been received or + when the limit of stream identifiers has been reached. */ + connclose(data->conn, "http/2: No new requests allowed"); + } } /* @@ -1456,7 +1467,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn, } else if(httpc->error_code != NGHTTP2_NO_ERROR) { failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)", - stream->stream_id, nghttp2_strerror(httpc->error_code), + stream->stream_id, nghttp2_http2_strerror(httpc->error_code), httpc->error_code); *err = CURLE_HTTP2_STREAM; return -1; @@ -1470,6 +1481,31 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn, return -1; } + if(Curl_dyn_len(&stream->trailer_recvbuf)) { + char *trailp = Curl_dyn_ptr(&stream->trailer_recvbuf); + char *lf; + + do { + size_t len = 0; + CURLcode result; + /* each trailer line ends with a newline */ + lf = strchr(trailp, '\n'); + if(!lf) + break; + len = lf + 1 - trailp; + + if(data->set.verbose) + Curl_debug(data, CURLINFO_HEADER_IN, trailp, len); + /* pass the trailers one by one to the callback */ + result = Curl_client_write(conn, CLIENTWRITE_HEADER, trailp, len); + if(result) { + *err = result; + return -1; + } + trailp = ++lf; + } while(lf); + } + stream->close_handled = TRUE; H2BUGF(infof(data, "http2_recv returns 0, http2_handle_stream_close\n")); @@ -2075,6 +2111,9 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, h2_pri_spec(conn->data, &pri_spec); + H2BUGF(infof(conn->data, "http2_send request allowed %d (easy handle %p)\n", + nghttp2_session_check_request_allowed(h2), (void *)conn->data)); + switch(conn->data->state.httpreq) { case HTTPREQ_POST: case HTTPREQ_POST_FORM: @@ -2151,6 +2190,7 @@ CURLcode Curl_http2_setup(struct connectdata *conn) stream->stream_id = -1; Curl_dyn_init(&stream->header_recvbuf, DYN_H2_HEADERS); + Curl_dyn_init(&stream->trailer_recvbuf, DYN_H2_TRAILERS); if((conn->handler == &Curl_handler_http2_ssl) || (conn->handler == &Curl_handler_http2)) diff --git a/Utilities/cmcurl/lib/md4.c b/Utilities/cmcurl/lib/md4.c index 0fab52d..67119cd 100644 --- a/Utilities/cmcurl/lib/md4.c +++ b/Utilities/cmcurl/lib/md4.c @@ -102,7 +102,9 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx) #include <openssl/md4.h> #elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \ - (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \ + (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040) && \ + defined(__MAC_OS_X_VERSION_MIN_ALLOWED) && \ + (__MAC_OS_X_VERSION_MIN_ALLOWED < 101500)) || \ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000)) diff --git a/Utilities/cmcurl/lib/md5.c b/Utilities/cmcurl/lib/md5.c index 557a51e..d21625f 100644 --- a/Utilities/cmcurl/lib/md5.c +++ b/Utilities/cmcurl/lib/md5.c @@ -139,7 +139,9 @@ static void MD5_Final(unsigned char *digest, MD5_CTX *ctx) } #elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \ - (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \ + (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040) && \ + defined(__MAC_OS_X_VERSION_MIN_ALLOWED) && \ + (__MAC_OS_X_VERSION_MIN_ALLOWED < 101500)) || \ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000)) diff --git a/Utilities/cmcurl/lib/memdebug.c b/Utilities/cmcurl/lib/memdebug.c index 1c6b151..da75c9f 100644 --- a/Utilities/cmcurl/lib/memdebug.c +++ b/Utilities/cmcurl/lib/memdebug.c @@ -456,6 +456,16 @@ FILE *curl_dbg_fopen(const char *file, const char *mode, return res; } +FILE *curl_dbg_fdopen(int filedes, const char *mode, + int line, const char *source) +{ + FILE *res = fdopen(filedes, mode); + if(source) + curl_dbg_log("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n", + source, line, filedes, mode, (void *)res); + return res; +} + int curl_dbg_fclose(FILE *file, int line, const char *source) { int res; diff --git a/Utilities/cmcurl/lib/memdebug.h b/Utilities/cmcurl/lib/memdebug.h index 7ca4426..4edafdf 100644 --- a/Utilities/cmcurl/lib/memdebug.h +++ b/Utilities/cmcurl/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2020, 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 @@ -79,6 +79,9 @@ CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd, /* FILE functions */ CURL_EXTERN FILE *curl_dbg_fopen(const char *file, const char *mode, int line, const char *source); +CURL_EXTERN FILE *curl_dbg_fdopen(int filedes, const char *mode, + int line, const char *source); + CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source); #ifndef MEMDEBUG_NODEFINES diff --git a/Utilities/cmcurl/lib/mprintf.c b/Utilities/cmcurl/lib/mprintf.c index 63c9d11..80735be 100644 --- a/Utilities/cmcurl/lib/mprintf.c +++ b/Utilities/cmcurl/lib/mprintf.c @@ -178,12 +178,14 @@ static long dprintf_DollarString(char *input, char **end) { int number = 0; while(ISDIGIT(*input)) { - number *= 10; - number += *input-'0'; + if(number < MAX_PARAMETERS) { + number *= 10; + number += *input - '0'; + } input++; } - if(number && ('$'==*input++)) { - *end = input; + if(number <= MAX_PARAMETERS && ('$' == *input)) { + *end = ++input; return number; } return 0; @@ -377,6 +379,8 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto, if(width > max_param) max_param = width; break; + case '\0': + fmt--; default: break; } @@ -458,6 +462,9 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto, /* we have the width specified from a parameter, so we make that parameter's info setup properly */ long k = width - 1; + if((k < 0) || (k >= MAX_PARAMETERS)) + /* out of allowed range */ + return 1; vto[i].width = k; vto[k].type = FORMAT_WIDTH; vto[k].flags = FLAGS_NEW; @@ -469,6 +476,9 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto, /* we have the precision specified from a parameter, so we make that parameter's info setup properly */ long k = precision - 1; + if((k < 0) || (k >= MAX_PARAMETERS)) + /* out of allowed range */ + return 1; vto[i].precision = k; vto[k].type = FORMAT_WIDTH; vto[k].flags = FLAGS_NEW; @@ -476,7 +486,7 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto, vto[k].width = 0; vto[k].precision = 0; } - *endpos++ = fmt + 1; /* end of this sequence */ + *endpos++ = fmt + ((*fmt == '\0') ? 0 : 1); /* end of this sequence */ } } @@ -754,7 +764,7 @@ static int dprintf_formatf( if(prec > 0) { width -= prec; - while(prec-- > 0) + while(prec-- > 0 && w >= work) *w-- = '0'; } @@ -918,6 +928,8 @@ static int dprintf_formatf( precision */ size_t maxprec = sizeof(work) - 2; double val = p->data.dnum; + if(width > 0 && prec <= width) + maxprec -= width; while(val >= 10.0) { val /= 10; maxprec--; @@ -925,6 +937,8 @@ static int dprintf_formatf( if(prec > (long)maxprec) prec = (long)maxprec-1; + if(prec < 0) + prec = 0; /* RECURSIVE USAGE */ len = curl_msnprintf(fptr, left, ".%ld", prec); fptr += len; diff --git a/Utilities/cmcurl/lib/multi.c b/Utilities/cmcurl/lib/multi.c index 249e360..3c7fb85 100644 --- a/Utilities/cmcurl/lib/multi.c +++ b/Utilities/cmcurl/lib/multi.c @@ -455,6 +455,7 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi, data->state.conn_cache = &data->share->conn_cache; else data->state.conn_cache = &multi->conn_cache; + data->state.lastconnect_id = -1; #ifdef USE_LIBPSL /* Do the same for PSL. */ @@ -677,11 +678,11 @@ static CURLcode multi_done(struct Curl_easy *data, CONNCACHE_UNLOCK(data); if(Curl_conncache_return_conn(data, conn)) { /* remember the most recently used connection */ - data->state.lastconnect = conn; + data->state.lastconnect_id = conn->connection_id; infof(data, "%s\n", buffer); } else - data->state.lastconnect = NULL; + data->state.lastconnect_id = -1; } Curl_safefree(data->state.buffer); @@ -689,6 +690,26 @@ static CURLcode multi_done(struct Curl_easy *data, return result; } +static int close_connect_only(struct connectdata *conn, void *param) +{ + struct Curl_easy *data = param; + + if(data->state.lastconnect_id != conn->connection_id) + return 0; + + if(conn->data != data) + return 1; + conn->data = NULL; + + if(!conn->bits.connect_only) + return 1; + + connclose(conn, "Removing connect-only easy handle"); + conn->bits.connect_only = FALSE; + + return 1; +} + CURLMcode curl_multi_remove_handle(struct Curl_multi *multi, struct Curl_easy *data) { @@ -776,10 +797,6 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi, multi_done() as that may actually call Curl_expire that uses this */ Curl_llist_destroy(&data->state.timeoutlist, NULL); - /* as this was using a shared connection cache we clear the pointer to that - since we're not part of that multi handle anymore */ - data->state.conn_cache = NULL; - /* change state without using multistate(), only to make singlesocket() do what we want */ data->mstate = CURLM_STATE_COMPLETED; @@ -789,12 +806,22 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi, /* Remove the association between the connection and the handle */ Curl_detach_connnection(data); + if(data->state.lastconnect_id != -1) { + /* Mark any connect-only connection for closure */ + Curl_conncache_foreach(data, data->state.conn_cache, + data, &close_connect_only); + } + #ifdef USE_LIBPSL /* Remove the PSL association. */ if(data->psl == &multi->psl) data->psl = NULL; #endif + /* as this was using a shared connection cache we clear the pointer to that + since we're not part of that multi handle anymore */ + data->state.conn_cache = NULL; + data->multi = NULL; /* clear the association to this multi handle */ /* make sure there's no pending message in the queue sent from this easy @@ -958,19 +985,6 @@ static int multi_getsock(struct Curl_easy *data, switch(data->mstate) { default: -#if 0 /* switch back on these cases to get the compiler to check for all enums - to be present */ - case CURLM_STATE_TOOFAST: /* returns 0, so will not select. */ - case CURLM_STATE_COMPLETED: - case CURLM_STATE_MSGSENT: - case CURLM_STATE_INIT: - case CURLM_STATE_CONNECT: - case CURLM_STATE_WAITDO: - case CURLM_STATE_DONE: - case CURLM_STATE_LAST: - /* this will get called with CURLM_STATE_COMPLETED when a handle is - removed */ -#endif return 0; case CURLM_STATE_WAITRESOLVE: @@ -1255,7 +1269,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi, sleep_ms = timeout_ms; /* when there are no easy handles in the multi, this holds a -1 timeout */ - else if((sleep_ms < 0) && extrawait) + else if(sleep_ms < 0) sleep_ms = timeout_ms; Curl_wait_ms(sleep_ms); } @@ -1808,7 +1822,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, multistate(data, CURLM_STATE_SENDPROTOCONNECT); } } - else if(result) + else stream_error = TRUE; break; #endif @@ -1858,7 +1872,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, multistate(data, CURLM_STATE_DO); rc = CURLM_CALL_MULTI_PERFORM; } - else if(result) { + else { /* failure detected */ Curl_posttransfer(data); multi_done(data, result, TRUE); @@ -2962,9 +2976,7 @@ CURLMcode curl_multi_setopt(struct Curl_multi *multi, long streams = va_arg(param, long); if(streams < 1) streams = 100; - multi->max_concurrent_streams = - (streams > (long)INITIAL_MAX_CONCURRENT_STREAMS)? - INITIAL_MAX_CONCURRENT_STREAMS : (unsigned int)streams; + multi->max_concurrent_streams = curlx_sltoui(streams); } break; default: diff --git a/Utilities/cmcurl/lib/multihandle.h b/Utilities/cmcurl/lib/multihandle.h index 91eca16..9d73df0 100644 --- a/Utilities/cmcurl/lib/multihandle.h +++ b/Utilities/cmcurl/lib/multihandle.h @@ -81,7 +81,7 @@ struct Curl_multi { this multi handle with an easy handle. Set this to CURL_MULTI_HANDLE. */ long type; - /* We have a doubly-linked circular list with easy handles */ + /* We have a doubly-linked list with easy handles */ struct Curl_easy *easyp; struct Curl_easy *easylp; /* last node */ diff --git a/Utilities/cmcurl/lib/parsedate.c b/Utilities/cmcurl/lib/parsedate.c index 585d7ea..4c7a40c 100644 --- a/Utilities/cmcurl/lib/parsedate.c +++ b/Utilities/cmcurl/lib/parsedate.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2020, 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 @@ -624,6 +624,7 @@ CURLcode Curl_gmtime(time_t intime, struct tm *store) /* thread-safe version */ tm = (struct tm *)gmtime_r(&intime, store); #else + /* !checksrc! disable BANNEDFUNC 1 */ tm = gmtime(&intime); if(tm) *store = *tm; /* copy the pointed struct to the local copy */ diff --git a/Utilities/cmcurl/lib/rename.c b/Utilities/cmcurl/lib/rename.c index bb170d3..fe5f95d 100644 --- a/Utilities/cmcurl/lib/rename.c +++ b/Utilities/cmcurl/lib/rename.c @@ -27,6 +27,7 @@ #if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)) || \ defined(USE_ALTSVC) +#include "curl_multibyte.h" #include "timeval.h" /* The last 3 #include files should be in this order */ @@ -39,17 +40,25 @@ int Curl_rename(const char *oldpath, const char *newpath) { #ifdef WIN32 /* rename() on Windows doesn't overwrite, so we can't use it here. - MoveFileExA() will overwrite and is usually atomic, however it fails + MoveFileEx() will overwrite and is usually atomic, however it fails when there are open handles to the file. */ const int max_wait_ms = 1000; struct curltime start = Curl_now(); + TCHAR *tchar_oldpath = curlx_convert_UTF8_to_tchar((char *)oldpath); + TCHAR *tchar_newpath = curlx_convert_UTF8_to_tchar((char *)newpath); for(;;) { timediff_t diff; - if(MoveFileExA(oldpath, newpath, MOVEFILE_REPLACE_EXISTING)) + if(MoveFileEx(tchar_oldpath, tchar_newpath, MOVEFILE_REPLACE_EXISTING)) { + curlx_unicodefree(tchar_oldpath); + curlx_unicodefree(tchar_newpath); break; + } diff = Curl_timediff(Curl_now(), start); - if(diff < 0 || diff > max_wait_ms) + if(diff < 0 || diff > max_wait_ms) { + curlx_unicodefree(tchar_oldpath); + curlx_unicodefree(tchar_newpath); return 1; + } Sleep(1); } #else diff --git a/Utilities/cmcurl/lib/setopt.c b/Utilities/cmcurl/lib/setopt.c index 90edf6a..d621335 100644 --- a/Utilities/cmcurl/lib/setopt.c +++ b/Utilities/cmcurl/lib/setopt.c @@ -274,6 +274,8 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) if(data->set.opt_no_body) /* in HTTP lingo, no body means using the HEAD request... */ data->set.method = HTTPREQ_HEAD; + else if(data->set.method == HTTPREQ_HEAD) + data->set.method = HTTPREQ_GET; break; case CURLOPT_FAILONERROR: /* diff --git a/Utilities/cmcurl/lib/smtp.c b/Utilities/cmcurl/lib/smtp.c index 685513b..aea41bb 100644 --- a/Utilities/cmcurl/lib/smtp.c +++ b/Utilities/cmcurl/lib/smtp.c @@ -1760,8 +1760,10 @@ static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma, return CURLE_OUT_OF_MEMORY; length = strlen(dup); - if(dup[length - 1] == '>') - dup[length - 1] = '\0'; + if(length) { + if(dup[length - 1] == '>') + dup[length - 1] = '\0'; + } /* Extract the host name from the address (if we can) */ host->name = strpbrk(dup, "@"); diff --git a/Utilities/cmcurl/lib/socks.c b/Utilities/cmcurl/lib/socks.c index b2215fe..44783d0 100644 --- a/Utilities/cmcurl/lib/socks.c +++ b/Utilities/cmcurl/lib/socks.c @@ -327,18 +327,18 @@ CURLcode Curl_SOCKS4(const char *proxy_user, * Make connection */ { - ssize_t packetsize = 9 + + size_t packetsize = 9 + strlen((char *)socksreq + 8); /* size including NUL */ /* If SOCKS4a, set special invalid IP address 0.0.0.x */ if(protocol4a) { - ssize_t hostnamelen = 0; + size_t hostnamelen = 0; socksreq[4] = 0; socksreq[5] = 0; socksreq[6] = 0; socksreq[7] = 1; /* append hostname */ - hostnamelen = (ssize_t)strlen(hostname) + 1; /* length including NUL */ + hostnamelen = strlen(hostname) + 1; /* length including NUL */ if(hostnamelen <= 255) strcpy((char *)socksreq + packetsize, hostname); else { diff --git a/Utilities/cmcurl/lib/strdup.c b/Utilities/cmcurl/lib/strdup.c index 1ab10fd..7732802 100644 --- a/Utilities/cmcurl/lib/strdup.c +++ b/Utilities/cmcurl/lib/strdup.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2020, 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 @@ -39,19 +39,14 @@ char *curlx_strdup(const char *str) if(!str) return (char *)NULL; - len = strlen(str); + len = strlen(str) + 1; - if(len >= ((size_t)-1) / sizeof(char)) - return (char *)NULL; - - newstr = malloc((len + 1)*sizeof(char)); + newstr = malloc(len); if(!newstr) return (char *)NULL; - memcpy(newstr, str, (len + 1)*sizeof(char)); - + memcpy(newstr, str, len); return newstr; - } #endif diff --git a/Utilities/cmcurl/lib/system_win32.c b/Utilities/cmcurl/lib/system_win32.c index b9587b5..2e59e03 100644 --- a/Utilities/cmcurl/lib/system_win32.c +++ b/Utilities/cmcurl/lib/system_win32.c @@ -26,6 +26,7 @@ #include <curl/curl.h> #include "system_win32.h" +#include "version_win32.h" #include "curl_sspi.h" #include "warnless.h" @@ -106,8 +107,8 @@ CURLcode Curl_win32_init(long flags) Curl_if_nametoindex = pIfNameToIndex; } - if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT, - VERSION_GREATER_THAN_EQUAL)) { + if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT, + VERSION_GREATER_THAN_EQUAL)) { Curl_isVistaOrGreater = TRUE; } else @@ -160,198 +161,6 @@ typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD); #endif /* - * Curl_verify_windows_version() - * - * This is used to verify if we are running on a specific windows version. - * - * Parameters: - * - * majorVersion [in] - The major version number. - * minorVersion [in] - The minor version number. - * platform [in] - The optional platform identifier. - * condition [in] - The test condition used to specifier whether we are - * checking a version less then, equal to or greater than - * what is specified in the major and minor version - * numbers. - * - * Returns TRUE if matched; otherwise FALSE. - */ -bool Curl_verify_windows_version(const unsigned int majorVersion, - const unsigned int minorVersion, - const PlatformIdentifier platform, - const VersionCondition condition) -{ - bool matched = FALSE; - -#if defined(CURL_WINDOWS_APP) - /* We have no way to determine the Windows version from Windows apps, - so let's assume we're running on the target Windows version. */ - const WORD fullVersion = MAKEWORD(minorVersion, majorVersion); - const WORD targetVersion = (WORD)_WIN32_WINNT; - - switch(condition) { - case VERSION_LESS_THAN: - matched = targetVersion < fullVersion; - break; - - case VERSION_LESS_THAN_EQUAL: - matched = targetVersion <= fullVersion; - break; - - case VERSION_EQUAL: - matched = targetVersion == fullVersion; - break; - - case VERSION_GREATER_THAN_EQUAL: - matched = targetVersion >= fullVersion; - break; - - case VERSION_GREATER_THAN: - matched = targetVersion > fullVersion; - break; - } - - if(matched && (platform == PLATFORM_WINDOWS)) { - /* we're always running on PLATFORM_WINNT */ - matched = FALSE; - } -#elif !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \ - (_WIN32_WINNT < _WIN32_WINNT_WIN2K) - OSVERSIONINFO osver; - - memset(&osver, 0, sizeof(osver)); - osver.dwOSVersionInfoSize = sizeof(osver); - - /* Find out Windows version */ - if(GetVersionEx(&osver)) { - /* Verify the Operating System version number */ - switch(condition) { - case VERSION_LESS_THAN: - if(osver.dwMajorVersion < majorVersion || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion < minorVersion)) - matched = TRUE; - break; - - case VERSION_LESS_THAN_EQUAL: - if(osver.dwMajorVersion < majorVersion || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion <= minorVersion)) - matched = TRUE; - break; - - case VERSION_EQUAL: - if(osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion == minorVersion) - matched = TRUE; - break; - - case VERSION_GREATER_THAN_EQUAL: - if(osver.dwMajorVersion > majorVersion || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion >= minorVersion)) - matched = TRUE; - break; - - case VERSION_GREATER_THAN: - if(osver.dwMajorVersion > majorVersion || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion > minorVersion)) - matched = TRUE; - break; - } - - /* Verify the platform identifier (if necessary) */ - if(matched) { - switch(platform) { - case PLATFORM_WINDOWS: - if(osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) - matched = FALSE; - break; - - case PLATFORM_WINNT: - if(osver.dwPlatformId != VER_PLATFORM_WIN32_NT) - matched = FALSE; - - default: /* like platform == PLATFORM_DONT_CARE */ - break; - } - } - } -#else - ULONGLONG cm = 0; - OSVERSIONINFOEX osver; - BYTE majorCondition; - BYTE minorCondition; - BYTE spMajorCondition; - BYTE spMinorCondition; - - switch(condition) { - case VERSION_LESS_THAN: - majorCondition = VER_LESS; - minorCondition = VER_LESS; - spMajorCondition = VER_LESS_EQUAL; - spMinorCondition = VER_LESS_EQUAL; - break; - - case VERSION_LESS_THAN_EQUAL: - majorCondition = VER_LESS_EQUAL; - minorCondition = VER_LESS_EQUAL; - spMajorCondition = VER_LESS_EQUAL; - spMinorCondition = VER_LESS_EQUAL; - break; - - case VERSION_EQUAL: - majorCondition = VER_EQUAL; - minorCondition = VER_EQUAL; - spMajorCondition = VER_GREATER_EQUAL; - spMinorCondition = VER_GREATER_EQUAL; - break; - - case VERSION_GREATER_THAN_EQUAL: - majorCondition = VER_GREATER_EQUAL; - minorCondition = VER_GREATER_EQUAL; - spMajorCondition = VER_GREATER_EQUAL; - spMinorCondition = VER_GREATER_EQUAL; - break; - - case VERSION_GREATER_THAN: - majorCondition = VER_GREATER; - minorCondition = VER_GREATER; - spMajorCondition = VER_GREATER_EQUAL; - spMinorCondition = VER_GREATER_EQUAL; - break; - - default: - return FALSE; - } - - memset(&osver, 0, sizeof(osver)); - osver.dwOSVersionInfoSize = sizeof(osver); - osver.dwMajorVersion = majorVersion; - osver.dwMinorVersion = minorVersion; - if(platform == PLATFORM_WINDOWS) - osver.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; - else if(platform == PLATFORM_WINNT) - osver.dwPlatformId = VER_PLATFORM_WIN32_NT; - - cm = VerSetConditionMask(cm, VER_MAJORVERSION, majorCondition); - cm = VerSetConditionMask(cm, VER_MINORVERSION, minorCondition); - cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, spMajorCondition); - cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, spMinorCondition); - if(platform != PLATFORM_DONT_CARE) - cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL); - - if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION | - VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR), - cm)) - matched = TRUE; -#endif - - return matched; -} - -/* * Curl_load_library() * * This is used to dynamically load DLLs using the most secure method available diff --git a/Utilities/cmcurl/lib/system_win32.h b/Utilities/cmcurl/lib/system_win32.h index d2882fc..2547bda 100644 --- a/Utilities/cmcurl/lib/system_win32.h +++ b/Utilities/cmcurl/lib/system_win32.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2016 - 2019, Steve Holme, <steve_holme@hotmail.com>. + * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -32,34 +32,12 @@ extern bool Curl_isVistaOrGreater; CURLcode Curl_win32_init(long flags); void Curl_win32_cleanup(long init_flags); -/* Version condition */ -typedef enum { - VERSION_LESS_THAN, - VERSION_LESS_THAN_EQUAL, - VERSION_EQUAL, - VERSION_GREATER_THAN_EQUAL, - VERSION_GREATER_THAN -} VersionCondition; - -/* Platform identifier */ -typedef enum { - PLATFORM_DONT_CARE, - PLATFORM_WINDOWS, - PLATFORM_WINNT -} PlatformIdentifier; - /* We use our own typedef here since some headers might lack this */ typedef unsigned int(WINAPI *IF_NAMETOINDEX_FN)(const char *); /* This is used instead of if_nametoindex if available on Windows */ extern IF_NAMETOINDEX_FN Curl_if_nametoindex; -/* This is used to verify if we are running on a specific windows version */ -bool Curl_verify_windows_version(const unsigned int majorVersion, - const unsigned int minorVersion, - const PlatformIdentifier platform, - const VersionCondition condition); - /* This is used to dynamically load DLLs */ HMODULE Curl_load_library(LPCTSTR filename); diff --git a/Utilities/cmcurl/lib/transfer.c b/Utilities/cmcurl/lib/transfer.c index 133a478..a07c7af 100644 --- a/Utilities/cmcurl/lib/transfer.c +++ b/Utilities/cmcurl/lib/transfer.c @@ -487,6 +487,12 @@ CURLcode Curl_readrewind(struct connectdata *conn) static int data_pending(const struct Curl_easy *data) { struct connectdata *conn = data->conn; + +#ifdef ENABLE_QUIC + if(conn->transport == TRNSPRT_QUIC) + return Curl_quic_data_pending(data); +#endif + /* in the case of libssh2, we can never be really sure that we have emptied its internal buffers so we MUST always try until we get EAGAIN back */ return conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP) || @@ -500,8 +506,6 @@ static int data_pending(const struct Curl_easy *data) be called and we cannot signal the HTTP/2 stream has closed. As a workaround, we return nonzero here to call http2_recv. */ ((conn->handler->protocol&PROTO_FAMILY_HTTP) && conn->httpversion >= 20); -#elif defined(ENABLE_QUIC) - Curl_ssl_data_pending(conn, FIRSTSOCKET) || Curl_quic_data_pending(data); #else Curl_ssl_data_pending(conn, FIRSTSOCKET); #endif @@ -1441,8 +1445,9 @@ CURLcode Curl_pretransfer(struct Curl_easy *data) if(!data->change.url && data->set.uh) { CURLUcode uc; + free(data->set.str[STRING_SET_URL]); uc = curl_url_get(data->set.uh, - CURLUPART_URL, &data->set.str[STRING_SET_URL], 0); + CURLUPART_URL, &data->set.str[STRING_SET_URL], 0); if(uc) { failf(data, "No URL set!"); return CURLE_URL_MALFORMAT; @@ -1799,12 +1804,14 @@ CURLcode Curl_retry_request(struct connectdata *conn, } if(retry) { #define CONN_MAX_RETRIES 5 - if(conn->retrycount++ >= CONN_MAX_RETRIES) { + if(data->state.retrycount++ >= CONN_MAX_RETRIES) { failf(data, "Connection died, tried %d times before giving up", CONN_MAX_RETRIES); + data->state.retrycount = 0; return CURLE_SEND_ERROR; } - infof(conn->data, "Connection died, retrying a fresh connect\n"); + infof(conn->data, "Connection died, retrying a fresh connect\ +(retry count: %d)\n", data->state.retrycount); *url = strdup(conn->data->change.url); if(!*url) return CURLE_OUT_OF_MEMORY; diff --git a/Utilities/cmcurl/lib/url.c b/Utilities/cmcurl/lib/url.c index a1a6b69..150667a 100644 --- a/Utilities/cmcurl/lib/url.c +++ b/Utilities/cmcurl/lib/url.c @@ -630,7 +630,7 @@ CURLcode Curl_open(struct Curl_easy **curl) Curl_initinfo(data); /* most recent connection is not yet defined */ - data->state.lastconnect = NULL; + data->state.lastconnect_id = -1; data->progress.flags |= PGRS_HIDE; data->state.current_speed = -1; /* init to negative == impossible */ @@ -1836,11 +1836,12 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, CURLU *uh; CURLUcode uc; char *hostname; + bool use_set_uh = (data->set.uh && !data->state.this_is_a_follow); up_free(data); /* cleanup previous leftovers first */ /* parse the URL */ - if(data->set.uh) { + if(use_set_uh) { uh = data->state.uh = curl_url_dup(data->set.uh); } else { @@ -1863,7 +1864,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, data->change.url_alloc = TRUE; } - if(!data->set.uh) { + if(!use_set_uh) { char *newurl; uc = curl_url_set(uh, CURLUPART_URL, data->change.url, CURLU_GUESS_SCHEME | @@ -3170,7 +3171,7 @@ static CURLcode resolve_server(struct Curl_easy *data, else { /* this is a fresh connect */ int rc; - struct Curl_dns_entry *hostaddr; + struct Curl_dns_entry *hostaddr = NULL; #ifdef USE_UNIX_SOCKETS if(conn->unix_domain_socket) { diff --git a/Utilities/cmcurl/lib/urldata.h b/Utilities/cmcurl/lib/urldata.h index f80a02d..0ae9269 100644 --- a/Utilities/cmcurl/lib/urldata.h +++ b/Utilities/cmcurl/lib/urldata.h @@ -1090,7 +1090,6 @@ struct connectdata { struct http_connect_state *connect_state; /* for HTTP CONNECT */ struct connectbundle *bundle; /* The bundle we are member of */ int negnpn; /* APLN or NPN TLS negotiated protocol, CURL_HTTP_VERSION* */ - int retrycount; /* number of retries on a new connection */ #ifdef USE_UNIX_SOCKETS char *unix_domain_socket; #endif @@ -1195,7 +1194,6 @@ typedef enum { HTTPREQ_POST_MIME, /* we make a difference internally */ HTTPREQ_PUT, HTTPREQ_HEAD, - HTTPREQ_OPTIONS, HTTPREQ_LAST /* last in list */ } Curl_HttpReq; @@ -1297,10 +1295,12 @@ struct UrlState { /* Points to the connection cache */ struct conncache *conn_cache; + int retrycount; /* number of retries on a new connection */ + /* buffers to store authentication data in, as parsed from input options */ struct curltime keeps_speed; /* for the progress meter really */ - struct connectdata *lastconnect; /* The last connection, NULL if undefined */ + long lastconnect_id; /* The last connection, -1 if undefined */ struct dynbuf headerb; /* buffer to store headers in */ char *buffer; /* download buffer */ diff --git a/Utilities/cmcurl/lib/vauth/ntlm.c b/Utilities/cmcurl/lib/vauth/ntlm.c index 3b46e1a..ecfeacb 100644 --- a/Utilities/cmcurl/lib/vauth/ntlm.c +++ b/Utilities/cmcurl/lib/vauth/ntlm.c @@ -191,6 +191,7 @@ static CURLcode ntlm_decode_type2_target(struct Curl_easy *data, return CURLE_BAD_CONTENT_ENCODING; } + free(ntlm->target_info); /* replace any previous data */ ntlm->target_info = malloc(target_info_len); if(!ntlm->target_info) return CURLE_OUT_OF_MEMORY; diff --git a/Utilities/cmcurl/lib/version.c b/Utilities/cmcurl/lib/version.c index 14e5096..4f6dda2 100644 --- a/Utilities/cmcurl/lib/version.c +++ b/Utilities/cmcurl/lib/version.c @@ -66,6 +66,10 @@ #include <brotli/decode.h> #endif +#ifdef HAVE_ZSTD +#include <zstd.h> +#endif + #ifdef HAVE_BROTLI static size_t brotli_version(char *buf, size_t bufsz) { @@ -78,6 +82,20 @@ static size_t brotli_version(char *buf, size_t bufsz) } #endif +#ifdef HAVE_ZSTD +static size_t zstd_version(char *buf, size_t bufsz) +{ + unsigned long zstd_version = (unsigned long)ZSTD_versionNumber(); + unsigned int major = (unsigned int)(zstd_version / (100 * 100)); + unsigned int minor = (unsigned int)((zstd_version - + (major * 100 * 100)) / 100); + unsigned int patch = (unsigned int)(zstd_version - + (major * 100 * 100) - (minor * 100)); + + return msnprintf(buf, bufsz, "%u.%u.%u", major, minor, patch); +} +#endif + /* * curl_version() returns a pointer to a static buffer. * @@ -103,6 +121,9 @@ char *curl_version(void) #ifdef HAVE_BROTLI char br_version[40] = "brotli/"; #endif +#ifdef HAVE_ZSTD + char zst_version[40] = "zstd/"; +#endif #ifdef USE_ARES char cares_version[40]; #endif @@ -153,6 +174,10 @@ char *curl_version(void) brotli_version(&br_version[7], sizeof(br_version) - 7); src[i++] = br_version; #endif +#ifdef HAVE_ZSTD + zstd_version(&zst_version[5], sizeof(zst_version) - 5); + src[i++] = zst_version; +#endif #ifdef USE_ARES msnprintf(cares_version, sizeof(cares_version), "c-ares/%s", ares_version(NULL)); @@ -365,6 +390,9 @@ static curl_version_info_data version_info = { ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) ) | CURL_VERSION_LARGEFILE #endif +#if defined(WIN32) && defined(UNICODE) && defined(_UNICODE) + | CURL_VERSION_UNICODE +#endif #if defined(CURL_DOES_CONVERSIONS) | CURL_VERSION_CONV #endif @@ -389,6 +417,9 @@ static curl_version_info_data version_info = { #if defined(HAVE_BROTLI) | CURL_VERSION_BROTLI #endif +#if defined(HAVE_ZSTD) + | CURL_VERSION_ZSTD +#endif #if defined(USE_ALTSVC) | CURL_VERSION_ALTSVC #endif @@ -413,10 +444,12 @@ static curl_version_info_data version_info = { NULL, #endif #ifdef CURL_CA_PATH - CURL_CA_PATH /* capath */ + CURL_CA_PATH, /* capath */ #else - NULL + NULL, #endif + 0, /* zstd_ver_num */ + NULL /* zstd version */ }; curl_version_info_data *curl_version_info(CURLversion stamp) @@ -434,6 +467,10 @@ curl_version_info_data *curl_version_info(CURLversion stamp) #ifdef HAVE_BROTLI static char brotli_buffer[80]; #endif +#ifdef HAVE_ZSTD + static char zstd_buffer[80]; +#endif + #ifdef USE_SSL Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer)); @@ -485,6 +522,12 @@ curl_version_info_data *curl_version_info(CURLversion stamp) version_info.brotli_version = brotli_buffer; #endif +#ifdef HAVE_ZSTD + version_info.zstd_ver_num = (unsigned int)ZSTD_versionNumber(); + zstd_version(zstd_buffer, sizeof(zstd_buffer)); + version_info.zstd_version = zstd_buffer; +#endif + #ifdef USE_NGHTTP2 { nghttp2_info *h2 = nghttp2_version(0); diff --git a/Utilities/cmcurl/lib/version_win32.c b/Utilities/cmcurl/lib/version_win32.c new file mode 100644 index 0000000..6561d36 --- /dev/null +++ b/Utilities/cmcurl/lib/version_win32.c @@ -0,0 +1,226 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#if defined(WIN32) + +#include <curl/curl.h> +#include "version_win32.h" + +/* The last #include files should be: */ +#include "curl_memory.h" +#include "memdebug.h" + +/* + * curlx_verify_windows_version() + * + * This is used to verify if we are running on a specific windows version. + * + * Parameters: + * + * majorVersion [in] - The major version number. + * minorVersion [in] - The minor version number. + * platform [in] - The optional platform identifier. + * condition [in] - The test condition used to specifier whether we are + * checking a version less then, equal to or greater than + * what is specified in the major and minor version + * numbers. + * + * Returns TRUE if matched; otherwise FALSE. + */ +bool curlx_verify_windows_version(const unsigned int majorVersion, + const unsigned int minorVersion, + const PlatformIdentifier platform, + const VersionCondition condition) +{ + bool matched = FALSE; + +#if defined(CURL_WINDOWS_APP) + /* We have no way to determine the Windows version from Windows apps, + so let's assume we're running on the target Windows version. */ + const WORD fullVersion = MAKEWORD(minorVersion, majorVersion); + const WORD targetVersion = (WORD)_WIN32_WINNT; + + switch(condition) { + case VERSION_LESS_THAN: + matched = targetVersion < fullVersion; + break; + + case VERSION_LESS_THAN_EQUAL: + matched = targetVersion <= fullVersion; + break; + + case VERSION_EQUAL: + matched = targetVersion == fullVersion; + break; + + case VERSION_GREATER_THAN_EQUAL: + matched = targetVersion >= fullVersion; + break; + + case VERSION_GREATER_THAN: + matched = targetVersion > fullVersion; + break; + } + + if(matched && (platform == PLATFORM_WINDOWS)) { + /* we're always running on PLATFORM_WINNT */ + matched = FALSE; + } +#elif !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \ + (_WIN32_WINNT < _WIN32_WINNT_WIN2K) + OSVERSIONINFO osver; + + memset(&osver, 0, sizeof(osver)); + osver.dwOSVersionInfoSize = sizeof(osver); + + /* Find out Windows version */ + if(GetVersionEx(&osver)) { + /* Verify the Operating System version number */ + switch(condition) { + case VERSION_LESS_THAN: + if(osver.dwMajorVersion < majorVersion || + (osver.dwMajorVersion == majorVersion && + osver.dwMinorVersion < minorVersion)) + matched = TRUE; + break; + + case VERSION_LESS_THAN_EQUAL: + if(osver.dwMajorVersion < majorVersion || + (osver.dwMajorVersion == majorVersion && + osver.dwMinorVersion <= minorVersion)) + matched = TRUE; + break; + + case VERSION_EQUAL: + if(osver.dwMajorVersion == majorVersion && + osver.dwMinorVersion == minorVersion) + matched = TRUE; + break; + + case VERSION_GREATER_THAN_EQUAL: + if(osver.dwMajorVersion > majorVersion || + (osver.dwMajorVersion == majorVersion && + osver.dwMinorVersion >= minorVersion)) + matched = TRUE; + break; + + case VERSION_GREATER_THAN: + if(osver.dwMajorVersion > majorVersion || + (osver.dwMajorVersion == majorVersion && + osver.dwMinorVersion > minorVersion)) + matched = TRUE; + break; + } + + /* Verify the platform identifier (if necessary) */ + if(matched) { + switch(platform) { + case PLATFORM_WINDOWS: + if(osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) + matched = FALSE; + break; + + case PLATFORM_WINNT: + if(osver.dwPlatformId != VER_PLATFORM_WIN32_NT) + matched = FALSE; + + default: /* like platform == PLATFORM_DONT_CARE */ + break; + } + } + } +#else + ULONGLONG cm = 0; + OSVERSIONINFOEX osver; + BYTE majorCondition; + BYTE minorCondition; + BYTE spMajorCondition; + BYTE spMinorCondition; + + switch(condition) { + case VERSION_LESS_THAN: + majorCondition = VER_LESS; + minorCondition = VER_LESS; + spMajorCondition = VER_LESS_EQUAL; + spMinorCondition = VER_LESS_EQUAL; + break; + + case VERSION_LESS_THAN_EQUAL: + majorCondition = VER_LESS_EQUAL; + minorCondition = VER_LESS_EQUAL; + spMajorCondition = VER_LESS_EQUAL; + spMinorCondition = VER_LESS_EQUAL; + break; + + case VERSION_EQUAL: + majorCondition = VER_EQUAL; + minorCondition = VER_EQUAL; + spMajorCondition = VER_GREATER_EQUAL; + spMinorCondition = VER_GREATER_EQUAL; + break; + + case VERSION_GREATER_THAN_EQUAL: + majorCondition = VER_GREATER_EQUAL; + minorCondition = VER_GREATER_EQUAL; + spMajorCondition = VER_GREATER_EQUAL; + spMinorCondition = VER_GREATER_EQUAL; + break; + + case VERSION_GREATER_THAN: + majorCondition = VER_GREATER; + minorCondition = VER_GREATER; + spMajorCondition = VER_GREATER_EQUAL; + spMinorCondition = VER_GREATER_EQUAL; + break; + + default: + return FALSE; + } + + memset(&osver, 0, sizeof(osver)); + osver.dwOSVersionInfoSize = sizeof(osver); + osver.dwMajorVersion = majorVersion; + osver.dwMinorVersion = minorVersion; + if(platform == PLATFORM_WINDOWS) + osver.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; + else if(platform == PLATFORM_WINNT) + osver.dwPlatformId = VER_PLATFORM_WIN32_NT; + + cm = VerSetConditionMask(cm, VER_MAJORVERSION, majorCondition); + cm = VerSetConditionMask(cm, VER_MINORVERSION, minorCondition); + cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, spMajorCondition); + cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, spMinorCondition); + if(platform != PLATFORM_DONT_CARE) + cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL); + + if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION | + VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR), + cm)) + matched = TRUE; +#endif + + return matched; +} + +#endif /* WIN32 */ diff --git a/Utilities/cmcurl/lib/version_win32.h b/Utilities/cmcurl/lib/version_win32.h new file mode 100644 index 0000000..94cc626 --- /dev/null +++ b/Utilities/cmcurl/lib/version_win32.h @@ -0,0 +1,53 @@ +#ifndef HEADER_CURL_VERSION_WIN32_H +#define HEADER_CURL_VERSION_WIN32_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#if defined(WIN32) + +/* Version condition */ +typedef enum { + VERSION_LESS_THAN, + VERSION_LESS_THAN_EQUAL, + VERSION_EQUAL, + VERSION_GREATER_THAN_EQUAL, + VERSION_GREATER_THAN +} VersionCondition; + +/* Platform identifier */ +typedef enum { + PLATFORM_DONT_CARE, + PLATFORM_WINDOWS, + PLATFORM_WINNT +} PlatformIdentifier; + +/* This is used to verify if we are running on a specific windows version */ +bool curlx_verify_windows_version(const unsigned int majorVersion, + const unsigned int minorVersion, + const PlatformIdentifier platform, + const VersionCondition condition); + +#endif /* WIN32 */ + +#endif /* HEADER_CURL_VERSION_WIN32_H */ diff --git a/Utilities/cmcurl/lib/vquic/ngtcp2.c b/Utilities/cmcurl/lib/vquic/ngtcp2.c index d29cb37..20ee08d 100644 --- a/Utilities/cmcurl/lib/vquic/ngtcp2.c +++ b/Utilities/cmcurl/lib/vquic/ngtcp2.c @@ -150,9 +150,11 @@ quic_from_gtls_level(gnutls_record_encryption_level_t gtls_level) } #endif -static void qlog_callback(void *user_data, const void *data, size_t datalen) +static void qlog_callback(void *user_data, uint32_t flags, + const void *data, size_t datalen) { struct quicsocket *qs = (struct quicsocket *)user_data; + (void)flags; if(qs->qlogfd != -1) { ssize_t rc = write(qs->qlogfd, data, datalen); if(rc == -1) { @@ -826,9 +828,8 @@ CURLcode Curl_quic_connect(struct connectdata *conn, if(rv == -1) return CURLE_QUIC_CONNECT_ERROR; - ngtcp2_addr_init(&path.local, (uint8_t *)&qs->local_addr, qs->local_addrlen, - NULL); - ngtcp2_addr_init(&path.remote, (uint8_t*)addr, addrlen, NULL); + ngtcp2_addr_init(&path.local, &qs->local_addr, qs->local_addrlen, NULL); + ngtcp2_addr_init(&path.remote, addr, addrlen, NULL); #ifdef NGTCP2_PROTO_VER #define QUICVER NGTCP2_PROTO_VER @@ -1744,10 +1745,10 @@ static CURLcode ng_process_ingress(struct connectdata *conn, int sockfd, return CURLE_RECV_ERROR; } - ngtcp2_addr_init(&path.local, (uint8_t *)&qs->local_addr, + ngtcp2_addr_init(&path.local, &qs->local_addr, qs->local_addrlen, NULL); - ngtcp2_addr_init(&path.remote, (uint8_t *)&remote_addr, remote_addrlen, - NULL); + ngtcp2_addr_init(&path.remote, (struct sockaddr *)&remote_addr, + remote_addrlen, NULL); rv = ngtcp2_conn_read_pkt(qs->qconn, &path, buf, recvd, ts); if(rv != 0) { @@ -1778,7 +1779,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, nghttp3_vec vec[16]; ssize_t ndatalen; - switch(qs->local_addr.ss_family) { + switch(qs->local_addr.sa_family) { case AF_INET: pktlen = NGTCP2_MAX_PKTLEN_IPV4; break; @@ -1834,7 +1835,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, } continue; } - else if(outlen == NGTCP2_ERR_WRITE_STREAM_MORE) { + else if(outlen == NGTCP2_ERR_WRITE_MORE) { assert(ndatalen > 0); rv = nghttp3_conn_add_write_offset(qs->h3conn, stream_id, ndatalen); diff --git a/Utilities/cmcurl/lib/vquic/ngtcp2.h b/Utilities/cmcurl/lib/vquic/ngtcp2.h index e2f8b56..afdd01b 100644 --- a/Utilities/cmcurl/lib/vquic/ngtcp2.h +++ b/Utilities/cmcurl/lib/vquic/ngtcp2.h @@ -58,7 +58,7 @@ struct quicsocket { struct quic_handshake crypto_data[3]; /* the last TLS alert description generated by the local endpoint */ uint8_t tls_alert; - struct sockaddr_storage local_addr; + struct sockaddr local_addr; socklen_t local_addrlen; nghttp3_conn *h3conn; diff --git a/Utilities/cmcurl/lib/vquic/quiche.c b/Utilities/cmcurl/lib/vquic/quiche.c index be6f15c..fd9cb8b 100644 --- a/Utilities/cmcurl/lib/vquic/quiche.c +++ b/Utilities/cmcurl/lib/vquic/quiche.c @@ -95,8 +95,14 @@ static CURLcode qs_disconnect(struct quicsocket *qs) quiche_h3_config_free(qs->h3config); if(qs->h3c) quiche_h3_conn_free(qs->h3c); - quiche_config_free(qs->cfg); - quiche_conn_free(qs->conn); + if(qs->cfg) { + quiche_config_free(qs->cfg); + qs->cfg = NULL; + } + if(qs->conn) { + quiche_conn_free(qs->conn); + qs->conn = NULL; + } return CURLE_OK; } diff --git a/Utilities/cmcurl/lib/vssh/libssh2.c b/Utilities/cmcurl/lib/vssh/libssh2.c index 555afc9..4f56bb4 100644 --- a/Utilities/cmcurl/lib/vssh/libssh2.c +++ b/Utilities/cmcurl/lib/vssh/libssh2.c @@ -1256,7 +1256,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) result = CURLE_SSH; sshc->actualcode = result; DEBUGF(infof(data, "error = %d makes libcurl = %d\n", - ssherr, (int)result)); + sftperr, (int)result)); state(conn, SSH_STOP); break; } diff --git a/Utilities/cmcurl/lib/vtls/bearssl.c b/Utilities/cmcurl/lib/vtls/bearssl.c index 628e16a..44e7406 100644 --- a/Utilities/cmcurl/lib/vtls/bearssl.c +++ b/Utilities/cmcurl/lib/vtls/bearssl.c @@ -300,8 +300,12 @@ static CURLcode bearssl_connect_step1(struct connectdata *conn, int sockindex) struct ssl_connect_data *connssl = &conn->ssl[sockindex]; struct ssl_backend_data *backend = connssl->backend; const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile); +#ifndef CURL_DISABLE_PROXY const char *hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name : conn->host.name; +#else + const char *hostname = conn->host.name; +#endif const bool verifypeer = SSL_CONN_CONFIG(verifypeer); const bool verifyhost = SSL_CONN_CONFIG(verifyhost); CURLcode ret; @@ -386,8 +390,11 @@ static CURLcode bearssl_connect_step1(struct connectdata *conn, int sockindex) */ #ifdef USE_NGHTTP2 - if(data->set.httpversion >= CURL_HTTP_VERSION_2 && - (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) { + if(data->set.httpversion >= CURL_HTTP_VERSION_2 +#ifndef CURL_DISABLE_PROXY + && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy) +#endif + ) { backend->protocols[cur++] = NGHTTP2_PROTO_VERSION_ID; infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID); } diff --git a/Utilities/cmcurl/lib/vtls/gtls.c b/Utilities/cmcurl/lib/vtls/gtls.c index 9b4c365..16b0bd6 100644 --- a/Utilities/cmcurl/lib/vtls/gtls.c +++ b/Utilities/cmcurl/lib/vtls/gtls.c @@ -399,10 +399,15 @@ gtls_connect_step1(struct connectdata *conn, #endif const char *prioritylist; const char *err = NULL; +#ifndef CURL_DISABLE_PROXY const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name : conn->host.name; long * const certverifyresult = SSL_IS_PROXY() ? &data->set.proxy_ssl.certverifyresult : &data->set.ssl.certverifyresult; +#else + const char * const hostname = conn->host.name; + long * const certverifyresult = &data->set.ssl.certverifyresult; +#endif if(connssl->state == ssl_connection_complete) /* to make us tolerant against being called more than once for the @@ -620,8 +625,11 @@ gtls_connect_step1(struct connectdata *conn, gnutls_datum_t protocols[2]; #ifdef USE_NGHTTP2 - if(data->set.httpversion >= CURL_HTTP_VERSION_2 && - (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) { + if(data->set.httpversion >= CURL_HTTP_VERSION_2 +#ifndef CURL_DISABLE_PROXY + && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy) +#endif + ) { protocols[cur].data = (unsigned char *)NGHTTP2_PROTO_VERSION_ID; protocols[cur].size = NGHTTP2_PROTO_VERSION_ID_LEN; cur++; @@ -694,12 +702,15 @@ gtls_connect_step1(struct connectdata *conn, } } +#ifndef CURL_DISABLE_PROXY if(conn->proxy_ssl[sockindex].use) { transport_ptr = conn->proxy_ssl[sockindex].backend->session; gnutls_transport_push = Curl_gtls_push_ssl; gnutls_transport_pull = Curl_gtls_pull_ssl; } - else { + else +#endif + { /* file descriptor for the socket */ transport_ptr = &conn->sock[sockindex]; gnutls_transport_push = Curl_gtls_push; @@ -828,10 +839,15 @@ gtls_connect_step3(struct connectdata *conn, unsigned int bits; gnutls_protocol_t version = gnutls_protocol_get_version(session); #endif +#ifndef CURL_DISABLE_PROXY const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name : conn->host.name; long * const certverifyresult = SSL_IS_PROXY() ? &data->set.proxy_ssl.certverifyresult : &data->set.ssl.certverifyresult; +#else + const char * const hostname = conn->host.name; + long * const certverifyresult = &data->set.ssl.certverifyresult; +#endif /* the name of the cipher suite used, e.g. ECDHE_RSA_AES_256_GCM_SHA384. */ ptr = gnutls_cipher_suite_get_name(gnutls_kx_get(session), @@ -1112,8 +1128,12 @@ gtls_connect_step3(struct connectdata *conn, } #endif if(!rc) { +#ifndef CURL_DISABLE_PROXY const char * const dispname = SSL_IS_PROXY() ? conn->http_proxy.host.dispname : conn->host.dispname; +#else + const char * const dispname = conn->host.dispname; +#endif if(SSL_CONN_CONFIG(verifyhost)) { failf(data, "SSL: certificate subject name (%s) does not match " @@ -1216,20 +1236,23 @@ gtls_connect_step3(struct connectdata *conn, rc = gnutls_x509_crt_get_dn2(x509_cert, &certfields); - if(rc != 0) - return CURLE_OUT_OF_MEMORY; - infof(data, "\t subject: %s\n", certfields.data); + if(rc) + infof(data, "Failed to get certificate name\n"); + else { + infof(data, "\t subject: %s\n", certfields.data); - certclock = gnutls_x509_crt_get_activation_time(x509_cert); - showtime(data, "start date", certclock); + certclock = gnutls_x509_crt_get_activation_time(x509_cert); + showtime(data, "start date", certclock); - certclock = gnutls_x509_crt_get_expiration_time(x509_cert); - showtime(data, "expire date", certclock); + certclock = gnutls_x509_crt_get_expiration_time(x509_cert); + showtime(data, "expire date", certclock); + } rc = gnutls_x509_crt_get_issuer_dn2(x509_cert, &certfields); - if(rc != 0) - return CURLE_OUT_OF_MEMORY; - infof(data, "\t issuer: %s\n", certfields.data); + if(rc) + infof(data, "Failed to get certificate issuer\n"); + else + infof(data, "\t issuer: %s\n", certfields.data); #endif gnutls_x509_crt_deinit(x509_cert); @@ -1381,10 +1404,13 @@ static bool Curl_gtls_data_pending(const struct connectdata *conn, 0 != gnutls_record_check_pending(backend->session)) res = TRUE; +#ifndef CURL_DISABLE_PROXY connssl = &conn->proxy_ssl[connindex]; + backend = connssl->backend; if(backend->session && 0 != gnutls_record_check_pending(backend->session)) res = TRUE; +#endif return res; } @@ -1433,7 +1459,9 @@ static void close_one(struct ssl_connect_data *connssl) static void Curl_gtls_close(struct connectdata *conn, int sockindex) { close_one(&conn->ssl[sockindex]); +#ifndef CURL_DISABLE_PROXY close_one(&conn->proxy_ssl[sockindex]); +#endif } /* diff --git a/Utilities/cmcurl/lib/vtls/nss.c b/Utilities/cmcurl/lib/vtls/nss.c index fca2926..0f0d1ee 100644 --- a/Utilities/cmcurl/lib/vtls/nss.c +++ b/Utilities/cmcurl/lib/vtls/nss.c @@ -1027,9 +1027,11 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock) CERTCertificate *cert; /* remember the cert verification result */ +#ifndef CURL_DISABLE_PROXY if(SSL_IS_PROXY()) data->set.proxy_ssl.certverifyresult = err; else +#endif data->set.ssl.certverifyresult = err; if(err == SSL_ERROR_BAD_CERT_DOMAIN && !SSL_CONN_CONFIG(verifyhost)) @@ -1553,24 +1555,32 @@ static void nss_close(struct ssl_connect_data *connssl) static void Curl_nss_close(struct connectdata *conn, int sockindex) { struct ssl_connect_data *connssl = &conn->ssl[sockindex]; +#ifndef CURL_DISABLE_PROXY struct ssl_connect_data *connssl_proxy = &conn->proxy_ssl[sockindex]; +#endif struct ssl_backend_data *backend = connssl->backend; - if(backend->handle || connssl_proxy->backend->handle) { + if(backend->handle +#ifndef CURL_DISABLE_PROXY + || connssl_proxy->backend->handle +#endif + ) { /* NSS closes the socket we previously handed to it, so we must mark it as closed to avoid double close */ fake_sclose(conn->sock[sockindex]); conn->sock[sockindex] = CURL_SOCKET_BAD; } +#ifndef CURL_DISABLE_PROXY if(backend->handle) /* nss_close(connssl) will transitively close also connssl_proxy->backend->handle if both are used. Clear it to avoid a double close leading to crash. */ connssl_proxy->backend->handle = NULL; - nss_close(connssl); nss_close(connssl_proxy); +#endif + nss_close(connssl); } /* return true if NSS can provide error code (and possibly msg) for the @@ -1828,6 +1838,12 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) CURLcode result; bool second_layer = FALSE; SSLVersionRange sslver_supported; +#ifndef CURL_DISABLE_PROXY + const char *hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name : + conn->host.name; +#else + const char *hostname = conn->host.name; +#endif SSLVersionRange sslver = { SSL_LIBRARY_VERSION_TLS_1_0, /* min */ @@ -1932,9 +1948,11 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) goto error; /* not checked yet */ +#ifndef CURL_DISABLE_PROXY if(SSL_IS_PROXY()) data->set.proxy_ssl.certverifyresult = 0; else +#endif data->set.ssl.certverifyresult = 0; if(SSL_BadCertHook(model, BadCertHandler, conn) != SECSuccess) @@ -1991,12 +2009,14 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) goto error; } +#ifndef CURL_DISABLE_PROXY if(conn->proxy_ssl[sockindex].use) { DEBUGASSERT(ssl_connection_complete == conn->proxy_ssl[sockindex].state); DEBUGASSERT(conn->proxy_ssl[sockindex].backend->handle != NULL); nspr_io = conn->proxy_ssl[sockindex].backend->handle; second_layer = TRUE; } +#endif else { /* wrap OS file descriptor by NSPR's file descriptor abstraction */ nspr_io = PR_ImportTCPSocket(sockfd); @@ -2077,8 +2097,11 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) unsigned char protocols[128]; #ifdef USE_NGHTTP2 - if(data->set.httpversion >= CURL_HTTP_VERSION_2 && - (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) { + if(data->set.httpversion >= CURL_HTTP_VERSION_2 +#ifndef CURL_DISABLE_PROXY + && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy) +#endif + ) { protocols[cur++] = NGHTTP2_PROTO_VERSION_ID_LEN; memcpy(&protocols[cur], NGHTTP2_PROTO_VERSION_ID, NGHTTP2_PROTO_VERSION_ID_LEN); @@ -2101,14 +2124,11 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex) goto error; /* propagate hostname to the TLS layer */ - if(SSL_SetURL(backend->handle, SSL_IS_PROXY() ? conn->http_proxy.host.name : - conn->host.name) != SECSuccess) + if(SSL_SetURL(backend->handle, hostname) != SECSuccess) goto error; /* prevent NSS from re-using the session for a different hostname */ - if(SSL_SetSockPeerID(backend->handle, SSL_IS_PROXY() ? - conn->http_proxy.host.name : conn->host.name) - != SECSuccess) + if(SSL_SetSockPeerID(backend->handle, hostname) != SECSuccess) goto error; return CURLE_OK; @@ -2127,11 +2147,17 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex) struct Curl_easy *data = conn->data; CURLcode result = CURLE_SSL_CONNECT_ERROR; PRUint32 timeout; +#ifndef CURL_DISABLE_PROXY long * const certverifyresult = SSL_IS_PROXY() ? &data->set.proxy_ssl.certverifyresult : &data->set.ssl.certverifyresult; const char * const pinnedpubkey = SSL_IS_PROXY() ? data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] : data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]; +#else + long * const certverifyresult = &data->set.ssl.certverifyresult; + const char * const pinnedpubkey = + data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]; +#endif /* check timeout situation */ diff --git a/Utilities/cmcurl/lib/vtls/openssl.c b/Utilities/cmcurl/lib/vtls/openssl.c index 2e9f900..1685a4a 100644 --- a/Utilities/cmcurl/lib/vtls/openssl.c +++ b/Utilities/cmcurl/lib/vtls/openssl.c @@ -619,7 +619,9 @@ SSL_CTX_use_certificate_chain_bio(SSL_CTX *ctx, BIO* in, const char *key_passwd) { /* SSL_CTX_add1_chain_cert introduced in OpenSSL 1.0.2 */ -#if (OPENSSL_VERSION_NUMBER >= 0x1000200fL) /* 1.0.2 or later */ +#if (OPENSSL_VERSION_NUMBER >= 0x1000200fL) && /* OpenSSL 1.0.2 or later */ \ + !(defined(LIBRESSL_VERSION_NUMBER) && \ + (LIBRESSL_VERSION_NUMBER < 0x2090100fL)) /* LibreSSL 2.9.1 or later */ int ret = 0; X509 *x = NULL; void *passwd_callback_userdata = (void *)key_passwd; @@ -2825,7 +2827,8 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex) if((SSL_CONN_CONFIG(verifypeer) || SSL_CONN_CONFIG(verifyhost)) && (SSL_SET_OPTION(native_ca_store))) { X509_STORE *store = SSL_CTX_get_cert_store(backend->ctx); - HCERTSTORE hStore = CertOpenSystemStoreA((HCRYPTPROV_LEGACY)NULL, "ROOT"); + HCERTSTORE hStore = CertOpenSystemStore((HCRYPTPROV_LEGACY)NULL, + TEXT("ROOT")); if(hStore) { PCCERT_CONTEXT pContext = NULL; diff --git a/Utilities/cmcurl/lib/vtls/schannel.c b/Utilities/cmcurl/lib/vtls/schannel.c index 1996526..1c1432d 100644 --- a/Utilities/cmcurl/lib/vtls/schannel.c +++ b/Utilities/cmcurl/lib/vtls/schannel.c @@ -50,7 +50,7 @@ #include "x509asn1.h" #include "curl_printf.h" #include "multiif.h" -#include "system_win32.h" +#include "version_win32.h" /* The last #include file should be: */ #include "curl_memory.h" @@ -436,8 +436,8 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) "schannel: SSL/TLS connection with %s port %hu (step 1/3)\n", hostname, conn->remote_port)); - if(Curl_verify_windows_version(5, 1, PLATFORM_WINNT, - VERSION_LESS_THAN_EQUAL)) { + if(curlx_verify_windows_version(5, 1, PLATFORM_WINNT, + VERSION_LESS_THAN_EQUAL)) { /* Schannel in Windows XP (OS version 5.1) uses legacy handshakes and algorithms that may not be supported by all servers. */ infof(data, "schannel: Windows version is old and may not be able to " @@ -448,10 +448,10 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) /* ALPN is only supported on Windows 8.1 / Server 2012 R2 and above. Also it doesn't seem to be supported for Wine, see curl bug #983. */ BACKEND->use_alpn = conn->bits.tls_enable_alpn && - !GetProcAddress(GetModuleHandleA("ntdll"), + !GetProcAddress(GetModuleHandle(TEXT("ntdll")), "wine_get_version") && - Curl_verify_windows_version(6, 3, PLATFORM_WINNT, - VERSION_GREATER_THAN_EQUAL); + curlx_verify_windows_version(6, 3, PLATFORM_WINNT, + VERSION_GREATER_THAN_EQUAL); #else BACKEND->use_alpn = false; #endif @@ -467,8 +467,8 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) #else #ifdef HAS_MANUAL_VERIFY_API if(SSL_CONN_CONFIG(CAfile)) { - if(Curl_verify_windows_version(6, 1, PLATFORM_WINNT, - VERSION_GREATER_THAN_EQUAL)) { + if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT, + VERSION_GREATER_THAN_EQUAL)) { BACKEND->use_manual_cred_validation = true; } else { @@ -2015,8 +2015,8 @@ schannel_recv(struct connectdata *conn, int sockindex, */ if(len && !BACKEND->decdata_offset && BACKEND->recv_connection_closed && !BACKEND->recv_sspi_close_notify) { - bool isWin2k = Curl_verify_windows_version(5, 0, PLATFORM_WINNT, - VERSION_EQUAL); + bool isWin2k = curlx_verify_windows_version(5, 0, PLATFORM_WINNT, + VERSION_EQUAL); if(isWin2k && sspi_status == SEC_E_OK) BACKEND->recv_sspi_close_notify = true; diff --git a/Utilities/cmcurl/lib/vtls/schannel_verify.c b/Utilities/cmcurl/lib/vtls/schannel_verify.c index bdd7199..ab7be39 100644 --- a/Utilities/cmcurl/lib/vtls/schannel_verify.c +++ b/Utilities/cmcurl/lib/vtls/schannel_verify.c @@ -45,7 +45,7 @@ #include "curl_multibyte.h" #include "curl_printf.h" #include "hostcheck.h" -#include "system_win32.h" +#include "version_win32.h" /* The last #include file should be: */ #include "curl_memory.h" @@ -317,8 +317,8 @@ static DWORD cert_get_name_string(struct Curl_easy *data, DWORD i; /* CERT_NAME_SEARCH_ALL_NAMES_FLAG is available from Windows 8 onwards. */ - if(Curl_verify_windows_version(6, 2, PLATFORM_WINNT, - VERSION_GREATER_THAN_EQUAL)) { + if(curlx_verify_windows_version(6, 2, PLATFORM_WINNT, + VERSION_GREATER_THAN_EQUAL)) { #ifdef CERT_NAME_SEARCH_ALL_NAMES_FLAG /* CertGetNameString will provide the 8-bit character string without * any decoding */ @@ -564,7 +564,7 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex) * trusted certificates. This is only supported on Windows 7+. */ - if(Curl_verify_windows_version(6, 1, PLATFORM_WINNT, VERSION_LESS_THAN)) { + if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT, VERSION_LESS_THAN)) { failf(data, "schannel: this version of Windows is too old to support " "certificate verification via CA bundle file."); result = CURLE_SSL_CACERT_BADFILE; diff --git a/Utilities/cmcurl/lib/vtls/vtls.c b/Utilities/cmcurl/lib/vtls/vtls.c index c3a55fb..281043a 100644 --- a/Utilities/cmcurl/lib/vtls/vtls.c +++ b/Utilities/cmcurl/lib/vtls/vtls.c @@ -621,6 +621,7 @@ void Curl_ssl_close(struct connectdata *conn, int sockindex) { DEBUGASSERT((sockindex <= 1) && (sockindex >= -1)); Curl_ssl->close_one(conn, sockindex); + conn->ssl[sockindex].state = ssl_connection_none; } CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex) @@ -236,6 +236,7 @@ cmake_xdgdata_dir_default="`cmake_install_dest_default XDGDATA ${cmake_xdgdata_d CMAKE_KNOWN_C_COMPILERS="cc gcc clang xlc icc tcc" CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ clang++ c++ icc como " CMAKE_KNOWN_MAKE_PROCESSORS="gmake make" +CMAKE_KNOWN_NINJA_PROCESSORS="ninja-build ninja" CMAKE_PROBLEMATIC_FILES="\ CMakeCache.txt \ @@ -309,8 +310,6 @@ CMAKE_CXX_SOURCES="\ cmCustomCommandLines \ cmDefinePropertyCommand \ cmDefinitions \ - cmDepends \ - cmDependsC \ cmDocumentationFormatter \ cmEnableLanguageCommand \ cmEnableTestingCommand \ @@ -361,7 +360,6 @@ CMAKE_CXX_SOURCES="\ cmGetTestPropertyCommand \ cmGlobalCommonGenerator \ cmGlobalGenerator \ - cmGlobalUnixMakefileGenerator3 \ cmGlobVerificationManager \ cmHexFileConverter \ cmIfCommand \ @@ -392,15 +390,10 @@ CMAKE_CXX_SOURCES="\ cmListFileCache \ cmLocalCommonGenerator \ cmLocalGenerator \ - cmLocalUnixMakefileGenerator3 \ cmMSVC60LinkLineComputer \ cmMacroCommand \ cmMakeDirectoryCommand \ cmMakefile \ - cmMakefileExecutableTargetGenerator \ - cmMakefileLibraryTargetGenerator \ - cmMakefileTargetGenerator \ - cmMakefileUtilityTargetGenerator \ cmMarkAsAdvancedCommand \ cmMathCommand \ cmMessageCommand \ @@ -607,6 +600,8 @@ Configuration: --verbose display more information --parallel=n bootstrap cmake in parallel, where n is number of nodes [1] + --generator=<generator> generator to use (MSYS Makefiles, Unix Makefiles, + or Ninja) --enable-ccache Enable ccache when building cmake --init=FILE load FILE as script to populate cache --system-libs use all system-installed third-party libraries @@ -637,6 +632,8 @@ Configuration: --no-system-libuv use cmake-provided libuv library (default) --bootstrap-system-libuv use system-installed libuv library for bootstrap + --bootstrap-system-jsoncpp use system-installed jsoncpp library for bootstrap + --bootstrap-system-librhash use system-installed librhash library for bootstrap --qt-gui build the Qt-based GUI (requires Qt >= 4.2) --no-qt-gui do not build the Qt-based GUI (default) @@ -689,16 +686,23 @@ cmake_error() exit ${res} } +cmake_generate_file_tmp () +{ + OUTFILE="$1" + TMPFILE="$2" + if "${_diff}" "$TMPFILE" "$OUTFILE" > /dev/null 2> /dev/null ; then + rm -f "$TMPFILE" + else + mv -f "$TMPFILE" "$OUTFILE" + fi +} + cmake_generate_file () { OUTFILE="$1" CONTENT="$2" echo "$CONTENT" > "$OUTFILE.tmp" - if "${_diff}" "$OUTFILE.tmp" "$OUTFILE" > /dev/null 2> /dev/null ; then - rm -f "$OUTFILE.tmp" - else - mv -f "$OUTFILE.tmp" "$OUTFILE" - fi + cmake_generate_file_tmp "$OUTFILE" "$OUTFILE.tmp" } # Replace KWSYS_NAMESPACE with cmsys @@ -760,8 +764,18 @@ cmake_report () echo "$*" >> ${FILE} } -# Escape spaces in strings -cmake_escape () +# Escape spaces in strings for artifacts +cmake_escape_artifact () +{ + if test "${cmake_bootstrap_generator}" = "Ninja"; then + echo $1 | sed "s/ /$ /g" + else + echo $1 | sed "s/ /\\\\ /g" + fi +} + +# Escape spaces in strings for shell +cmake_escape_shell () { echo $1 | sed "s/ /\\\\ /g" } @@ -861,11 +875,14 @@ cmake_parallel_make= cmake_ccache_enabled= cmake_prefix_dir="${cmake_default_prefix}" bootstrap_system_libuv= +bootstrap_system_jsoncpp= +bootstrap_system_librhash= while test $# != 0; do case "$1" in --prefix=*) dir=`cmake_arg "$1"` cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;; --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;; + --generator=*) cmake_bootstrap_generator=`cmake_arg "$1"` ;; --bindir=*) cmake_bin_dir=`cmake_arg "$1"` ;; --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;; --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;; @@ -881,6 +898,8 @@ while test $# != 0; do lib=`cmake_arg "$1" "--no-system-"` cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;; --bootstrap-system-libuv) bootstrap_system_libuv="1" ;; + --bootstrap-system-jsoncpp) bootstrap_system_jsoncpp="1" ;; + --bootstrap-system-librhash) bootstrap_system_librhash="1" ;; --qt-gui) cmake_bootstrap_qt_gui="1" ;; --no-qt-gui) cmake_bootstrap_qt_gui="0" ;; --qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;; @@ -905,6 +924,13 @@ while test $# != 0; do shift done +# Make sure the generator is valid +if test "${cmake_bootstrap_generator}" != "MSYS Makefiles" -a \ + "${cmake_bootstrap_generator}" != "Unix Makefiles" -a \ + "${cmake_bootstrap_generator}" != "Ninja"; then + cmake_error 10 "Invalid generator: ${cmake_bootstrap_generator}" +fi + # If verbose, display some information about bootstrap if test -n "${cmake_verbose}"; then echo "---------------------------------------------" @@ -912,6 +938,7 @@ if test -n "${cmake_verbose}"; then echo "Binary directory: ${cmake_binary_dir}" echo "Prefix directory: ${cmake_prefix_dir}" echo "System: ${cmake_system}" + echo "Generator: ${cmake_bootstrap_generator}" if test "x${cmake_parallel_make}" != "x"; then echo "Doing parallel make: ${cmake_parallel_make}" fi @@ -980,6 +1007,58 @@ cmake_c_flags=${CFLAGS} cmake_cxx_flags=${CXXFLAGS} cmake_ld_flags=${LDFLAGS} +# Add generator-specific files +if test "${cmake_bootstrap_generator}" = "Ninja"; then + CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES} \ + cmCryptoHash \ + cmFortranParserImpl \ + cmGlobalNinjaGenerator \ + cmLocalNinjaGenerator \ + cmNinjaLinkLineComputer \ + cmNinjaLinkLineDeviceComputer \ + cmNinjaNormalTargetGenerator \ + cmNinjaTargetGenerator \ + cmNinjaUtilityTargetGenerator \ + " + + LexerParser_CXX_SOURCES="${LexerParser_CXX_SOURCES} \ + cmFortranLexer \ + cmFortranParser \ + " + + JSONCPP_CXX_SOURCES="\ + src/lib_json/json_reader.cpp \ + src/lib_json/json_value.cpp \ + src/lib_json/json_writer.cpp \ + " + + LIBRHASH_C_SOURCES="\ + librhash/algorithms.c \ + librhash/byte_order.c \ + librhash/hex.c \ + librhash/md5.c \ + librhash/rhash.c \ + librhash/sha1.c \ + librhash/sha256.c \ + librhash/sha3.c \ + librhash/sha512.c \ + " +else + CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES} \ + cmDepends \ + cmDependsC \ + cmGlobalUnixMakefileGenerator3 \ + cmLocalUnixMakefileGenerator3 \ + cmMakefileExecutableTargetGenerator \ + cmMakefileLibraryTargetGenerator \ + cmMakefileTargetGenerator \ + cmMakefileUtilityTargetGenerator \ + " + + JSONCPP_CXX_SOURCES= + LIBRHASH_C_SOURCES= +fi + # Add Cygwin-specific flags if ${cmake_system_cygwin}; then cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import" @@ -1288,6 +1367,8 @@ cmake_make_flags= # If MAKE is set, use that for make processor, otherwise use list of known make if test -n "${MAKE}"; then cmake_make_processors="${MAKE}" +elif test "${cmake_bootstrap_generator}" = "Ninja"; then + cmake_make_processors="${CMAKE_KNOWN_NINJA_PROCESSORS}" else cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}" fi @@ -1296,10 +1377,18 @@ TMPFILE="`cmake_tmp_file`_dir" rm -rf "${cmake_bootstrap_dir}/${TMPFILE}" mkdir "${cmake_bootstrap_dir}/${TMPFILE}" cd "${cmake_bootstrap_dir}/${TMPFILE}" -echo ' +if test "${cmake_bootstrap_generator}" = "Ninja"; then + echo ' +rule cc + command = "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o $out $in +build test: cc test.c +'>"build.ninja" +else + echo ' test: test.c "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c '>"Makefile" +fi echo ' #include <stdio.h> int main(){ printf("1%c", (char)0x0a); return 0; } @@ -1326,15 +1415,20 @@ if test "x${cmake_original_make_flags}" != "x${cmake_make_flags}"; then fi cd "${cmake_bootstrap_dir}" +if test "${cmake_bootstrap_generator}" = "Ninja"; then + mf_str=Ninja +else + mf_str=Makefile +fi if test -z "${cmake_make_processor}"; then - cmake_error 8 "Cannot find appropriate Makefile processor on this system. + cmake_error 8 "Cannot find appropriate ${mf_str} processor on this system. Please specify one using environment variable MAKE." fi rm -rf "${cmake_bootstrap_dir}/${TMPFILE}" -echo "Makefile processor on this system is: ${cmake_make_processor}" +echo "${mf_str} processor on this system is: ${cmake_make_processor}" if test "x${cmake_full_make_flags}" != "x${cmake_make_flags}"; then echo "---------------------------------------------" - echo "Makefile processor ${cmake_make_processor} does not support parallel build" + echo "${mf_str} processor ${cmake_make_processor} does not support parallel build" echo "---------------------------------------------" fi @@ -1431,6 +1525,10 @@ cmake_compiler_settings_comment="/* * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} * libuv Sources: * ${LIBUV_C_SOURCES} + * jsoncpp Sources: + * ${JSONCPP_CXX_SOURCES} + * librhash Sources: + * ${LIBRHASH_C_SOURCES} */ " @@ -1458,6 +1556,12 @@ cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insall cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CM_FALLTHROUGH" +if test "${cmake_bootstrap_generator}" = "Ninja"; then + cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_NINJA" +else + cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_MAKEFILES" +fi + if ${cmake_system_mingw}; then cmake_report cmConfigure.h${_tmp} "#if defined(_WIN32) && !defined(NOMINMAX)" cmake_report cmConfigure.h${_tmp} "# define NOMINMAX" @@ -1474,6 +1578,7 @@ for h in Configure VersionConfig; do done # Prepare KWSYS +cmsys_header_files="cmsys/Configure.h cmsys/Configure.hxx" cmake_kwsys_config_replace_string \ "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \ "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \ @@ -1486,14 +1591,33 @@ cmake_kwsys_config_replace_string \ for a in ${KWSYS_FILES}; do cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \ "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys + cmsys_header_files="${cmsys_header_files} cmsys/${a}" done -cmake_generate_file "${cmake_bootstrap_dir}/cmThirdParty.h" "" +echo "#ifndef cmThirdParty_h" > "${cmake_bootstrap_dir}/cmThirdParty.h.tmp" +echo "#define cmThirdParty_h" >> "${cmake_bootstrap_dir}/cmThirdParty.h.tmp" +if test "x${bootstrap_system_libuv}" != "x"; then + echo "#define CMAKE_USE_SYSTEM_LIBUV" >> "${cmake_bootstrap_dir}/cmThirdParty.h.tmp" +fi +if test "x${bootstrap_system_jsoncpp}" != "x"; then + echo "#define CMAKE_USE_SYSTEM_JSONCPP" >> "${cmake_bootstrap_dir}/cmThirdParty.h.tmp" +fi +if test "x${bootstrap_system_librhash}" != "x"; then + echo "#define CMAKE_USE_SYSTEM_LIBRHASH" >> "${cmake_bootstrap_dir}/cmThirdParty.h.tmp" +fi +echo "#endif" >> "${cmake_bootstrap_dir}/cmThirdParty.h.tmp" +cmake_generate_file_tmp "${cmake_bootstrap_dir}/cmThirdParty.h" "${cmake_bootstrap_dir}/cmThirdParty.h.tmp" # Generate Makefile -dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.hxx `cmake_escape \"${cmake_source_dir}\"`/Source/*.h" +dep="cmConfigure.h ${cmsys_header_files}" +for h in "${cmake_source_dir}"/Source/*.hxx; do + dep="${dep} `cmake_escape_artifact \"${h}\"`" +done +for h in "${cmake_source_dir}"/Source/*.h; do + dep="${dep} `cmake_escape_artifact \"${h}\"`" +done for h in ${CMAKE_STD_CXX_HEADERS}; do - dep="${dep} `cmake_escape \"${cmake_source_dir}\"`/Utilities/std/cm/${h}" + dep="${dep} `cmake_escape_artifact \"${cmake_source_dir}\"`/Utilities/std/cm/${h}" done objs="" for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${CMAKE_STD_CXX_SOURCES} ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do @@ -1504,6 +1628,18 @@ if test "x${bootstrap_system_libuv}" = "x"; then objs="${objs} uv-`cmake_obj ${a}`" done fi +if test "${cmake_bootstrap_generator}" = "Ninja"; then + if test "x${bootstrap_system_jsoncpp}" = "x"; then + for a in ${JSONCPP_CXX_SOURCES}; do + objs="${objs} jsoncpp-`cmake_obj ${a}`" + done + fi + if test "x${bootstrap_system_librhash}" = "x"; then + for a in ${LIBRHASH_C_SOURCES}; do + objs="${objs} rhash-`cmake_obj ${a}`" + done + fi +fi libs="" @@ -1542,19 +1678,44 @@ else esac fi if test "x${bootstrap_system_libuv}" = "x"; then - uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/include"`" + uv_c_flags="${uv_c_flags} `cmake_escape_shell "-I${cmake_source_dir}/Utilities/cmlibuv/include"`" if ${cmake_system_mingw}; then - uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src/win"`" + uv_c_flags="${uv_c_flags} `cmake_escape_shell "-I${cmake_source_dir}/Utilities/cmlibuv/src/win"`" else - uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src/unix"`" + uv_c_flags="${uv_c_flags} `cmake_escape_shell "-I${cmake_source_dir}/Utilities/cmlibuv/src/unix"`" fi - uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src"`" + uv_c_flags="${uv_c_flags} `cmake_escape_shell "-I${cmake_source_dir}/Utilities/cmlibuv/src"`" else if test `which pkg-config`; then - uv_c_flags="${uv_c_flags} `pkg-config --cflags libuv`" + use_uv_flags="`pkg-config --cflags libuv`" + cmake_c_flags="${cmake_c_flags} ${use_uv_flags}" + cmake_cxx_flags="${cmake_cxx_flags} ${use_uv_flags}" fi libs="${libs} -luv" fi + +if test "${cmake_bootstrap_generator}" = "Ninja"; then + jsoncpp_cxx_flags= + if test "x${bootstrap_system_jsoncpp}" = "x"; then + jsoncpp_cxx_flags="${jsoncpp_cxx_flags} `cmake_escape_shell "-I${cmake_source_dir}/Utilities/cmjsoncpp/include"`" + else + if test `which pkg-config`; then + use_jsoncpp_flags="`pkg-config --cflags jsoncpp`" + cmake_cxx_flags="${cmake_cxx_flags} ${use_jsoncpp_flags}" + fi + libs="${libs} -ljsoncpp" + fi + + if test "x${bootstrap_system_librhash}" != "x"; then + if test `which pkg-config`; then + use_librhash_flags="`pkg-config --cflags librhash`" + cmake_c_flags="${cmake_c_flags} ${use_librhash_flags}" + cmake_cxx_flags="${cmake_cxx_flags} ${use_librhash_flags}" + fi + libs="${libs} -lrhash" + fi +fi + if test "x${cmake_ansi_cxx_flags}" != "x"; then cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}" fi @@ -1567,6 +1728,31 @@ if test "x${cmake_cxx_flags}" != "x"; then cmake_cxx_flags="${cmake_cxx_flags} " fi +write_source_rule() { + lang="$1" + obj="$2" + src="$3" + src_flags="$4" + + if test "${lang}" = "c"; then + ninja_rule=cc + compiler="${cmake_c_compiler}" + flags="${cmake_c_flags}" + elif test "${lang}" = "cxx"; then + ninja_rule=cxx + compiler="${cmake_cxx_compiler}" + flags="${cmake_cxx_flags}" + fi + + if test "${cmake_bootstrap_generator}" = "Ninja"; then + echo "build ${obj} : ${ninja_rule} ${src} | ${dep}" >> "${cmake_bootstrap_dir}/build.ninja" + echo " srcflags = ${src_flags}" >> "${cmake_bootstrap_dir}/build.ninja" + else + echo "${obj} : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" + echo " ${compiler} ${flags} ${src_flags} -c ${src} -o ${obj}" >> "${cmake_bootstrap_dir}/Makefile" + fi +} + cmake_c_flags_String="-DKWSYS_STRING_C" if ${cmake_system_mingw}; then cmake_c_flags_EncodingC="-DKWSYS_ENCODING_DEFAULT_CODEPAGE=CP_ACP" @@ -1582,71 +1768,102 @@ cmake_cxx_flags_SystemTools=" " cmake_c_flags="${cmake_c_flags} \ -DCMAKE_BOOTSTRAP \ - -I`cmake_escape \"${cmake_bootstrap_dir}\"` \ - -I`cmake_escape \"${cmake_source_dir}/Source\"` \ - -I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \ - -I`cmake_escape \"${cmake_source_dir}/Utilities\"`" + -I`cmake_escape_shell \"${cmake_bootstrap_dir}\"` \ + -I`cmake_escape_shell \"${cmake_source_dir}/Source\"` \ + -I`cmake_escape_shell \"${cmake_source_dir}/Source/LexerParser\"` \ + -I`cmake_escape_shell \"${cmake_source_dir}/Utilities\"`" cmake_cxx_flags="${cmake_cxx_flags} \ -DCMAKE_BOOTSTRAP \ ${cmake_have_cxx_features} \ - -I`cmake_escape \"${cmake_bootstrap_dir}\"` \ - -I`cmake_escape \"${cmake_source_dir}/Source\"` \ - -I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \ - -I`cmake_escape \"${cmake_source_dir}/Utilities/std\"` \ - -I`cmake_escape \"${cmake_source_dir}/Utilities\"`" -echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile" -echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} ${libs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile" + -I`cmake_escape_shell \"${cmake_bootstrap_dir}\"` \ + -I`cmake_escape_shell \"${cmake_source_dir}/Source\"` \ + -I`cmake_escape_shell \"${cmake_source_dir}/Source/LexerParser\"` \ + -I`cmake_escape_shell \"${cmake_source_dir}/Utilities/std\"` \ + -I`cmake_escape_shell \"${cmake_source_dir}/Utilities\"`" +if test "${cmake_bootstrap_generator}" = "Ninja"; then + echo "cc = ${cmake_c_compiler}" > "${cmake_bootstrap_dir}/build.ninja" + echo "cxx = ${cmake_cxx_compiler}" >> "${cmake_bootstrap_dir}/build.ninja" + echo "cflags = ${cmake_c_flags}" >> "${cmake_bootstrap_dir}/build.ninja" + echo "cxxflags = ${cmake_cxx_flags}" >> "${cmake_bootstrap_dir}/build.ninja" + echo "ldflags = ${cmake_ld_flags}" >> "${cmake_bootstrap_dir}/build.ninja" + echo "rule cc" >> "${cmake_bootstrap_dir}/build.ninja" + echo " command = \$cc \$cflags \$srcflags -c \$in -o \$out" >> "${cmake_bootstrap_dir}/build.ninja" + echo "rule cxx" >> "${cmake_bootstrap_dir}/build.ninja" + echo " command = \$cxx \$cxxflags \$srcflags -c \$in -o \$out" >> "${cmake_bootstrap_dir}/build.ninja" + echo "rule link" >> "${cmake_bootstrap_dir}/build.ninja" + echo " command = \$cxx \$ldflags \$cxxflags \$in \$libs -o \$out" >> "${cmake_bootstrap_dir}/build.ninja" + echo "build cmake: link ${objs}" >> "${cmake_bootstrap_dir}/build.ninja" + echo " libs = ${libs}" >> "${cmake_bootstrap_dir}/build.ninja" +else + echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile" + echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} ${libs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile" +fi for a in ${CMAKE_CXX_SOURCES}; do - src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"` + src=`cmake_escape_artifact "${cmake_source_dir}/Source/${a}.cxx"` src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` - echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" + write_source_rule "cxx" "${a}.o" "${src}" "${src_flags}" done for a in ${CMAKE_C_SOURCES}; do - src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"` - echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" + src=`cmake_escape_artifact "${cmake_source_dir}/Source/${a}.c"` + write_source_rule "c" "${a}.o" "${src}" "" done for a in ${CMAKE_STD_CXX_SOURCES}; do - src=`cmake_escape "${cmake_source_dir}/Utilities/std/cm/bits/${a}.cxx"` + src=`cmake_escape_artifact "${cmake_source_dir}/Utilities/std/cm/bits/${a}.cxx"` src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` - echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" + write_source_rule "cxx" "${a}.o" "${src}" "${src_flags}" done for a in ${LexerParser_CXX_SOURCES}; do - src=`cmake_escape "${cmake_source_dir}/Source/LexerParser/${a}.cxx"` + src=`cmake_escape_artifact "${cmake_source_dir}/Source/LexerParser/${a}.cxx"` src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` - echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" + write_source_rule "cxx" "${a}.o" "${src}" "${src_flags}" done for a in ${LexerParser_C_SOURCES}; do - src=`cmake_escape "${cmake_source_dir}/Source/LexerParser/${a}.c"` - echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" + src=`cmake_escape_artifact "${cmake_source_dir}/Source/LexerParser/${a}.c"` + write_source_rule "c" "${a}.o" "${src}" "" done for a in ${KWSYS_C_SOURCES}; do - src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"` - src_flags=`eval echo \\${cmake_c_flags_\${a}}` - echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" + src=`cmake_escape_artifact "${cmake_source_dir}/Source/kwsys/${a}.c"` + src_flags="`eval echo \\${cmake_c_flags_\${a}}` -DKWSYS_NAMESPACE=cmsys" + write_source_rule "c" "${a}.o" "${src}" "${src_flags}" done for a in ${KWSYS_CXX_SOURCES}; do - src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"` - src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` - echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" + src=`cmake_escape_artifact "${cmake_source_dir}/Source/kwsys/${a}.cxx"` + src_flags="`eval echo \\${cmake_cxx_flags_\${a}}` -DKWSYS_NAMESPACE=cmsys" + write_source_rule "cxx" "${a}.o" "${src}" "${src_flags}" done if test "x${bootstrap_system_libuv}" = "x"; then for a in ${LIBUV_C_SOURCES}; do - src=`cmake_escape "${cmake_source_dir}/Utilities/cmlibuv/${a}"` - echo "uv-`cmake_obj ${a}` : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_c_compiler} ${cmake_c_flags} ${uv_c_flags} -c ${src} -o uv-`cmake_obj ${a}`" >> "${cmake_bootstrap_dir}/Makefile" + src=`cmake_escape_artifact "${cmake_source_dir}/Utilities/cmlibuv/${a}"` + write_source_rule "c" "uv-`cmake_obj ${a}`" "${src}" "${uv_c_flags}" done fi -echo ' +if test "${cmake_bootstrap_generator}" = "Ninja"; then + if test "x${bootstrap_system_jsoncpp}" = "x"; then + for a in ${JSONCPP_CXX_SOURCES}; do + src=`cmake_escape_artifact "${cmake_source_dir}/Utilities/cmjsoncpp/${a}"` + write_source_rule "cxx" "jsoncpp-`cmake_obj ${a}`" "${src}" "${jsoncpp_cxx_flags}" + done + fi + if test "x${bootstrap_system_librhash}" = "x"; then + for a in ${LIBRHASH_C_SOURCES}; do + src=`cmake_escape_artifact "${cmake_source_dir}/Utilities/cmlibrhash/${a}"` + write_source_rule "c" "rhash-`cmake_obj ${a}`" "${src}" "" + done + fi +fi +if test "${cmake_bootstrap_generator}" = "Ninja"; then + echo " +rule rebuild_cache + command = cd \"${cmake_binary_dir}\" && \"${cmake_source_dir}/bootstrap\" --generator=\"${cmake_bootstrap_generator}\" + generator = 1 +build build.ninja : rebuild_cache +" >> "${cmake_bootstrap_dir}/build.ninja" +else + echo " rebuild_cache: - cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap" -' >> "${cmake_bootstrap_dir}/Makefile" + cd \"${cmake_binary_dir}\" && \"${cmake_source_dir}/bootstrap\" --generator=\"${cmake_bootstrap_generator}\" +" >> "${cmake_bootstrap_dir}/Makefile" +fi # Write our default settings to Bootstrap${_cmk}/InitialCacheFlags.cmake. echo ' @@ -1715,10 +1932,15 @@ fi echo "---------------------------------------------" # Run make to build bootstrap cmake +if test "${cmake_bootstrap_generator}" = "Ninja"; then + ninja_v=-v +else + ninja_v= +fi if test "x${cmake_parallel_make}" != "x"; then - ${cmake_make_processor} ${cmake_make_flags} + ${cmake_make_processor} ${cmake_make_flags} ${ninja_v} else - ${cmake_make_processor} + ${cmake_make_processor} ${ninja_v} fi RES=$? if test "${RES}" -ne "0"; then |