diff options
103 files changed, 1138 insertions, 291 deletions
diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index 3532765..4b4656a 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -35,7 +35,7 @@ variables: VCVARSALL: "${VS170COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat" VCVARSPLATFORM: "x64" - VCVARSVERSION: "14.31.31103" + VCVARSVERSION: "14.32.31326" .windows_vs2022_x64_ninja: extends: @@ -54,7 +54,7 @@ CMAKE_CONFIGURATION: windows_vs2022_x64 CMAKE_GENERATOR: "Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM: "x64" - CMAKE_GENERATOR_TOOLSET: "v143,version=14.31.31103" + CMAKE_GENERATOR_TOOLSET: "v143,version=14.32.31326" CMAKE_CI_NIGHTLY_IGNORE_DEPS: "true" .windows_vs2019_x64: @@ -173,7 +173,7 @@ - windows - shell - vs2022 - - msvc-19.31 + - msvc-19.32 - nonconcurrent .windows_tags_concurrent_vs2022: @@ -182,7 +182,7 @@ - windows - shell - vs2022 - - msvc-19.31 + - msvc-19.32 - concurrent .windows_tags_concurrent_vs2019: diff --git a/Copyright.txt b/Copyright.txt index 4b6a7f5..2cf1769 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -78,6 +78,7 @@ The following individuals and institutions are among the Contributors: * Michael Hirsch, Ph.D. <www.scivision.co> * Michael Stürmer * Miguel A. Figueroa-Villanueva +* Mike Durso <rbprogrammer@gmail.com> * Mike Jackson * Mike McQuaid <mike@mikemcquaid.com> * Nicolas Bock <nicolasbock@gmail.com> diff --git a/Help/command/install.rst b/Help/command/install.rst index 1a9dfd7..973aa31 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -85,7 +85,7 @@ signatures that specify them. The common options are: ``COMPONENT`` Specify an installation component name with which the install rule - is associated, such as "runtime" or "development". During + is associated, such as ``Runtime`` or ``Development``. During component-specific installation only install rules associated with the given component name will be executed. During a full installation all components are installed unless marked with ``EXCLUDE_FROM_ALL``. diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 08f8d5b..4b2a631 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -150,6 +150,7 @@ Other Behavior Settings * :variable:`CMAKE_LINK_SEARCH_END_STATIC` * :variable:`CMAKE_MSVC_RUNTIME_LIBRARY` * :variable:`CMAKE_POSITION_INDEPENDENT_CODE` + * :variable:`CMAKE_WATCOM_RUNTIME_LIBRARY` If :policy:`CMP0056` is set to ``NEW``, then :variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well. diff --git a/Help/dev/source.rst b/Help/dev/source.rst index 0ee104f..f488b3e 100644 --- a/Help/dev/source.rst +++ b/Help/dev/source.rst @@ -35,6 +35,18 @@ Available features are: * From ``C++14``: + * ``<cm/array>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + + * ``<cm/deque>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + + * ``<cm/forward_list>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + * ``<cm/iomanip>``: ``cm::quoted`` @@ -42,68 +54,142 @@ Available features are: ``cm::make_reverse_iterator``, ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, ``cm::crbegin``, ``cm::crend`` + * ``<cm/list>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + + * ``<cm/map>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + * ``<cm/memory>``: ``cm::make_unique`` + * ``<cm/set>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + + * ``<cm/string>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + + * ``<cm/string_view>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + * ``<cm/shared_mutex>``: ``cm::shared_lock`` * ``<cm/type_traits>``: ``cm::enable_if_t`` + * ``<cm/unordered_map>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + + * ``<cm/unordered_set>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + + * ``<cm/vector>``: + ``cm::cbegin``, ``cm::cend``, ``cm::rbegin``, ``cm::rend``, + ``cm::crbegin``, ``cm::crend`` + * From ``C++17``: * ``<cm/algorithm>``: ``cm::clamp`` + * ``<cm/array>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + + * ``<cm/deque>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + * ``cm/filesystem>``: ``cm::filesystem::path`` + * ``<cm/forward_list>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + * ``<cm/iterator>``: ``cm::size``, ``cm::empty``, ``cm::data`` + * ``<cm/list>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + + * ``<cm/map>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + * ``<cm/optional>``: ``cm::nullopt_t``, ``cm::nullopt``, ``cm::optional``, ``cm::make_optional``, ``cm::bad_optional_access`` + * ``<cm/set>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + * ``<cm/shared_mutex>``: ``cm::shared_mutex`` + * ``<cm/string>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + * ``<cm/string_view>``: - ``cm::string_view`` + ``cm::string_view``, ``cm::size``, ``cm::empty``, ``cm::data`` * ``<cm/type_traits>``: ``cm::bool_constant``, ``cm::invoke_result_t``, ``cm::invoke_result``, ``cm::void_t`` + * ``<cm/unordered_map>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + + * ``<cm/unordered_set>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + * ``<cm/utility>``: ``cm::in_place_t``, ``cm::in_place`` + * ``<cm/vector>``: + ``cm::size``, ``cm::empty``, ``cm::data`` + * From ``C++20``: + * ``<cm/array>``: + ``cm::ssize`` + * ``<cm/deque>``: - ``cm::erase``, ``cm::erase_if`` + ``cm::erase``, ``cm::erase_if``, ``cm::ssize`` + + * ``<cm/forward_list>``: + ``cm::ssize`` + + * ``<cm/iterator>``: + ``cm::ssize`` * ``<cm/list>``: - ``cm::erase``, ``cm::erase_if`` + ``cm::erase``, ``cm::erase_if``, ``cm::ssize`` * ``<cm/map>`` : - ``cm::erase_if`` + ``cm::erase_if``, ``cm::ssize`` * ``<cm/set>`` : - ``cm::erase_if`` + ``cm::erase_if``, ``cm::ssize`` + + * ``<cm/string_view>``: + ``cm::ssize`` * ``<cm/string>``: - ``cm::erase``, ``cm::erase_if`` + ``cm::erase``, ``cm::erase_if``, ``cm::ssize`` * ``<cm/unordered_map>``: - ``cm::erase_if`` + ``cm::erase_if``, ``cm::ssize`` * ``<cm/unordered_set>``: - ``cm::erase_if`` + ``cm::erase_if``, ``cm::ssize`` * ``<cm/vector>``: - ``cm::erase``, ``cm::erase_if`` + ``cm::erase``, ``cm::erase_if``, ``cm::ssize`` Additionally, some useful non-standard extensions to the C++ standard library are available in headers under the directory ``cmext/`` in namespace ``cm``. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index b3091fa..259cebb 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -58,6 +58,7 @@ Policies Introduced by CMake 3.24 .. toctree:: :maxdepth: 1 + CMP0136: Watcom runtime library flags are selected by an abstraction. </policy/CMP0136> CMP0135: ExternalProject ignores timestamps in archives by default for the URL download method. </policy/CMP0135> CMP0134: Fallback to \"HOST\" Windows registry view when \"TARGET\" view is not usable. </policy/CMP0134> CMP0133: The CPack module disables SLA by default in the CPack DragNDrop Generator. </policy/CMP0133> diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index c8d24f2..948d87a 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -1068,6 +1068,17 @@ Recognized macros include: A literal dollar sign (``$``). +``${pathListSep}`` + + Native character for separating lists of paths, such as ``:`` or ``;``. + + For example, by setting ``PATH`` to + ``/path/to/ninja/bin${pathListSep}$env{PATH}``, ``${pathListSep}`` will + expand to the underlying operating system's character used for + concatenation in ``PATH``. + + This is allowed in preset files specifying version ``5`` or above. + ``$env{<variable-name>}`` Environment variable with name ``<variable-name>``. The variable name may diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 8c2f8c4..20b62c5 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -171,6 +171,7 @@ Properties on Targets /prop_tgt/COMPILE_PDB_NAME_CONFIG /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG + /prop_tgt/COMPILE_WARNING_AS_ERROR /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX /prop_tgt/CROSSCOMPILING_EMULATOR @@ -423,6 +424,7 @@ Properties on Targets /prop_tgt/VS_WINRT_COMPONENT /prop_tgt/VS_WINRT_EXTENSIONS /prop_tgt/VS_WINRT_REFERENCES + /prop_tgt/WATCOM_RUNTIME_LIBRARY /prop_tgt/WIN32_EXECUTABLE /prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS /prop_tgt/XCODE_ATTRIBUTE_an-attribute diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index b82ff2f..00ea0bc 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -402,6 +402,7 @@ Variables that Control the Build /variable/CMAKE_BUILD_WITH_INSTALL_RPATH /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG + /variable/CMAKE_COMPILE_WARNING_AS_ERROR /variable/CMAKE_CONFIG_POSTFIX /variable/CMAKE_CROSS_CONFIGS /variable/CMAKE_CTEST_ARGUMENTS @@ -522,6 +523,7 @@ Variables that Control the Build /variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES /variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES /variable/CMAKE_VS_WINRT_BY_DEFAULT + /variable/CMAKE_WATCOM_RUNTIME_LIBRARY /variable/CMAKE_WIN32_EXECUTABLE /variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS /variable/CMAKE_XCODE_ATTRIBUTE_an-attribute diff --git a/Help/policy/CMP0136.rst b/Help/policy/CMP0136.rst new file mode 100644 index 0000000..5414278 --- /dev/null +++ b/Help/policy/CMP0136.rst @@ -0,0 +1,50 @@ +CMP0136 +------- + +.. versionadded:: 3.24 + +Watcom runtime library flags are selected by an abstraction. + +Compilers targeting the Watcom ABI have flags to select the Watcom runtime +library. + +In CMake 3.23 and below, Watcom runtime library selection flags are added to +the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache entries by CMake +automatically. This allows users to edit their cache entries to adjust the +flags. However, the presence of such default flags is problematic for +projects that want to choose a different runtime library programmatically. +In particular, it requires string editing of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variables with knowledge of the +CMake builtin defaults so they can be replaced. + +CMake 3.24 and above prefer to leave the Watcom runtime library selection flags +out of the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` values and instead +offer a first-class abstraction. The :variable:`CMAKE_WATCOM_RUNTIME_LIBRARY` +variable and :prop_tgt:`WATCOM_RUNTIME_LIBRARY` target property may be set to +select the Watcom runtime library. If they are not set then CMake uses the +default value ``MultiThreadedDLL`` on Windows and ``SingleThreaded`` on other +platforms, which is equivalent to the original flags. + +This policy provides compatibility with projects that have not been updated +to be aware of the abstraction. The policy setting takes effect as of the +first :command:`project` or :command:`enable_language` command that enables +a language whose compiler targets the Watcom ABI. + +.. note:: + + Once the policy has taken effect at the top of a project, that choice + must be used throughout the tree. In projects that have nested projects + in subdirectories, be sure to convert everything together. + +The ``OLD`` behavior for this policy is to place Watcom runtime library +flags in the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache +entries and ignore the :variable:`CMAKE_WATCOM_RUNTIME_LIBRARY` abstraction. +The ``NEW`` behavior for this policy is to *not* place Watcom runtime +library flags in the default cache entries and use the abstraction instead. + +This policy was introduced in CMake version 3.24. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +Unlike many policies, CMake version |release| does *not* warn +when this policy is not set and simply uses ``OLD`` behavior. + +.. include:: DEPRECATED.txt diff --git a/Help/prop_tgt/COMPILE_WARNING_AS_ERROR.rst b/Help/prop_tgt/COMPILE_WARNING_AS_ERROR.rst new file mode 100644 index 0000000..86a0f7f --- /dev/null +++ b/Help/prop_tgt/COMPILE_WARNING_AS_ERROR.rst @@ -0,0 +1,10 @@ +COMPILE_WARNING_AS_ERROR +------------------------ + +.. versionadded:: 3.24 + +Specify whether to treat warnings on compile as errors. +If enabled, adds a flag to treat warnings on compile as errors. + +This property is initialized by the value of the variable +:variable:`CMAKE_COMPILE_WARNING_AS_ERROR` if it is set when a target is created. diff --git a/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt b/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt new file mode 100644 index 0000000..cdf99d0 --- /dev/null +++ b/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt @@ -0,0 +1,20 @@ +``SingleThreaded`` + Compile without additional flags to use a single-threaded + statically-linked runtime library. +``SingleThreadedDLL`` + Compile with ``-br`` or equivalent flag(s) to use a single-threaded + dynamically-linked runtime library. This is not available for Linux + targets. +``MultiThreaded`` + Compile with ``-bm`` or equivalent flag(s) to use a multi-threaded + statically-linked runtime library. +``MultiThreadedDLL`` + Compile with ``-bm -br`` or equivalent flag(s) to use a multi-threaded + dynamically-linked runtime library. This is not available for Linux + targets. + +The value is ignored on non-Watcom compilers but an unsupported value will +be rejected as an error when using a compiler targeting the Watcom ABI. + +The value may also be the empty string (``""``) in which case no runtime +library selection flag will be added explicitly by CMake. diff --git a/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY.rst b/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY.rst new file mode 100644 index 0000000..3752862 --- /dev/null +++ b/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY.rst @@ -0,0 +1,34 @@ +WATCOM_RUNTIME_LIBRARY +---------------------- + +.. versionadded:: 3.24 + +Select the Watcom runtime library for use by compilers targeting the Watcom ABI. + +The allowed values are: + +.. include:: WATCOM_RUNTIME_LIBRARY-VALUES.txt + +Use :manual:`generator expressions <cmake-generator-expressions(7)>` to +support per-configuration specification. + +For example, the code: + +.. code-block:: cmake + + add_executable(foo foo.c) + set_property(TARGET foo PROPERTY + WATCOM_RUNTIME_LIBRARY "MultiThreaded") + +selects for the target ``foo`` a multi-threaded statically-linked runtime +library. + +If this property is not set then CMake uses the default value +``MultiThreadedDLL`` on Windows and ``SingleThreaded`` on other +platforms to select a Watcom runtime library. + +.. note:: + + This property has effect only when policy :policy:`CMP0136` is set to ``NEW`` + prior to the first :command:`project` or :command:`enable_language` command + that enables a language using a compiler targeting the Watcom ABI. diff --git a/Help/release/dev/presets-pathListSep.rst b/Help/release/dev/presets-pathListSep.rst new file mode 100644 index 0000000..84b129f --- /dev/null +++ b/Help/release/dev/presets-pathListSep.rst @@ -0,0 +1,5 @@ +presets-pathListSep +------------------- + +* :manual:`cmake-presets(7)` files now support a ``${pathListSep}`` macro, + which expands to ``:`` or ``;`` based on the platform. diff --git a/Help/release/dev/watcom-runtime-library.rst b/Help/release/dev/watcom-runtime-library.rst new file mode 100644 index 0000000..3a07b32 --- /dev/null +++ b/Help/release/dev/watcom-runtime-library.rst @@ -0,0 +1,7 @@ +watcom-runtime-library +---------------------- + +* The :variable:`CMAKE_WATCOM_RUNTIME_LIBRARY` variable and + :prop_tgt:`WATCOM_RUNTIME_LIBRARY` target property were introduced to + select the runtime library used by compilers targeting the Watcom ABI. + See policy :policy:`CMP0136`. diff --git a/Help/release/dev/werror-property.rst b/Help/release/dev/werror-property.rst new file mode 100644 index 0000000..c337df7 --- /dev/null +++ b/Help/release/dev/werror-property.rst @@ -0,0 +1,8 @@ +werror-property +--------------- + +* Added the Target Property :prop_tgt:`COMPILE_WARNING_AS_ERROR` and the + Variable :variable:`CMAKE_COMPILE_WARNING_AS_ERROR` which initializes the + Target Property. If :prop_tgt:`COMPILE_WARNING_AS_ERROR` is true, it expands + to a different flag depending on the compiler such that any warnings at + compile will be treated as errors. diff --git a/Help/variable/CMAKE_COMPILE_WARNING_AS_ERROR.rst b/Help/variable/CMAKE_COMPILE_WARNING_AS_ERROR.rst new file mode 100644 index 0000000..56dc6a6 --- /dev/null +++ b/Help/variable/CMAKE_COMPILE_WARNING_AS_ERROR.rst @@ -0,0 +1,9 @@ +CMAKE_COMPILE_WARNING_AS_ERROR +------------------------------ + +.. versionadded:: 3.24 + +Specify whether to treat warnings on compile as errors. + +This variable is used to initialize the +:prop_tgt:`COMPILE_WARNING_AS_ERROR` property on all the targets. diff --git a/Help/variable/CMAKE_WATCOM_RUNTIME_LIBRARY.rst b/Help/variable/CMAKE_WATCOM_RUNTIME_LIBRARY.rst new file mode 100644 index 0000000..feb2a60 --- /dev/null +++ b/Help/variable/CMAKE_WATCOM_RUNTIME_LIBRARY.rst @@ -0,0 +1,36 @@ +CMAKE_WATCOM_RUNTIME_LIBRARY +---------------------------- + +.. versionadded:: 3.24 + +Select the Watcom runtime library for use by compilers targeting the Watcom ABI. +This variable is used to initialize the :prop_tgt:`WATCOM_RUNTIME_LIBRARY` +property on all targets as they are created. It is also propagated by +calls to the :command:`try_compile` command into the test project. + +The allowed values are: + +.. include:: ../prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt + +Use :manual:`generator expressions <cmake-generator-expressions(7)>` to +support per-configuration specification. + +For example, the code: + +.. code-block:: cmake + + set(CMAKE_WATCOM_RUNTIME_LIBRARY "MultiThreaded") + +selects for all following targets a multi-threaded statically-linked runtime +library. + +If this variable is not set then the :prop_tgt:`WATCOM_RUNTIME_LIBRARY` target +property will not be set automatically. If that property is not set then +CMake uses the default value ``MultiThreadedDLL`` on Windows and +``SingleThreaded`` on other platforms to select a Watcom runtime library. + +.. note:: + + This variable has effect only when policy :policy:`CMP0136` is set to ``NEW`` + prior to the first :command:`project` or :command:`enable_language` command + that enables a language using a compiler targeting the Watcom ABI. diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 5813956..6f5702a 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -177,9 +177,9 @@ macro. packages with no binaries. .. versionadded:: 3.19 - ``COMPATIBILITY_MODE`` ``AnyNewerVersion``, ``SameMajorVersion`` and - ``SameMinorVersion`` handle the version range if any is specified - (see :command:`find_package` command for the details). + The version file generated by ``AnyNewerVersion``, ``SameMajorVersion`` and + ``SameMinorVersion`` arguments of ``COMPATIBILITY`` handle the version range + if any is specified (see :command:`find_package` command for the details). ``ExactVersion`` mode is incompatible with version ranges and will display an author warning if one is specified. diff --git a/Modules/Compiler/Fujitsu.cmake b/Modules/Compiler/Fujitsu.cmake index 78495cb..55c2aa4 100644 --- a/Modules/Compiler/Fujitsu.cmake +++ b/Modules/Compiler/Fujitsu.cmake @@ -11,6 +11,7 @@ include(Compiler/CMakeCommonCompilerMacros) macro(__compiler_fujitsu lang) set(CMAKE_${lang}_VERBOSE_FLAG "-###") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-cwno") # Initial configuration flags string(APPEND CMAKE_${lang}_FLAGS_INIT " ") diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 2eef532..c5946f0 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -18,6 +18,7 @@ set(__pch_header_OBJCXX "objective-c++-header") macro(__compiler_gnu lang) # Feature flags. set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror") set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO) if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4) diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake index 9a760c8..20989d2 100644 --- a/Modules/Compiler/Intel.cmake +++ b/Modules/Compiler/Intel.cmake @@ -13,6 +13,7 @@ include(Compiler/CMakeCommonCompilerMacros) if(CMAKE_HOST_WIN32) # MSVC-like macro(__compiler_intel lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror-all") endmacro() else() # GNU-like @@ -24,6 +25,7 @@ else() string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os") string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3") string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror-all") set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}") if(CMAKE_${lang}_COMPILER_ARG1) diff --git a/Modules/Compiler/IntelLLVM.cmake b/Modules/Compiler/IntelLLVM.cmake index 14b7ad8..c344f32 100644 --- a/Modules/Compiler/IntelLLVM.cmake +++ b/Modules/Compiler/IntelLLVM.cmake @@ -20,6 +20,7 @@ if(CMAKE_HOST_WIN32) macro(__compiler_intel_llvm lang) if(NOT "x${lang}" STREQUAL "xFortran") set(CMAKE_${lang}_COMPILE_OPTIONS_INVALID_PCH -Winvalid-pch) + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX") endif() endmacro() else() @@ -38,6 +39,7 @@ else() set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie") set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") diff --git a/Modules/Compiler/LCC.cmake b/Modules/Compiler/LCC.cmake index 8353ab6..bdee9a6 100644 --- a/Modules/Compiler/LCC.cmake +++ b/Modules/Compiler/LCC.cmake @@ -18,6 +18,7 @@ set(__pch_header_OBJCXX "objective-c++-header") macro(__compiler_lcc lang) # Feature flags. set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror") set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO) set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake index df3691c..6bf6b4e 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -1,6 +1,9 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +include(Compiler/MSVC) +__compiler_msvc(C) + include(Compiler/CMakeCommonCompilerMacros) if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) @@ -67,16 +70,3 @@ else() endif() set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -TC) -set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") -set(CMAKE_C_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") - -# /JMC "Just My Code" is only supported by MSVC 19.05 onward. -if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) - set(CMAKE_C_COMPILE_OPTIONS_JMC "-JMC") -endif() - -# The `/external:I` flag was made non-experimental in 19.29.30036.3. -if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) - set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-external:I") - set(_CMAKE_INCLUDE_SYSTEM_FLAG_C_WARNING "-external:W0 ") -endif () diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 17cbc3c..75165fd 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -1,10 +1,10 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -include(Compiler/CMakeCommonCompilerMacros) +include(Compiler/MSVC) +__compiler_msvc(CXX) -set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") -set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") +include(Compiler/CMakeCommonCompilerMacros) if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR @@ -76,14 +76,3 @@ elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) endmacro() endif() - -# /JMC "Just My Code" is only supported by MSVC 19.05 onward. -if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) - set(CMAKE_CXX_COMPILE_OPTIONS_JMC "-JMC") -endif() - -# The `/external:I` flag was made non-experimental in 19.29.30036.3. -if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) - set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-external:I") - set(_CMAKE_INCLUDE_SYSTEM_FLAG_CXX_WARNING "-external:W0 ") -endif () diff --git a/Modules/Compiler/MSVC.cmake b/Modules/Compiler/MSVC.cmake new file mode 100644 index 0000000..154b657 --- /dev/null +++ b/Modules/Compiler/MSVC.cmake @@ -0,0 +1,25 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_MSVC) + return() +endif() +set(__COMPILER_MSVC 1) + +macro(__compiler_msvc lang) + set(CMAKE_${lang}_CLANG_TIDY_DRIVER_MODE "cl") + set(CMAKE_${lang}_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX") + + # /JMC "Just My Code" is only supported by MSVC 19.05 onward. + if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) + set(CMAKE_${lang}_COMPILE_OPTIONS_JMC "-JMC") + endif() + + # The `/external:I` flag was made non-experimental in 19.29.30036.3. + if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-external:I") + set(_CMAKE_INCLUDE_SYSTEM_FLAG_${lang}_WARNING "-external:W0 ") + endif () +endmacro() diff --git a/Modules/Compiler/NVHPC.cmake b/Modules/Compiler/NVHPC.cmake index b51bb43..21d0665 100644 --- a/Modules/Compiler/NVHPC.cmake +++ b/Modules/Compiler/NVHPC.cmake @@ -13,4 +13,5 @@ include(Compiler/PGI) macro(__compiler_nvhpc lang) # Logic specific to NVHPC. set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "--Werror all-warnings") endmacro() diff --git a/Modules/Compiler/SunPro-ASM.cmake b/Modules/Compiler/SunPro-ASM.cmake index 0d67400..fc0f2fa 100644 --- a/Modules/Compiler/SunPro-ASM.cmake +++ b/Modules/Compiler/SunPro-ASM.cmake @@ -1,3 +1,6 @@ +include(Compiler/SunPro) +__compiler_sunpro(ASM) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) set(CMAKE_ASM_VERBOSE_FLAG "-#") diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 7a406ac..b06719d 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -2,6 +2,7 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Compiler/SunPro) +__compiler_sunpro(C) set(CMAKE_C_VERBOSE_FLAG "-#") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index aa8a9c5..f835f2d 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -2,6 +2,7 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Compiler/SunPro) +__compiler_sunpro(CXX) set(CMAKE_CXX_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index 0ba5015..d336980 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -1,3 +1,6 @@ +include(Compiler/SunPro) +__compiler_sunpro(Fortran) + set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") diff --git a/Modules/Compiler/SunPro.cmake b/Modules/Compiler/SunPro.cmake index 52da39a..331cdfc 100644 --- a/Modules/Compiler/SunPro.cmake +++ b/Modules/Compiler/SunPro.cmake @@ -8,3 +8,7 @@ endif() set(__COMPILER_SUNPRO 1) include(Compiler/CMakeCommonCompilerMacros) + +macro(__compiler_sunpro lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-errwarn=%all") +endmacro() diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index 8b9d4a9..844fcfd 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -15,6 +15,7 @@ macro(__compiler_xl lang) set(CMAKE_${lang}_VERBOSE_FLAG "-V") set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic") set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-qpic") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-qhalt=i") set(CMAKE_${lang}_RESPONSE_FILE_FLAG "-qoptfile=") set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-qoptfile=") diff --git a/Modules/Compiler/XLClang.cmake b/Modules/Compiler/XLClang.cmake index cdf0fdc..8c3e5e9 100644 --- a/Modules/Compiler/XLClang.cmake +++ b/Modules/Compiler/XLClang.cmake @@ -17,6 +17,7 @@ macro(__compiler_xlclang lang) set(CMAKE_${lang}_VERBOSE_FLAG "-V") set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror") set(CMAKE_${lang}_RESPONSE_FILE_FLAG "@") set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") endmacro() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 5c37be2..707de88 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -2530,6 +2530,12 @@ function(_ep_add_download_command name) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) + get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_DOWNLOAD) + if(uses_terminal) + set(svn_interactive_args "") + else() + set(svn_interactive_args "--non-interactive") + endif() get_filename_component(src_name "${source_dir}" NAME) get_filename_component(work_dir "${source_dir}" PATH) @@ -2545,7 +2551,8 @@ function(_ep_add_download_command name) set(svn_trust_cert_args --trust-server-cert) endif() set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} - --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name}) + ${svn_interactive_args} ${svn_trust_cert_args} ${svn_user_pw_args} + ${src_name}) elseif(git_repository) set(method git) @@ -2934,6 +2941,12 @@ function(_ep_add_update_command name) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) + get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_UPDATE) + if(uses_terminal) + set(svn_interactive_args "") + else() + set(svn_interactive_args "--non-interactive") + endif() set(svn_user_pw_args "") if(DEFINED svn_username) set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}") @@ -2945,7 +2958,7 @@ function(_ep_add_update_command name) set(svn_trust_cert_args --trust-server-cert) endif() set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision} - --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args}) + ${svn_interactive_args} ${svn_trust_cert_args} ${svn_user_pw_args}) set(always 1) elseif(git_repository) # FetchContent gives us these directly, so don't try to recompute them diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index 1b81778..b92c679 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -1351,6 +1351,14 @@ ExternalProject_Add_Step(${contentName}-populate copyfile list(APPEND subCMakeOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}") endif() + # Override the sub-build's configuration types for multi-config generators. + # This ensures we are not affected by any custom setting from the project + # and can always request a known configuration further below. + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + list(APPEND subCMakeOpts "-DCMAKE_CONFIGURATION_TYPES:STRING=Release") + endif() + else() # Likely we've been invoked via CMake's script mode where no # generator is set (and hence CMAKE_MAKE_PROGRAM could not be @@ -1395,7 +1403,8 @@ set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION # If we've already previously done these steps, they will not cause # anything to be updated, so extra rebuilds of the project won't occur. # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project - # has this set to something not findable on the PATH. + # has this set to something not findable on the PATH. We also ensured above + # that the Release config will be defined for multi-config generators. configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/FetchContent/CMakeLists.cmake.in" "${ARG_SUBBUILD_DIR}/CMakeLists.txt") execute_process( @@ -1411,7 +1420,7 @@ set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION message(FATAL_ERROR "CMake step for ${contentName} failed: ${result}") endif() execute_process( - COMMAND ${CMAKE_COMMAND} --build . + COMMAND ${CMAKE_COMMAND} --build . --config Release RESULT_VARIABLE result ${outputOptions} WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}" diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 43041c5..72d4db5 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -96,7 +96,21 @@ endfunction() find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) + # Tell pkg-config not to strip any -I flags to make sure GLUT_INCLUDE_DIRS + # will be defined. + if(DEFINED ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}) + set(_pkgconfig_allow_system_cflags_old "$ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}") + else() + unset(_pkgconfig_allow_system_cflags_old) + endif() + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} 1) pkg_check_modules(GLUT QUIET glut) + if(DEFINED _pkgconfig_allow_system_cflags_old) + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} "${_pkgconfig_allow_system_cflags_old}") + unset(_pkgconfig_allow_system_cflags_old) + else() + unset(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}) + endif() if(NOT GLUT_FOUND) pkg_check_modules(GLUT QUIET freeglut) endif() diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index 1b4662b..5c7aa22 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -45,7 +45,7 @@ function(_FIND_OPENCL_VERSION) set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY}) CMAKE_PUSH_CHECK_STATE() - foreach(VERSION "2_2" "2_1" "2_0" "1_2" "1_1" "1_0") + foreach(VERSION "3_0" "2_2" "2_1" "2_0" "1_2" "1_1" "1_0") set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}") if(APPLE) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 5a8bfef..d6a3a88 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -148,6 +148,19 @@ if(OPENSSL_USE_STATIC_LIBS) endif() endif() +if(CMAKE_SYSTEM_NAME STREQUAL "QNX" AND + CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "7.0" AND CMAKE_SYSTEM_VERSION VERSION_LESS "7.1" AND + OpenSSL_FIND_VERSION VERSION_GREATER_EQUAL "1.1" AND OpenSSL_FIND_VERSION VERSION_LESS "1.2") + # QNX 7.0.x provides openssl 1.0.2 and 1.1.1 in parallel: + # * openssl 1.0.2: libcrypto.so.2 and libssl.so.2, headers under usr/include/openssl + # * openssl 1.1.1: libcrypto1_1.so.2.1 and libssl1_1.so.2.1, header under usr/include/openssl1_1 + # See http://www.qnx.com/developers/articles/rel_6726_0.html + set(_OPENSSL_FIND_PATH_SUFFIX "openssl1_1") + set(_OPENSSL_NAME_POSTFIX "1_1") +else() + set(_OPENSSL_FIND_PATH_SUFFIX "include") +endif() + if (WIN32) # http://www.slproweb.com/products/Win32OpenSSL.html set(_OPENSSL_ROOT_HINTS @@ -200,7 +213,7 @@ find_path(OPENSSL_INCLUDE_DIR ${_OPENSSL_INCLUDEDIR} ${_OPENSSL_INCLUDE_DIRS} PATH_SUFFIXES - include + ${_OPENSSL_FIND_PATH_SUFFIX} ) if(WIN32 AND NOT CYGWIN) @@ -430,7 +443,7 @@ else() find_library(OPENSSL_SSL_LIBRARY NAMES - ssl + ssl${_OPENSSL_NAME_POSTFIX} ssleay32 ssleay32MD NAMES_PER_DIR @@ -444,7 +457,7 @@ else() find_library(OPENSSL_CRYPTO_LIBRARY NAMES - crypto + crypto${_OPENSSL_NAME_POSTFIX} NAMES_PER_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS} HINTS @@ -681,3 +694,6 @@ endif() if(OPENSSL_USE_STATIC_LIBS) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) endif() + +unset(_OPENSSL_FIND_PATH_SUFFIX) +unset(_OPENSSL_NAME_POSTFIX) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 547bc52..ab8af3e 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -429,7 +429,7 @@ macro(_pkg_set_path_internal) else() unset(_pkgconfig_allow_system_libs_old) endif() - set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} 0) + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} 1) endmacro() macro(_pkg_restore_path_internal) @@ -440,6 +440,8 @@ macro(_pkg_restore_path_internal) if(DEFINED _pkgconfig_allow_system_libs_old) set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} "${_pkgconfig_allow_system_libs_old}") unset(_pkgconfig_allow_system_libs_old) + else() + unset(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}) endif() unset(_extra_paths) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 6edfbea..cbb6c1c 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -22,7 +22,7 @@ if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) message (FATAL_ERROR "FindPython: INTERNAL ERROR") endif() if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "3") - set(_${_PYTHON_PREFIX}_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) + set(_${_PYTHON_PREFIX}_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "2") set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) else() diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 4fc40c8..7ad3587 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -54,7 +54,7 @@ unset(_Python_NAMES) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonInterp_FIND_VERSION) if(PythonInterp_FIND_VERSION_COUNT GREATER 1) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index c0caf34..43a84dd 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -79,7 +79,7 @@ set(CMAKE_FIND_FRAMEWORK LAST) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonLibs_FIND_VERSION) if(PythonLibs_FIND_VERSION_COUNT GREATER 1) diff --git a/Modules/Platform/Linux-OpenWatcom-C.cmake b/Modules/Platform/Linux-OpenWatcom-C.cmake index 383349a..7236c74 100644 --- a/Modules/Platform/Linux-OpenWatcom-C.cmake +++ b/Modules/Platform/Linux-OpenWatcom-C.cmake @@ -1 +1,2 @@ include(Platform/Linux-OpenWatcom) +__linux_open_watcom(C) diff --git a/Modules/Platform/Linux-OpenWatcom-CXX.cmake b/Modules/Platform/Linux-OpenWatcom-CXX.cmake index 383349a..a5f386b 100644 --- a/Modules/Platform/Linux-OpenWatcom-CXX.cmake +++ b/Modules/Platform/Linux-OpenWatcom-CXX.cmake @@ -1 +1,2 @@ include(Platform/Linux-OpenWatcom) +__linux_open_watcom(CXX) diff --git a/Modules/Platform/Linux-OpenWatcom.cmake b/Modules/Platform/Linux-OpenWatcom.cmake index 5b4e995..678d373 100644 --- a/Modules/Platform/Linux-OpenWatcom.cmake +++ b/Modules/Platform/Linux-OpenWatcom.cmake @@ -10,6 +10,14 @@ string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " system linux opt noextension") string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " system linux") string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " system linux") +cmake_policy(GET CMP0136 __LINUX_WATCOM_CMP0136) +if(__LINUX_WATCOM_CMP0136 STREQUAL "NEW") + set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "SingleThreaded") +else() + set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "") +endif() +unset(__LINUX_WATCOM_CMP0136) + # single/multi-threaded /-bm # default is setup for single-threaded libraries string(APPEND CMAKE_C_FLAGS_INIT " -bt=linux") @@ -23,3 +31,8 @@ if(CMAKE_CROSSCOMPILING) set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES $ENV{WATCOM}/lh) endif() endif() + +macro(__linux_open_watcom lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_SingleThreaded "") + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_MultiThreaded -bm) +endmacro() diff --git a/Modules/Platform/OS2-OpenWatcom-C.cmake b/Modules/Platform/OS2-OpenWatcom-C.cmake index 21a4d9e..a6a6b78 100644 --- a/Modules/Platform/OS2-OpenWatcom-C.cmake +++ b/Modules/Platform/OS2-OpenWatcom-C.cmake @@ -1 +1,2 @@ include(Platform/OS2-OpenWatcom) +__os2_open_watcom(C) diff --git a/Modules/Platform/OS2-OpenWatcom-CXX.cmake b/Modules/Platform/OS2-OpenWatcom-CXX.cmake index 21a4d9e..846bb29 100644 --- a/Modules/Platform/OS2-OpenWatcom-CXX.cmake +++ b/Modules/Platform/OS2-OpenWatcom-CXX.cmake @@ -1 +1,2 @@ include(Platform/OS2-OpenWatcom) +__os2_open_watcom(CXX) diff --git a/Modules/Platform/OS2-OpenWatcom.cmake b/Modules/Platform/OS2-OpenWatcom.cmake index 998fb9f..720b953 100644 --- a/Modules/Platform/OS2-OpenWatcom.cmake +++ b/Modules/Platform/OS2-OpenWatcom.cmake @@ -16,6 +16,14 @@ endif() set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string. +cmake_policy(GET CMP0136 __OS2_WATCOM_CMP0136) +if(__OS2_WATCOM_CMP0136 STREQUAL "NEW") + set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "SingleThreaded") +else() + set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "") +endif() +unset(__OS2_WATCOM_CMP0136) + string(APPEND CMAKE_C_FLAGS_INIT " -bt=os2") string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=os2 -xs") @@ -33,3 +41,10 @@ if(NOT CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES) set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES $ENV{WATCOM}/h $ENV{WATCOM}/h/os2) endif() endif() + +macro(__os2_open_watcom lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_SingleThreaded "") + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_SingleThreadedDLL -br) + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_MultiThreaded -bm) + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_MultiThreadedDLL -bm -br) +endmacro() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 7600c8d..82c4383 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -39,6 +39,7 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP) set(CMAKE_${lang}_LINKER_MANIFEST_FLAG " -Xlinker /MANIFESTINPUT:") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror") if("${CMAKE_${lang}_SIMULATE_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)") math(EXPR MSVC_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}") @@ -189,6 +190,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" macro(__windows_compiler_clang_base lang) set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc ") endmacro() else() diff --git a/Modules/Platform/Windows-OpenWatcom.cmake b/Modules/Platform/Windows-OpenWatcom.cmake index 19bcb97..657a923 100644 --- a/Modules/Platform/Windows-OpenWatcom.cmake +++ b/Modules/Platform/Windows-OpenWatcom.cmake @@ -14,11 +14,20 @@ set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated st set(CMAKE_RC_COMPILER "rc" ) -# single/multi-threaded /-bm -# static/DLL run-time libraries /-br -# default is setup for multi-threaded + DLL run-time libraries -string(APPEND CMAKE_C_FLAGS_INIT " -bt=nt -dWIN32 -br -bm") -string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=nt -xs -dWIN32 -br -bm") +cmake_policy(GET CMP0136 __WINDOWS_WATCOM_CMP0136) +if(__WINDOWS_WATCOM_CMP0136 STREQUAL "NEW") + set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "MultiThreadedDLL") + set(_br_bm "") +else() + set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "") + set(_br_bm "-br -bm") +endif() + +string(APPEND CMAKE_C_FLAGS_INIT " -bt=nt -dWIN32 ${_br_bm}") +string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=nt -xs -dWIN32 ${_br_bm}") + +unset(__WINDOWS_WATCOM_CMP0136) +unset(_br_bm) if(CMAKE_CROSSCOMPILING) if(NOT CMAKE_C_STANDARD_INCLUDE_DIRECTORIES) @@ -32,4 +41,9 @@ endif() macro(__windows_open_watcom lang) set(CMAKE_${lang}_CREATE_WIN32_EXE "system nt_win") set(CMAKE_${lang}_CREATE_CONSOLE_EXE "system nt") + + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_SingleThreaded "") + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_SingleThreadedDLL -br) + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_MultiThreaded -bm) + set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_MultiThreadedDLL -bm -br) endmacro() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 59a97e2..4433f06 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 23) -set(CMake_VERSION_PATCH 20220508) +set(CMake_VERSION_PATCH 20220516) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 11b3b35..3e254e0 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -35,11 +35,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args, : Args(std::move(args)) , InitialWidth(initWidth) { - this->HasNonStatusOutputs = false; - this->NumberOfPages = 0; - this->AdvancedMode = false; - this->NumberOfVisibleEntries = 0; - this->OkToGenerate = false; this->HelpMessage.emplace_back( "Welcome to ccmake, curses based user interface for CMake."); this->HelpMessage.emplace_back(); @@ -54,7 +49,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args, cmStrCat(cmSystemTools::GetProgramPath(this->Args[0]), "/cmake"); this->Args[0] = whereCMake; this->CMakeInstance->SetArgs(this->Args); - this->SearchMode = false; } cmCursesMainForm::~cmCursesMainForm() @@ -99,13 +93,13 @@ void cmCursesMainForm::InitializeUI() int entrywidth = this->InitialWidth - 35; - if (count == 0) { - // If cache is empty, display a label saying so and a - // dummy entry widget (does not respond to input) - cmCursesCacheEntryComposite comp("EMPTY CACHE", 30, 30); - comp.Entry = cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1); - newEntries.emplace_back(std::move(comp)); - } else { + // Add a label to display when cache is empty + // dummy entry widget (does not respond to input) + cmCursesCacheEntryComposite comp("EMPTY CACHE", 30, 30); + comp.Entry = cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1); + newEntries.emplace_back(std::move(comp)); + + if (count > 0) { // Create the composites. // First add entries which are new @@ -196,7 +190,8 @@ void cmCursesMainForm::RePost() this->Fields.push_back(entry.Entry->Field); } // if no cache entries there should still be one dummy field - if (this->Fields.empty()) { + this->IsEmpty = this->Fields.empty(); + if (this->IsEmpty) { const auto& front = this->Entries.front(); this->Fields.push_back(front.Label->Field); this->Fields.push_back(front.IsNewLabel->Field); @@ -875,7 +870,7 @@ void cmCursesMainForm::HandleInput() } } // delete cache entry - else if (key == 'd' && this->NumberOfVisibleEntries) { + else if (key == 'd' && this->NumberOfVisibleEntries && !this->IsEmpty) { this->OkToGenerate = false; FIELD* cur = current_field(this->Form); size_t findex = field_index(cur); diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index c6db66f..fb44a45 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -138,7 +138,7 @@ protected: // Output produced by the last pass std::vector<std::string> Outputs; // Did the last pass produced outputs of interest (errors, warnings, ...) - bool HasNonStatusOutputs; + bool HasNonStatusOutputs = false; // Last progress bar std::string LastProgress; @@ -155,17 +155,18 @@ protected: // Fields displayed. Includes labels, new entry markers, entries std::vector<FIELD*> Fields; // Number of entries shown (depends on mode -normal or advanced-) - size_t NumberOfVisibleEntries; - bool AdvancedMode; + size_t NumberOfVisibleEntries = 0; + bool AdvancedMode = false; // Did the iteration converge (no new entries) ? - bool OkToGenerate; + bool OkToGenerate = false; // Number of pages displayed - int NumberOfPages; + int NumberOfPages = 0; + bool IsEmpty = false; int InitialWidth; std::unique_ptr<cmake> CMakeInstance; std::string SearchString; std::string OldSearchString; - bool SearchMode; + bool SearchMode = false; }; diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx index 478c175..b737c1f 100644 --- a/Source/cmCMakePresetsGraph.cxx +++ b/Source/cmCMakePresetsGraph.cxx @@ -361,6 +361,13 @@ bool ExpandMacros(const cmCMakePresetsGraph& graph, const T& preset, cmSystemTools::GetParentDirectory(preset.OriginFile->Filename); return ExpandMacroResult::Ok; } + if (macroName == "pathListSep") { + if (version < 5) { + return ExpandMacroResult::Error; + } + macroOut += cmSystemTools::GetSystemPathlistSeparator(); + return ExpandMacroResult::Ok; + } } return ExpandMacroResult::Ignore; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 5bdd888..4909948 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -228,6 +228,8 @@ std::string const kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES = std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES = "CMAKE_TRY_COMPILE_PLATFORM_VARIABLES"; std::string const kCMAKE_WARN_DEPRECATED = "CMAKE_WARN_DEPRECATED"; +std::string const kCMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT = + "CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT"; /* GHS Multi platform variables */ std::set<std::string> const ghs_platform_vars{ @@ -555,6 +557,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, !msvcRuntimeLibraryDefault->empty() ? "NEW" : "OLD"); } + /* Set Watcom runtime library policy to match our selection. */ + if (cmValue watcomRuntimeLibraryDefault = this->Makefile->GetDefinition( + kCMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT)) { + fprintf(fout, "cmake_policy(SET CMP0136 %s)\n", + !watcomRuntimeLibraryDefault->empty() ? "NEW" : "OLD"); + } + /* Set CUDA architectures policy to match outer project. */ if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0104) != cmPolicies::NEW && @@ -902,6 +911,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, vars.insert(kCMAKE_SYSROOT_LINK); vars.insert(kCMAKE_WARN_DEPRECATED); vars.emplace("CMAKE_MSVC_RUNTIME_LIBRARY"_s); + vars.emplace("CMAKE_WATCOM_RUNTIME_LIBRARY"_s); if (cmValue varListStr = this->Makefile->GetDefinition( kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c54d5bf..e2bcea8 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1025,6 +1025,14 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags, flags.emplace_back(std::move(compReqFlag)); } + // Add Warning as errors flags + const cmValue wError = target->GetProperty("COMPILE_WARNING_AS_ERROR"); + const cmValue wErrorFlag = this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_WARNING_AS_ERROR")); + if (wError.IsOn() && wErrorFlag.IsSet()) { + flags.emplace_back(wErrorFlag); + } + // Add compile flag for the MSVC compiler only. cmMakefile* mf = this->GetMakefile(); if (cmValue jmc = @@ -1919,6 +1927,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, std::string compilerSimulateId = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_SIMULATE_ID")); + if (lang == "Swift") { if (cmValue v = target->GetProperty("Swift_LANGUAGE_VERSION")) { if (cmSystemTools::VersionCompare( @@ -1994,6 +2003,38 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } } } + + // Add Watcom runtime library flags. This is activated by the presence + // of a default selection whether or not it is overridden by a property. + cmValue watcomRuntimeLibraryDefault = + this->Makefile->GetDefinition("CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT"); + if (cmNonempty(watcomRuntimeLibraryDefault)) { + cmValue watcomRuntimeLibraryValue = + target->GetProperty("WATCOM_RUNTIME_LIBRARY"); + if (!watcomRuntimeLibraryValue) { + watcomRuntimeLibraryValue = watcomRuntimeLibraryDefault; + } + std::string const watcomRuntimeLibrary = cmGeneratorExpression::Evaluate( + *watcomRuntimeLibraryValue, this, config, target); + if (!watcomRuntimeLibrary.empty()) { + if (cmValue watcomRuntimeLibraryOptions = this->Makefile->GetDefinition( + "CMAKE_" + lang + "_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_" + + watcomRuntimeLibrary)) { + this->AppendCompileOptions(flags, *watcomRuntimeLibraryOptions); + } else if ((this->Makefile->GetSafeDefinition( + "CMAKE_" + lang + "_COMPILER_ID") == "OpenWatcom" || + this->Makefile->GetSafeDefinition( + "CMAKE_" + lang + "_SIMULATE_ID") == "OpenWatcom") && + !cmSystemTools::GetErrorOccuredFlag()) { + // The compiler uses the Watcom ABI so it needs a known runtime + // library. + this->IssueMessage(MessageType::FATAL_ERROR, + "WATCOM_RUNTIME_LIBRARY value '" + + watcomRuntimeLibrary + "' not known for this " + + lang + " compiler."); + } + } + } } void cmLocalGenerator::AddLanguageFlagsForLinking( diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7d06607..4977083 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -408,7 +408,10 @@ class cmMakefile; SELECT(POLICY, CMP0135, \ "ExternalProject ignores timestamps in archives by default for the " \ "URL download method", \ - 3, 24, 0, cmPolicies::WARN) + 3, 24, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0136, \ + "Watcom runtime library flags are selected by an abstraction.", 3, \ + 24, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index cb32172..527175d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3429,3 +3429,12 @@ cm::string_view cmSystemTools::GetSystemName() return ""; #endif } + +char cmSystemTools::GetSystemPathlistSeparator() +{ +#if defined(_WIN32) + return ';'; +#else + return ':'; +#endif +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index c17ecbd..4865a4b 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -535,6 +535,9 @@ public: /** Get the system name. */ static cm::string_view GetSystemName(); + /** Get the system path separator character */ + static char GetSystemPathlistSeparator(); + private: static bool s_ForceUnixPaths; static bool s_RunCommandHideConsole; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index feb2ee3..80d1940 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -543,6 +543,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("LINK_DEPENDS_NO_SHARED"); initProp("LINK_INTERFACE_LIBRARIES"); initProp("MSVC_RUNTIME_LIBRARY"); + initProp("WATCOM_RUNTIME_LIBRARY"); initProp("WIN32_EXECUTABLE"); initProp("MACOSX_BUNDLE"); initProp("MACOSX_RPATH"); @@ -587,6 +588,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("UNITY_BUILD_UNIQUE_ID"); initProp("OPTIMIZE_DEPENDENCIES"); initProp("EXPORT_COMPILE_COMMANDS"); + initProp("COMPILE_WARNING_AS_ERROR"); initPropValue("UNITY_BUILD_BATCH_SIZE", "8"); initPropValue("UNITY_BUILD_MODE", "BATCH"); initPropValue("PCH_WARN_INVALID", "ON"); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index d5d08b8..00c65ed 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -171,14 +171,15 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() code.clear(); } - if (arch.empty() && gencode.empty()) { - return; - } - // Create a CodeGeneration field with [arch],[code] syntax in each entry. // CUDA will convert it to `-gencode=arch=[arch],code="[code],[arch]"`. FlagValue& result = this->FlagMap["CodeGeneration"]; + // If there are no flags, leave the CodeGeneration field empty. + if (arch.empty() && gencode.empty()) { + return; + } + // First entries for the -arch=<arch> [-code=<code>,...] pair. if (!arch.empty()) { std::string arch_name = arch[0]; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9a1cf69..7fdfaea 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -431,8 +431,10 @@ if(BUILD_TESTING) if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") ADD_TEST_MACRO(CSharpOnly CSharpOnly) - ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx) - ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx) + if(NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") + ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx) + ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx) + endif() ADD_TEST_MACRO(CSharpWin32GenEx CSharpWin32GenEx) set_tests_properties(CSharpWin32GenEx PROPERTIES PASS_REGULAR_EXPRESSION "Target \"CSharpWin32GenEx\" has a generator expression in its\n WIN32_EXECUTABLE property\\. This is not supported on managed executables\\." @@ -2077,6 +2079,10 @@ if(BUILD_TESTING) ADD_TEST_MACRO(ModuleDefinition example_exe) endif() + if (CMAKE_C_COMPILER_ID MATCHES "Watcom" AND WIN32) + ADD_TEST_MACRO(WatcomRuntimeLibrary) + endif() + ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR @@ -2109,6 +2115,7 @@ if(BUILD_TESTING) if(MSVC AND NOT MSVC_VERSION LESS 1310 AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio 9 " OR CMAKE_SIZEOF_VOID_P EQUAL 4) + AND (NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") ) ADD_TEST_MACRO(VSMASM VSMASM) endif() @@ -2119,7 +2126,8 @@ if(BUILD_TESTING) endif() if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio 9 " - AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v90") + AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v90" + AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx) ADD_TEST_MACRO(VSManagedCustomCommand) endif() diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 7490a80..d3b0e9e 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -19,7 +19,7 @@ extern int testStaticLibPlugin(void); #else # define testLib4libcfg testLib4libopt #endif -extern testLib4libcfg(void); +extern int testLib4libcfg(void); int main() { diff --git a/Tests/RunCMake/AutoExportDll/AutoExport.cmake b/Tests/RunCMake/AutoExportDll/AutoExport.cmake index 85eff7e..dbcf4b8 100644 --- a/Tests/RunCMake/AutoExportDll/AutoExport.cmake +++ b/Tests/RunCMake/AutoExportDll/AutoExport.cmake @@ -6,7 +6,8 @@ add_library(objlib OBJECT objlib.c) set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(autoexport SHARED hello.cxx world.cxx foo.c $<TARGET_OBJECTS:objlib>) add_library(autoexport3 SHARED cppCLI.cxx) -if(MSVC AND NOT MSVC_VERSION VERSION_LESS 1600) +if(MSVC AND NOT MSVC_VERSION VERSION_LESS 1600 + AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") set_property(TARGET autoexport3 PROPERTY COMMON_LANGUAGE_RUNTIME "") endif() @@ -15,7 +16,8 @@ if(MSVC) set_target_properties(say PROPERTIES ENABLE_EXPORTS ON) add_library(autoexport_for_exec SHARED hello2.c) target_link_libraries(autoexport_for_exec say) - if(NOT MSVC_VERSION VERSION_LESS 1600) + if(NOT MSVC_VERSION VERSION_LESS 1600 AND + NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") enable_language(ASM_MASM) target_sources(autoexport PRIVATE nop.asm) set_property(SOURCE nop.asm PROPERTY COMPILE_FLAGS /safeseh) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index dd540ea..4fe6ac1 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -369,6 +369,7 @@ add_RunCMake_test(TargetProperties) add_RunCMake_test(ToolchainFile) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) +add_RunCMake_test(CompileWarningAsError) add_RunCMake_test(CompileFeatures -DCMake_NO_C_STANDARD=${CMake_NO_C_STANDARD} -DCMake_NO_CXX_STANDARD=${CMake_NO_CXX_STANDARD}) add_RunCMake_test(Policy) add_RunCMake_test(PolicyScope) @@ -959,7 +960,9 @@ endif() if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|9[0-9])") add_RunCMake_test(CSharpCustomCommand) - add_RunCMake_test(CSharpReferenceImport) + if(NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") + add_RunCMake_test(CSharpReferenceImport) + endif() endif() add_RunCMake_test("CTestCommandExpandLists") diff --git a/Tests/RunCMake/CMakePresets/PathListSep.cmake b/Tests/RunCMake/CMakePresets/PathListSep.cmake new file mode 100644 index 0000000..52c225b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSep.cmake @@ -0,0 +1,7 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +if(CMAKE_HOST_WIN32) + test_variable(TEST_PATH_LIST_SEP "" "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}") +else() + test_variable(TEST_PATH_LIST_SEP "" "${CMAKE_CURRENT_SOURCE_DIR}:${CMAKE_CURRENT_SOURCE_DIR}") +endif() diff --git a/Tests/RunCMake/CMakePresets/PathListSep.json.in b/Tests/RunCMake/CMakePresets/PathListSep.json.in new file mode 100644 index 0000000..4c25029 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSep.json.in @@ -0,0 +1,13 @@ +{ + "version": 5, + "configurePresets": [ + { + "name": "PathListSep", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_PATH_LIST_SEP": "${sourceDir}${pathListSep}${sourceDir}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt b/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt b/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt new file mode 100644 index 0000000..b961aaf --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/PathListSepFuture: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in b/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in new file mode 100644 index 0000000..2fd6b7e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in @@ -0,0 +1,13 @@ +{ + "version": 4, + "configurePresets": [ + { + "name": "PathListSepFuture", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_PATH_LIST_SEP": "${sourceDir}${pathListSep}${sourceDir}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 5867efd..d097086 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -335,6 +335,12 @@ unset(CMakePresets_EXTRA_FILES) set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/FileDirFuture.json.in") run_cmake_presets(FileDirFuture) +# Test ${pathListSep} macro +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/PathListSep.json.in") +run_cmake_presets(PathListSep) +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/PathListSepFuture.json.in") +run_cmake_presets(PathListSepFuture) + # Test conditions set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Conditions.json.in") run_cmake_presets(ListConditions --list-presets) diff --git a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt index 4dd6be1..a182e1c 100644 --- a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt +++ b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt @@ -1 +1 @@ --- CMAKE_VS_PLATFORM_NAME='(x64|Win32)' +-- CMAKE_VS_PLATFORM_NAME='(x64|Win32|ARM64)' diff --git a/Tests/RunCMake/CompileWarningAsError/CMakeLists.txt b/Tests/RunCMake/CompileWarningAsError/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake b/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake new file mode 100644 index 0000000..059c80f --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake @@ -0,0 +1,12 @@ +include(RunCMake) + +function(run_compile_warn test) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake(${test}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) +endfunction() + +run_compile_warn(WerrorOn) +run_compile_warn(WerrorOff) diff --git a/Tests/RunCMake/CompileWarningAsError/WarningAsErrorOptions.cmake b/Tests/RunCMake/CompileWarningAsError/WarningAsErrorOptions.cmake new file mode 100644 index 0000000..ccc6cc5 --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WarningAsErrorOptions.cmake @@ -0,0 +1,18 @@ +# add compile options to warning_options to ensure unused-function throws a warning +# if warning_options is NOT DEFINED, assume compiler doesn't support warning as error +macro(get_warning_options warning_options) + if (CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|XLClang|IBMClang|LCC|NVCC|IntelLLVM)$") + set(${warning_options} "-Wall") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")) + set(${warning_options} "-W4") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set(${warning_options} "-w3") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "XL") + set(${warning_options} "-qinfo=all") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") + set(${warning_options} "+w;+w2") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Fujitsu") + set(${warning_options} "SHELL:-w 8") + endif() +endmacro() diff --git a/Tests/RunCMake/CompileWarningAsError/WerrorOff.cmake b/Tests/RunCMake/CompileWarningAsError/WerrorOff.cmake new file mode 100644 index 0000000..b05d65e --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WerrorOff.cmake @@ -0,0 +1,8 @@ +enable_language(CXX) + +include(WarningAsErrorOptions.cmake) +get_warning_options(warning_options) + +add_executable(WerrorOff warn.cxx) +target_compile_options(WerrorOff PUBLIC "${warning_options}") +set_target_properties(WerrorOff PROPERTIES COMPILE_WARNING_AS_ERROR OFF) diff --git a/Tests/RunCMake/CompileWarningAsError/WerrorOn-Build-result.txt b/Tests/RunCMake/CompileWarningAsError/WerrorOn-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WerrorOn-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CompileWarningAsError/WerrorOn.cmake b/Tests/RunCMake/CompileWarningAsError/WerrorOn.cmake new file mode 100644 index 0000000..4310333 --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WerrorOn.cmake @@ -0,0 +1,13 @@ +enable_language(CXX) + +include(WarningAsErrorOptions.cmake) +get_warning_options(warning_options) + +if (DEFINED warning_options) + add_executable(WerrorOn warn.cxx) + target_compile_options(WerrorOn PUBLIC "${warning_options}") + set_target_properties(WerrorOn PROPERTIES COMPILE_WARNING_AS_ERROR ON) +else() + # if no werror option is set for the environment, use err.cxx so that build fails as expected + add_executable(WerrorOn err.cxx) +endif() diff --git a/Tests/RunCMake/CompileWarningAsError/err.cxx b/Tests/RunCMake/CompileWarningAsError/err.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/err.cxx diff --git a/Tests/RunCMake/CompileWarningAsError/warn.cxx b/Tests/RunCMake/CompileWarningAsError/warn.cxx new file mode 100644 index 0000000..64a245a --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/warn.cxx @@ -0,0 +1,17 @@ +static void unused_function(); + +#ifdef __SUNPRO_CC +struct A +{ + virtual ~A() throw(); +}; +struct B : public A +{ + virtual ~B() throw(int); +}; +#endif + +int main(int unused_argument, char* []) +{ + return 1; +} diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake index 854f3dc..5ea02a5 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake @@ -1,10 +1,15 @@ message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") +message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR='${CMAKE_HOST_SYSTEM_PROCESSOR}'") if(CMAKE_GENERATOR MATCHES "Visual Studio 1[67]") cmake_host_system_information(RESULT is_64_bit QUERY IS_64BIT) if(is_64_bit) - if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64") + if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "ARM64") + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not empty as expected.") + endif() + elseif(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64") message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'x64' as expected.") endif() endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake index 3e418c3..2ba8c3b 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake @@ -17,9 +17,9 @@ set(releaseOK FALSE) file(STRINGS "${csProjectFile}" lines) foreach(line IN LISTS lines) #message(STATUS ${line}) - if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*") + if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64|ARM64).*") set(inDebug TRUE) - elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*") + elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64|ARM64).*") set(inRelease TRUE) elseif(line MATCHES "^ *</PropertyGroup> *$") set(inRelease FALSE) diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake index 631abac..d47bac9 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake @@ -17,9 +17,9 @@ set(releaseOK FALSE) file(STRINGS "${csProjectFile}" lines) foreach(line IN LISTS lines) #message(STATUS ${line}) - if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*") + if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64|ARM64).*") set(inDebug TRUE) - elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*") + elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64|ARM64).*") set(inRelease TRUE) elseif(line MATCHES "^ *</PropertyGroup> *$") set(inRelease FALSE) diff --git a/Tests/TargetName/executables/hello_world.c b/Tests/TargetName/executables/hello_world.c index 5b6eaf8..71d71f5 100644 --- a/Tests/TargetName/executables/hello_world.c +++ b/Tests/TargetName/executables/hello_world.c @@ -1,5 +1,6 @@ #include <stdio.h> -main() +int main(void) { printf("hello, world\n"); + return 0; } diff --git a/Tests/WatcomRuntimeLibrary/CMakeLists.txt b/Tests/WatcomRuntimeLibrary/CMakeLists.txt new file mode 100644 index 0000000..e8a3edc --- /dev/null +++ b/Tests/WatcomRuntimeLibrary/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.23) +cmake_policy(SET CMP0136 NEW) +project(WatcomRuntimeLibrary) + +function(verify_combinations threads lang src) + set(verify_def_MultiThreaded -DVERIFY_MT) + set(verify_def_DLL -DVERIFY_DLL) + foreach(dll "" DLL) + # Construct the name of this runtime library combination. + set(rtl "${threads}${dll}") + + # Test that try_compile builds with this RTL. + set(CMAKE_WATCOM_RUNTIME_LIBRARY "${rtl}") + set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") + try_compile(${rtl}_COMPILES + ${CMAKE_CURRENT_BINARY_DIR}/try_compile/${rtl} + ${CMAKE_CURRENT_SOURCE_DIR}/${src} + COMPILE_DEFINITIONS ${verify_def_${threads}} ${verify_def_${dll}} + OUTPUT_VARIABLE ${rtl}_OUTPUT + ) + if(${rtl}_COMPILES) + message(STATUS "try_compile with ${rtl} worked") + else() + string(REPLACE "\n" "\n " ${rtl}_OUTPUT " ${${rtl}_OUTPUT}") + message(SEND_ERROR "try_compile with ${rtl} failed:\n${${rtl}_OUTPUT}") + endif() + + # Test that targets build with this RTL. + set(CMAKE_WATCOM_RUNTIME_LIBRARY "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${rtl}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>") + add_library(${rtl}-${lang} ${src}) + set_property(TARGET ${rtl}-${lang} PROPERTY BOOL_TRUE TRUE) + target_compile_definitions(${rtl}-${lang} PRIVATE ${verify_def_${threads}} ${verify_def_${dll}}) + endforeach() +endfunction() + +function(verify lang src) + add_library(default-${lang} ${src}) + target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL) + + verify_combinations(SingleThreaded ${lang} ${src}) + verify_combinations(MultiThreaded ${lang} ${src}) + + # Test known default behavior when no flag is given. + set(CMAKE_WATCOM_RUNTIME_LIBRARY "") + add_library(empty-${lang} ${src}) +endfunction() + +verify(C verify.c) +verify(CXX verify.cxx) diff --git a/Tests/WatcomRuntimeLibrary/verify.c b/Tests/WatcomRuntimeLibrary/verify.c new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/WatcomRuntimeLibrary/verify.c @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/WatcomRuntimeLibrary/verify.cxx b/Tests/WatcomRuntimeLibrary/verify.cxx new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/WatcomRuntimeLibrary/verify.cxx @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/WatcomRuntimeLibrary/verify.h b/Tests/WatcomRuntimeLibrary/verify.h new file mode 100644 index 0000000..6c67e6d --- /dev/null +++ b/Tests/WatcomRuntimeLibrary/verify.h @@ -0,0 +1,31 @@ +#ifdef VERIFY_DLL +# ifndef _DLL +# error "_DLL not defined by DLL runtime library selection" +# endif +# ifndef __SW_BR +# error "__SW_BR not defined by DLL runtime library selection" +# endif +#else +# ifdef _DLL +# error "_DLL defined by non-DLL runtime library selection" +# endif +# ifdef __SW_BR +# error "__SW_BR defined by non-DLL runtime library selection" +# endif +#endif + +#ifdef VERIFY_MT +# ifndef _MT +# error "_MT not defined by multi-threaded runtime library selection" +# endif +# ifndef __SW_BM +# error "__SW_BM not defined by multi-threaded runtime library selection" +# endif +#else +# ifdef _MT +# error "_MT defined by single-threaded runtime library selection" +# endif +# ifdef __SW_BM +# error "__SW_BM defined by single-threaded runtime library selection" +# endif +#endif diff --git a/Utilities/std/cm/array b/Utilities/std/cm/array new file mode 100644 index 0000000..f344ee7 --- /dev/null +++ b/Utilities/std/cm/array @@ -0,0 +1,10 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include <array> // IWYU pragma: export + +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export diff --git a/Utilities/std/cm/bits/container_helpers.hxx b/Utilities/std/cm/bits/container_helpers.hxx new file mode 100644 index 0000000..abcdacb --- /dev/null +++ b/Utilities/std/cm/bits/container_helpers.hxx @@ -0,0 +1,302 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#pragma once + +#include <iterator> // IWYU pragma: keep + +#if __cplusplus < 201402L || defined(_MSVC_LANG) && _MSVC_LANG < 201402L +# include <initializer_list> +#endif +#if __cplusplus < 202002L || defined(_MSVC_LANG) && _MSVC_LANG < 202002L +# include <cstddef> +# include <type_traits> +#endif + +namespace cm { + +using std::begin; +using std::end; + +#if __cplusplus < 201402L || defined(_MSVC_LANG) && _MSVC_LANG < 201402L + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto cbegin(const C& c) +# else +inline constexpr auto cbegin(const C& c) noexcept(noexcept(std::begin(c))) +# endif + -> decltype(std::begin(c)) +{ + return std::begin(c); +} + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto cend(const C& c) +# else +inline constexpr auto cend(const C& c) noexcept(noexcept(std::end(c))) +# endif + -> decltype(std::end(c)) +{ + return std::end(c); +} + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto rbegin(C& c) +# else +inline constexpr auto rbegin(C& c) +# endif + -> decltype(c.rbegin()) +{ + return c.rbegin(); +} +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto rbegin(const C& c) +# else +inline constexpr auto rbegin(const C& c) +# endif + -> decltype(c.rbegin()) +{ + return c.rbegin(); +} +template <typename T, std::size_t N> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline std::reverse_iterator<T*> rbegin(T (&array)[N]) +# else +inline constexpr std::reverse_iterator<T*> rbegin(T (&array)[N]) noexcept +# endif +{ + return std::reverse_iterator<T*>(array + N); +} +template <typename T> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline std::reverse_iterator<const T*> rbegin(std::initializer_list<T> il) +# else +inline constexpr std::reverse_iterator<const T*> rbegin( + std::initializer_list<T> il) noexcept +# endif +{ + return std::reverse_iterator<const T*>(il.end()); +} + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto rend(C& c) +# else +inline constexpr auto rend(C& c) +# endif + -> decltype(c.rend()) + +{ + return c.rend(); +} +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto rend(const C& c) +# else +inline constexpr auto rend(const C& c) +# endif + -> decltype(c.rend()) +{ + return c.rend(); +} +template <typename T, std::size_t N> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline std::reverse_iterator<T*> rend(T (&array)[N]) +# else +inline constexpr std::reverse_iterator<T*> rend(T (&array)[N]) noexcept +# endif +{ + return std::reverse_iterator<T*>(array); +} +template <typename T> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline std::reverse_iterator<const T*> rend(std::initializer_list<T> il) +# else +inline constexpr std::reverse_iterator<const T*> rend( + std::initializer_list<T> il) noexcept +# endif +{ + return std::reverse_iterator<const T*>(il.begin()); +} + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto crbegin(const C& c) +# else +inline constexpr auto crbegin(const C& c) +# endif + -> decltype(cm::rbegin(c)) +{ + return cm::rbegin(c); +} + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto crend(const C& c) +# else +inline constexpr auto crend(const C& c) +# endif + -> decltype(cm::rend(c)) +{ + return cm::rend(c); +} + +#else + +using std::cbegin; +using std::cend; + +using std::rbegin; +using std::rend; + +using std::crbegin; +using std::crend; + +#endif + +#if __cplusplus < 201703L || defined(_MSVC_LANG) && _MSVC_LANG < 201703L + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto size(const C& c) +# else +inline constexpr auto size(const C& c) noexcept(noexcept(c.size())) +# endif + -> decltype(c.size()) +{ + return c.size(); +} + +template <typename T, std::size_t N> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline std::size_t size(const T (&)[N]) +# else +inline constexpr std::size_t size(const T (&)[N]) noexcept +# endif +{ + return N; +} + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto empty(const C& c) +# else +inline constexpr auto empty(const C& c) noexcept(noexcept(c.empty())) +# endif + -> decltype(c.empty()) +{ + return c.empty(); +} + +template <typename T, std::size_t N> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline bool empty(const T (&)[N]) +# else +inline constexpr bool empty(const T (&)[N]) noexcept +# endif +{ + return false; +} + +template <typename E> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline bool empty(std::initializer_list<E> il) +# else +inline constexpr bool empty(std::initializer_list<E> il) noexcept +# endif +{ + return il.size() == 0; +} + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto data(C& c) -> decltype(c.data()) +# else +inline constexpr auto data(C& c) noexcept(noexcept(c.data())) +# endif + -> decltype(c.data()) +{ + return c.data(); +} + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto data(const C& c) +# else +inline constexpr auto data(const C& c) noexcept(noexcept(c.data())) +# endif + -> decltype(c.data()) +{ + return c.data(); +} + +template <typename T, std::size_t N> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline T* data(T (&array)[N]) +# else +inline constexpr T* data(T (&array)[N]) noexcept +# endif +{ + return array; +} + +template <typename E> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline const E* data(std::initializer_list<E> il) +# else +inline constexpr const E* data(std::initializer_list<E> il) noexcept +# endif +{ + return il.begin(); +} + +#else + +using std::size; +using std::empty; +using std::data; + +#endif + +#if __cplusplus < 202002L || defined(_MSVC_LANG) && _MSVC_LANG < 202002L + +template <typename C> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline auto ssize(const C& c) +# else +inline constexpr auto ssize(const C& c) +# endif + -> typename std::common_type< + std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type +{ + using signed_type = typename std::make_signed<decltype(c.size())>::type; + using result_type = + typename std::common_type<std::ptrdiff_t, signed_type>::type; + + return static_cast<result_type>(c.size()); +} + +template <typename T, std::ptrdiff_t N> +# if defined(_MSC_VER) && _MSC_VER < 1900 +inline std::ptrdiff_t ssize(const T (&)[N]) +# else +inline constexpr std::ptrdiff_t ssize(const T (&)[N]) noexcept +# endif +{ + return N; +} + +#else + +using std::ssize; + +#endif + +} // namespace cm diff --git a/Utilities/std/cm/deque b/Utilities/std/cm/deque index b7b6959..df5f8df 100644 --- a/Utilities/std/cm/deque +++ b/Utilities/std/cm/deque @@ -8,6 +8,8 @@ #include <algorithm> #include <deque> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export + namespace cm { // should be updated when C++20 is finalized diff --git a/Utilities/std/cm/forward_list b/Utilities/std/cm/forward_list new file mode 100644 index 0000000..3397a09 --- /dev/null +++ b/Utilities/std/cm/forward_list @@ -0,0 +1,10 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include <forward_list> // IWYU pragma: export + +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export diff --git a/Utilities/std/cm/iterator b/Utilities/std/cm/iterator index 3b38cc7..3bfd947 100644 --- a/Utilities/std/cm/iterator +++ b/Utilities/std/cm/iterator @@ -7,18 +7,13 @@ #include <iterator> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export + namespace cm { #if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L using std::make_reverse_iterator; -using std::cbegin; -using std::cend; - -using std::rbegin; -using std::rend; -using std::crbegin; -using std::crend; #else template <class Iter> std::reverse_iterator<Iter> make_reverse_iterator(Iter it) @@ -26,188 +21,6 @@ std::reverse_iterator<Iter> make_reverse_iterator(Iter it) return std::reverse_iterator<Iter>(it); } -// std::c{begin,end} backport from C++14 -template <class C> -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto cbegin(C const& c) -# else -constexpr auto cbegin(C const& c) noexcept(noexcept(std::begin(c))) -# endif - -> decltype(std::begin(c)) -{ - return std::begin(c); -} - -template <class C> -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto cend(C const& c) -# else -constexpr auto cend(C const& c) noexcept(noexcept(std::end(c))) -# endif - -> decltype(std::end(c)) -{ - return std::end(c); -} - -// std::r{begin,end} backport from C++14 -template <class C> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - rbegin(C& c) -> decltype(c.rbegin()) -{ - return c.rbegin(); -} -template <class C> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - rbegin(C const& c) -> decltype(c.rbegin()) -{ - return c.rbegin(); -} -template <typename T, size_t N> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - std::reverse_iterator<T*> - rbegin(T (&arr)[N]) -{ - return std::reverse_iterator<T*>(arr + N); -} - -template <class C> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - rend(C& c) -> decltype(c.rend()) -{ - return c.rend(); -} -template <class C> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - rend(C const& c) -> decltype(c.rend()) -{ - return c.rend(); -} -template <typename T, size_t N> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - std::reverse_iterator<T*> - rend(T (&arr)[N]) -{ - return std::reverse_iterator<T*>(arr); -} - -// std::cr{begin,end} backport from C++14 -template <class C> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - crbegin(C const& c) -> decltype(cm::rbegin(c)) -{ - return cm::rbegin(c); -} - -template <class C> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - crend(C const& c) -> decltype(cm::rend(c)) -{ - return cm::rend(c); -} -#endif - -#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L -using std::size; - -using std::empty; -using std::data; -#else - -// std::size backport from C++17. -template <class C> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - size(C const& c) -> decltype(c.size()) -{ - return c.size(); -} - -template <typename T, size_t N> -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - std::size_t - size(const T (&)[N]) throw() -{ - return N; -} - -// std::empty backport from C++17. -template <class C> -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto empty(C const& c) -# else -constexpr auto empty(C const& c) noexcept(noexcept(c.empty())) -# endif - -> decltype(c.empty()) -{ - return c.empty(); -} -template <typename T, size_t N> -# if defined(_MSC_VER) && _MSC_VER < 1900 -bool empty(const T (&)[N]) -# else -constexpr bool empty(const T (&)[N]) noexcept -# endif -{ - return false; -} - -// std::data backport from C++17. -template <class C> -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto data(C const& c) -# else -constexpr auto data(C const& c) noexcept(noexcept(c.data())) -# endif - -> decltype(c.data()) -{ - return c.data(); -} -template <class C> -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto data(C& c) -# else -constexpr auto data(C& c) noexcept(noexcept(c.data())) -# endif - -> decltype(c.data()) -{ - return c.data(); -} -template <typename T, size_t N> -# if defined(_MSC_VER) && _MSC_VER < 1900 -T* data(T (&)[N]) -# else -constexpr T* data(T (&arr)[N]) noexcept -# endif -{ - return arr; -} - #endif } // namespace cm diff --git a/Utilities/std/cm/list b/Utilities/std/cm/list index 380bff8..bd02e86 100644 --- a/Utilities/std/cm/list +++ b/Utilities/std/cm/list @@ -7,6 +7,8 @@ #include <list> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export + namespace cm { // should be updated when C++20 is finalized diff --git a/Utilities/std/cm/map b/Utilities/std/cm/map index 1794cd7..4270d78 100644 --- a/Utilities/std/cm/map +++ b/Utilities/std/cm/map @@ -7,6 +7,7 @@ #include <map> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export #include <cm/bits/erase_if.hxx> namespace cm { diff --git a/Utilities/std/cm/set b/Utilities/std/cm/set index 9fd24d3..70e2c49 100644 --- a/Utilities/std/cm/set +++ b/Utilities/std/cm/set @@ -7,6 +7,7 @@ #include <set> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export #include <cm/bits/erase_if.hxx> namespace cm { diff --git a/Utilities/std/cm/string b/Utilities/std/cm/string index 30b1b85..d3d899f 100644 --- a/Utilities/std/cm/string +++ b/Utilities/std/cm/string @@ -8,6 +8,8 @@ #include <algorithm> #include <string> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export + namespace cm { // should be updated when C++20 is finalized diff --git a/Utilities/std/cm/string_view b/Utilities/std/cm/string_view index 9542bac..35cf5d9 100644 --- a/Utilities/std/cm/string_view +++ b/Utilities/std/cm/string_view @@ -9,6 +9,8 @@ # define CMake_HAVE_CXX_STRING_VIEW #endif +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export + #ifdef CMake_HAVE_CXX_STRING_VIEW # include <string_view> // IWYU pragma: export namespace cm { diff --git a/Utilities/std/cm/unordered_map b/Utilities/std/cm/unordered_map index d21c37e..0b085f3 100644 --- a/Utilities/std/cm/unordered_map +++ b/Utilities/std/cm/unordered_map @@ -7,6 +7,7 @@ #include <unordered_map> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export #include <cm/bits/erase_if.hxx> namespace cm { diff --git a/Utilities/std/cm/unordered_set b/Utilities/std/cm/unordered_set index 2545ff6..0593051 100644 --- a/Utilities/std/cm/unordered_set +++ b/Utilities/std/cm/unordered_set @@ -7,6 +7,7 @@ #include <unordered_set> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export #include <cm/bits/erase_if.hxx> namespace cm { diff --git a/Utilities/std/cm/vector b/Utilities/std/cm/vector index 33d9365..efd4404 100644 --- a/Utilities/std/cm/vector +++ b/Utilities/std/cm/vector @@ -8,6 +8,8 @@ #include <algorithm> #include <vector> // IWYU pragma: export +#include <cm/bits/container_helpers.hxx> // IWYU pragma: export + namespace cm { // should be updated when C++20 is finalized |