diff options
1069 files changed, 19269 insertions, 7646 deletions
diff --git a/.clang-tidy b/.clang-tidy index 3ae249fabf..dace6f1781 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -11,12 +11,9 @@ misc-*,\ -misc-static-assert,\ modernize-*,\ -modernize-deprecated-headers,\ --modernize-pass-by-value,\ -modernize-raw-string-literal,\ -modernize-return-braced-init-list,\ -modernize-use-auto,\ --modernize-use-emplace,\ --modernize-use-equals-default,\ -modernize-use-equals-delete,\ -modernize-use-noexcept,\ -modernize-use-transparent-functors,\ diff --git a/.gitattributes b/.gitattributes index d6fd5d6c92..24fd9c2014 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,6 +21,7 @@ configure eol=lf *.pfx -text *.png -text +*.png.in -text *.c our-c-style *.cc our-c-style diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 1083036376..7e029de4e0 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -2212,6 +2212,8 @@ syn keyword cmakeGeneratorExpressions contained \ DEBUG_MODE \ EXPORT \ FOO_EXTRA_THINGS + \ Fortran_COMPILER_ID + \ Fortran_COMPILER_VERSION \ GENEX_EVAL \ GNU \ IF diff --git a/Help/command/ctest_submit.rst b/Help/command/ctest_submit.rst index 426475c251..fba03fd586 100644 --- a/Help/command/ctest_submit.rst +++ b/Help/command/ctest_submit.rst @@ -6,6 +6,7 @@ Perform the :ref:`CTest Submit Step` as a :ref:`Dashboard Client`. :: ctest_submit([PARTS <part>...] [FILES <file>...] + [SUBMIT_URL <url>] [HTTPHEADER <header>] [RETRY_COUNT <count>] [RETRY_DELAY <delay>] @@ -39,6 +40,10 @@ The options are: Specify an explicit list of specific files to be submitted. Each individual file must exist at the time of the call. +``SUBMIT_URL <url>`` + The ``http`` or ``https`` URL of the dashboard server to send the submission + to. If not given, the :variable:`CTEST_SUBMIT_URL` variable is used. + ``HTTPHEADER <HTTP-header>`` Specify HTTP header to be included in the request to CDash during submission. This suboption can be repeated several times. @@ -68,6 +73,7 @@ Submit to CDash Upload API :: ctest_submit(CDASH_UPLOAD <file> [CDASH_UPLOAD_TYPE <type>] + [SUBMIT_URL <url>] [HTTPHEADER <header>] [RETRY_COUNT <count>] [RETRY_DELAY <delay>] @@ -80,5 +86,5 @@ with a content hash of the file. If CDash does not already have the file, then it is uploaded. Along with the file, a CDash type string is specified to tell CDash which handler to use to process the data. -This signature accepts the ``HTTPHEADER``, ``RETRY_COUNT``, ``RETRY_DELAY``, -``RETURN_VALUE`` and ``QUIET`` options as described above. +This signature accepts the ``SUBMIT_URL``, ``HTTPHEADER``, ``RETRY_COUNT``, +``RETRY_DELAY``, ``RETURN_VALUE`` and ``QUIET`` options as described above. diff --git a/Help/command/file.rst b/Help/command/file.rst index 6e2a6dd2ff..db4d6fce7b 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -27,6 +27,7 @@ Synopsis file({`COPY`_ | `INSTALL`_} <file>... DESTINATION <dir> [...]) file(`SIZE`_ <filename> <out-var>) file(`READ_SYMLINK`_ <filename> <out-var>) + file(`CREATE_LINK`_ <file> <new-file> [...]) `Path Conversion`_ file(`RELATIVE_PATH`_ <out-var> <directory> <file>) @@ -368,6 +369,28 @@ could do something like this: set(result "${dir}/${result}") endif() +.. _CREATE_LINK: + +.. code-block:: cmake + + file(CREATE_LINK <file> <new-file> + [RESULT <result>] [COPY_ON_ERROR] [SYMBOLIC]) + +Create a link to ``<file>`` at ``<new-file>``. + +It is a hard link by default. This can be changed to symbolic links by +using ``SYMBOLIC``. The original file needs to exist for hard links. + +The ``<result>`` variable, if specified, gets the status of the operation. +It is set to ``0`` in case of success. Otherwise, it contains the error +generated. In case of failures, if ``RESULT`` is not specified, a fatal error +is emitted. + +Specifying ``COPY_ON_ERROR`` enables copying the file as a fallback if +creating the link fails. + +Overwrites the ``<new-file>`` if it exists. + Path Conversion ^^^^^^^^^^^^^^^ diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index cafef8cb56..54d5f68fe5 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -354,6 +354,11 @@ enabled. .. include:: FIND_XXX_ROOT.txt .. include:: FIND_XXX_ORDER.txt +By default the value stored in the result variable will be the path at +which the file is found. The :variable:`CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS` +variable may be set to ``TRUE`` before calling ``find_package`` in order +to resolve symbolic links and store the real path to the file. + Every non-REQUIRED ``find_package`` call can be disabled by setting the :variable:`CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` variable to ``TRUE``. diff --git a/Help/command/get_filename_component.rst b/Help/command/get_filename_component.rst index 3e3c9c362e..f55499ac51 100644 --- a/Help/command/get_filename_component.rst +++ b/Help/command/get_filename_component.rst @@ -15,6 +15,8 @@ Sets ``<var>`` to a component of ``<FileName>``, where ``<mode>`` is one of: NAME = File name without directory EXT = File name longest extension (.b.c from d/a.b.c) NAME_WE = File name without directory or longest extension + LAST_EXT = File name last extention (.c from d/a.b.c) + NAME_WLE = File name without directory or last extension PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11) Paths are returned with forward slashes and have no trailing slashes. diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index cf9e06f164..77f42a1be5 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -168,3 +168,6 @@ then the language standard variables are honored: Their values are used to set the corresponding target properties in the generated project (unless overridden by an explicit option). + +For the :generator:`Green Hills MULTI` generator the GHS toolset and target +system customization cache variables are also propagated into the test project. diff --git a/Help/dev/review.rst b/Help/dev/review.rst index 0c4ededd61..1d664c4b82 100644 --- a/Help/dev/review.rst +++ b/Help/dev/review.rst @@ -238,12 +238,10 @@ Referencing Commits in Commit Messages ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The preferred form for references to other commits is -``commit <commit> (<subject>, <date>)``, where: +``commit <shorthash> (<subject>, <date>)``, where: -* ``<commit>``: - If available, a tag-relative name of the commit produced by - ``git describe --contains <commit-ish>``. Otherwise, the first - 8-10 characters of the commit ``<hash>``. +* ``<shorthash>``: + The abbreviated hash of the commit. * ``<subject>``: The first line of the commit message. @@ -252,6 +250,17 @@ The preferred form for references to other commits is The author date of the commit, in its original time zone, formatted as ``CCYY-MM-DD``. ``git-log(1)`` shows the original time zone by default. +This may be generated with +``git show -s --date=short --pretty="format:%h (%s, %ad)" <commit>``. + +If the commit is a fix for the mentioned commit, consider using a ``Fixes:`` +trailer in the commit message with the specified format. This trailer should +not be word-wrapped. Note that if there is also an issue for what is being +fixed, it is preferrable 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>)``. + Alternatively, the full commit ``<hash>`` may be used. Revising Commit Messages diff --git a/Help/envvar/CMAKE_NO_VERBOSE.rst b/Help/envvar/CMAKE_NO_VERBOSE.rst new file mode 100644 index 0000000000..149efbd6f4 --- /dev/null +++ b/Help/envvar/CMAKE_NO_VERBOSE.rst @@ -0,0 +1,8 @@ +CMAKE_NO_VERBOSE +---------------- + +Disables verbose output from CMake when :envvar:`VERBOSE` environment variable +is set. + +Only your build tool of choice will still print verbose output when you start +to actually build your project. diff --git a/Help/envvar/VERBOSE.rst b/Help/envvar/VERBOSE.rst new file mode 100644 index 0000000000..2d775a5bec --- /dev/null +++ b/Help/envvar/VERBOSE.rst @@ -0,0 +1,10 @@ +VERBOSE +------- + +Activates verbose output from CMake and your build tools of choice when +you start to actually build your project. + +Note that any given value is ignored. It's just checked for existence. + +See also :ref:`Build Tool Mode <Build Tool Mode>` and +:envvar:`CMAKE_NO_VERBOSE` environment variable diff --git a/Help/generator/Green Hills MULTI.rst b/Help/generator/Green Hills MULTI.rst index 1b4960d895..bfe671f503 100644 --- a/Help/generator/Green Hills MULTI.rst +++ b/Help/generator/Green Hills MULTI.rst @@ -3,49 +3,63 @@ Green Hills MULTI Generates Green Hills MULTI project files (experimental, work-in-progress). +The buildsystem has predetermined build-configuration settings that can be controlled +via the :variable:`CMAKE_BUILD_TYPE` variable. + Customizations that are used to pick toolset and target system: The ``-A <arch>`` can be supplied for setting the target architecture. ``<arch>`` usually is one of "arm", "ppc", "86", etcetera. If the target architecture is not specified then the default architecture of "arm" will be used. -The ``-T <toolset>`` can be supplied for setting the toolset to be used. -All toolsets are expected to be located at ``GHS_TOOLSET_ROOT``. -If the toolset is not specified then the latest toolset will be used. +The ``-T <toolset>`` option can be used to set the directory location of the toolset. +Both absolute and relative paths are valid. Relative paths use ``GHS_TOOLSET_ROOT`` +as the root. If the toolset is not specified then the latest toolset found in +``GHS_TOOLSET_ROOT`` will be used. + +Cache variables that are used for toolset and target system customization: * ``GHS_TARGET_PLATFORM`` -Default to ``integrity``. -Usual values are ``integrity``, ``threadx``, ``uvelosity``, -``velosity``, ``vxworks``, ``standalone``. + | Defaults to ``integrity``. + | Usual values are ``integrity``, ``threadx``, ``uvelosity``, ``velosity``, + ``vxworks``, ``standalone``. * ``GHS_PRIMARY_TARGET`` -Sets ``primaryTarget`` field in project file. -Defaults to ``<arch>_<GHS_TARGET_PLATFORM>.tgt``. + | Sets ``primaryTarget`` entry in project file. + | Defaults to ``<arch>_<GHS_TARGET_PLATFORM>.tgt``. * ``GHS_TOOLSET_ROOT`` -Default to ``C:/ghs``. Root path for ``toolset``. + | Root path for ``toolset`` searches. + | Defaults to ``C:/ghs``. * ``GHS_OS_ROOT`` -Default to ``C:/ghs``. Root path for RTOS searches. + | Root path for RTOS searches. + | Defaults to ``C:/ghs``. * ``GHS_OS_DIR`` -Default to latest platform OS installation at ``GHS_OS_ROOT``. Set this value if -a specific RTOS is to be used. + | Sets ``-os_dir`` entry in project file. + | Defaults to latest platform OS installation at ``GHS_OS_ROOT``. Set this value if + a specific RTOS is to be used. * ``GHS_BSP_NAME`` -Defaults to ``sim<arch>`` if not set by user. + | Sets ``-bsp`` entry in project file. + | Defaults to ``sim<arch>`` for ``integrity`` platforms. Customizations are available through the following cache variables: * ``GHS_CUSTOMIZATION`` * ``GHS_GPJ_MACROS`` +The following properties are available: + +* :prop_tgt:`GHS_INTEGRITY_APP` + .. note:: This generator is deemed experimental as of CMake |release| and is still a work in progress. Future versions of CMake diff --git a/Help/generator/VS_TOOLSET_HOST_ARCH.txt b/Help/generator/VS_TOOLSET_HOST_ARCH.txt index 5d13e7741e..4eb900f81f 100644 --- a/Help/generator/VS_TOOLSET_HOST_ARCH.txt +++ b/Help/generator/VS_TOOLSET_HOST_ARCH.txt @@ -1,6 +1,7 @@ For each toolset that comes with this version of Visual Studio, there are variants that are themselves compiled for 32-bit (x86) and 64-bit (x64) hosts -(independent of the architecture they target). By default Visual Studio -chooses the 32-bit variant even on a 64-bit host. One may request use of the -64-bit host tools by adding a ``host=x64`` option to the toolset specification. +(independent of the architecture they target). +|VS_TOOLSET_HOST_ARCH_DEFAULT| +One may explicitly request use of either the 32-bit or 64-bit host tools +by adding either ``host=x86`` or ``host=x64`` to the toolset specification. See the :variable:`CMAKE_GENERATOR_TOOLSET` variable for details. diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst index d342c5395d..fb8e021bc7 100644 --- a/Help/generator/Visual Studio 12 2013.rst +++ b/Help/generator/Visual Studio 12 2013.rst @@ -42,4 +42,7 @@ The ``v120`` toolset that comes with Visual Studio 12 2013 is selected by default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. +.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace:: + By default this generator uses the 32-bit variant even on a 64-bit host. + .. include:: VS_TOOLSET_HOST_ARCH.txt diff --git a/Help/generator/Visual Studio 14 2015.rst b/Help/generator/Visual Studio 14 2015.rst index 106b7c5e92..7383f7a6f9 100644 --- a/Help/generator/Visual Studio 14 2015.rst +++ b/Help/generator/Visual Studio 14 2015.rst @@ -39,4 +39,7 @@ The ``v140`` toolset that comes with Visual Studio 14 2015 is selected by default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. +.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace:: + By default this generator uses the 32-bit variant even on a 64-bit host. + .. include:: VS_TOOLSET_HOST_ARCH.txt diff --git a/Help/generator/Visual Studio 15 2017.rst b/Help/generator/Visual Studio 15 2017.rst index 52c1fa0236..7e6f0fb20f 100644 --- a/Help/generator/Visual Studio 15 2017.rst +++ b/Help/generator/Visual Studio 15 2017.rst @@ -56,4 +56,7 @@ The ``v141`` toolset that comes with Visual Studio 15 2017 is selected by default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. +.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace:: + By default this generator uses the 32-bit variant even on a 64-bit host. + .. include:: VS_TOOLSET_HOST_ARCH.txt diff --git a/Help/generator/Visual Studio 16 2019.rst b/Help/generator/Visual Studio 16 2019.rst index 6f2bc56a50..b456554b92 100644 --- a/Help/generator/Visual Studio 16 2019.rst +++ b/Help/generator/Visual Studio 16 2019.rst @@ -46,4 +46,8 @@ The ``v142`` toolset that comes with Visual Studio 16 2019 is selected by default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. +.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace:: + By default this generator uses the 64-bit variant on x64 hosts and + the 32-bit variant otherwise. + .. include:: VS_TOOLSET_HOST_ARCH.txt diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index edf80f4fee..c433412760 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -24,11 +24,13 @@ Environment Variables that Control the Build /envvar/CMAKE_BUILD_PARALLEL_LEVEL /envvar/CMAKE_CONFIG_TYPE /envvar/CMAKE_MSVCIDE_RUN_PATH + /envvar/CMAKE_NO_VERBOSE /envvar/CMAKE_OSX_ARCHITECTURES /envvar/DESTDIR /envvar/LDFLAGS /envvar/MACOSX_DEPLOYMENT_TARGET /envvar/PackageName_ROOT + /envvar/VERBOSE Environment Variables for Languages =================================== diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 63e43e1ed9..7f484a42a8 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -122,12 +122,19 @@ Variable Queries ``1`` if the CMake-id of the CXX compiler matches ``compiler_id``, otherwise ``0``. See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. +``$<Fortran_COMPILER_ID:compiler_id>`` + ``1`` if the CMake-id of the Fortran compiler matches ``compiler_id``, + otherwise ``0``. + See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. ``$<C_COMPILER_VERSION:version>`` ``1`` if the version of the C compiler matches ``version``, otherwise ``0``. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. ``$<CXX_COMPILER_VERSION:version>`` ``1`` if the version of the CXX compiler matches ``version``, otherwise ``0``. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. +``$<Fortran_COMPILER_VERSION:version>`` + ``1`` if the version of the Fortran compiler matches ``version``, otherwise ``0``. + See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. ``$<TARGET_POLICY:policy>`` ``1`` if the ``policy`` was NEW when the 'head' target was created, else ``0``. If the ``policy`` was not set, the warning message for the policy @@ -339,12 +346,18 @@ Variable Queries ``$<CXX_COMPILER_ID>`` The CMake-id of the CXX compiler used. See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. +``$<Fortran_COMPILER_ID>`` + The CMake-id of the Fortran compiler used. + See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. ``$<C_COMPILER_VERSION>`` The version of the C compiler used. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. ``$<CXX_COMPILER_VERSION>`` The version of the CXX compiler used. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. +``$<Fortran_COMPILER_VERSION>`` + The version of the Fortran compiler used. + See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. ``$<COMPILE_LANGUAGE>`` The compile language of source files when evaluating compile options. See :ref:`the related boolean expression diff --git a/Help/manual/cmake-gui.1.rst b/Help/manual/cmake-gui.1.rst index 9322e33cbb..856aa2fba2 100644 --- a/Help/manual/cmake-gui.1.rst +++ b/Help/manual/cmake-gui.1.rst @@ -10,6 +10,7 @@ Synopsis cmake-gui [<options>] cmake-gui [<options>] {<path-to-source> | <path-to-existing-build>} + cmake-gui [<options>] -S <path-to-source> -B <path-to-build> Description =========== @@ -27,6 +28,14 @@ native tool on their platform. Options ======= +``-S <path-to-source>`` + Path to root directory of the CMake project to build. + +``-B <path-to-build>`` + Path to directory which CMake will use as the root of build directory. + + If the directory doesn't already exist CMake will make it. + .. include:: OPTIONS_HELP.txt See Also diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 02aaf4abdb..e1de134523 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -194,6 +194,7 @@ Properties on Targets /prop_tgt/FRAMEWORK /prop_tgt/FRAMEWORK_VERSION /prop_tgt/GENERATOR_FILE_NAME + /prop_tgt/GHS_INTEGRITY_APP /prop_tgt/GNUtoMS /prop_tgt/HAS_CXX /prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM @@ -205,7 +206,6 @@ Properties on Targets /prop_tgt/IMPORTED_LIBNAME_CONFIG /prop_tgt/IMPORTED_LIBNAME /prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG - /prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG /prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES /prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG /prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index e464b0c1ef..de4ce3debc 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -170,6 +170,7 @@ Variables that Change Behavior /variable/CMAKE_FIND_NO_INSTALL_PREFIX /variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY /variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY + /variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS /variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE /variable/CMAKE_FIND_ROOT_PATH /variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE @@ -189,6 +190,7 @@ Variables that Change Behavior /variable/CMAKE_LIBRARY_PATH /variable/CMAKE_LINK_DIRECTORIES_BEFORE /variable/CMAKE_MFC_FLAG + /variable/CMAKE_MAXIMUM_RECURSION_DEPTH /variable/CMAKE_MODULE_PATH /variable/CMAKE_NOT_USING_CONFIG_FLAGS /variable/CMAKE_POLICY_DEFAULT_CMPNNNN @@ -482,11 +484,6 @@ Variables for Languages /variable/CMAKE_LANG_FLAGS_RELEASE_INIT /variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO /variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT - /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_CONFIG - /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG - /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL - /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE - /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO /variable/CMAKE_LANG_IGNORE_EXTENSIONS /variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES /variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES @@ -574,6 +571,7 @@ Variables for CTest /variable/CTEST_RUN_CURRENT_SCRIPT /variable/CTEST_SCP_COMMAND /variable/CTEST_SITE + /variable/CTEST_SUBMIT_URL /variable/CTEST_SOURCE_DIRECTORY /variable/CTEST_SVN_COMMAND /variable/CTEST_SVN_OPTIONS diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 915e0d47de..f3b81ecb68 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -289,6 +289,14 @@ following options: ``--use-stderr`` Ignored. Behavior is default in CMake >= 3.0. +``-v, --verbose`` + Enable verbose output - if supported - including the build commands to be + executed. + + This option can be omitted if :envvar:`VERBOSE` environment variable or + :variable:`CMAKE_VERBOSE_MAKEFILE` cached variable is set. + + ``--`` Pass remaining options to the native tool. @@ -373,9 +381,10 @@ Available commands are: ``chdir <dir> <cmd> [<arg>...]`` Change the current working directory and run a command. -``compare_files <file1> <file2>`` +``compare_files [--ignore-eol] <file1> <file2>`` Check if ``<file1>`` is same as ``<file2>``. If files are the same, - then returns 0, if not it returns 1. + then returns 0, if not it returns 1. The ``--ignore-eol`` option + implies line-wise comparison and ignores LF/CRLF differences. ``copy <file>... <destination>`` Copy files to ``<destination>`` (either file or directory). diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index 8490e3db83..bcf75ac7f1 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -1109,38 +1109,45 @@ Configuration settings include: * :module:`CTest` module variable: ``CTEST_CURL_OPTIONS`` ``DropLocation`` - The path on the dashboard server to send the submission. + Legacy option. When ``SubmitURL`` is not set, it is constructed from + ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and + ``DropLocation``. * `CTest Script`_ variable: :variable:`CTEST_DROP_LOCATION` * :module:`CTest` module variable: ``DROP_LOCATION`` if set, else ``CTEST_DROP_LOCATION`` ``DropMethod`` - Specify the method by which results should be submitted to the - dashboard server. The value may be ``http`` or ``https``. + Legacy option. When ``SubmitURL`` is not set, it is constructed from + ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and + ``DropLocation``. * `CTest Script`_ variable: :variable:`CTEST_DROP_METHOD` * :module:`CTest` module variable: ``DROP_METHOD`` if set, else ``CTEST_DROP_METHOD`` ``DropSite`` - The dashboard server name. + Legacy option. When ``SubmitURL`` is not set, it is constructed from + ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and + ``DropLocation``. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE` * :module:`CTest` module variable: ``DROP_SITE`` if set, else ``CTEST_DROP_SITE`` ``DropSitePassword`` - The dashboard server login password, if any - (for ``ftp``, ``http``, and ``https``). + Legacy option. When ``SubmitURL`` is not set, it is constructed from + ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and + ``DropLocation``. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_PASSWORD` * :module:`CTest` module variable: ``DROP_SITE_PASSWORD`` if set, else ``CTEST_DROP_SITE_PASWORD`` ``DropSiteUser`` - The dashboard server login user name, if any - (for ``ftp``, ``http``, and ``https``). + Legacy option. When ``SubmitURL`` is not set, it is constructed from + ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and + ``DropLocation``. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_USER` * :module:`CTest` module variable: ``DROP_SITE_USER`` if set, @@ -1166,6 +1173,14 @@ Configuration settings include: * :module:`CTest` module variable: ``SITE``, initialized by the :command:`site_name` command +``SubmitURL`` + The ``http`` or ``https`` URL of the dashboard server to send the submission + to. + + * `CTest Script`_ variable: :variable:`CTEST_SUBMIT_URL` + * :module:`CTest` module variable: ``SUBMIT_URL`` if set, + else ``CTEST_SUBMIT_URL`` + ``TriggerSite`` Legacy option. Not used. diff --git a/Help/prop_dir/EXCLUDE_FROM_ALL.rst b/Help/prop_dir/EXCLUDE_FROM_ALL.rst index 1aa24e44bf..9d3192c1bb 100644 --- a/Help/prop_dir/EXCLUDE_FROM_ALL.rst +++ b/Help/prop_dir/EXCLUDE_FROM_ALL.rst @@ -7,3 +7,9 @@ A property on a directory that indicates if its targets are excluded from the default build target. If it is not, then with a Makefile for example typing make will cause the targets to be built. The same concept applies to the default build of other generators. + +Targets inherit the :prop_tgt:`EXCLUDE_FROM_ALL` property from the directory +that they are created in. When a directory is excluded, all of its targets will +have :prop_tgt:`EXCLUDE_FROM_ALL` set to ``TRUE``. After creating such a target +you can change its :prop_tgt:`EXCLUDE_FROM_ALL` property to ``FALSE``. This +will cause the target to be included in the default build target. diff --git a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst index caa5741f85..e7457e1e29 100644 --- a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst +++ b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst @@ -8,3 +8,6 @@ the default build target. If it is not, then with a Makefile for example typing make will cause this target to be built. The same concept applies to the default build of other generators. Installing a target with EXCLUDE_FROM_ALL set to true has undefined behavior. + +This property is enabled by default for targets that are created in +directories that have :prop_dir:`EXCLUDE_FROM_ALL` set to ``TRUE``. diff --git a/Help/prop_tgt/GHS_INTEGRITY_APP.rst b/Help/prop_tgt/GHS_INTEGRITY_APP.rst new file mode 100644 index 0000000000..7643038503 --- /dev/null +++ b/Help/prop_tgt/GHS_INTEGRITY_APP.rst @@ -0,0 +1,10 @@ +GHS_INTEGRITY_APP +----------------- + +``ON`` / ``OFF`` boolean to determine if an executable target should +be treated as an `Integrity Application`. + +If no value is set and if a `.int` file is added as a source file to the +executable target it will be treated as an `Integrity Application`. + +Supported on :generator:`Green Hills MULTI`. diff --git a/Help/release/3.13.rst b/Help/release/3.13.rst index 68e05c37f0..1c58550fff 100644 --- a/Help/release/3.13.rst +++ b/Help/release/3.13.rst @@ -252,3 +252,29 @@ Changes made since CMake 3.13.0 include the following. directories to the ``moc`` tool for :prop_tgt:`AUTOMOC`. This has been reverted due to regressing existing builds and will need further investigation before being re-introduced in a later release. + +3.13.3 +------ + +* The :generator:`Visual Studio 15 2017` generator has been fixed to work + when VS 2019 is installed. + +* CMake now checks that at least one of the source or binary directory + is specified when running CMake and issues an error if both are missing. + This has always been a documented requirement, but the implementation + previously accidentally accepted cases in which neither are specified + so long as some other argument is given, and silently used the current + working directory as the source and build tree. + +3.13.4 +------ + +* The error added by 3.13.3 in cases that neither a source or binary + directory is specified has been downgraded to a warning. While this + was never intended, documented, nor supported behavior, some projects + relied on it. The error has been downgraded to a warning for the + remainder of the 3.13.x release series to allow a transition period, + but it may become a fatal error again in a later release. Scripts + relying on the old behavior can be trivially fixed by specifying + the path to the source tree (even if just ``.``) explicitly and + continue to work with all versions of CMake. diff --git a/Help/release/dev/EXCLUDE_FROM_ALL.rst b/Help/release/dev/EXCLUDE_FROM_ALL.rst new file mode 100644 index 0000000000..519ac42e81 --- /dev/null +++ b/Help/release/dev/EXCLUDE_FROM_ALL.rst @@ -0,0 +1,7 @@ +EXCLUDE_FROM_ALL +---------------- + +* A target's :prop_tgt:`EXCLUDE_FROM_ALL` property can now override the + setting of its directory. A target will now be built as part of "all" + if its :prop_tgt:`EXCLUDE_FROM_ALL` property is set to ``OFF``, even if its + containing directory is marked as :prop_dir:`EXCLUDE_FROM_ALL`. diff --git a/Help/release/dev/ExternalProject-non-cmake-source-subdir.rst b/Help/release/dev/ExternalProject-non-cmake-source-subdir.rst new file mode 100644 index 0000000000..29fe2ad5d5 --- /dev/null +++ b/Help/release/dev/ExternalProject-non-cmake-source-subdir.rst @@ -0,0 +1,7 @@ +ExternalProject-non-cmake-source-subdir +--------------------------------------- + +* The :module:`ExternalProject` module's ``ExternalProject_Add`` command + learned to apply ``SOURCE_SUBDIR`` when ``BUILD_IN_SOURCE`` is also used. + The ``BUILD_COMMAND`` is run in the given ``SOURCE_SUBDIR`` of the + ``SOURCE_DIR``. diff --git a/Help/release/dev/FindPython-NumPy-component.rst b/Help/release/dev/FindPython-NumPy-component.rst new file mode 100644 index 0000000000..5ea6cfb6ca --- /dev/null +++ b/Help/release/dev/FindPython-NumPy-component.rst @@ -0,0 +1,5 @@ +FindPython-NumPy-component +-------------------------- + +* The :module:`FindPython`, :module:`FindPython2`, and :module:`FindPython3` + modules gained support for ``NumPy`` component. diff --git a/Help/release/dev/cmake-build-verbose.rst b/Help/release/dev/cmake-build-verbose.rst new file mode 100644 index 0000000000..dee212edb6 --- /dev/null +++ b/Help/release/dev/cmake-build-verbose.rst @@ -0,0 +1,6 @@ +cmake-build-verbose +------------------- + +* The :manual:`cmake(1)` :ref:`Build Tool Mode` (``cmake --build``) gained + ``--verbose`` and ``-v`` options to specify verbose build output. Some + generators such as Xcode don't support this option currently. diff --git a/Help/release/dev/cmake-gui-s-b.rst b/Help/release/dev/cmake-gui-s-b.rst new file mode 100644 index 0000000000..9447eb39a6 --- /dev/null +++ b/Help/release/dev/cmake-gui-s-b.rst @@ -0,0 +1,5 @@ +cmake-gui-s-b +------------- + +* The :manual:`cmake-gui(1)` dialog gained new ``-S`` and ``-B`` arguments to + explicitly specify source and build directories. diff --git a/Help/release/dev/compare_files-ignore-eol.rst b/Help/release/dev/compare_files-ignore-eol.rst new file mode 100644 index 0000000000..bc329217d0 --- /dev/null +++ b/Help/release/dev/compare_files-ignore-eol.rst @@ -0,0 +1,6 @@ +compare_files-ignore-eol +------------------------ + +* The :manual:`cmake(1)` ``-E compare_files`` command learned a new + ``--ignore-eol`` option to specify that end-of-line differences (e.g. LF vs + CRLF) should be ignored when comparing files. diff --git a/Help/release/dev/ctest-submit-url.rst b/Help/release/dev/ctest-submit-url.rst new file mode 100644 index 0000000000..f848877fbf --- /dev/null +++ b/Help/release/dev/ctest-submit-url.rst @@ -0,0 +1,7 @@ +ctest-submit-url +---------------- + +* CTest learned to accept the dashboard server submission URL from a single + variable. See the ``SubmitURL`` setting in :manual:`ctest(1)`, + the :variable:`CTEST_SUBMIT_URL` variable, and the ``SUBMIT_URL`` + argument of the :command:`ctest_submit` command. diff --git a/Help/release/dev/find-package-resolve-symlinks.rst b/Help/release/dev/find-package-resolve-symlinks.rst new file mode 100644 index 0000000000..7adb9fe622 --- /dev/null +++ b/Help/release/dev/find-package-resolve-symlinks.rst @@ -0,0 +1,6 @@ +find-package-resolve-symlinks +----------------------------- + +* The :command:`find_package` command learned to optionally resolve + symbolic links in the paths to package configuration files. + See the :variable:`CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS` variable. diff --git a/Help/release/dev/findgit-imported-target.rst b/Help/release/dev/findgit-imported-target.rst new file mode 100644 index 0000000000..cabbae5128 --- /dev/null +++ b/Help/release/dev/findgit-imported-target.rst @@ -0,0 +1,5 @@ +findgit-imported-target +----------------------- + +* The :module:`FindGit` module now provides an ``IMPORTED`` target for the Git + executable. diff --git a/Help/release/dev/findpython-script.rst b/Help/release/dev/findpython-script.rst new file mode 100644 index 0000000000..5de1ebfd0f --- /dev/null +++ b/Help/release/dev/findpython-script.rst @@ -0,0 +1,6 @@ +findpython-script +----------------- + +* The :module:`FindPython2`, :module:`FindPython3`, and :module:`FindPython` + modules now support running in script mode by skipping the creation of + imported targets and helper functions. diff --git a/Help/release/dev/fortran-compiler-id.rst b/Help/release/dev/fortran-compiler-id.rst new file mode 100644 index 0000000000..1ea3bf9a17 --- /dev/null +++ b/Help/release/dev/fortran-compiler-id.rst @@ -0,0 +1,5 @@ +Fortran_COMPILER_ID +------------------- + +* The ``$<Fortran_COMPILER_ID:...>`` and ``$<Fortran_COMPILER_VERSION:...>`` + :manual:`generator expressions <cmake-generator-expressions(7)>` were added. diff --git a/Help/release/dev/get_filename_component_last_ext.rst b/Help/release/dev/get_filename_component_last_ext.rst new file mode 100644 index 0000000000..2487dbcce1 --- /dev/null +++ b/Help/release/dev/get_filename_component_last_ext.rst @@ -0,0 +1,6 @@ +get_filename_component_last_ext +------------------------------- + +* The :command:`get_filename_component` command gained new + ``LAST_EXT`` and ``NAME_WLE`` variants to work with the + extension after the last ``.`` in the name. diff --git a/Help/release/dev/max-recursion-depth.rst b/Help/release/dev/max-recursion-depth.rst new file mode 100644 index 0000000000..3d9c781dcd --- /dev/null +++ b/Help/release/dev/max-recursion-depth.rst @@ -0,0 +1,6 @@ +max-recursion-depth +------------------- + +* CMake now imposes a maximum recursion limit to prevent a stack overflow on + scripts that recurse infinitely. The limit can be adjusted at runtime with + :variable:`CMAKE_MAXIMUM_RECURSION_DEPTH`. diff --git a/Help/release/dev/vs2019.rst b/Help/release/dev/vs2019.rst index 1ffdeec2fd..ee9a2f2857 100644 --- a/Help/release/dev/vs2019.rst +++ b/Help/release/dev/vs2019.rst @@ -2,7 +2,7 @@ vs2019 ------ * The :generator:`Visual Studio 16 2019` generator was added. This is - experimental and based on "Visual Studio 2019 Preview 1.1" because this + experimental and based on "Visual Studio 2019 Preview 2" because this version of VS has not been released. The VS 2019 generator differs from generators for earlier versions @@ -10,4 +10,5 @@ vs2019 in the generator name. Instead :variable:`CMAKE_GENERATOR_PLATFORM` must be used, e.g. through the ``-A`` command-line option. Furthermore, the default target platform (architecture) is now based on the *host* - platform. + platform. The VS host toolset selection is now based on the host + architecture as well. diff --git a/Help/variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS.rst b/Help/variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS.rst new file mode 100644 index 0000000000..dfbde20351 --- /dev/null +++ b/Help/variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS.rst @@ -0,0 +1,10 @@ +CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS +----------------------------------- + +Set to ``TRUE`` to tell :command:`find_package` calls to resolve symbolic +links in the value of ``<PackageName>_DIR``. + +This is helpful in use cases where the package search path points at a +proxy directory in which symlinks to the real package locations appear. +This is not enabled by default because there are also common use cases +in which the symlinks should be preserved. diff --git a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst index e9bc28b9e5..e77f211dd3 100644 --- a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst +++ b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst @@ -44,8 +44,8 @@ Supported pairs are: and above with the CUDA toolkit VS integration installed. See the :variable:`CMAKE_VS_PLATFORM_TOOLSET_CUDA` variable. -``host=x64`` - Request use of the native ``x64`` toolchain on ``x64`` hosts. +``host=<arch>`` + Specify the host tools architecture as ``x64`` or ``x86``. Supported by VS 2013 and above. See the :variable:`CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE` variable. diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 2264269706..5323880d58 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -17,8 +17,10 @@ include: Clang = LLVM Clang (clang.llvm.org) Cray = Cray Compiler (cray.com) Embarcadero, Borland = Embarcadero (embarcadero.com) + Flang = Flang LLVM Fortran Compiler G95 = G95 Fortran (g95.org) GNU = GNU Compiler Collection (gcc.gnu.org) + GHS = Green Hills Software (www.ghs.com) HP = Hewlett-Packard Compiler (hp.com) IAR = IAR Systems (iar.com) Intel = Intel Compiler (intel.com) @@ -27,7 +29,6 @@ include: NVIDIA = NVIDIA CUDA Compiler (nvidia.com) OpenWatcom = Open Watcom (openwatcom.org) PGI = The Portland Group (pgroup.com) - Flang = Flang Fortran Compiler PathScale = PathScale (pathscale.com) SDCC = Small Device C Compiler (sdcc.sourceforge.net) SunPro = Oracle Solaris Studio (oracle.com) diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_CONFIG.rst deleted file mode 100644 index 8ed1c02cc2..0000000000 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_CONFIG.rst +++ /dev/null @@ -1,5 +0,0 @@ -CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG> --------------------------------------- - -GHS kernel flags for language ``<LANG>`` when building for the ``<CONFIG>`` -configuration. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst deleted file mode 100644 index 4fea67a4a5..0000000000 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst +++ /dev/null @@ -1,5 +0,0 @@ -CMAKE_<LANG>_GHS_KERNEL_FLAGS_DEBUG ------------------------------------ - -This variable is the ``Debug`` variant of the -:variable:`CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst deleted file mode 100644 index 31f87f2acc..0000000000 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst +++ /dev/null @@ -1,5 +0,0 @@ -CMAKE_<LANG>_GHS_KERNEL_FLAGS_MINSIZEREL ----------------------------------------- - -This variable is the ``MinSizeRel`` variant of the -:variable:`CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst deleted file mode 100644 index 1acd198760..0000000000 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst +++ /dev/null @@ -1,5 +0,0 @@ -CMAKE_<LANG>_GHS_KERNEL_FLAGS_RELEASE -------------------------------------- - -This variable is the ``Release`` variant of the -:variable:`CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst deleted file mode 100644 index ac1b6bceba..0000000000 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst +++ /dev/null @@ -1,5 +0,0 @@ -CMAKE_<LANG>_GHS_KERNEL_FLAGS_RELWITHDEBINFO --------------------------------------------- - -This variable is the ``RelWithDebInfo`` variant of the -:variable:`CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst b/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst new file mode 100644 index 0000000000..7110b16851 --- /dev/null +++ b/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst @@ -0,0 +1,33 @@ +CMAKE_MAXIMUM_RECURSION_DEPTH +----------------------------- + +Maximum recursion depth for CMake scripts. It is intended to be set on the +command line with ``-DCMAKE_MAXIMUM_RECURSION_DEPTH=<x>``, or within +``CMakeLists.txt`` by projects that require a large recursion depth. Projects +that set this variable should provide the user with a way to override it. For +example: + +.. code-block:: cmake + + # About to perform deeply recursive actions + if(NOT CMAKE_MAXIMUM_RECURSION_DEPTH) + set(CMAKE_MAXIMUM_RECURSION_DEPTH 2000) + endif() + +If it is not set, or is set to a non-integer value, a sensible default limit is +used. If the recursion limit is reached, the script terminates immediately with +a fatal error. + +Calling any of the following commands increases the recursion depth: + +* :command:`include` +* :command:`find_package` +* :command:`add_subdirectory` +* :command:`try_compile` +* :command:`ctest_read_custom_files` +* :command:`ctest_run_script` (unless ``NEW_PROCESS`` is specified) +* User-defined :command:`function`'s and :command:`macro`'s (note that + :command:`function` and :command:`macro` themselves don't increase recursion + depth) +* Reading or writing variables that are being watched by a + :command:`variable_watch` diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst index 9b59c52a64..99ac90ddc6 100644 --- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst @@ -3,8 +3,8 @@ CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE Visual Studio preferred tool architecture. -The :ref:`Visual Studio Generators` for VS 2013 and above support optional -selection of a 64-bit toolchain on 64-bit hosts by specifying a ``host=x64`` -value in the :variable:`CMAKE_GENERATOR_TOOLSET` option. CMake provides -the selected toolchain architecture preference in this variable (either -``x64`` or empty). +The :ref:`Visual Studio Generators` for VS 2013 and above support using +either the 32-bit or 64-bit host toolchains by specifying a ``host=x86`` +or ``host=x64`` value in the :variable:`CMAKE_GENERATOR_TOOLSET` option. +CMake provides the selected toolchain architecture preference in this +variable (``x86``, ``x64``, or empty). diff --git a/Help/variable/CTEST_SUBMIT_URL.rst b/Help/variable/CTEST_SUBMIT_URL.rst new file mode 100644 index 0000000000..7d84da4b42 --- /dev/null +++ b/Help/variable/CTEST_SUBMIT_URL.rst @@ -0,0 +1,5 @@ +CTEST_SUBMIT_URL +---------------- + +Specify the CTest ``SubmitURL`` setting +in a :manual:`ctest(1)` dashboard client script. diff --git a/Help/variable/GHS-MULTI.rst b/Help/variable/GHS-MULTI.rst index 0f91be8ad8..fe3b17e189 100644 --- a/Help/variable/GHS-MULTI.rst +++ b/Help/variable/GHS-MULTI.rst @@ -1,4 +1,4 @@ GHS-MULTI --------- -True when using Green Hills MULTI +``True`` when using :generator:`Green Hills MULTI` generator. diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index e75c74e6a9..f473b0d1c8 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -69,6 +69,7 @@ endif() @CMAKE_C_SYSROOT_FLAG_CODE@ @CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ +set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES@") set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@") set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index feb3e7905d..711129a390 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -23,6 +23,7 @@ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBR set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") +set(CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES@") set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES@") set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 5f52fd85d0..a1be02b5cc 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -72,6 +72,7 @@ endif() @CMAKE_CXX_SYSROOT_FLAG_CODE@ @CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ +set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@") set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 9b2a91fc4e..4d0c681d53 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -63,6 +63,7 @@ function(compiler_id_detection outvar lang) Cray TI Fujitsu + GHS ) if (lang STREQUAL C) list(APPEND ordered_compilers diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 1a0d8a6657..4f355f3535 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -31,6 +31,7 @@ if(NOT CMAKE_C_COMPILER_NAMES) endif() if(${CMAKE_GENERATOR} MATCHES "Visual Studio") +elseif("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI") elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") set(CMAKE_C_COMPILER_XCODE_TYPE sourcecode.c.c) _cmake_find_compiler_path(C) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 0a0c37b48a..96b420915a 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -30,6 +30,7 @@ if(NOT CMAKE_CXX_COMPILER_NAMES) endif() if(${CMAKE_GENERATOR} MATCHES "Visual Studio") +elseif("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI") elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") set(CMAKE_CXX_COMPILER_XCODE_TYPE sourcecode.cpp.cpp) _cmake_find_compiler_path(CXX) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 604ac27e6a..e55b83f04b 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -6,7 +6,9 @@ # This is used internally by CMake and should not be included by user # code. +include(${CMAKE_ROOT}/Modules/CMakeParseImplicitIncludeInfo.cmake) include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake) +include(CMakeTestCompilerCommon) function(CMAKE_DETERMINE_COMPILER_ABI lang src) if(NOT DEFINED CMAKE_${lang}_ABI_COMPILED) @@ -15,23 +17,47 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) # Compile the ABI identification source. set(BIN "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerABI_${lang}.bin") set(CMAKE_FLAGS ) + set(COMPILE_DEFINITIONS ) if(DEFINED CMAKE_${lang}_VERBOSE_FLAG) set(CMAKE_FLAGS "-DEXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}") + set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_FLAG}") + endif() + if(DEFINED CMAKE_${lang}_VERBOSE_COMPILE_FLAG) + set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_COMPILE_FLAG}") endif() if(NOT "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC") # Avoid adding our own platform standard libraries for compilers # from which we might detect implicit link libraries. list(APPEND CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD_LIBRARIES=") endif() + __TestCompiler_setTryCompileTargetType() + + # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables + # and set them to "C" that way GCC's "search starts here" text is in + # English and we can grok it. + set(_orig_lc_all $ENV{LC_ALL}) + set(_orig_lc_messages $ENV{LC_MESSAGES}) + set(_orig_lang $ENV{LANG}) + set(ENV{LC_ALL} C) + set(ENV{LC_MESSAGES} C) + set(ENV{LANG} C) + try_compile(CMAKE_${lang}_ABI_COMPILED ${CMAKE_BINARY_DIR} ${src} CMAKE_FLAGS ${CMAKE_FLAGS} # Ignore unused flags when we are just determining the ABI. "--no-warn-unused-cli" + COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} OUTPUT_VARIABLE OUTPUT COPY_FILE "${BIN}" COPY_FILE_ERROR _copy_error ) + + # Restore original LC_ALL, LC_MESSAGES, and LANG + set(ENV{LC_ALL} ${_orig_lc_all}) + set(ENV{LC_MESSAGES} ${_orig_lc_messages}) + set(ENV{LANG} ${_orig_lang}) + # Move result from cache to normal variable. set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED}) unset(CMAKE_${lang}_ABI_COMPILED CACHE) @@ -62,6 +88,18 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) set(CMAKE_${lang}_COMPILER_ABI "${ABI_NAME}" PARENT_SCOPE) endif() + # Parse implicit include directory for this language, if available. + set (implicit_incdirs "") + if(CMAKE_${lang}_VERBOSE_FLAG) + cmake_parse_implicit_include_info("${OUTPUT}" "${lang}" + implicit_incdirs log rv) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Parsed ${lang} implicit include dir info from above output: rv=${rv}\n${log}\n\n") + if("${rv}" STREQUAL "done") # update parent if parse completed ok + set(CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES "${implicit_incdirs}" PARENT_SCOPE) + endif() + endif() + # Parse implicit linker information for this language, if available. set(implicit_dirs "") set(implicit_libs "") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index f987d9aba6..2a0dbd3ca3 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -52,6 +52,13 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endforeach() endif() + # If the compiler is still unknown, fallback to GHS + if(NOT CMAKE_${lang}_COMPILER_ID AND "${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI") + set(CMAKE_${lang}_COMPILER_ID GHS) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "The ${lang} compiler identification is falling back to GHS.\n\n") + endif() + # CUDA < 7.5 is missing version macros if(lang STREQUAL "CUDA" AND CMAKE_${lang}_COMPILER_ID STREQUAL "NVIDIA" @@ -391,6 +398,40 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} separate_arguments(CMAKE_${lang}_XCODE_ARCHS) set(CMAKE_${lang}_XCODE_ARCHS "${CMAKE_${lang}_XCODE_ARCHS}" PARENT_SCOPE) endif() + elseif("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI") + set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) + set(id_src "${src}") + if (GHS_PRIMARY_TARGET) + set(ghs_primary_target "${GHS_PRIMARY_TARGET}") + else() + set(ghs_primary_target "${CMAKE_GENERATOR_PLATFORM}_${GHS_TARGET_PLATFORM}.tgt") + endif() + if ("${GHS_TARGET_PLATFORM}" MATCHES "integrity") + set(bsp_name "macro GHS_BSP=${GHS_BSP_NAME}") + set(os_dir "macro GHS_OS=${GHS_OS_DIR}") + endif() + set(command "${CMAKE_MAKE_PROGRAM}" "-commands" "-top" "GHS_default.gpj") + configure_file(${CMAKE_ROOT}/Modules/CompilerId/GHS_default.gpj.in + ${id_dir}/GHS_default.gpj @ONLY) + configure_file(${CMAKE_ROOT}/Modules/CompilerId/GHS_lib.gpj.in + ${id_dir}/GHS_lib.gpj @ONLY) + execute_process(COMMAND ${command} + WORKING_DIRECTORY ${id_dir} + OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT + ) + # Match the compiler location line printed out. + set(ghs_toolpath "${CMAKE_MAKE_PROGRAM}") + string(REPLACE "/gbuild.exe" "/" ghs_toolpath ${ghs_toolpath}) + string(REPLACE / "\\\\" ghs_toolpath ${ghs_toolpath}) + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "(${ghs_toolpath}[^ ]*)") + set(_comp "${CMAKE_MATCH_1}.exe") + if(EXISTS "${_comp}") + file(TO_CMAKE_PATH "${_comp}" _comp) + set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE) + endif() + endif() else() execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" @@ -550,7 +591,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) set(ARCHITECTURE_ID "${CMAKE_MATCH_1}") endif() if("${info}" MATCHES "INFO:compiler_version\\[([^]\"]*)\\]") - string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}") + string(REGEX REPLACE "^0+([0-9]+)" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}") string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}") endif() if("${info}" MATCHES "INFO:compiler_version_internal\\[([^]\"]*)\\]") @@ -602,26 +643,28 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) if(WIN32) # The offset to the PE signature is stored at 0x3c. file(READ ${file} peoffsethex LIMIT 1 OFFSET 60 HEX) - string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1) - string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2) - set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}") - string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}") - string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}") - string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}") - string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}") - string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}") - string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}") - math(EXPR peoffset "${peoffsetexpression}") - - file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX) - if(peheader STREQUAL "50450000a201") - set(ARCHITECTURE_ID "SH3") - elseif(peheader STREQUAL "50450000a301") - set(ARCHITECTURE_ID "SH3DSP") - elseif(peheader STREQUAL "50450000a601") - set(ARCHITECTURE_ID "SH4") - elseif(peheader STREQUAL "50450000a801") - set(ARCHITECTURE_ID "SH5") + if(NOT peoffsethex STREQUAL "") + string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1) + string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2) + set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}") + string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}") + math(EXPR peoffset "${peoffsetexpression}") + + file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX) + if(peheader STREQUAL "50450000a201") + set(ARCHITECTURE_ID "SH3") + elseif(peheader STREQUAL "50450000a301") + set(ARCHITECTURE_ID "SH3DSP") + elseif(peheader STREQUAL "50450000a601") + set(ARCHITECTURE_ID "SH4") + elseif(peheader STREQUAL "50450000a801") + set(ARCHITECTURE_ID "SH5") + endif() endif() endif() diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index 9b951fc4e2..ae7b73ac4a 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -61,6 +61,7 @@ endif() @CMAKE_Fortran_SYSROOT_FLAG_CODE@ @CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ +set(CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES@") set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "@CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES@") set(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake new file mode 100644 index 0000000000..211406df7c --- /dev/null +++ b/Modules/CMakeParseImplicitIncludeInfo.cmake @@ -0,0 +1,180 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# This is used internally by CMake and should not be included by user code. + +# helper function that parses implicit include dirs from a single line +# for compilers that report them that way. on success we return the +# list of dirs in id_var and set state_var to the 'done' state. +function(cmake_parse_implicit_include_line line lang id_var log_var state_var) + # clear variables we append to (avoids possible polution from parent scopes) + unset(rv) + set(log "") + + # Cray compiler (from cray wrapper, via PrgEnv-cray) + if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "Cray" AND + "${line}" MATCHES "^/" AND "${line}" MATCHES "/ccfe |/ftnfe " AND + "${line}" MATCHES " -isystem| -I") + string(REGEX MATCHALL " (-I ?|-isystem )([^ ]*)" incs "${line}") + foreach(inc IN LISTS incs) + string(REGEX REPLACE " (-I ?|-isystem )([^ ]*)" "\\2" idir "${inc}") + list(APPEND rv "${idir}") + endforeach() + if(rv) + string(APPEND log " got implicit includes via cray ccfe parser!\n") + else() + string(APPEND log " warning: cray ccfe parse failed!\n") + endif() + endif() + + # SunPro compiler + if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "SunPro" AND + "${line}" MATCHES "-D__SUNPRO_C") + string(REGEX MATCHALL " (-I ?)([^ ]*)" incs "${line}") + foreach(inc IN LISTS incs) + string(REGEX REPLACE " (-I ?)([^ ]*)" "\\2" idir "${inc}") + if(NOT "${idir}" STREQUAL "-xbuiltin") + list(APPEND rv "${idir}") + endif() + endforeach() + if(rv) + # /usr/include appears to be hardwired in + list(APPEND rv "/usr/include") + string(APPEND log " got implicit includes via sunpro parser!\n") + else() + string(APPEND log " warning: sunpro parse failed!\n") + endif() + endif() + + # XL compiler + if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XL" AND "${line}" MATCHES "^/" + AND ( ("${lang}" STREQUAL "Fortran" AND + "${line}" MATCHES "/xl[fF]entry " AND + "${line}" MATCHES "OSVAR\\([^ ]+\\)") + OR + ( ("${lang}" STREQUAL "C" OR "${lang}" STREQUAL "CXX") AND + "${line}" MATCHES "/xl[cC]entry " AND + "${line}" MATCHES " -qosvar=") + ) ) + # -qnostdinc cancels other stdinc flags, even if present + string(FIND "${line}" " -qnostdinc" nostd) + if(NOT ${nostd} EQUAL -1) + set(rv "") # defined but empty + string(APPEND log " got implicit includes via XL parser (nostdinc)\n") + else() + if("${lang}" STREQUAL "CXX") + string(REGEX MATCHALL " -qcpp_stdinc=([^ ]*)" std "${line}") + string(REGEX MATCHALL " -qgcc_cpp_stdinc=([^ ]*)" gcc_std "${line}") + else() + string(REGEX MATCHALL " -qc_stdinc=([^ ]*)" std "${line}") + string(REGEX MATCHALL " -qgcc_c_stdinc=([^ ]*)" gcc_std "${line}") + endif() + set(xlstd ${std} ${gcc_std}) + foreach(inc IN LISTS xlstd) + string(REGEX REPLACE " -q(cpp|gcc_cpp|c|gcc_c)_stdinc=([^ ]*)" "\\2" + ipath "${inc}") + string(REPLACE ":" ";" ipath "${ipath}") + list(APPEND rv ${ipath}) + endforeach() + endif() + # user can add -I flags via CMAKE_{C,CXX}_FLAGS, look for that too + string(REGEX MATCHALL " (-I ?)([^ ]*)" incs "${line}") + unset(urv) + foreach(inc IN LISTS incs) + string(REGEX REPLACE " (-I ?)([^ ]*)" "\\2" idir "${inc}") + list(APPEND urv "${idir}") + endforeach() + if(urv) + if ("${rv}" STREQUAL "") + set(rv ${urv}) + else() + list(APPEND rv ${urv}) + endif() + endif() + + if(DEFINED rv) + string(APPEND log " got implicit includes via XL parser!\n") + else() + string(APPEND log " warning: XL parse failed!\n") + endif() + endif() + + if(log) + set(${log_var} "${log}" PARENT_SCOPE) + else() + unset(${log_var} PARENT_SCOPE) + endif() + if(DEFINED rv) + set(${id_var} "${rv}" PARENT_SCOPE) + set(${state_var} "done" PARENT_SCOPE) + endif() +endfunction() + +# top-level function to parse implicit include directory information +# from verbose compiler output. sets state_var in parent to 'done' on success. +function(cmake_parse_implicit_include_info text lang dir_var log_var state_var) + set(state start) # values: start, loading, done + + # clear variables we append to (avoids possible polution from parent scopes) + set(implicit_dirs_tmp) + set(log "") + + # go through each line of output... + string(REGEX REPLACE "\r?\n" ";" output_lines "${text}") + foreach(line IN LISTS output_lines) + if(state STREQUAL start) + string(FIND "${line}" "#include \"...\" search starts here:" rv) + if(rv GREATER -1) + set(state loading) + set(preload 1) # looking for include <...> now + string(APPEND log " found start of include info\n") + else() + cmake_parse_implicit_include_line("${line}" "${lang}" implicit_dirs_tmp + linelog state) + if(linelog) + string(APPEND log ${linelog}) + endif() + if(state STREQUAL done) + break() + endif() + endif() + elseif(state STREQUAL loading) + string(FIND "${line}" "End of search list." rv) + if(rv GREATER -1) + set(state done) + string(APPEND log " end of search list found\n") + break() + endif() + if(preload) + string(FIND "${line}" "#include <...> search starts here:" rv) + if(rv GREATER -1) + set(preload 0) + string(APPEND log " found start of implicit include info\n") + endif() + continue() + endif() + if("${line}" MATCHES "^ ") + string(SUBSTRING "${line}" 1 -1 line) # remove leading space + endif() + if ("${line}" MATCHES " \\(framework directory\\)$") + continue() # frameworks are handled elsewhere, ignore them here + endif() + string(REPLACE "\\" "/" path "${line}") + list(APPEND implicit_dirs_tmp "${path}") + string(APPEND log " add: [${path}]\n") + endif() + endforeach() + + # Log results. + if(state STREQUAL done) + string(APPEND log " implicit include dirs: [${implicit_dirs_tmp}]\n") + else() + string(APPEND log " warn: unable to parse implicit include dirs!\n") + endif() + + # Return results. + set(${dir_var} "${implicit_dirs_tmp}" PARENT_SCOPE) + set(${log_var} "${log}" PARENT_SCOPE) + set(${state_var} "${state}" PARENT_SCOPE) + +endfunction() diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index c2b5aa9291..3cb7f2474d 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -91,6 +91,14 @@ # define PLATFORM_ID # endif +#elif defined(__INTEGRITY) +# if defined(INT_178B) +# define PLATFORM_ID "Integrity178" + +# else /* regular Integrity */ +# define PLATFORM_ID "Integrity" +# endif + #else /* unknown platform */ # define PLATFORM_ID @@ -154,6 +162,26 @@ # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif + +#elif defined(__ghs__) +# if defined(__PPC64__) +# define ARCHITECTURE_ID "PPC64" + +# elif defined(__ppc__) +# define ARCHITECTURE_ID "PPC" + +# elif defined(__ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__x86_64__) +# define ARCHITECTURE_ID "x64" + +# elif defined(__i386__) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif #else # define ARCHITECTURE_ID #endif diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index e34ae756de..f74a1c64de 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -22,6 +22,7 @@ unset(CMAKE_C_COMPILER_WORKS CACHE) # any makefiles or projects. if(NOT CMAKE_C_COMPILER_WORKS) PrintTestCompilerStatus("C" "") + __TestCompiler_setTryCompileTargetType() file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c "#ifdef __cplusplus\n" "# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n" @@ -41,6 +42,7 @@ if(NOT CMAKE_C_COMPILER_WORKS) set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS}) unset(CMAKE_C_COMPILER_WORKS CACHE) set(C_TEST_WAS_RUN 1) + __TestCompiler_restoreTryCompileTargetType() endif() if(NOT CMAKE_C_COMPILER_WORKS) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index e4d49ae842..fe6bd253f4 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -22,6 +22,7 @@ unset(CMAKE_CXX_COMPILER_WORKS CACHE) # any makefiles or projects. if(NOT CMAKE_CXX_COMPILER_WORKS) PrintTestCompilerStatus("CXX" "") + __TestCompiler_setTryCompileTargetType() file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx "#ifndef __cplusplus\n" "# error \"The CMAKE_CXX_COMPILER is set to a C compiler\"\n" @@ -34,6 +35,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS}) unset(CMAKE_CXX_COMPILER_WORKS CACHE) set(CXX_TEST_WAS_RUN 1) + __TestCompiler_restoreTryCompileTargetType() endif() if(NOT CMAKE_CXX_COMPILER_WORKS) diff --git a/Modules/CMakeTestCompilerCommon.cmake b/Modules/CMakeTestCompilerCommon.cmake index f76076fe26..6ee5175dd2 100644 --- a/Modules/CMakeTestCompilerCommon.cmake +++ b/Modules/CMakeTestCompilerCommon.cmake @@ -5,3 +5,23 @@ function(PrintTestCompilerStatus LANG MSG) message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}") endfunction() + +# if required set the target type if not already explicitly set +macro(__TestCompiler_setTryCompileTargetType) + if(NOT CMAKE_TRY_COMPILE_TARGET_TYPE) + if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI") + #prefer static libraries to avoid linking issues + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + set(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE 1) + endif() + endif() +endmacro() + +# restore the original value +# -- not necessary if __TestCompiler_setTryCompileTargetType() was used in function scope +macro(__TestCompiler_restoreTryCompileTargetType) + if(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE) + unset(CMAKE_TRY_COMPILE_TARGET_TYPE) + unset(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE) + endif() +endmacro() diff --git a/Modules/CPack.background.png.in b/Modules/CPack.background.png.in Binary files differindex 9339e7cad2..a32ab3762e 100644 --- a/Modules/CPack.background.png.in +++ b/Modules/CPack.background.png.in diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index 8848bdd7f9..d100704dfe 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -28,10 +28,7 @@ To enable submissions to a CDash server, create a ``CTestConfig.cmake`` file at the top of the project with content such as:: set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") - set(CTEST_DROP_METHOD "http") - set(CTEST_DROP_SITE "my.cdash.org") - set(CTEST_DROP_LOCATION "/submit.php?project=MyProject") - set(CTEST_DROP_SITE_CDASH TRUE) + set(CTEST_SUBMIT_URL "http://my.cdash.org/submit.php?project=MyProject") (the CDash server can provide the file to a project administrator who configures ``MyProject``). Settings in the config file are shared by @@ -89,6 +86,7 @@ if(BUILD_TESTING) if(EXISTS "${PROJECT_SOURCE_DIR}/CTestConfig.cmake") include("${PROJECT_SOURCE_DIR}/CTestConfig.cmake") SET_IF_SET_AND_NOT_SET(NIGHTLY_START_TIME "${CTEST_NIGHTLY_START_TIME}") + SET_IF_SET_AND_NOT_SET(SUBMIT_URL "${CTEST_SUBMIT_URL}") SET_IF_SET_AND_NOT_SET(DROP_METHOD "${CTEST_DROP_METHOD}") SET_IF_SET_AND_NOT_SET(DROP_SITE "${CTEST_DROP_SITE}") SET_IF_SET_AND_NOT_SET(DROP_SITE_USER "${CTEST_DROP_SITE_USER}") @@ -111,6 +109,18 @@ if(BUILD_TESTING) endif() SET_IF_NOT_SET (NIGHTLY_START_TIME "00:00:00 EDT") + if(NOT SUBMIT_URL) + set(SUBMIT_URL "${DROP_METHOD}://") + if(DROP_SITE_USER) + string(APPEND SUBMIT_URL "${DROP_SITE_USER}") + if(DROP_SITE_PASSWORD) + string(APPEND SUBMIT_URL ":${DROP_SITE_PASSWORD}") + endif() + string(APPEND SUBMIT_URL "@") + endif() + string(APPEND SUBMIT_URL "${DROP_SITE}${DROP_SITE_LOCATION}") + endif() + find_program(CVSCOMMAND cvs ) set(CVS_UPDATE_OPTIONS "-d -A -P" CACHE STRING "Options passed to the cvs update command.") diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake index 1820407d5d..f94b254689 100644 --- a/Modules/CheckFortranSourceCompiles.cmake +++ b/Modules/CheckFortranSourceCompiles.cmake @@ -17,8 +17,20 @@ Check if given Fortran source compiles and links into an executable. ) Checks that the source supplied in ``<code>`` can be compiled as a Fortran - source file and linked as an executable (so it must contain at least a - ``PROGRAM`` entry point). The result will be stored in the internal cache + source file and linked as an executable. The ``<code>`` must be a Fortran program + containing at least an ``end`` statement--for example: + + .. code-block:: cmake + + check_fortran_source_compiles("character :: b; error stop b; end" F2018ESTOPOK SRC_EXT F90) + + This command can help avoid costly build processes when a compiler lacks support + for a necessary feature, or a particular vendor library is not compatible with + the Fortran compiler version being used. This generate-time check may advise the + user of such before the main build process. See also the + :command:`check_fortran_source_runs` command to actually run the compiled code. + + The result will be stored in the internal cache variable ``<resultVar>``, with a boolean true value for success and boolean false for failure. diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake index 58d90d7289..13fdb0bedd 100644 --- a/Modules/CheckFortranSourceRuns.cmake +++ b/Modules/CheckFortranSourceRuns.cmake @@ -16,8 +16,20 @@ subsequently be run. [SRC_EXT <extension>]) Check that the source supplied in ``<code>`` can be compiled as a Fortran source - file, linked as an executable and then run. The ``<code>`` must contain at - least ``program; end program`` statements. If the ``<code>`` could be built and run + file, linked as an executable and then run. The ``<code>`` must be a Fortran program + containing at least an ``end`` statement--for example: + + .. code-block:: cmake + + check_fortran_source_runs("real :: x[*]; call co_sum(x); end" F2018coarrayOK) + + This command can help avoid costly build processes when a compiler lacks support + for a necessary feature, or a particular vendor library is not compatible with + the Fortran compiler version being used. Some of these failures only occur at runtime + instead of linktime, and a trivial runtime example can catch the issue before the + main build process. + + If the ``<code>`` could be built and run successfully, the internal cache variable specified by ``<resultVar>`` will be set to 1, otherwise it will be set to an value that evaluates to boolean false (e.g. an empty string or an error message). diff --git a/Modules/Compiler/GHS-C.cmake b/Modules/Compiler/GHS-C.cmake index c30bdecaf0..a825b0bbae 100644 --- a/Modules/Compiler/GHS-C.cmake +++ b/Modules/Compiler/GHS-C.cmake @@ -8,23 +8,3 @@ string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -Odebug -g") string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -Ospace") string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -O") string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -O -g") - -set(CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT "-ldebug ${CMAKE_C_FLAGS_DEBUG_INIT}") -set(CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT}") -set(CMAKE_C_GHS_KERNEL_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT}") -set(CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT - "-ldebug ${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}") - -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - set (CMAKE_C_GHS_KERNEL_FLAGS_DEBUG "${CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT}" - CACHE STRING "Kernel flags used by the compiler during debug builds.") - set (CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL - "${CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Kernel flags used by the compiler during release builds for minimum size.") - set (CMAKE_C_GHS_KERNEL_FLAGS_RELEASE - "${CMAKE_C_GHS_KERNEL_FLAGS_RELEASE_INIT}" - CACHE STRING "Kernel flags used by the compiler during release builds.") - set (CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO - "${CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Kernel flags used by the compiler during release builds with debug info.") -endif() diff --git a/Modules/Compiler/GHS-CXX.cmake b/Modules/Compiler/GHS-CXX.cmake index b3018a7b66..07b5044245 100644 --- a/Modules/Compiler/GHS-CXX.cmake +++ b/Modules/Compiler/GHS-CXX.cmake @@ -8,27 +8,3 @@ string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -Odebug -g") string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -Ospace") string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -O") string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -O -g") - -set(CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT - "-ldebug ${CMAKE_CXX_FLAGS_DEBUG_INIT}") -set(CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL_INIT - "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}") -set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE_INIT - "${CMAKE_CXX_FLAGS_RELEASE_INIT}") -set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT - "-ldebug ${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}") - -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - set (CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG - "${CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT}" - CACHE STRING "Kernel flags used by the compiler during debug builds.") - set (CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL - "${CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Kernel flags used by the compiler during release builds for minimum size.") - set (CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE - "${CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE_INIT}" - CACHE STRING "Kernel flags used by the compiler during release builds.") - set (CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO - "${CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Kernel flags used by the compiler during release builds with debug info.") -endif() diff --git a/Modules/Compiler/GHS-DetermineCompiler.cmake b/Modules/Compiler/GHS-DetermineCompiler.cmake index 56d24e266c..368b3759d7 100644 --- a/Modules/Compiler/GHS-DetermineCompiler.cmake +++ b/Modules/Compiler/GHS-DetermineCompiler.cmake @@ -1,6 +1,9 @@ -set(_compiler_id_pp_test "defined(__INTEGRITY)") +set(_compiler_id_pp_test "defined(__ghs__)") set(_compiler_id_version_compute " -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__INTEGRITY_MAJOR_VERSION) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__INTEGRITY_MINOR_VERSION) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEGRITY_PATCH_VERSION)") +/* __GHS_VERSION_NUMBER = VVVVRP */ +# ifdef __GHS_VERSION_NUMBER +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__GHS_VERSION_NUMBER / 100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__GHS_VERSION_NUMBER / 10 % 10) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__GHS_VERSION_NUMBER % 10) +# endif") diff --git a/Modules/Compiler/GHS.cmake b/Modules/Compiler/GHS.cmake index e6a867d042..b41c3ebf88 100644 --- a/Modules/Compiler/GHS.cmake +++ b/Modules/Compiler/GHS.cmake @@ -3,6 +3,6 @@ if(__COMPILER_GHS) endif() set(__COMPILER_GHS 1) -set(CMAKE_EXECUTABLE_SUFFIX ".as") -set(CMAKE_LIBRARY_PATH_TERMINATOR "\n") -set(CMAKE_LIBRARY_PATH_FLAG " -L") +set(CMAKE_EXECUTABLE_SUFFIX "") +set(CMAKE_LIBRARY_PATH_TERMINATOR "") +set(CMAKE_LIBRARY_PATH_FLAG "") diff --git a/Modules/Compiler/Intel-CXX-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake index 0df6c0fe92..aa35b977e0 100644 --- a/Modules/Compiler/Intel-CXX-FeatureTests.cmake +++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake @@ -24,7 +24,7 @@ set(DETECT_CXX14 "((__cplusplus >= 201300L) || ((__cplusplus == 201103L) && !def unset(DETECT_BUGGY_ICC15) set(Intel17_CXX14 "__INTEL_COMPILER >= 1700 && ${DETECT_CXX14}") -set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && __INTEL_COMPILER != 1800 && !defined(_MSC_VER))") +set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && !(__INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 5) && !defined(_MSC_VER))") set(Intel16_CXX14 "__INTEL_COMPILER >= 1600 && ${DETECT_CXX14}") set(_cmake_feature_test_cxx_aggregate_default_initializers "${Intel16_CXX14}") diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index 05db548f57..de9dd99ba3 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -1,4 +1,5 @@ set(CMAKE_CUDA_VERBOSE_FLAG "-v") +set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v") if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE) diff --git a/Modules/CompilerId/GHS_default.gpj.in b/Modules/CompilerId/GHS_default.gpj.in new file mode 100644 index 0000000000..b5cea5cf89 --- /dev/null +++ b/Modules/CompilerId/GHS_default.gpj.in @@ -0,0 +1,8 @@ +#!gbuild +@bsp_name@ +@os_dir@ +primaryTarget=@ghs_primary_target@ +[Project] + {isdefined(GHS_BSP)} -bsp $GHS_BSP + {isdefined(GHS_OS)} -os_dir $GHS_OS +GHS_lib.gpj [Library] diff --git a/Modules/CompilerId/GHS_lib.gpj.in b/Modules/CompilerId/GHS_lib.gpj.in new file mode 100644 index 0000000000..149b98144c --- /dev/null +++ b/Modules/CompilerId/GHS_lib.gpj.in @@ -0,0 +1,3 @@ +#!gbuild +[Library] +@id_src@ diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index 24e7b55cd2..e4513b363d 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -20,12 +20,7 @@ BuildName: @BUILDNAME@ LabelsForSubprojects: @CTEST_LABELS_FOR_SUBPROJECTS@ # Submission information -DropSite: @DROP_SITE@ -DropLocation: @DROP_LOCATION@ -DropSiteUser: @DROP_SITE_USER@ -DropSitePassword: @DROP_SITE_PASSWORD@ -DropSiteMode: @DROP_SITE_MODE@ -DropMethod: @DROP_METHOD@ +SubmitURL: @SUBMIT_URL@ # Dashboard start time NightlyStartTime: @NIGHTLY_START_TIME@ diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index e763babdb7..c5d6b4576f 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -425,7 +425,9 @@ External Project Definition can be used to point to an alternative directory within the source tree to use as the top of the CMake source tree instead. This must be a relative path and it will be interpreted as being relative to - ``SOURCE_DIR``. + ``SOURCE_DIR``. When ``BUILD_IN_SOURCE 1`` is specified, the + ``BUILD_COMMAND`` is used to point to an alternative directory within the + source tree. **Build Step Options:** If the configure step assumed the external project uses CMake as its build @@ -1676,7 +1678,11 @@ function(_ep_set_directories name) endif() if(build_in_source) get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR) - set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}") + if(source_subdir) + set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}/${source_subdir}") + else() + set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}") + endif() endif() # Make the directories at CMake configure time *and* add a custom command diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index d28dfeae3d..b1989b10e0 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -110,12 +110,12 @@ if(CURL_FIND_COMPONENTS) OUTPUT_VARIABLE CURL_CONFIG_FEATURES_STRING ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REPLACE "\n" ";" CURL_CONFIG_FEATURES "${CURL_CONFIG_FEATURES_STRING}") + string(REPLACE "\n" ";" CURL_SUPPORTED_FEATURES "${CURL_CONFIG_FEATURES_STRING}") execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --protocols OUTPUT_VARIABLE CURL_CONFIG_PROTOCOLS_STRING ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REPLACE "\n" ";" CURL_CONFIG_PROTOCOLS "${CURL_CONFIG_PROTOCOLS_STRING}") + string(REPLACE "\n" ";" CURL_SUPPORTED_PROTOCOLS "${CURL_CONFIG_PROTOCOLS_STRING}") endif() endif() diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index fdd3a9276c..32b4aa2c84 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -713,7 +713,9 @@ if(TARGET Doxygen::doxygen) if(_line MATCHES "([A-Z][A-Z0-9_]+)( *=)(.*)") set(_key "${CMAKE_MATCH_1}") set(_eql "${CMAKE_MATCH_2}") - string(REPLACE ";" "\\\n" _value "${CMAKE_MATCH_3}") + set(_value "${CMAKE_MATCH_3}") + string(REPLACE "\\" "\\\\" _value "${_value}") + string(REPLACE ";" "\\\n" _value "${_value}") list(APPEND _Doxygen_tpl_params "${_key}${_eql}${_value}") endif() endforeach() diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake index c447a1a627..3491cdcc2f 100644 --- a/Modules/FindGit.cmake +++ b/Modules/FindGit.cmake @@ -5,6 +5,12 @@ FindGit ------- +The module defines the following ``IMPORTED`` targets (when +:prop_gbl:`CMAKE_ROLE` is ``PROJECT``): + +``Git::Git`` + Executable of the Git command-line client. + The module defines the following variables: ``GIT_EXECUTABLE`` @@ -78,6 +84,12 @@ if(GIT_EXECUTABLE) string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}") endif() unset(git_version) + + get_property(_findgit_role GLOBAL PROPERTY CMAKE_ROLE) + if(_findgit_role STREQUAL "PROJECT" AND NOT TARGET Git::Git) + add_executable(Git::Git IMPORTED) + set_property(TARGET Git::Git PROPERTY IMPORTED_LOCATION "${GIT_EXECUTABLE}") + endif() endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindICU.cmake b/Modules/FindICU.cmake index 70e10f5b9a..e4b4909b5d 100644 --- a/Modules/FindICU.cmake +++ b/Modules/FindICU.cmake @@ -165,7 +165,9 @@ function(_ICU_FIND) find_program("${cache_var}" "${program}" HINTS ${icu_roots} PATH_SUFFIXES ${icu_binary_suffixes} - DOC "ICU ${program} executable") + DOC "ICU ${program} executable" + NO_PACKAGE_ROOT_PATH + ) mark_as_advanced(cache_var) set("${program_var}" "${${cache_var}}" PARENT_SCOPE) endforeach() @@ -229,11 +231,15 @@ function(_ICU_FIND) find_library("${component_cache_release}" ${component_libnames} HINTS ${icu_roots} PATH_SUFFIXES ${icu_library_suffixes} - DOC "ICU ${component} library (release)") + DOC "ICU ${component} library (release)" + NO_PACKAGE_ROOT_PATH + ) find_library("${component_cache_debug}" ${component_debug_libnames} HINTS ${icu_roots} PATH_SUFFIXES ${icu_library_suffixes} - DOC "ICU ${component} library (debug)") + DOC "ICU ${component} library (debug)" + NO_PACKAGE_ROOT_PATH + ) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(ICU_${component_upcase}) mark_as_advanced("${component_cache_release}" "${component_cache_debug}") diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 8645a0db59..f014916b29 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -14,11 +14,12 @@ Three components are supported: * ``Compiler``: search for Python compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and libraries). +* ``NumPy``: search for NumPy include directories. If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed. -To ensure consistent versions between components ``Interpreter``, ``Compiler`` -and ``Development``, specify all components at the same time:: +To ensure consistent versions between components ``Interpreter``, ``Compiler``, +``Development`` and ``NumPy``, specify all components at the same time:: find_package (Python COMPONENTS Interpreter Development) @@ -30,7 +31,8 @@ To manage concurrent versions 3 and 2 of Python, use :module:`FindPython3` and Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets <Imported Targets>`: +This module defines the following :ref:`Imported Targets <Imported Targets>` +(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): ``Python::Interpreter`` Python interpreter. Target defined if component ``Interpreter`` is found. @@ -38,6 +40,8 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`: Python compiler. Target defined if component ``Compiler`` is found. ``Python::Python`` Python library. Target defined if component ``Development`` is found. +``Python::NumPy`` + NumPy Python library. Target defined if component ``NumPy`` is found. Result Variables ^^^^^^^^^^^^^^^^ @@ -103,6 +107,12 @@ This module will set the following variables in your project Python minor version. ``Python_VERSION_PATCH`` Python patch version. +``Python_NumPy_FOUND`` + System has the NumPy. +``Python_NumPy_INCLUDE_DIRS`` + The NumPy include directries. +``Python_NumPy_VERSION`` + The NumPy version. Hints ^^^^^ @@ -144,9 +154,10 @@ Hints Commands ^^^^^^^^ -This module defines the command ``Python_add_library`` which have the same -semantic as :command:`add_library` but take care of Python module naming rules -(only applied if library is of type ``MODULE``) and add dependency to target +This module defines the command ``Python_add_library`` (when +:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as +:command:`add_library`, but takes care of Python module naming rules +(only applied if library is of type ``MODULE``), and adds a dependency to target ``Python::Python``:: Python_add_library (my_module MODULE src1.cpp) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index e0ebb90337..0138b04b8d 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -24,6 +24,8 @@ else() message (FATAL_ERROR "FindPython: INTERNAL ERROR") endif() +get_property(_${_PYTHON_PREFIX}_CMAKE_ROLE GLOBAL PROPERTY CMAKE_ROLE) + # # helper commands @@ -207,6 +209,10 @@ if (NOT ${_PYTHON_PREFIX}_FIND_COMPONENTS) set (${_PYTHON_PREFIX}_FIND_COMPONENTS Interpreter) set (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter TRUE) endif() +if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) + list (APPEND ${_PYTHON_PREFIX}_FIND_COMPONENTS "Interpreter" "Development") + list (REMOVE_DUPLICATES ${_PYTHON_PREFIX}_FIND_COMPONENTS) +endif() foreach (_${_PYTHON_PREFIX}_COMPONENT IN LISTS ${_PYTHON_PREFIX}_FIND_COMPONENTS) set (${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_FOUND FALSE) endforeach() @@ -1120,6 +1126,41 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() +if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Interpreter_FOUND) + if (${_PYTHON_PREFIX}_FIND_REQUIRED_NumPy) + list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + endif() + execute_process( + COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + "from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n" + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_PATH + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT _${_PYTHON_PREFIX}_RESULT) + find_path(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR + NAMES arrayobject.h numpyconfig.h + HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}" + PATH_SUFFIXES numpy + NO_DEFAULT_PATH) + endif() + if(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + set(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + set(${_PYTHON_PREFIX}_NumPy_FOUND TRUE) + endif() + if(${_PYTHON_PREFIX}_NumPy_FOUND) + execute_process( + COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + "from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n" + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_VERSION) + if (NOT _${_PYTHON_PREFIX}_RESULT) + set(${_PYTHON_PREFIX}_NumPy_VERSION "${_${_PYTHON_PREFIX}_NumPy_VERSION}") + endif() + endif() +endif() + # final validation if (${_PYTHON_PREFIX}_VERSION_MAJOR AND NOT ${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) @@ -1133,118 +1174,128 @@ find_package_handle_standard_args (${_PYTHON_PREFIX} HANDLE_COMPONENTS) # Create imported targets and helper functions -if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS - AND ${_PYTHON_PREFIX}_Interpreter_FOUND - AND NOT TARGET ${_PYTHON_PREFIX}::Interpreter) - add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED) - set_property (TARGET ${_PYTHON_PREFIX}::Interpreter - PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}") -endif() - -if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS - AND ${_PYTHON_PREFIX}_Compiler_FOUND - AND NOT TARGET ${_PYTHON_PREFIX}::Compiler) - add_executable (${_PYTHON_PREFIX}::Compiler IMPORTED) - set_property (TARGET ${_PYTHON_PREFIX}::Compiler - PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_COMPILER}") -endif() - -if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS - AND ${_PYTHON_PREFIX}_Development_FOUND AND NOT TARGET ${_PYTHON_PREFIX}::Python) +if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") + if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS + AND ${_PYTHON_PREFIX}_Interpreter_FOUND + AND NOT TARGET ${_PYTHON_PREFIX}::Interpreter) + add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED) + set_property (TARGET ${_PYTHON_PREFIX}::Interpreter + PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}") + endif() - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" - OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" - OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG) - set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED) - else() - set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC) + if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS + AND ${_PYTHON_PREFIX}_Compiler_FOUND + AND NOT TARGET ${_PYTHON_PREFIX}::Compiler) + add_executable (${_PYTHON_PREFIX}::Compiler IMPORTED) + set_property (TARGET ${_PYTHON_PREFIX}::Compiler + PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_COMPILER}") endif() - add_library (${_PYTHON_PREFIX}::Python ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED) - - set_property (TARGET ${_PYTHON_PREFIX}::Python - PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}") - - if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) - OR (${_PYTHON_PREFIX}_LIBRARY_DEBUG AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)) - # System manage shared libraries in two parts: import and runtime - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) - set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" - IMPORTED_IMPLIB_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" - IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}") - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" - IMPORTED_IMPLIB_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}" - IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}") + if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS + AND ${_PYTHON_PREFIX}_Development_FOUND AND NOT TARGET ${_PYTHON_PREFIX}::Python) + + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" + OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" + OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG) + set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED) else() - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARY}" - IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY}") + set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC) endif() - else() - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) - set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" - IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}") - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" - IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}") + + add_library (${_PYTHON_PREFIX}::Python ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED) + + set_property (TARGET ${_PYTHON_PREFIX}::Python + PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}") + + if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) + OR (${_PYTHON_PREFIX}_LIBRARY_DEBUG AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)) + # System manage shared libraries in two parts: import and runtime + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) + set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_IMPLIB_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" + IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}") + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_IMPLIB_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}" + IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}") + else() + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARY}" + IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY}") + endif() else() - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY}") + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) + set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}") + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}") + else() + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY}") + endif() endif() - endif() - if (_${_PYTHON_PREFIX}_CONFIG AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC") - # extend link information with dependent libraries - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT _${_PYTHON_PREFIX}_RESULT) - string (REGEX MATCHALL "-[Ll][^ ]+" _${_PYTHON_PREFIX}_LINK_LIBRARIES "${_${_PYTHON_PREFIX}_FLAGS}") - # remove elements relative to python library itself - list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-lpython") - foreach (_${_PYTHON_PREFIX}_DIR IN LISTS ${_PYTHON_PREFIX}_LIBRARY_DIRS) - list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-L${${_PYTHON_PREFIX}_DIR}") - endforeach() - set_property (TARGET ${_PYTHON_PREFIX}::Python - PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES}) + if (_${_PYTHON_PREFIX}_CONFIG AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC") + # extend link information with dependent libraries + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT _${_PYTHON_PREFIX}_RESULT) + string (REGEX MATCHALL "-[Ll][^ ]+" _${_PYTHON_PREFIX}_LINK_LIBRARIES "${_${_PYTHON_PREFIX}_FLAGS}") + # remove elements relative to python library itself + list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-lpython") + foreach (_${_PYTHON_PREFIX}_DIR IN LISTS ${_PYTHON_PREFIX}_LIBRARY_DIRS) + list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-L${${_PYTHON_PREFIX}_DIR}") + endforeach() + set_property (TARGET ${_PYTHON_PREFIX}::Python + PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES}) + endif() endif() - endif() - # - # PYTHON_ADD_LIBRARY (<name> [STATIC|SHARED|MODULE] src1 src2 ... srcN) - # It is used to build modules for python. - # - function (__${_PYTHON_PREFIX}_ADD_LIBRARY prefix name) - cmake_parse_arguments (PARSE_ARGV 2 PYTHON_ADD_LIBRARY - "STATIC;SHARED;MODULE" "" "") - - unset (type) - if (NOT (PYTHON_ADD_LIBRARY_STATIC - OR PYTHON_ADD_LIBRARY_SHARED - OR PYTHON_ADD_LIBRARY_MODULE)) - set (type MODULE) - endif() - add_library (${name} ${type} ${ARGN}) - target_link_libraries (${name} PRIVATE ${prefix}::Python) - - # customize library name to follow module name rules - get_property (type TARGET ${name} PROPERTY TYPE) - if (type STREQUAL "MODULE_LIBRARY") - set_property (TARGET ${name} PROPERTY PREFIX "") - if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set_property (TARGET ${name} PROPERTY SUFFIX ".pyd") + # + # PYTHON_ADD_LIBRARY (<name> [STATIC|SHARED|MODULE] src1 src2 ... srcN) + # It is used to build modules for python. + # + function (__${_PYTHON_PREFIX}_ADD_LIBRARY prefix name) + cmake_parse_arguments (PARSE_ARGV 2 PYTHON_ADD_LIBRARY + "STATIC;SHARED;MODULE" "" "") + + unset (type) + if (NOT (PYTHON_ADD_LIBRARY_STATIC + OR PYTHON_ADD_LIBRARY_SHARED + OR PYTHON_ADD_LIBRARY_MODULE)) + set (type MODULE) endif() - endif() - endfunction() + add_library (${name} ${type} ${ARGN}) + target_link_libraries (${name} PRIVATE ${prefix}::Python) + + # customize library name to follow module name rules + get_property (type TARGET ${name} PROPERTY TYPE) + if (type STREQUAL "MODULE_LIBRARY") + set_property (TARGET ${name} PROPERTY PREFIX "") + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set_property (TARGET ${name} PROPERTY SUFFIX ".pyd") + endif() + endif() + endfunction() + endif() + + if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_NumPy_FOUND + AND NOT TARGET ${_PYTHON_PREFIX}::NumPy AND TARGET ${_PYTHON_PREFIX}::Python) + add_library (${_PYTHON_PREFIX}::NumPy INTERFACE IMPORTED) + set_property (TARGET ${_PYTHON_PREFIX}::NumPy + PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + target_link_libraries (${_PYTHON_PREFIX}::NumPy INTERFACE ${_PYTHON_PREFIX}::Python) + endif() endif() # final clean-up diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 998e99223c..0bb7b28e58 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -14,11 +14,12 @@ Three components are supported: * ``Compiler``: search for Python 2 compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and libraries) +* ``NumPy``: search for NumPy include directories. If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed. -To ensure consistent versions between components ``Interpreter``, ``Compiler`` -and ``Development``, specify all components at the same time:: +To ensure consistent versions between components ``Interpreter``, ``Compiler``, +``Development`` and ``NumPy``, specify all components at the same time:: find_package (Python2 COMPONENTS Interpreter Development) @@ -31,7 +32,8 @@ for you. Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets <Imported Targets>`: +This module defines the following :ref:`Imported Targets <Imported Targets>` +(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): ``Python2::Interpreter`` Python 2 interpreter. Target defined if component ``Interpreter`` is found. @@ -39,6 +41,8 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`: Python 2 compiler. Target defined if component ``Compiler`` is found. ``Python2::Python`` Python 2 library. Target defined if component ``Development`` is found. +``Python2::NumPy`` + NumPy library for Python 2. Target defined if component ``NumPy`` is found. Result Variables ^^^^^^^^^^^^^^^^ @@ -104,6 +108,12 @@ This module will set the following variables in your project Python 2 minor version. ``Python2_VERSION_PATCH`` Python 2 patch version. +``Python2_NumPy_FOUND`` + System has the NumPy. +``Python2_NumPy_INCLUDE_DIRS`` + The NumPy include directries. +``Python2_NumPy_VERSION`` + The NumPy version. Hints ^^^^^ @@ -145,9 +155,10 @@ Hints Commands ^^^^^^^^ -This module defines the command ``Python2_add_library`` which have the same -semantic as :command:`add_library` but take care of Python module naming rules -(only applied if library is of type ``MODULE``) and add dependency to target +This module defines the command ``Python2_add_library`` (when +:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as +:command:`add_library`, but takes care of Python module naming rules +(only applied if library is of type ``MODULE``), and adds a dependency to target ``Python2::Python``:: Python2_add_library (my_module MODULE src1.cpp) diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 2176f3f4f4..b3dfff3035 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -14,11 +14,12 @@ Three components are supported: * ``Compiler``: search for Python 3 compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and libraries) +* ``NumPy``: search for NumPy include directories. If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed. -To ensure consistent versions between components ``Interpreter``, ``Compiler`` -and ``Development``, specify all components at the same time:: +To ensure consistent versions between components ``Interpreter``, ``Compiler``, +``Development`` and ``NumPy``, specify all components at the same time:: find_package (Python3 COMPONENTS Interpreter Development) @@ -31,7 +32,8 @@ for you. Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets <Imported Targets>`: +This module defines the following :ref:`Imported Targets <Imported Targets>` +(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): ``Python3::Interpreter`` Python 3 interpreter. Target defined if component ``Interpreter`` is found. @@ -39,6 +41,8 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`: Python 3 compiler. Target defined if component ``Compiler`` is found. ``Python3::Python`` Python 3 library. Target defined if component ``Development`` is found. +``Python3::NumPy`` + NumPy library for Python 3. Target defined if component ``NumPy`` is found. Result Variables ^^^^^^^^^^^^^^^^ @@ -104,6 +108,12 @@ This module will set the following variables in your project Python 3 minor version. ``Python3_VERSION_PATCH`` Python 3 patch version. +``Python3_NumPy_FOUND`` + System has the NumPy. +``Python3_NumPy_INCLUDE_DIRS`` + The NumPy include directries. +``Python3_NumPy_VERSION`` + The NumPy version. Hints ^^^^^ @@ -145,9 +155,10 @@ Hints Commands ^^^^^^^^ -This module defines the command ``Python3_add_library`` which have the same -semantic as :command:`add_library` but take care of Python module naming rules -(only applied if library is of type ``MODULE``) and add dependency to target +This module defines the command ``Python3_add_library`` (when +:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as +:command:`add_library`, but takes care of Python module naming rules +(only applied if library is of type ``MODULE``), and adds a dependency to target ``Python3::Python``:: Python3_add_library (my_module MODULE src1.cpp) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index d1f7b31708..da33301af2 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -130,7 +130,9 @@ if(PYTHON_EXECUTABLE) endif() else() # sys.version predates sys.version_info, so use that - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)" + # sys.version was first documented for Python 1.5, so assume version 1.4 + # if retrieving sys.version fails. + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "try: import sys; sys.stdout.write(sys.version)\nexcept: sys.stdout.write(\"1.4.0\")" OUTPUT_VARIABLE _VERSION RESULT_VARIABLE _PYTHON_VERSION_RESULT ERROR_QUIET) @@ -144,12 +146,10 @@ if(PYTHON_EXECUTABLE) set(PYTHON_VERSION_PATCH "0") endif() else() - # sys.version was first documented for Python 1.5, so assume - # this is older. - set(PYTHON_VERSION_STRING "1.4") - set(PYTHON_VERSION_MAJOR "1") - set(PYTHON_VERSION_MINOR "4") - set(PYTHON_VERSION_PATCH "0") + unset(PYTHON_VERSION_STRING) + unset(PYTHON_VERSION_MAJOR) + unset(PYTHON_VERSION_MINOR) + unset(PYTHON_VERSION_PATCH) endif() endif() unset(_PYTHON_VERSION_RESULT) diff --git a/Modules/Platform/GHS-MULTI-Initialize.cmake b/Modules/Platform/GHS-MULTI-Initialize.cmake index 9b384df8ae..25004c60b0 100644 --- a/Modules/Platform/GHS-MULTI-Initialize.cmake +++ b/Modules/Platform/GHS-MULTI-Initialize.cmake @@ -9,6 +9,9 @@ mark_as_advanced(GHS_OS_ROOT) set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory") mark_as_advanced(GHS_OS_DIR) +set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler os option") +mark_as_advanced(GHS_OS_DIR) + #set GHS_OS_DIR if not set by user if ( NOT GHS_OS_DIR ) if (EXISTS ${GHS_OS_ROOT}) @@ -23,8 +26,11 @@ if ( NOT GHS_OS_DIR ) endif () #filter based on platform name - if (GHS_TARGET_PLATFORM STREQUAL "integrity") + if (GHS_TARGET_PLATFORM MATCHES "integrity") list(FILTER GHS_CANDIDATE_OS_DIRS INCLUDE REGEX "int[0-9][0-9][0-9][0-9a-z].*") + else() #fall-back for standalone + unset(GHS_CANDIDATE_OS_DIRS) + set(GHS_OS_DIR "IGNORE") endif () if (GHS_CANDIDATE_OS_DIRS) diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index 328d3c6d3a..fc22fce0ba 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -63,6 +63,13 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES /lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64 ) +# Platform-wide directories to avoid adding via -I<dir>. +list(APPEND CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES + /usr/include + ) + +# Default per-language values. These may be later replaced after +# parsing the implicit link directories from compiler output. list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES /usr/include ) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 2bcd28ea97..5600b4c1cd 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -446,7 +446,7 @@ function (__java_copy_file src dest comment) endfunction () function(__java_lcat VAR) - foreach(_line ${ARGN}) + foreach(_line IN LISTS ARGN) string(APPEND ${VAR} "${_line}\n") endforeach() @@ -568,7 +568,7 @@ function(add_jar _TARGET_NAME) set(CMAKE_JAVA_INCLUDE_FLAG_SEP ":") endif() - foreach (JAVA_INCLUDE_DIR ${CMAKE_JAVA_INCLUDE_PATH}) + foreach (JAVA_INCLUDE_DIR IN LISTS CMAKE_JAVA_INCLUDE_PATH) string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}") endforeach() @@ -592,7 +592,7 @@ function(add_jar _TARGET_NAME) set(_JAVA_COMPILE_DEPENDS) set(_JAVA_RESOURCE_FILES) set(_JAVA_RESOURCE_FILES_RELATIVE) - foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES}) + foreach(_JAVA_SOURCE_FILE IN LISTS _JAVA_SOURCE_FILES) get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT) get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE) get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH) @@ -607,7 +607,7 @@ function(add_jar _TARGET_NAME) file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL}) string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN) string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN) - if (${_BIN_LEN} LESS ${_SRC_LEN}) + if (_BIN_LEN LESS _SRC_LEN) set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH}) else () set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH}) @@ -637,7 +637,7 @@ function(add_jar _TARGET_NAME) endif () endforeach() - foreach(_JAVA_INCLUDE_JAR ${_add_jar_INCLUDE_JARS}) + foreach(_JAVA_INCLUDE_JAR IN LISTS _add_jar_INCLUDE_JARS) if (TARGET ${_JAVA_INCLUDE_JAR}) get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE) if (_JAVA_JAR_PATH) @@ -705,7 +705,7 @@ function(add_jar _TARGET_NAME) # create the jar file set(_JAVA_JAR_OUTPUT_PATH - ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME}) + "${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME}") if (CMAKE_JNI_TARGET) add_custom_command( OUTPUT ${_JAVA_JAR_OUTPUT_PATH} @@ -903,15 +903,15 @@ function (find_jar VARIABLE) set(_state "name") - foreach (arg ${ARGN}) - if (${_state} STREQUAL "name") - if (${arg} STREQUAL "VERSIONS") + foreach (arg IN LISTS ARGN) + if (_state STREQUAL "name") + if (arg STREQUAL "VERSIONS") set(_state "versions") - elseif (${arg} STREQUAL "NAMES") + elseif (arg STREQUAL "NAMES") set(_state "names") - elseif (${arg} STREQUAL "PATHS") + elseif (arg STREQUAL "PATHS") set(_state "paths") - elseif (${arg} STREQUAL "DOC") + elseif (arg STREQUAL "DOC") set(_state "doc") else () set(_jar_names ${arg}) @@ -919,22 +919,22 @@ function (find_jar VARIABLE) set(_jar_doc "Finding ${arg} jar") endif () endif () - elseif (${_state} STREQUAL "versions") - if (${arg} STREQUAL "NAMES") + elseif (_state STREQUAL "versions") + if (arg STREQUAL "NAMES") set(_state "names") - elseif (${arg} STREQUAL "PATHS") + elseif (arg STREQUAL "PATHS") set(_state "paths") - elseif (${arg} STREQUAL "DOC") + elseif (arg STREQUAL "DOC") set(_state "doc") else () set(_jar_versions ${_jar_versions} ${arg}) endif () - elseif (${_state} STREQUAL "names") - if (${arg} STREQUAL "VERSIONS") + elseif (_state STREQUAL "names") + if (arg STREQUAL "VERSIONS") set(_state "versions") - elseif (${arg} STREQUAL "PATHS") + elseif (arg STREQUAL "PATHS") set(_state "paths") - elseif (${arg} STREQUAL "DOC") + elseif (arg STREQUAL "DOC") set(_state "doc") else () set(_jar_names ${_jar_names} ${arg}) @@ -942,22 +942,22 @@ function (find_jar VARIABLE) set(_jar_doc "Finding ${arg} jar") endif () endif () - elseif (${_state} STREQUAL "paths") - if (${arg} STREQUAL "VERSIONS") + elseif (_state STREQUAL "paths") + if (arg STREQUAL "VERSIONS") set(_state "versions") - elseif (${arg} STREQUAL "NAMES") + elseif (arg STREQUAL "NAMES") set(_state "names") - elseif (${arg} STREQUAL "DOC") + elseif (arg STREQUAL "DOC") set(_state "doc") else () set(_jar_paths ${_jar_paths} ${arg}) endif () - elseif (${_state} STREQUAL "doc") - if (${arg} STREQUAL "VERSIONS") + elseif (_state STREQUAL "doc") + if (arg STREQUAL "VERSIONS") set(_state "versions") - elseif (${arg} STREQUAL "NAMES") + elseif (arg STREQUAL "NAMES") set(_state "names") - elseif (${arg} STREQUAL "PATHS") + elseif (arg STREQUAL "PATHS") set(_state "paths") else () set(_jar_doc ${arg}) @@ -969,8 +969,8 @@ function (find_jar VARIABLE) message(FATAL_ERROR "find_jar: No name to search for given") endif () - foreach (jar_name ${_jar_names}) - foreach (version ${_jar_versions}) + foreach (jar_name IN LISTS _jar_names) + foreach (version IN LISTS _jar_versions) set(_jar_files ${_jar_files} ${jar_name}-${version}.jar) endforeach () set(_jar_files ${_jar_files} ${jar_name}.jar) @@ -997,252 +997,252 @@ function(create_javadoc _target) set(_state "package") - foreach (arg ${ARGN}) - if (${_state} STREQUAL "package") - if (${arg} STREQUAL "PACKAGES") + foreach (arg IN LISTS ARGN) + if (_state STREQUAL "package") + if (arg STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () set(_javadoc_packages ${arg}) set(_state "packages") endif () - elseif (${_state} STREQUAL "packages") - if (${arg} STREQUAL "FILES") + elseif (_state STREQUAL "packages") + if (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () list(APPEND _javadoc_packages ${arg}) endif () - elseif (${_state} STREQUAL "files") - if (${arg} STREQUAL "PACKAGES") + elseif (_state STREQUAL "files") + if (arg STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () list(APPEND _javadoc_files ${arg}) endif () - elseif (${_state} STREQUAL "sourcepath") - if (${arg} STREQUAL "PACKAGES") + elseif (_state STREQUAL "sourcepath") + if (arg STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () list(APPEND _javadoc_sourcepath ${arg}) endif () - elseif (${_state} STREQUAL "classpath") - if (${arg} STREQUAL "PACKAGES") + elseif (_state STREQUAL "classpath") + if (arg STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () list(APPEND _javadoc_classpath ${arg}) endif () - elseif (${_state} STREQUAL "installpath") - if (${arg} STREQUAL "PACKAGES") + elseif (_state STREQUAL "installpath") + if (arg STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () set(_javadoc_installpath ${arg}) endif () - elseif (${_state} STREQUAL "doctitle") + elseif (_state STREQUAL "doctitle") if (${arg} STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () set(_javadoc_doctitle ${arg}) endif () - elseif (${_state} STREQUAL "windowtitle") + elseif (_state STREQUAL "windowtitle") if (${arg} STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () set(_javadoc_windowtitle ${arg}) endif () - elseif (${_state} STREQUAL "author") - if (${arg} STREQUAL "PACKAGES") + elseif (_state STREQUAL "author") + if (arg STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () set(_javadoc_author ${arg}) endif () - elseif (${_state} STREQUAL "use") - if (${arg} STREQUAL "PACKAGES") + elseif (_state STREQUAL "use") + if (arg STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () set(_javadoc_use ${arg}) endif () - elseif (${_state} STREQUAL "version") - if (${arg} STREQUAL "PACKAGES") + elseif (_state STREQUAL "version") + if (arg STREQUAL "PACKAGES") set(_state "packages") - elseif (${arg} STREQUAL "FILES") + elseif (arg STREQUAL "FILES") set(_state "files") - elseif (${arg} STREQUAL "SOURCEPATH") + elseif (arg STREQUAL "SOURCEPATH") set(_state "sourcepath") - elseif (${arg} STREQUAL "CLASSPATH") + elseif (arg STREQUAL "CLASSPATH") set(_state "classpath") - elseif (${arg} STREQUAL "INSTALLPATH") + elseif (arg STREQUAL "INSTALLPATH") set(_state "installpath") - elseif (${arg} STREQUAL "DOCTITLE") + elseif (arg STREQUAL "DOCTITLE") set(_state "doctitle") - elseif (${arg} STREQUAL "WINDOWTITLE") + elseif (arg STREQUAL "WINDOWTITLE") set(_state "windowtitle") - elseif (${arg} STREQUAL "AUTHOR") + elseif (arg STREQUAL "AUTHOR") set(_state "author") - elseif (${arg} STREQUAL "USE") + elseif (arg STREQUAL "USE") set(_state "use") - elseif (${arg} STREQUAL "VERSION") + elseif (arg STREQUAL "VERSION") set(_state "version") else () set(_javadoc_version ${arg}) @@ -1255,7 +1255,7 @@ function(create_javadoc _target) if (_javadoc_sourcepath) set(_start TRUE) - foreach(_path ${_javadoc_sourcepath}) + foreach(_path IN LISTS _javadoc_sourcepath) if (_start) set(_sourcepath ${_path}) set(_start FALSE) @@ -1268,7 +1268,7 @@ function(create_javadoc _target) if (_javadoc_classpath) set(_start TRUE) - foreach(_path ${_javadoc_classpath}) + foreach(_path IN LISTS _javadoc_classpath) if (_start) set(_classpath ${_path}) set(_start FALSE) @@ -1435,7 +1435,7 @@ function(export_jars) # Set content of generated exports file string(REPLACE ";" " " __targets__ "${_export_jars_TARGETS}") set(__targetdefs__ "") - foreach(_target ${_export_jars_TARGETS}) + foreach(_target IN LISTS _export_jars_TARGETS) get_target_property(_jarpath ${_target} JAR_FILE) get_filename_component(_jarpath ${_jarpath} PATH) __java_export_jar(__targetdefs__ ${_target} "${_jarpath}") @@ -1473,7 +1473,7 @@ function(install_jar_exports) endif() # Determine relative path from installed export file to install prefix - if(IS_ABSOLUTE ${_install_jar_exports_DESTINATION}) + if(IS_ABSOLUTE "${_install_jar_exports_DESTINATION}") file(RELATIVE_PATH _relpath ${_install_jar_exports_DESTINATION} ${CMAKE_INSTALL_PREFIX} @@ -1492,7 +1492,7 @@ function(install_jar_exports) # Set content of generated exports file string(REPLACE ";" " " __targets__ "${_install_jar_exports_TARGETS}") set(__targetdefs__ "set(_prefix \${CMAKE_CURRENT_LIST_DIR}/${_relpath})\n\n") - foreach(_target ${_install_jar_exports_TARGETS}) + foreach(_target IN LISTS _install_jar_exports_TARGETS) get_target_property(_dir ${_target} INSTALL_DESTINATION) __java_export_jar(__targetdefs__ ${_target} "\${_prefix}/${_dir}") endforeach() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9e753e6c85..1c06052fd6 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -31,6 +31,16 @@ else() set(CMAKE_USE_ELF_PARSER) endif() +if(NOT CMake_DEFAULT_RECURSION_LIMIT) + if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST}) + set(CMake_DEFAULT_RECURSION_LIMIT 100) + elseif(MINGW) + set(CMake_DEFAULT_RECURSION_LIMIT 400) + else() + set(CMake_DEFAULT_RECURSION_LIMIT 1000) + endif() +endif() + if(APPLE) set(CMAKE_USE_MACH_PARSER 1) endif() @@ -809,9 +819,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc" endif() endif() -# On Apple we need CoreFoundation +# On Apple we need CoreFoundation and CoreServices if(APPLE) target_link_libraries(CMakeLib "-framework CoreFoundation") + target_link_libraries(CMakeLib "-framework CoreServices") endif() if(WIN32 AND NOT UNIX) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index dd9eccd9a5..9e64efa8dc 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 13) -set(CMake_VERSION_PATCH 20190117) +set(CMake_VERSION_PATCH 20190130) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 180c92eeda..9102e3e20e 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -21,9 +21,7 @@ cmCPackIFWGenerator::cmCPackIFWGenerator() this->Generator = this; } -cmCPackIFWGenerator::~cmCPackIFWGenerator() -{ -} +cmCPackIFWGenerator::~cmCPackIFWGenerator() = default; int cmCPackIFWGenerator::PackageFiles() { diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 8f492afde9..01e3ea4a7e 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -16,9 +16,7 @@ #include <stddef.h> #include <utility> -cmCPackIFWInstaller::cmCPackIFWInstaller() -{ -} +cmCPackIFWInstaller::cmCPackIFWInstaller() = default; void cmCPackIFWInstaller::printSkippedOptionWarning( const std::string& optionName, const std::string& optionValue) @@ -288,8 +286,7 @@ protected: content = cmSystemTools::TrimWhitespace(content); std::string source = this->basePath + "/" + content; std::string destination = this->path + "/" + content; - if (!cmSystemTools::CopyFileIfDifferent(source.data(), - destination.data())) { + if (!cmSystemTools::CopyFileIfDifferent(source, destination)) { this->hasErrors = true; } } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index c96b5d41fc..a1a52b1852 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -24,9 +24,7 @@ cmCPackIFWPackage::CompareStruct::CompareStruct() } //------------------------------------------------------- DependenceStruct --- -cmCPackIFWPackage::DependenceStruct::DependenceStruct() -{ -} +cmCPackIFWPackage::DependenceStruct::DependenceStruct() = default; cmCPackIFWPackage::DependenceStruct::DependenceStruct( const std::string& dependence) diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 987cad89e9..8042167edb 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -200,7 +200,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml() fout.Close(); - return cmSystemTools::RenameFile(updatesPatchXml.data(), updatesXml.data()); + return cmSystemTools::RenameFile(updatesPatchXml, updatesXml); } void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout) diff --git a/Source/CPack/cmCPack7zGenerator.cxx b/Source/CPack/cmCPack7zGenerator.cxx index f0c41a2a1e..7413770120 100644 --- a/Source/CPack/cmCPack7zGenerator.cxx +++ b/Source/CPack/cmCPack7zGenerator.cxx @@ -10,6 +10,4 @@ cmCPack7zGenerator::cmCPack7zGenerator() { } -cmCPack7zGenerator::~cmCPack7zGenerator() -{ -} +cmCPack7zGenerator::~cmCPack7zGenerator() = default; diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 175621879e..98fb29d14e 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -22,9 +22,7 @@ cmCPackArchiveGenerator::cmCPackArchiveGenerator(cmArchiveWrite::Compress t, this->ArchiveFormat = format; } -cmCPackArchiveGenerator::~cmCPackArchiveGenerator() -{ -} +cmCPackArchiveGenerator::~cmCPackArchiveGenerator() = default; std::string cmCPackArchiveGenerator::GetArchiveComponentFileName( const std::string& component, bool isGroupName) diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index f8fd108d30..3a476f44b9 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -8,13 +8,9 @@ #include "cmCPackLog.h" #include "cmSystemTools.h" -cmCPackBundleGenerator::cmCPackBundleGenerator() -{ -} +cmCPackBundleGenerator::cmCPackBundleGenerator() = default; -cmCPackBundleGenerator::~cmCPackBundleGenerator() -{ -} +cmCPackBundleGenerator::~cmCPackBundleGenerator() = default; int cmCPackBundleGenerator::InitializeInternal() { diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 29968affcc..635de490ac 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -23,17 +23,15 @@ namespace { class DebGenerator { public: - DebGenerator(cmCPackLog* logger, std::string const& outputName, - std::string const& workDir, std::string const& topLevelDir, - std::string const& temporaryDir, + DebGenerator(cmCPackLog* logger, std::string outputName, std::string workDir, + std::string topLevelDir, std::string temporaryDir, const char* debianCompressionType, const char* debianArchiveType, - std::map<std::string, std::string> const& controlValues, - bool genShLibs, std::string const& shLibsFilename, - bool genPostInst, std::string const& postInst, bool genPostRm, - std::string const& postRm, const char* controlExtra, - bool permissionStrctPolicy, - std::vector<std::string> const& packageFiles); + std::map<std::string, std::string> controlValues, + bool genShLibs, std::string shLibsFilename, bool genPostInst, + std::string postInst, bool genPostRm, std::string postRm, + const char* controlExtra, bool permissionStrctPolicy, + std::vector<std::string> packageFiles); bool generate() const; @@ -66,31 +64,29 @@ private: }; DebGenerator::DebGenerator( - cmCPackLog* logger, std::string const& outputName, - std::string const& workDir, std::string const& topLevelDir, - std::string const& temporaryDir, const char* debianCompressionType, - const char* debianArchiveType, - std::map<std::string, std::string> const& controlValues, bool genShLibs, - std::string const& shLibsFilename, bool genPostInst, - std::string const& postInst, bool genPostRm, std::string const& postRm, - const char* controlExtra, bool permissionStrictPolicy, - std::vector<std::string> const& packageFiles) + cmCPackLog* logger, std::string outputName, std::string workDir, + std::string topLevelDir, std::string temporaryDir, + const char* debianCompressionType, const char* debianArchiveType, + std::map<std::string, std::string> controlValues, bool genShLibs, + std::string shLibsFilename, bool genPostInst, std::string postInst, + bool genPostRm, std::string postRm, const char* controlExtra, + bool permissionStrictPolicy, std::vector<std::string> packageFiles) : Logger(logger) - , OutputName(outputName) - , WorkDir(workDir) - , TopLevelDir(topLevelDir) - , TemporaryDir(temporaryDir) + , OutputName(std::move(outputName)) + , WorkDir(std::move(workDir)) + , TopLevelDir(std::move(topLevelDir)) + , TemporaryDir(std::move(temporaryDir)) , DebianArchiveType(debianArchiveType ? debianArchiveType : "gnutar") - , ControlValues(controlValues) + , ControlValues(std::move(controlValues)) , GenShLibs(genShLibs) - , ShLibsFilename(shLibsFilename) + , ShLibsFilename(std::move(shLibsFilename)) , GenPostInst(genPostInst) - , PostInst(postInst) + , PostInst(std::move(postInst)) , GenPostRm(genPostRm) - , PostRm(postRm) + , PostRm(std::move(postRm)) , ControlExtra(controlExtra) , PermissionStrictPolicy(permissionStrictPolicy) - , PackageFiles(packageFiles) + , PackageFiles(std::move(packageFiles)) { if (!debianCompressionType) { debianCompressionType = "gzip"; @@ -436,13 +432,9 @@ bool DebGenerator::generateDeb() const } // end anonymous namespace -cmCPackDebGenerator::cmCPackDebGenerator() -{ -} +cmCPackDebGenerator::cmCPackDebGenerator() = default; -cmCPackDebGenerator::~cmCPackDebGenerator() -{ -} +cmCPackDebGenerator::~cmCPackDebGenerator() = default; int cmCPackDebGenerator::InitializeInternal() { diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 326d26c8a9..013ad8163e 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -62,17 +62,15 @@ cmCPackDragNDropGenerator::cmCPackDragNDropGenerator() this->componentPackageMethod = ONE_PACKAGE; } -cmCPackDragNDropGenerator::~cmCPackDragNDropGenerator() -{ -} +cmCPackDragNDropGenerator::~cmCPackDragNDropGenerator() = default; int cmCPackDragNDropGenerator::InitializeInternal() { // Starting with Xcode 4.3, look in "/Applications/Xcode.app" first: // std::vector<std::string> paths; - paths.push_back("/Applications/Xcode.app/Contents/Developer/Tools"); - paths.push_back("/Developer/Tools"); + paths.emplace_back("/Applications/Xcode.app/Contents/Developer/Tools"); + paths.emplace_back("/Developer/Tools"); const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false); @@ -212,8 +210,7 @@ int cmCPackDragNDropGenerator::PackageFiles() bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source, std::ostringstream& target) { - if (!cmSystemTools::CopyFileIfDifferent(source.str().c_str(), - target.str().c_str())) { + if (!cmSystemTools::CopyFileIfDifferent(source.str(), target.str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error copying " << source.str() << " to " << target.str() << std::endl); diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx index ff6941825f..9dc9853318 100644 --- a/Source/CPack/cmCPackExternalGenerator.cxx +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -68,7 +68,7 @@ int cmCPackExternalGenerator::PackageFiles() return 0; } - int res = this->MakefileMap->ReadListFile(packageScript); + bool res = this->MakefileMap->ReadListFile(packageScript); if (cmSystemTools::GetErrorOccuredFlag() || !res) { return 0; diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index 1e6b1184c7..fcf8af1f8d 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -17,6 +17,7 @@ #include <pkg.h> #include <algorithm> +#include <utility> cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator() : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr") @@ -30,9 +31,7 @@ int cmCPackFreeBSDGenerator::InitializeInternal() return this->Superclass::InitializeInternal(); } -cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() -{ -} +cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() = default; // This is a wrapper, for use only in stream-based output, // that will output a string in UCL escaped fashion (in particular, @@ -97,12 +96,12 @@ class ManifestKey public: std::string key; - ManifestKey(const std::string& k) - : key(k) + ManifestKey(std::string k) + : key(std::move(k)) { } - virtual ~ManifestKey() {} + virtual ~ManifestKey() = default; // Output the value associated with this key to the stream @p s. // Format is to be decided by subclasses. @@ -115,9 +114,9 @@ class ManifestKeyValue : public ManifestKey public: std::string value; - ManifestKeyValue(const std::string& k, const std::string& v) + ManifestKeyValue(const std::string& k, std::string v) : ManifestKey(k) - , value(v) + , value(std::move(v)) { } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index b205105c86..57c054590f 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -43,12 +43,6 @@ cmCPackGenerator::~cmCPackGenerator() this->MakefileMap = nullptr; } -void cmCPackGeneratorProgress(const char* msg, float prog, void* ptr) -{ - cmCPackGenerator* self = static_cast<cmCPackGenerator*>(ptr); - self->DisplayVerboseOutput(msg, prog); -} - void cmCPackGenerator::DisplayVerboseOutput(const char* msg, float progress) { (void)progress; @@ -392,8 +386,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( std::move(inFileRelative)); } /* If it is not a symlink then do a plain copy */ - else if (!(cmSystemTools::CopyFileIfDifferent(inFile.c_str(), - filePath.c_str()) && + else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) && cmSystemTools::CopyFileTime(inFile.c_str(), filePath.c_str()))) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -498,7 +491,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( tempInstallDirectory.c_str()); this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR", tempInstallDirectory.c_str()); - int res = this->MakefileMap->ReadListFile(installScript.c_str()); + bool res = this->MakefileMap->ReadListFile(installScript); if (cmSystemTools::GetErrorOccuredFlag() || !res) { return 0; } @@ -696,7 +689,9 @@ int cmCPackGenerator::InstallCMakeProject( cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.AddCMakePaths(); - cm.SetProgressCallback(cmCPackGeneratorProgress, this); + cm.SetProgressCallback([this](const char* msg, float prog) { + this->DisplayVerboseOutput(msg, prog); + }); cm.SetTrace(this->Trace); cm.SetTraceExpand(this->TraceExpand); cmGlobalGenerator gg(&cm); @@ -851,7 +846,7 @@ int cmCPackGenerator::InstallCMakeProject( mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); } // do installation - int res = mf.ReadListFile(installFile.c_str()); + bool res = mf.ReadListFile(installFile); // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES // to CPack (may be used by generators like CPack RPM or DEB) // in order to transparently handle ABSOLUTE PATH @@ -927,7 +922,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName) { bool retval; std::string fullPath = this->MakefileMap->GetModulesFile(moduleName); - retval = this->MakefileMap->ReadListFile(fullPath.c_str()); + retval = this->MakefileMap->ReadListFile(fullPath); // include FATAL_ERROR and ERROR in the return status retval = retval && (!cmSystemTools::GetErrorOccuredFlag()); return retval; @@ -1036,7 +1031,8 @@ int cmCPackGenerator::DoPackage() * may update this during PackageFiles. * (either putting several names or updating the provided one) */ - packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : ""); + packageFileNames.emplace_back(tempPackageFileName ? tempPackageFileName + : ""); toplevel = tempDirectory; { // scope that enables package generators to run internal scripts with // latest CMake policies enabled @@ -1076,8 +1072,7 @@ int cmCPackGenerator::DoPackage() << (tempPackageFileName ? tempPackageFileName : "(NULL)") << " to " << (packageFileName ? packageFileName : "(NULL)") << std::endl); - if (!cmSystemTools::CopyFileIfDifferent(tempPackageFileName, - packageFileName)) { + if (!cmSystemTools::CopyFileIfDifferent(pkgFileName, tmpPF)) { cmCPackLogger( cmCPackLog::LOG_ERROR, "Problem copying the package: " diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index d02aa5aafa..37ea66e76a 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -30,9 +30,7 @@ cmCPackNSISGenerator::cmCPackNSISGenerator(bool nsis64) Nsis64 = nsis64; } -cmCPackNSISGenerator::~cmCPackNSISGenerator() -{ -} +cmCPackNSISGenerator::~cmCPackNSISGenerator() = default; int cmCPackNSISGenerator::PackageFiles() { @@ -610,7 +608,7 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories( } } } - dirs.push_back(topdir); + dirs.emplace_back(topdir); return true; } diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 1908c17a31..486633c905 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -11,13 +11,9 @@ #include "cmSystemTools.h" #include "cm_sys_stat.h" -cmCPackOSXX11Generator::cmCPackOSXX11Generator() -{ -} +cmCPackOSXX11Generator::cmCPackOSXX11Generator() = default; -cmCPackOSXX11Generator::~cmCPackOSXX11Generator() -{ -} +cmCPackOSXX11Generator::~cmCPackOSXX11Generator() = default; int cmCPackOSXX11Generator::PackageFiles() { diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 9401bca5ca..ae227aab11 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -15,9 +15,7 @@ cmCPackPKGGenerator::cmCPackPKGGenerator() this->componentPackageMethod = ONE_PACKAGE; } -cmCPackPKGGenerator::~cmCPackPKGGenerator() -{ -} +cmCPackPKGGenerator::~cmCPackPKGGenerator() = default; bool cmCPackPKGGenerator::SupportsComponentInstallation() const { diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index a24dd30942..246178d8f3 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -30,9 +30,7 @@ cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator() this->PackageCompatibilityVersion = getVersion(10, 4); } -cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator() -{ -} +cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator() = default; bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const { @@ -340,16 +338,16 @@ int cmCPackPackageMakerGenerator::InitializeInternal() // If found, save result in the CPACK_INSTALLER_PROGRAM variable. std::vector<std::string> paths; - paths.push_back("/Applications/Xcode.app/Contents/Applications" - "/PackageMaker.app/Contents/MacOS"); - paths.push_back("/Applications/Utilities" - "/PackageMaker.app/Contents/MacOS"); - paths.push_back("/Applications" - "/PackageMaker.app/Contents/MacOS"); - paths.push_back("/Developer/Applications/Utilities" - "/PackageMaker.app/Contents/MacOS"); - paths.push_back("/Developer/Applications" - "/PackageMaker.app/Contents/MacOS"); + paths.emplace_back("/Applications/Xcode.app/Contents/Applications" + "/PackageMaker.app/Contents/MacOS"); + paths.emplace_back("/Applications/Utilities" + "/PackageMaker.app/Contents/MacOS"); + paths.emplace_back("/Applications" + "/PackageMaker.app/Contents/MacOS"); + paths.emplace_back("/Developer/Applications/Utilities" + "/PackageMaker.app/Contents/MacOS"); + paths.emplace_back("/Developer/Applications" + "/PackageMaker.app/Contents/MacOS"); std::string pkgPath; const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM"); diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index e73d01f370..a556e0c520 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -17,9 +17,7 @@ cmCPackProductBuildGenerator::cmCPackProductBuildGenerator() this->componentPackageMethod = ONE_PACKAGE; } -cmCPackProductBuildGenerator::~cmCPackProductBuildGenerator() -{ -} +cmCPackProductBuildGenerator::~cmCPackProductBuildGenerator() = default; int cmCPackProductBuildGenerator::PackageFiles() { diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 5834829c61..33ab62bdf1 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -14,13 +14,9 @@ #include "cmCPackLog.h" #include "cmSystemTools.h" -cmCPackRPMGenerator::cmCPackRPMGenerator() -{ -} +cmCPackRPMGenerator::cmCPackRPMGenerator() = default; -cmCPackRPMGenerator::~cmCPackRPMGenerator() -{ -} +cmCPackRPMGenerator::~cmCPackRPMGenerator() = default; int cmCPackRPMGenerator::InitializeInternal() { diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index e55ea870d0..aba15d239c 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -13,13 +13,9 @@ #include "cmSystemTools.h" #include "cm_sys_stat.h" -cmCPackSTGZGenerator::cmCPackSTGZGenerator() -{ -} +cmCPackSTGZGenerator::cmCPackSTGZGenerator() = default; -cmCPackSTGZGenerator::~cmCPackSTGZGenerator() -{ -} +cmCPackSTGZGenerator::~cmCPackSTGZGenerator() = default; int cmCPackSTGZGenerator::InitializeInternal() { diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index eaf8186fe1..6f4676ef91 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -10,6 +10,4 @@ cmCPackTGZGenerator::cmCPackTGZGenerator() { } -cmCPackTGZGenerator::~cmCPackTGZGenerator() -{ -} +cmCPackTGZGenerator::~cmCPackTGZGenerator() = default; diff --git a/Source/CPack/cmCPackTXZGenerator.cxx b/Source/CPack/cmCPackTXZGenerator.cxx index e55e903e90..ccbccde955 100644 --- a/Source/CPack/cmCPackTXZGenerator.cxx +++ b/Source/CPack/cmCPackTXZGenerator.cxx @@ -10,6 +10,4 @@ cmCPackTXZGenerator::cmCPackTXZGenerator() { } -cmCPackTXZGenerator::~cmCPackTXZGenerator() -{ -} +cmCPackTXZGenerator::~cmCPackTXZGenerator() = default; diff --git a/Source/CPack/cmCPackTarBZip2Generator.cxx b/Source/CPack/cmCPackTarBZip2Generator.cxx index c7a3dd429b..85abeb1ca2 100644 --- a/Source/CPack/cmCPackTarBZip2Generator.cxx +++ b/Source/CPack/cmCPackTarBZip2Generator.cxx @@ -10,6 +10,4 @@ cmCPackTarBZip2Generator::cmCPackTarBZip2Generator() { } -cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator() -{ -} +cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator() = default; diff --git a/Source/CPack/cmCPackTarCompressGenerator.cxx b/Source/CPack/cmCPackTarCompressGenerator.cxx index 0a7cd978c5..55a6de53c4 100644 --- a/Source/CPack/cmCPackTarCompressGenerator.cxx +++ b/Source/CPack/cmCPackTarCompressGenerator.cxx @@ -10,6 +10,4 @@ cmCPackTarCompressGenerator::cmCPackTarCompressGenerator() { } -cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator() -{ -} +cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator() = default; diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx index 6b77c363d7..f06494c443 100644 --- a/Source/CPack/cmCPackZIPGenerator.cxx +++ b/Source/CPack/cmCPackZIPGenerator.cxx @@ -10,6 +10,4 @@ cmCPackZIPGenerator::cmCPackZIPGenerator() { } -cmCPackZIPGenerator::~cmCPackZIPGenerator() -{ -} +cmCPackZIPGenerator::~cmCPackZIPGenerator() = default; diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index db9a0e7394..0413422b2d 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -90,12 +90,8 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, return 1; } -static void cpackProgressCallback(const char* message, float progress, - void* clientdata) +static void cpackProgressCallback(const char* message, float /*unused*/) { - (void)progress; - (void)clientdata; - std::cout << "-- " << message << std::endl; } @@ -212,7 +208,7 @@ int main(int argc, char const* const* argv) cmake cminst(cmake::RoleScript, cmState::CPack); cminst.SetHomeDirectory(""); cminst.SetHomeOutputDirectory(""); - cminst.SetProgressCallback(cpackProgressCallback, nullptr); + cminst.SetProgressCallback(cpackProgressCallback); cminst.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator cmgg(&cminst); cmMakefile globalMF(&cmgg, cminst.GetCurrentSnapshot()); @@ -256,7 +252,7 @@ int main(int argc, char const* const* argv) // paths, so FIND_XXX() commands can be used in scripts std::string systemFile = globalMF.GetModulesFile("CMakeDetermineSystem.cmake"); - if (!globalMF.ReadListFile(systemFile.c_str())) { + if (!globalMF.ReadListFile(systemFile)) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error reading CMakeDetermineSystem.cmake" << std::endl); return 1; @@ -264,7 +260,7 @@ int main(int argc, char const* const* argv) systemFile = globalMF.GetModulesFile("CMakeSystemSpecificInformation.cmake"); - if (!globalMF.ReadListFile(systemFile.c_str())) { + if (!globalMF.ReadListFile(systemFile)) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error reading CMakeSystemSpecificInformation.cmake" << std::endl); @@ -280,7 +276,7 @@ int main(int argc, char const* const* argv) cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack configuration file: " << cpackConfigFile << std::endl); - if (!globalMF.ReadListFile(cpackConfigFile.c_str())) { + if (!globalMF.ReadListFile(cpackConfigFile)) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reading CPack config file: \"" << cpackConfigFile << "\"" << std::endl); diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 365f267748..b154caf301 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -77,9 +77,7 @@ cmCTestBZR::cmCTestBZR(cmCTest* ct, std::ostream& log) cmSystemTools::PutEnv("BZR_PROGRESS_BAR=none"); } -cmCTestBZR::~cmCTestBZR() -{ -} +cmCTestBZR::~cmCTestBZR() = default; class cmCTestBZR::InfoParser : public cmCTestVC::LineParser { diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index d49fba22c8..38aa1b3fde 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -109,27 +109,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, return 0; } -void CMakeMessageCallback(const char* m, const char* /*unused*/, - bool& /*unused*/, void* s) -{ - std::string* out = static_cast<std::string*>(s); - *out += m; - *out += "\n"; -} - -void CMakeProgressCallback(const char* msg, float /*unused*/, void* s) -{ - std::string* out = static_cast<std::string*>(s); - *out += msg; - *out += "\n"; -} - -void CMakeOutputCallback(const char* m, size_t len, void* s) -{ - std::string* out = static_cast<std::string*>(s); - out->append(m, len); -} - class cmCTestBuildAndTestCaptureRAII { cmake& CM; @@ -138,17 +117,30 @@ public: cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s) : CM(cm) { - cmSystemTools::SetMessageCallback(CMakeMessageCallback, &s); - cmSystemTools::SetStdoutCallback(CMakeOutputCallback, &s); - cmSystemTools::SetStderrCallback(CMakeOutputCallback, &s); - this->CM.SetProgressCallback(CMakeProgressCallback, &s); + cmSystemTools::SetMessageCallback( + [&s](const char* msg, const char* /*unused*/) { + s += msg; + s += "\n"; + }); + + cmSystemTools::SetStdoutCallback( + [&s](const char* m, size_t len) { s.append(m, len); }); + + cmSystemTools::SetStderrCallback( + [&s](const char* m, size_t len) { s.append(m, len); }); + + this->CM.SetProgressCallback([&s](const char* msg, float /*unused*/) { + s += msg; + s += "\n"; + }); } + ~cmCTestBuildAndTestCaptureRAII() { - this->CM.SetProgressCallback(nullptr, nullptr); - cmSystemTools::SetStderrCallback(nullptr, nullptr); - cmSystemTools::SetStdoutCallback(nullptr, nullptr); - cmSystemTools::SetMessageCallback(nullptr, nullptr); + this->CM.SetProgressCallback(nullptr); + cmSystemTools::SetStderrCallback(nullptr); + cmSystemTools::SetStdoutCallback(nullptr); + cmSystemTools::SetMessageCallback(nullptr); } }; @@ -164,7 +156,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) return 1; } - cmake cm(cmake::RoleProject, cmState::CTest); + cmake cm(cmake::RoleProject, cmState::Project); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); std::string cmakeOutString; @@ -232,7 +224,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) // do the build if (this->BuildTargets.empty()) { - this->BuildTargets.push_back(""); + this->BuildTargets.emplace_back(); } for (std::string const& tar : this->BuildTargets) { cmDuration remainingTime = std::chrono::seconds(0); diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 361883c182..d934c003cf 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -341,17 +341,17 @@ int cmCTestBuildHandler::ProcessHandler() // warnings and warning exceptions. std::vector<std::string>::size_type cc; for (cc = 0; cmCTestErrorMatches[cc]; cc++) { - this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]); + this->CustomErrorMatches.emplace_back(cmCTestErrorMatches[cc]); } for (cc = 0; cmCTestErrorExceptions[cc]; cc++) { - this->CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]); + this->CustomErrorExceptions.emplace_back(cmCTestErrorExceptions[cc]); } for (cc = 0; cmCTestWarningMatches[cc]; cc++) { - this->CustomWarningMatches.push_back(cmCTestWarningMatches[cc]); + this->CustomWarningMatches.emplace_back(cmCTestWarningMatches[cc]); } for (cc = 0; cmCTestWarningExceptions[cc]; cc++) { - this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]); + this->CustomWarningExceptions.emplace_back(cmCTestWarningExceptions[cc]); } // Pre-compile regular expressions objects for all regular expressions @@ -365,7 +365,7 @@ int cmCTestBuildHandler::ProcessHandler() cmCTestOptionalLog(this->CTest, DEBUG, \ "Add " #strings ": " << s << std::endl, \ this->Quiet); \ - (regexes).push_back(s.c_str()); \ + (regexes).emplace_back(s); \ } \ } while (false) @@ -507,14 +507,13 @@ public: : FTC(ftc) { } - FragmentCompare() {} + FragmentCompare() = default; bool operator()(std::string const& l, std::string const& r) const { // Order files by modification time. Use lexicographic order // among files with the same time. int result; - if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) && - result != 0) { + if (this->FTC->FileTimeCompare(l, r, &result) && result != 0) { return result < 0; } return l < r; @@ -1034,7 +1033,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length, } } else { // Otherwise store pre-context for the next error - this->PreContext.push_back(line); + this->PreContext.emplace_back(line); if (this->PreContext.size() > this->MaxPreContext) { this->PreContext.erase(this->PreContext.begin(), this->PreContext.end() - diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 4fb3273bb2..6e8f73f83c 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -16,9 +16,7 @@ cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log) { } -cmCTestCVS::~cmCTestCVS() -{ -} +cmCTestCVS::~cmCTestCVS() = default; class cmCTestCVS::UpdateParser : public cmCTestVC::LineParser { @@ -111,8 +109,8 @@ public: , Revisions(revs) , Section(SectionHeader) { - this->SetLog(&cvs->Log, prefix), - this->RegexRevision.compile("^revision +([^ ]*) *$"); + this->SetLog(&cvs->Log, prefix); + this->RegexRevision.compile("^revision +([^ ]*) *$"); this->RegexBranches.compile("^branches: .*$"); this->RegexPerson.compile("^date: +([^;]+); +author: +([^;]+);"); } diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 5967b7458a..6b7601b6e3 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -11,9 +11,7 @@ #include <ostream> #include <string> -cmCTestConfigureHandler::cmCTestConfigureHandler() -{ -} +cmCTestConfigureHandler::cmCTestConfigureHandler() = default; void cmCTestConfigureHandler::Initialize() { diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index fbd1038d6f..225383ce09 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -15,7 +15,6 @@ #include "cmSystemTools.h" #include "cmWorkingDirectory.h" #include "cmXMLWriter.h" -#include "cmake.h" #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" @@ -56,12 +55,12 @@ public: void SetCommand(const char* command) { this->CommandLineStrings.clear(); - this->CommandLineStrings.push_back(command); + this->CommandLineStrings.emplace_back(command); } void AddArgument(const char* arg) { if (arg) { - this->CommandLineStrings.push_back(arg); + this->CommandLineStrings.emplace_back(arg); } } void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; } @@ -112,9 +111,7 @@ private: cmDuration TimeOut; }; -cmCTestCoverageHandler::cmCTestCoverageHandler() -{ -} +cmCTestCoverageHandler::cmCTestCoverageHandler() = default; void cmCTestCoverageHandler::Initialize() { @@ -316,8 +313,7 @@ int cmCTestCoverageHandler::ProcessHandler() // setup the regex exclude stuff this->CustomCoverageExcludeRegex.clear(); for (std::string const& rex : this->CustomCoverageExclude) { - this->CustomCoverageExcludeRegex.push_back( - cmsys::RegularExpression(rex.c_str())); + this->CustomCoverageExcludeRegex.emplace_back(rex); } if (this->HandleBullseyeCoverage(&cont)) { @@ -1005,7 +1001,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::vector<std::string> basecovargs = cmSystemTools::ParseArguments(gcovExtraFlags.c_str()); basecovargs.insert(basecovargs.begin(), gcovCommand); - basecovargs.push_back("-o"); + basecovargs.emplace_back("-o"); // files is a list of *.da and *.gcda files with coverage data in them. // These are binary files that you give as input to gcov so that it will @@ -2227,7 +2223,7 @@ int cmCTestCoverageHandler::GetLabelId(std::string const& label) void cmCTestCoverageHandler::LoadLabels() { std::string fileList = this->CTest->GetBinaryDir(); - fileList += cmake::GetCMakeFilesDirectory(); + fileList += "/CMakeFiles"; fileList += "/TargetDirectories.txt"; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " target directory list [" << fileList << "]\n", diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 4ede3d4ee1..210abe55ba 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -31,9 +31,7 @@ cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log) this->CurrentGitVersion = 0; } -cmCTestGIT::~cmCTestGIT() -{ -} +cmCTestGIT::~cmCTestGIT() = default; class cmCTestGIT::OneLineParser : public cmCTestVC::LineParser { @@ -477,7 +475,6 @@ private: std::string EMail; unsigned long Time = 0; long TimeZone = 0; - Person() {} }; void ParsePerson(const char* str, Person& person) diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index dc1bba051d..d3020b5135 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -18,9 +18,7 @@ cmCTestGenericHandler::cmCTestGenericHandler() this->TestLoad = 0; } -cmCTestGenericHandler::~cmCTestGenericHandler() -{ -} +cmCTestGenericHandler::~cmCTestGenericHandler() = default; void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) { diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx index d2714d90b4..a2d4d2c75a 100644 --- a/Source/CTest/cmCTestGlobalVC.cxx +++ b/Source/CTest/cmCTestGlobalVC.cxx @@ -15,9 +15,7 @@ cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log) this->PriorRev = this->Unknown; } -cmCTestGlobalVC::~cmCTestGlobalVC() -{ -} +cmCTestGlobalVC::~cmCTestGlobalVC() = default; const char* cmCTestGlobalVC::LocalPath(std::string const& path) { diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 9c6a80dc79..6fb99d8642 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -18,9 +18,7 @@ cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log) this->PriorRev = this->Unknown; } -cmCTestHG::~cmCTestHG() -{ -} +cmCTestHG::~cmCTestHG() = default; class cmCTestHG::IdentifyParser : public cmCTestVC::LineParser { diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 4facea2f7c..5e66e056ac 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -146,7 +146,7 @@ void cmCTestLaunch::HandleRealArg(const char* arg) return; } #endif - this->RealArgs.push_back(arg); + this->RealArgs.emplace_back(arg); } void cmCTestLaunch::ComputeFileNames() @@ -283,7 +283,7 @@ void cmCTestLaunch::LoadLabels() // Labels are listed in per-target files. std::string fname = this->OptionBuildDir; - fname += cmake::GetCMakeFilesDirectory(); + fname += "/CMakeFiles"; fname += "/"; fname += this->OptionTargetName; fname += ".dir/Labels.txt"; @@ -534,9 +534,9 @@ void cmCTestLaunch::LoadScrapeRules() // Common compiler warning formats. These are much simpler than the // full log-scraping expressions because we do not need to extract // file and line information. - this->RegexWarning.push_back("(^|[ :])[Ww][Aa][Rr][Nn][Ii][Nn][Gg]"); - this->RegexWarning.push_back("(^|[ :])[Rr][Ee][Mm][Aa][Rr][Kk]"); - this->RegexWarning.push_back("(^|[ :])[Nn][Oo][Tt][Ee]"); + this->RegexWarning.emplace_back("(^|[ :])[Ww][Aa][Rr][Nn][Ii][Nn][Gg]"); + this->RegexWarning.emplace_back("(^|[ :])[Rr][Ee][Mm][Aa][Rr][Kk]"); + this->RegexWarning.emplace_back("(^|[ :])[Nn][Oo][Tt][Ee]"); // Load custom match rules given to us by CTest. this->LoadScrapeRules("Warning", this->RegexWarning); @@ -619,7 +619,7 @@ void cmCTestLaunch::LoadConfig() cmMakefile mf(&gg, cm.GetCurrentSnapshot()); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; - if (cmSystemTools::FileExists(fname) && mf.ReadListFile(fname.c_str())) { + if (cmSystemTools::FileExists(fname) && mf.ReadListFile(fname)) { this->SourceDir = mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); cmSystemTools::ConvertToUnixSlashes(this->SourceDir); } diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 9c9532a081..8ba59d3f99 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -261,8 +261,8 @@ void cmCTestMemCheckHandler::InitializeResultsVectors() }; this->GlobalResults.clear(); for (int i = 0; cmCTestMemCheckResultStrings[i] != nullptr; ++i) { - this->ResultStrings.push_back(cmCTestMemCheckResultStrings[i]); - this->ResultStringsLong.push_back(cmCTestMemCheckResultLongStrings[i]); + this->ResultStrings.emplace_back(cmCTestMemCheckResultStrings[i]); + this->ResultStringsLong.emplace_back(cmCTestMemCheckResultLongStrings[i]); this->GlobalResults.push_back(0); } } @@ -528,11 +528,11 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() switch (this->MemoryTesterStyle) { case cmCTestMemCheckHandler::VALGRIND: { if (this->MemoryTesterOptions.empty()) { - this->MemoryTesterOptions.push_back("-q"); - this->MemoryTesterOptions.push_back("--tool=memcheck"); - this->MemoryTesterOptions.push_back("--leak-check=yes"); - this->MemoryTesterOptions.push_back("--show-reachable=yes"); - this->MemoryTesterOptions.push_back("--num-callers=50"); + this->MemoryTesterOptions.emplace_back("-q"); + this->MemoryTesterOptions.emplace_back("--tool=memcheck"); + this->MemoryTesterOptions.emplace_back("--leak-check=yes"); + this->MemoryTesterOptions.emplace_back("--show-reachable=yes"); + this->MemoryTesterOptions.emplace_back("--num-callers=50"); } if (!this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile") .empty()) { @@ -586,11 +586,11 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() std::string dpbdFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.??.DPbd"; this->BoundsCheckerDPBDFile = dpbdFile; - this->MemoryTesterDynamicOptions.push_back("/B"); + this->MemoryTesterDynamicOptions.emplace_back("/B"); this->MemoryTesterDynamicOptions.push_back(std::move(dpbdFile)); - this->MemoryTesterDynamicOptions.push_back("/X"); + this->MemoryTesterDynamicOptions.emplace_back("/X"); this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile); - this->MemoryTesterOptions.push_back("/M"); + this->MemoryTesterOptions.emplace_back("/M"); break; } // these are almost the same but the env var used is different @@ -604,8 +604,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() // The MemoryTesterDynamicOptions is setup with the -E env // Then the MemoryTesterEnvironmentVariable gets the // TSAN_OPTIONS string with the log_path in it. - this->MemoryTesterDynamicOptions.push_back("-E"); - this->MemoryTesterDynamicOptions.push_back("env"); + this->MemoryTesterDynamicOptions.emplace_back("-E"); + this->MemoryTesterDynamicOptions.emplace_back("env"); std::string envVar; std::string extraOptions; std::string suppressionsOption; diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 886732364b..756ac6cf6f 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -44,7 +44,6 @@ public: : Handler(handler) { } - ~TestComparator() {} // Sorts tests in descending order of cost bool operator()(int index1, int index2) const @@ -70,9 +69,7 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler() this->SerialTestRunning = false; } -cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler() -{ -} +cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler() = default; // Set the tests void cmCTestMultiProcessHandler::SetTests(TestMap& tests, @@ -538,7 +535,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() fout << f << "\n"; } fout.close(); - cmSystemTools::RenameFile(tmpout.c_str(), fname.c_str()); + cmSystemTools::RenameFile(tmpout, fname); } void cmCTestMultiProcessHandler::ReadCostData() @@ -1039,6 +1036,11 @@ void cmCTestMultiProcessHandler::PrintOutputAsJson() testRun.SetTestProperties(&p); testRun.ComputeArguments(); + // Skip tests not available in this configuration. + if (p.Args.size() >= 2 && p.Args[1] == "NOT_AVAILABLE") { + continue; + } + Json::Value testInfo = DumpCTestInfo(testRun, p, backtraceGraph); tests.append(testInfo); } diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 511dbd2ec3..435be97b6d 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -19,9 +19,7 @@ cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log) this->PriorRev = this->Unknown; } -cmCTestP4::~cmCTestP4() -{ -} +cmCTestP4::~cmCTestP4() = default; class cmCTestP4::IdentifyParser : public cmCTestVC::LineParser { @@ -307,20 +305,20 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions) { if (P4Options.empty()) { const char* p4 = this->CommandLineTool.c_str(); - P4Options.push_back(p4); + P4Options.emplace_back(p4); // The CTEST_P4_CLIENT variable sets the P4 client used when issuing // Perforce commands, if it's different from the default one. std::string client = this->CTest->GetCTestConfiguration("P4Client"); if (!client.empty()) { - P4Options.push_back("-c"); + P4Options.emplace_back("-c"); P4Options.push_back(client); } // Set the message language to be English, in case the P4 admin // has localized them - P4Options.push_back("-L"); - P4Options.push_back("en"); + P4Options.emplace_back("-L"); + P4Options.emplace_back("en"); // The CTEST_P4_OPTIONS variable adds additional Perforce command line // options before the main command diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx index 238284a3fe..a7e47d35c6 100644 --- a/Source/CTest/cmCTestRunScriptCommand.cxx +++ b/Source/CTest/cmCTestRunScriptCommand.cxx @@ -39,7 +39,8 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args, ++i; } else { int ret; - cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np, &ret); + cmCTestScriptHandler::RunScript(this->CTest, this->Makefile, + args[i].c_str(), !np, &ret); std::ostringstream str; str << ret; this->Makefile->AddDefinition(returnVariable, str.str().c_str()); diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index c78641319a..918d5fa58b 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -27,8 +27,6 @@ class cmCTestRunTest public: explicit cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler); - ~cmCTestRunTest() = default; - void SetNumberOfRuns(int n) { this->NumberOfRunsLeft = n; } void SetRunUntilFailOn() { this->RunUntilFail = true; } void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties* prop) diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 6c439e9ad8..3bf66ca23f 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -26,9 +26,7 @@ cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log) this->PriorRev = this->Unknown; } -cmCTestSVN::~cmCTestSVN() -{ -} +cmCTestSVN::~cmCTestSVN() = default; void cmCTestSVN::CleanupImpl() { @@ -521,7 +519,7 @@ private: } else { local_path = path; } - this->SVN->Repositories.emplace_back(local_path.c_str()); + this->SVN->Repositories.emplace_back(local_path); } }; @@ -532,7 +530,7 @@ bool cmCTestSVN::LoadRepositories() } // Info for root repository - this->Repositories.emplace_back(""); + this->Repositories.emplace_back(); this->RootInfo = &(this->Repositories.back()); // Run "svn status" to get the list of external repositories diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h index a467ede28a..5c8505d490 100644 --- a/Source/CTest/cmCTestSVN.h +++ b/Source/CTest/cmCTestSVN.h @@ -41,7 +41,7 @@ private: struct SVNInfo { - SVNInfo(const char* path) + SVNInfo(std::string const& path = std::string()) : LocalPath(path) { } diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index aa37ff929c..33b8b4a4ca 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -53,8 +53,6 @@ struct cmListFileFunction; class cmCTestScriptFunctionBlocker : public cmFunctionBlocker { public: - cmCTestScriptFunctionBlocker() {} - ~cmCTestScriptFunctionBlocker() override {} bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus& /*status*/) override; // virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf); @@ -78,6 +76,7 @@ cmCTestScriptHandler::cmCTestScriptHandler() this->EmptyBinDir = false; this->EmptyBinDirOnce = false; this->Makefile = nullptr; + this->ParentMakefile = nullptr; this->CMake = nullptr; this->GlobalGenerator = nullptr; @@ -117,6 +116,7 @@ void cmCTestScriptHandler::Initialize() delete this->Makefile; this->Makefile = nullptr; + this->ParentMakefile = nullptr; delete this->GlobalGenerator; this->GlobalGenerator = nullptr; @@ -135,7 +135,7 @@ cmCTestScriptHandler::~cmCTestScriptHandler() void cmCTestScriptHandler::AddConfigurationScript(const char* script, bool pscope) { - this->ConfigurationScripts.push_back(script); + this->ConfigurationScripts.emplace_back(script); this->ScriptProcessScope.push_back(pscope); } @@ -263,15 +263,6 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) return retVal; } -static void ctestScriptProgressCallback(const char* m, float /*unused*/, - void* cd) -{ - cmCTest* ctest = static_cast<cmCTest*>(cd); - if (m && *m) { - cmCTestLog(ctest, HANDLER_OUTPUT, "-- " << m << std::endl); - } -} - void cmCTestScriptHandler::CreateCMake() { // create a cmake instance to read the configuration script @@ -292,8 +283,16 @@ void cmCTestScriptHandler::CreateCMake() snapshot.GetDirectory().SetCurrentSource(cwd); snapshot.GetDirectory().SetCurrentBinary(cwd); this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot); + if (this->ParentMakefile) { + this->Makefile->SetRecursionDepth( + this->ParentMakefile->GetRecursionDepth()); + } - this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); + this->CMake->SetProgressCallback([this](const char* m, float /*unused*/) { + if (m && *m) { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "-- " << m << std::endl); + } + }); this->AddCTestCommand("ctest_build", new cmCTestBuildCommand); this->AddCTestCommand("ctest_configure", new cmCTestConfigureCommand); @@ -373,7 +372,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) ctest scripting easier. */ std::string systemFile = this->Makefile->GetModulesFile("CTestScriptMode.cmake"); - if (!this->Makefile->ReadListFile(systemFile.c_str()) || + if (!this->Makefile->ReadListFile(systemFile) || cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" << systemFile << "\n"); @@ -388,7 +387,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) } // finally read in the script - if (!this->Makefile->ReadListFile(script.c_str()) || + if (!this->Makefile->ReadListFile(script) || cmSystemTools::GetErrorOccuredFlag()) { // Reset the error flag so that it can run more than // one script with an error when you use ctest_run_script. @@ -450,7 +449,7 @@ int cmCTestScriptHandler::ExtractVariables() updateVar, " specified without specifying CTEST_CVS_COMMAND."); return 12; } - this->ExtraUpdates.push_back(updateVal); + this->ExtraUpdates.emplace_back(updateVal); } } @@ -891,11 +890,13 @@ void cmCTestScriptHandler::RestoreBackupDirectories() } } -bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char* sname, - bool InProcess, int* returnValue) +bool cmCTestScriptHandler::RunScript(cmCTest* ctest, cmMakefile* mf, + const char* sname, bool InProcess, + int* returnValue) { cmCTestScriptHandler* sh = new cmCTestScriptHandler(); sh->SetCTestInstance(ctest); + sh->ParentMakefile = mf; sh->AddConfigurationScript(sname, InProcess); int res = sh->ProcessHandler(); if (returnValue) { diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index cf0762ec22..d93b5f8e72 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -72,8 +72,8 @@ public: /* * Run a script */ - static bool RunScript(cmCTest* ctest, const char* script, bool InProcess, - int* returnValue); + static bool RunScript(cmCTest* ctest, cmMakefile* mf, const char* script, + bool InProcess, int* returnValue); int RunCurrentScript(); /* @@ -166,6 +166,7 @@ private: std::chrono::steady_clock::time_point ScriptStartTime; cmMakefile* Makefile; + cmMakefile* ParentMakefile; cmGlobalGenerator* GlobalGenerator; cmake* CMake; }; diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 76a1830c1f..00c0610167 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -15,36 +15,28 @@ class cmExecutionStatus; cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() { - const char* ctestDropMethod = - this->Makefile->GetDefinition("CTEST_DROP_METHOD"); - const char* ctestDropSite = this->Makefile->GetDefinition("CTEST_DROP_SITE"); - const char* ctestDropLocation = - this->Makefile->GetDefinition("CTEST_DROP_LOCATION"); - if (!ctestDropMethod) { - ctestDropMethod = "http"; - } + const char* submitURL = !this->SubmitURL.empty() + ? this->SubmitURL.c_str() + : this->Makefile->GetDefinition("CTEST_SUBMIT_URL"); - if (!ctestDropSite) { - // error: CDash requires CTEST_DROP_SITE definition - // in CTestConfig.cmake - } - if (!ctestDropLocation) { - // error: CDash requires CTEST_DROP_LOCATION definition - // in CTestConfig.cmake + if (submitURL) { + this->CTest->SetCTestConfiguration("SubmitURL", submitURL, this->Quiet); + } else { + this->CTest->SetCTestConfigurationFromCMakeVariable( + this->Makefile, "DropMethod", "CTEST_DROP_METHOD", this->Quiet); + this->CTest->SetCTestConfigurationFromCMakeVariable( + this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet); + this->CTest->SetCTestConfigurationFromCMakeVariable( + this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD", + this->Quiet); + this->CTest->SetCTestConfigurationFromCMakeVariable( + this->Makefile, "DropSite", "CTEST_DROP_SITE", this->Quiet); + this->CTest->SetCTestConfigurationFromCMakeVariable( + this->Makefile, "DropLocation", "CTEST_DROP_LOCATION", this->Quiet); } - this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod, - this->Quiet); - this->CTest->SetCTestConfiguration("DropSite", ctestDropSite, this->Quiet); - this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation, - this->Quiet); this->CTest->SetCTestConfigurationFromCMakeVariable( this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet); - this->CTest->SetCTestConfigurationFromCMakeVariable( - this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet); - this->CTest->SetCTestConfigurationFromCMakeVariable( - this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD", - this->Quiet); const char* notesFilesVariable = this->Makefile->GetDefinition("CTEST_NOTES_FILES"); @@ -184,6 +176,11 @@ bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg) return true; } + if (arg == "SUBMIT_URL") { + this->ArgumentDoing = ArgumentDoingSubmitURL; + return true; + } + if (arg == "INTERNAL_TEST_CHECKSUM") { this->InternalTest = true; return true; @@ -249,6 +246,12 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg) return true; } + if (this->ArgumentDoing == ArgumentDoingSubmitURL) { + this->ArgumentDoing = ArgumentDoingNone; + this->SubmitURL = arg; + return true; + } + // Look for other arguments. return this->Superclass::CheckArgumentValue(arg); } diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index c4b84ce9fa..0caccd66d0 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -71,6 +71,7 @@ protected: ArgumentDoingCDashUpload, ArgumentDoingCDashUploadType, ArgumentDoingHttpHeader, + ArgumentDoingSubmitURL, ArgumentDoingLast2 }; @@ -85,6 +86,7 @@ protected: std::string CDashUploadFile; std::string CDashUploadType; std::vector<std::string> HttpHeaders; + std::string SubmitURL; }; #endif diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 30424802b1..87112da9e0 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -30,10 +30,6 @@ typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar; class cmCTestSubmitHandler::ResponseParser : public cmXMLParser { public: - ResponseParser() { this->Status = STATUS_OK; } - ~ResponseParser() override {} - -public: enum StatusType { STATUS_OK, @@ -41,7 +37,7 @@ public: STATUS_ERROR }; - StatusType Status; + StatusType Status = STATUS_OK; std::string Filename; std::string MD5; std::string Message; @@ -162,7 +158,6 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( /* In windows, this will init the winsock stuff */ ::curl_global_init(CURL_GLOBAL_ALL); - std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); std::vector<std::string> args; cmSystemTools::ExpandListArgument(curlopt, args); @@ -495,27 +490,6 @@ void cmCTestSubmitHandler::ParseResponse( } } -void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod, - std::string& url) -{ - dropMethod = this->CTest->GetCTestConfiguration("DropMethod"); - url = dropMethod; - url += "://"; - if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) { - url += this->CTest->GetCTestConfiguration("DropSiteUser"); - cmCTestOptionalLog( - this->CTest, HANDLER_OUTPUT, - this->CTest->GetCTestConfiguration("DropSiteUser").c_str(), this->Quiet); - if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) { - url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword"); - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******", this->Quiet); - } - url += "@"; - } - url += this->CTest->GetCTestConfiguration("DropSite") + - this->CTest->GetCTestConfiguration("DropLocation"); -} - int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, std::string const& typeString) { @@ -536,16 +510,15 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, curl.SetCurlOptions(args); curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT); curl.SetHttpHeaders(this->HttpHeaders); - std::string dropMethod; - std::string url; - this->ConstructCDashURL(dropMethod, url); + std::string url = this->CTest->GetSubmitURL(); std::string fields; std::string::size_type pos = url.find('?'); if (pos != std::string::npos) { fields = url.substr(pos + 1); url = url.substr(0, pos); } - if (!(dropMethod == "http" || dropMethod == "https")) { + if (!cmHasLiteralPrefix(url, "http://") && + !cmHasLiteralPrefix(url, "https://")) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Only http and https are supported for CDASH_UPLOAD\n"); return -1; @@ -861,7 +834,7 @@ int cmCTestSubmitHandler::ProcessHandler() // Submit Done.xml last if (this->SubmitPart[cmCTest::PartDone]) { - files.push_back("Done.xml"); + files.emplace_back("Done.xml"); } if (ofs) { @@ -872,10 +845,7 @@ int cmCTestSubmitHandler::ProcessHandler() cnt++; } } - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, - "Submit files (using " - << this->CTest->GetCTestConfiguration("DropMethod") - << ")" << std::endl, + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Submit files\n", this->Quiet); const char* specificTrack = this->CTest->GetSpecificTrack(); if (specificTrack) { @@ -885,72 +855,32 @@ int cmCTestSubmitHandler::ProcessHandler() } this->SetLogFile(&ofs); - std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); - - if (dropMethod.empty()) { - dropMethod = "http"; + std::string url = this->CTest->GetSubmitURL(); + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, + " SubmitURL: " << url << '\n', this->Quiet); + if (!this->SubmitUsingHTTP(buildDirectory + "/Testing/" + + this->CTest->GetCurrentTag(), + files, prefix, url)) { + cmCTestLog(this->CTest, ERROR_MESSAGE, + " Problems when submitting via HTTP\n"); + ofs << " Problems when submitting via HTTP\n"; + return -1; } - - if (dropMethod == "http" || dropMethod == "https") { - std::string url = dropMethod; - url += "://"; - ofs << "Using drop method: " << dropMethod << std::endl; - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, - " Using HTTP submit method" << std::endl - << " Drop site:" << url, - this->Quiet); - if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) { - url += this->CTest->GetCTestConfiguration("DropSiteUser"); - cmCTestOptionalLog( - this->CTest, HANDLER_OUTPUT, - this->CTest->GetCTestConfiguration("DropSiteUser").c_str(), - this->Quiet); - if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) { - url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword"); - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******", - this->Quiet); - } - url += "@"; - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet); - } - url += this->CTest->GetCTestConfiguration("DropSite") + - this->CTest->GetCTestConfiguration("DropLocation"); + if (this->HasErrors) { + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Errors occurred during submission.\n"); + ofs << " Errors occurred during submission.\n"; + } else { cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, - this->CTest->GetCTestConfiguration("DropSite") - << this->CTest->GetCTestConfiguration("DropLocation") + " Submission successful" + << (this->HasWarnings ? ", with warnings." : "") << std::endl, this->Quiet); - if (!this->SubmitUsingHTTP(buildDirectory + "/Testing/" + - this->CTest->GetCurrentTag(), - files, prefix, url)) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - " Problems when submitting via HTTP" << std::endl); - ofs << " Problems when submitting via HTTP" << std::endl; - return -1; - } - if (this->HasErrors) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, - " Errors occurred during " - "submission." - << std::endl); - ofs << " Errors occurred during submission. " << std::endl; - } else { - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, - " Submission successful" - << (this->HasWarnings ? ", with warnings." : "") - << std::endl, - this->Quiet); - ofs << " Submission successful" - << (this->HasWarnings ? ", with warnings." : "") << std::endl; - } - - return 0; + ofs << " Submission successful" + << (this->HasWarnings ? ", with warnings." : "") << std::endl; } - cmCTestLog(this->CTest, ERROR_MESSAGE, - " Unknown submission method: \"" << dropMethod << "\"" - << std::endl); - return -1; + return 0; } std::string cmCTestSubmitHandler::GetSubmitResultsPrefix() diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 393e826d17..58f4f975d9 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -48,8 +48,6 @@ public: this->HttpHeaders = v; } - void ConstructCDashURL(std::string& dropMethod, std::string& url); - private: void SetLogFile(std::ostream* ost) { this->LogFile = ost; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index acbe4652da..cf2652afe4 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -104,7 +104,7 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args, } fname += "/"; fname += testFilename; - readit = this->Makefile->ReadDependentFile(fname.c_str()); + readit = this->Makefile->ReadDependentFile(fname); } if (!readit) { std::string m = "Could not find include file: "; @@ -170,7 +170,7 @@ bool cmCTestAddSubdirectoryCommand::InitialPass( } fname += "/"; fname += testFilename; - readit = this->Makefile->ReadDependentFile(fname.c_str()); + readit = this->Makefile->ReadDependentFile(fname); } if (!readit) { std::string m = "Could not find include file: "; @@ -1524,7 +1524,7 @@ void cmCTestTestHandler::AddConfigurations( } tempPath = filepath + filename; attempted.push_back(tempPath); - attemptedConfigs.push_back(""); + attemptedConfigs.emplace_back(); if (!ctest->GetConfigType().empty()) { tempPath = filepath; @@ -1547,32 +1547,32 @@ void cmCTestTestHandler::AddConfigurations( tempPath += "Release/"; tempPath += filename; attempted.push_back(tempPath); - attemptedConfigs.push_back("Release"); + attemptedConfigs.emplace_back("Release"); tempPath = filepath; tempPath += "Debug/"; tempPath += filename; attempted.push_back(tempPath); - attemptedConfigs.push_back("Debug"); + attemptedConfigs.emplace_back("Debug"); tempPath = filepath; tempPath += "MinSizeRel/"; tempPath += filename; attempted.push_back(tempPath); - attemptedConfigs.push_back("MinSizeRel"); + attemptedConfigs.emplace_back("MinSizeRel"); tempPath = filepath; tempPath += "RelWithDebInfo/"; tempPath += filename; attempted.push_back(tempPath); - attemptedConfigs.push_back("RelWithDebInfo"); + attemptedConfigs.emplace_back("RelWithDebInfo"); tempPath = filepath; tempPath += "Deployment/"; tempPath += filename; attempted.push_back(tempPath); - attemptedConfigs.push_back("Deployment"); + attemptedConfigs.emplace_back("Deployment"); tempPath = filepath; tempPath += "Development/"; tempPath += filename; attempted.push_back(tempPath); - attemptedConfigs.push_back("Deployment"); + attemptedConfigs.emplace_back("Deployment"); } } diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 57e40ce351..e3b7e9ef3d 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -34,9 +34,7 @@ static const char* cmCTestUpdateHandlerUpdateToString(int type) return cmCTestUpdateHandlerUpdateStrings[type]; } -cmCTestUpdateHandler::cmCTestUpdateHandler() -{ -} +cmCTestUpdateHandler::cmCTestUpdateHandler() = default; void cmCTestUpdateHandler::Initialize() { diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index 63bd0e67d6..374e73ffb9 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -24,9 +24,7 @@ cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log) this->Unknown.Rev = "Unknown"; } -cmCTestVC::~cmCTestVC() -{ -} +cmCTestVC::~cmCTestVC() = default; void cmCTestVC::SetCommandLineTool(std::string const& tool) { diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx index 308e6f7a35..63d6a15d8e 100644 --- a/Source/CTest/cmParseBlanketJSCoverage.cxx +++ b/Source/CTest/cmParseBlanketJSCoverage.cxx @@ -20,7 +20,7 @@ public: { } - virtual ~JSONParser() {} + virtual ~JSONParser() = default; std::string getValue(std::string const& line, int type) { diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index 5bb64247ba..848a034c95 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -13,19 +13,12 @@ class cmParseCoberturaCoverage::XMLParser : public cmXMLParser { public: XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont) - : CTest(ctest) + : FilePaths{ cont.SourceDir, cont.BinaryDir } + , CTest(ctest) , Coverage(cont) { - this->InSources = false; - this->InSource = false; - this->SkipThisClass = false; - this->FilePaths.push_back(this->Coverage.SourceDir); - this->FilePaths.push_back(this->Coverage.BinaryDir); - this->CurFileName.clear(); } - ~XMLParser() override {} - protected: void EndElement(const std::string& name) override { @@ -144,9 +137,9 @@ protected: } private: - bool InSources; - bool InSource; - bool SkipThisClass; + bool InSources = false; + bool InSource = false; + bool SkipThisClass = false; std::vector<std::string> FilePaths; typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector FileLinesType; diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx index cc81979519..9eda6f8f3d 100644 --- a/Source/CTest/cmParseDelphiCoverage.cxx +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -20,7 +20,7 @@ public: { } - virtual ~HTMLParser() {} + virtual ~HTMLParser() = default; bool initializeDelphiFile( std::string const& filename, @@ -44,7 +44,7 @@ public: // Check that the begin is the first non-space string on the line if ((beginPos == line.find_first_not_of(' ')) && beginPos != std::string::npos) { - beginSet.push_back("begin"); + beginSet.emplace_back("begin"); coverageVector.push_back(-1); continue; } diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index 31e7cd4d45..61c5dcbbdb 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -18,13 +18,8 @@ public: : CTest(ctest) , Coverage(cont) { - this->FilePath.clear(); - this->PackagePath.clear(); - this->PackageName.clear(); } - ~XMLParser() override {} - protected: void EndElement(const std::string& /*name*/) override {} diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index 488d2378a8..4a81ee4f70 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -18,9 +18,7 @@ cmParseMumpsCoverage::cmParseMumpsCoverage( { } -cmParseMumpsCoverage::~cmParseMumpsCoverage() -{ -} +cmParseMumpsCoverage::~cmParseMumpsCoverage() = default; bool cmParseMumpsCoverage::ReadCoverageFile(const char* file) { diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index 7737f65ce8..70ef8dfcd0 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -69,9 +69,7 @@ cmProcess::cmProcess(cmCTestRunTest& runner) this->StartTime = std::chrono::steady_clock::time_point(); } -cmProcess::~cmProcess() -{ -} +cmProcess::~cmProcess() = default; void cmProcess::SetCommand(const char* command) { diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 6dc692e013..f2982a62ca 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -5,7 +5,7 @@ #include "cmCursesMainForm.h" #include "cmCursesStandardIncludes.h" #include "cmDocumentation.h" -#include "cmDocumentationEntry.h" +#include "cmDocumentationEntry.h" // IWYU pragma: keep #include "cmState.h" #include "cmSystemTools.h" #include "cmake.h" @@ -65,13 +65,6 @@ void onsig(int /*unused*/) } } -void CMakeMessageHandler(const char* message, const char* title, - bool& /*unused*/, void* clientData) -{ - cmCursesForm* self = static_cast<cmCursesForm*>(clientData); - self->AddError(message, title); -} - int main(int argc, char const* const* argv) { cmsys::Encoding::CommandLineArguments encoding_args = @@ -88,15 +81,14 @@ int main(int argc, char const* const* argv) hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); - std::vector<cmDocumentationEntry> generators; - hcm.GetGeneratorDocumentation(generators); + auto generators = hcm.GetGeneratorsDocumentation(); doc.SetName("ccmake"); doc.SetSection("Name", cmDocumentationName); doc.SetSection("Usage", cmDocumentationUsage); if (argc == 1) { doc.AppendSection("Usage", cmDocumentationUsageNote); } - doc.SetSection("Generators", generators); + doc.AppendSection("Generators", generators); doc.PrependSection("Options", cmDocumentationOptions); return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1; } @@ -109,7 +101,7 @@ int main(int argc, char const* const* argv) if (strcmp(argv[j], "-debug") == 0) { debug = true; } else { - args.push_back(argv[j]); + args.emplace_back(argv[j]); } } @@ -157,7 +149,10 @@ int main(int argc, char const* const* argv) return 1; } - cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform); + cmSystemTools::SetMessageCallback( + [myform](const char* message, const char* title) { + myform->AddError(message, title); + }); cmCursesForm::CurrentForm = myform; diff --git a/Source/CursesDialog/cmCursesLabelWidget.cxx b/Source/CursesDialog/cmCursesLabelWidget.cxx index 1dfd4ce47b..83aea5a2c6 100644 --- a/Source/CursesDialog/cmCursesLabelWidget.cxx +++ b/Source/CursesDialog/cmCursesLabelWidget.cxx @@ -14,9 +14,7 @@ cmCursesLabelWidget::cmCursesLabelWidget(int width, int height, int left, this->SetValue(name); } -cmCursesLabelWidget::~cmCursesLabelWidget() -{ -} +cmCursesLabelWidget::~cmCursesLabelWidget() = default; bool cmCursesLabelWidget::HandleInput(int& /*key*/, cmCursesMainForm* /*fm*/, WINDOW* /*w*/) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index a75d9135e5..8ca7802f1f 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -20,15 +20,16 @@ #include <algorithm> #include <stdio.h> #include <string.h> +#include <utility> inline int ctrl(int z) { return (z & 037); } -cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, +cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args, int initWidth) - : Args(args) + : Args(std::move(args)) , InitialWidth(initWidth) { this->NumberOfPages = 0; @@ -37,10 +38,10 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, this->AdvancedMode = false; this->NumberOfVisibleEntries = 0; this->OkToGenerate = false; - this->HelpMessage.push_back( + this->HelpMessage.emplace_back( "Welcome to ccmake, curses based user interface for CMake."); - this->HelpMessage.push_back(""); - this->HelpMessage.push_back(s_ConstHelpMessage); + this->HelpMessage.emplace_back(); + this->HelpMessage.emplace_back(s_ConstHelpMessage); this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project); this->CMakeInstance->SetCMakeEditCommand( cmSystemTools::GetCMakeCursesCommand()); @@ -505,12 +506,8 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) pos_form_cursor(this->Form); } -void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp) +void cmCursesMainForm::UpdateProgress(const char* msg, float prog) { - cmCursesMainForm* cm = static_cast<cmCursesMainForm*>(vp); - if (!cm) { - return; - } char tmp[1024]; const char* cmsg = tmp; if (prog >= 0) { @@ -518,8 +515,8 @@ void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp) } else { cmsg = msg; } - cm->UpdateStatusBar(cmsg); - cm->PrintKeys(1); + this->UpdateStatusBar(cmsg); + this->PrintKeys(1); curses_move(1, 1); touchwin(stdscr); refresh(); @@ -535,8 +532,8 @@ int cmCursesMainForm::Configure(int noconfigure) this->PrintKeys(1); touchwin(stdscr); refresh(); - this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, - this); + this->CMakeInstance->SetProgressCallback( + [this](const char* msg, float prog) { this->UpdateProgress(msg, prog); }); // always save the current gui values to disk this->FillCacheManagerFromUI(); @@ -559,7 +556,7 @@ int cmCursesMainForm::Configure(int noconfigure) } else { retVal = this->CMakeInstance->Configure(); } - this->CMakeInstance->SetProgressCallback(nullptr, nullptr); + this->CMakeInstance->SetProgressCallback(nullptr); keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ @@ -605,8 +602,8 @@ int cmCursesMainForm::Generate() this->PrintKeys(1); touchwin(stdscr); refresh(); - this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, - this); + this->CMakeInstance->SetProgressCallback( + [this](const char* msg, float prog) { this->UpdateProgress(msg, prog); }); // Get rid of previous errors this->Errors = std::vector<std::string>(); @@ -614,7 +611,7 @@ int cmCursesMainForm::Generate() // run the generate process int retVal = this->CMakeInstance->Generate(); - this->CMakeInstance->SetProgressCallback(nullptr, nullptr); + this->CMakeInstance->SetProgressCallback(nullptr); keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ if (retVal != 0 || !this->Errors.empty()) { @@ -652,7 +649,7 @@ int cmCursesMainForm::Generate() void cmCursesMainForm::AddError(const char* message, const char* /*unused*/) { - this->Errors.push_back(message); + this->Errors.emplace_back(message); } void cmCursesMainForm::RemoveEntry(const char* value) diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 2c006cfb88..88864bc545 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -26,7 +26,7 @@ class cmCursesMainForm : public cmCursesForm CM_DISABLE_COPY(cmCursesMainForm) public: - cmCursesMainForm(std::vector<std::string> const& args, int initwidth); + cmCursesMainForm(std::vector<std::string> args, int initwidth); ~cmCursesMainForm() override; /** @@ -101,8 +101,7 @@ public: /** * Progress callback */ - static void UpdateProgressOld(const char* msg, float prog, void*); - static void UpdateProgress(const char* msg, float prog, void*); + void UpdateProgress(const char* msg, float prog); protected: // Copy the cache values from the user interface to the actual diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index b4307bb7d5..cd30ad5476 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -30,7 +30,8 @@ static const char* cmDocumentationUsage[][2] = { { nullptr, " cmake-gui [options]\n" " cmake-gui [options] <path-to-source>\n" - " cmake-gui [options] <path-to-existing-build>" }, + " cmake-gui [options] <path-to-existing-build>\n" + " cmake-gui [options] -S <path-to-source> -B <path-to-build>\n" }, { nullptr, nullptr } }; @@ -69,8 +70,7 @@ int main(int argc, char** argv) hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); - std::vector<cmDocumentationEntry> generators; - hcm.GetGeneratorDocumentation(generators); + auto generators = hcm.GetGeneratorsDocumentation(); doc.SetName("cmake"); doc.SetSection("Name", cmDocumentationName); doc.SetSection("Usage", cmDocumentationUsage); @@ -143,23 +143,53 @@ int main(int argc, char** argv) CMakeSetupDialog dialog; dialog.show(); - cmsys::CommandLineArguments arg; - arg.Initialize(argc2, argv2); + QStringList args = QApplication::arguments(); std::string binaryDirectory; std::string sourceDirectory; - typedef cmsys::CommandLineArguments argT; - arg.AddArgument("-B", argT::CONCAT_ARGUMENT, &binaryDirectory, - "Binary Directory"); - arg.AddArgument("-S", argT::CONCAT_ARGUMENT, &sourceDirectory, - "Source Directory"); - // do not complain about unknown options - arg.StoreUnusedArguments(true); - arg.Parse(); + for (int i = 1; i < args.size(); ++i) { + const QString& arg = args[i]; + if (arg.startsWith("-S")) { + QString path = arg.mid(2); + if (path.isEmpty()) { + ++i; + if (i >= args.size()) { + std::cerr << "No source directory specified for -S" << std::endl; + return 1; + } + path = args[i]; + if (path[0] == '-') { + std::cerr << "No source directory specified for -S" << std::endl; + return 1; + } + } + + sourceDirectory = + cmSystemTools::CollapseFullPath(path.toLocal8Bit().data()); + cmSystemTools::ConvertToUnixSlashes(sourceDirectory); + } else if (arg.startsWith("-B")) { + QString path = arg.mid(2); + if (path.isEmpty()) { + ++i; + if (i >= args.size()) { + std::cerr << "No build directory specified for -B" << std::endl; + return 1; + } + path = args[i]; + if (path[0] == '-') { + std::cerr << "No build directory specified for -B" << std::endl; + return 1; + } + } + + binaryDirectory = + cmSystemTools::CollapseFullPath(path.toLocal8Bit().data()); + cmSystemTools::ConvertToUnixSlashes(binaryDirectory); + } + } if (!sourceDirectory.empty() && !binaryDirectory.empty()) { dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str())); dialog.setBinaryDirectory(QString::fromLocal8Bit(binaryDirectory.c_str())); } else { - QStringList args = QApplication::arguments(); if (args.count() == 2) { std::string filePath = cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data()); diff --git a/Source/QtDialog/CMakeSetup128.png b/Source/QtDialog/CMakeSetup128.png Binary files differindex 728ef0269f..32984e104e 100644 --- a/Source/QtDialog/CMakeSetup128.png +++ b/Source/QtDialog/CMakeSetup128.png diff --git a/Source/QtDialog/CMakeSetup32.png b/Source/QtDialog/CMakeSetup32.png Binary files differindex 1c36b31d0b..78df82f15b 100644 --- a/Source/QtDialog/CMakeSetup32.png +++ b/Source/QtDialog/CMakeSetup32.png diff --git a/Source/QtDialog/CMakeSetup64.png b/Source/QtDialog/CMakeSetup64.png Binary files differindex 44eb17173f..5c2dbf552d 100644 --- a/Source/QtDialog/CMakeSetup64.png +++ b/Source/QtDialog/CMakeSetup64.png diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 444a980836..72cce9f50a 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -751,6 +751,7 @@ bool CMakeSetupDialog::setupFirstConfigure() if (dialog.exec() == QDialog::Accepted) { dialog.saveToSettings(); this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator()); + this->CMakeThread->cmakeInstance()->setPlatform(dialog.getPlatform()); this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset()); QCMakeCacheModel* m = this->CacheValues->cacheModel(); diff --git a/Source/QtDialog/Delete16.png b/Source/QtDialog/Delete16.png Binary files differindex 16989fee12..9d2f2b7ec7 100644 --- a/Source/QtDialog/Delete16.png +++ b/Source/QtDialog/Delete16.png diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index 88ce7cb8ab..f28e1a8215 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -16,8 +16,12 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p) this->GeneratorOptions = new QComboBox(this); l->addWidget(this->GeneratorOptions); + // Add the generator platform + this->PlatformFrame = CreatePlatformWidgets(); + l->addWidget(PlatformFrame); + // Add the ability to specify toolset (-T parameter) - ToolsetFrame = CreateToolsetWidgets(); + this->ToolsetFrame = CreateToolsetWidgets(); l->addWidget(ToolsetFrame); l->addSpacing(6); @@ -45,7 +49,7 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p) SLOT(onSelectionChanged(bool))); QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)), this, SLOT(onSelectionChanged(bool))); - QObject::connect(GeneratorOptions, + QObject::connect(this->GeneratorOptions, SIGNAL(currentIndexChanged(QString const&)), this, SLOT(onGeneratorChanged(QString const&))); } @@ -65,10 +69,25 @@ QFrame* StartCompilerSetup::CreateToolsetWidgets() return frame; } -StartCompilerSetup::~StartCompilerSetup() +QFrame* StartCompilerSetup::CreatePlatformWidgets() { + QFrame* frame = new QFrame(this); + QVBoxLayout* l = new QVBoxLayout(frame); + l->setContentsMargins(0, 0, 0, 0); + + this->PlatformLabel = new QLabel(tr("Optional platform for generator")); + l->addWidget(this->PlatformLabel); + + this->PlatformOptions = new QComboBox(frame); + this->PlatformOptions->setEditable(true); + + l->addWidget(this->PlatformOptions); + + return frame; } +StartCompilerSetup::~StartCompilerSetup() = default; + void StartCompilerSetup::setGenerators( std::vector<cmake::GeneratorInfo> const& gens) { @@ -80,6 +99,26 @@ void StartCompilerSetup::setGenerators( for (it = gens.begin(); it != gens.end(); ++it) { generator_list.append(QString::fromLocal8Bit(it->name.c_str())); + if (it->supportsPlatform) { + this->GeneratorsSupportingPlatform.append( + QString::fromLocal8Bit(it->name.c_str())); + + this + ->GeneratorDefaultPlatform[QString::fromLocal8Bit(it->name.c_str())] = + QString::fromLocal8Bit(it->defaultPlatform.c_str()); + + std::vector<std::string>::const_iterator platformIt = + it->supportedPlatforms.cbegin(); + while (platformIt != it->supportedPlatforms.cend()) { + + this->GeneratorSupportedPlatforms.insert( + QString::fromLocal8Bit(it->name.c_str()), + QString::fromLocal8Bit((*platformIt).c_str())); + + platformIt++; + } + } + if (it->supportsToolset) { this->GeneratorsSupportingToolset.append( QString::fromLocal8Bit(it->name.c_str())); @@ -102,6 +141,11 @@ QString StartCompilerSetup::getGenerator() const return this->GeneratorOptions->currentText(); }; +QString StartCompilerSetup::getPlatform() const +{ + return this->PlatformOptions->currentText(); +}; + QString StartCompilerSetup::getToolset() const { return this->Toolset->text(); @@ -136,6 +180,31 @@ void StartCompilerSetup::onSelectionChanged(bool on) void StartCompilerSetup::onGeneratorChanged(QString const& name) { + // Display the generator platform for the generators supporting it + if (GeneratorsSupportingPlatform.contains(name)) { + + // Change the label title to include the default platform + std::string label = "Optional platform for generator"; + label += "(if empty, generator uses: "; + label += this->GeneratorDefaultPlatform[name].toStdString(); + label += ")"; + this->PlatformLabel->setText(tr(label.c_str())); + + // Regenerate the list of supported platform + this->PlatformOptions->clear(); + QStringList platform_list; + platform_list.append(""); + + QList<QString> platforms = this->GeneratorSupportedPlatforms.values(name); + platform_list.append(platforms); + + this->PlatformOptions->addItems(platform_list); + PlatformFrame->show(); + } else { + PlatformFrame->hide(); + } + + // Display the toolset box for the generators supporting it if (GeneratorsSupportingToolset.contains(name)) { ToolsetFrame->show(); } else { @@ -166,9 +235,7 @@ NativeCompilerSetup::NativeCompilerSetup(QWidget* p) this->setupUi(c); } -NativeCompilerSetup::~NativeCompilerSetup() -{ -} +NativeCompilerSetup::~NativeCompilerSetup() = default; QString NativeCompilerSetup::getCCompiler() const { @@ -230,9 +297,7 @@ CrossCompilerSetup::CrossCompilerSetup(QWidget* p) this->registerField("systemName*", this->systemName); } -CrossCompilerSetup::~CrossCompilerSetup() -{ -} +CrossCompilerSetup::~CrossCompilerSetup() = default; QString CrossCompilerSetup::getCCompiler() const { @@ -343,9 +408,7 @@ ToolchainCompilerSetup::ToolchainCompilerSetup(QWidget* p) l->addWidget(this->ToolchainFile); } -ToolchainCompilerSetup::~ToolchainCompilerSetup() -{ -} +ToolchainCompilerSetup::~ToolchainCompilerSetup() = default; QString ToolchainCompilerSetup::toolchainFile() const { @@ -375,9 +438,7 @@ FirstConfigure::FirstConfigure() this->setPage(ToolchainSetup, this->mToolchainCompilerSetupPage); } -FirstConfigure::~FirstConfigure() -{ -} +FirstConfigure::~FirstConfigure() = default; void FirstConfigure::setGenerators( std::vector<cmake::GeneratorInfo> const& gens) @@ -390,6 +451,11 @@ QString FirstConfigure::getGenerator() const return this->mStartCompilerSetupPage->getGenerator(); } +QString FirstConfigure::getPlatform() const +{ + return this->mStartCompilerSetupPage->getPlatform(); +} + QString FirstConfigure::getToolset() const { return this->mStartCompilerSetupPage->getToolset(); diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h index abfa03fd82..d1db5bff66 100644 --- a/Source/QtDialog/FirstConfigure.h +++ b/Source/QtDialog/FirstConfigure.h @@ -35,6 +35,7 @@ public: void setCurrentGenerator(const QString& gen); QString getGenerator() const; QString getToolset() const; + QString getPlatform() const; bool defaultSetup() const; bool compilerSetup() const; @@ -56,10 +57,17 @@ protected: QFrame* ToolsetFrame; QLineEdit* Toolset; QLabel* ToolsetLabel; + QFrame* PlatformFrame; + QComboBox* PlatformOptions; + QLabel* PlatformLabel; QStringList GeneratorsSupportingToolset; + QStringList GeneratorsSupportingPlatform; + QMultiMap<QString, QString> GeneratorSupportedPlatforms; + QMap<QString, QString> GeneratorDefaultPlatform; private: QFrame* CreateToolsetWidgets(); + QFrame* CreatePlatformWidgets(); }; //! the page that gives basic options for native compilers @@ -159,6 +167,7 @@ public: void setGenerators(std::vector<cmake::GeneratorInfo> const& gens); QString getGenerator() const; + QString getPlatform() const; QString getToolset() const; bool defaultSetup() const; diff --git a/Source/QtDialog/Plus16.png b/Source/QtDialog/Plus16.png Binary files differindex 552f6f0045..1c33bc7637 100644 --- a/Source/QtDialog/Plus16.png +++ b/Source/QtDialog/Plus16.png diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 9a6784e514..065d610151 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -23,19 +23,30 @@ QCMake::QCMake(QObject* p) cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); - cmSystemTools::SetMessageCallback(QCMake::messageCallback, this); - cmSystemTools::SetStdoutCallback(QCMake::stdoutCallback, this); - cmSystemTools::SetStderrCallback(QCMake::stderrCallback, this); + + cmSystemTools::SetMessageCallback( + [this](const char* msg, const char* title) { + this->messageCallback(msg, title); + }); + cmSystemTools::SetStdoutCallback( + [this](const char* msg, size_t len) { this->stdoutCallback(msg, len); }); + cmSystemTools::SetStderrCallback( + [this](const char* msg, size_t len) { this->stderrCallback(msg, len); }); this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project); this->CMakeInstance->SetCMakeEditCommand( cmSystemTools::GetCMakeGUICommand()); - this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this); + this->CMakeInstance->SetProgressCallback( + [this](const char* msg, float percent) { + this->progressCallback(msg, percent); + }); - cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this); + cmSystemTools::SetInterruptCallback( + [this] { return this->interruptCallback(); }); std::vector<cmake::GeneratorInfo> generators; - this->CMakeInstance->GetRegisteredGenerators(generators); + this->CMakeInstance->GetRegisteredGenerators( + generators, /*includeNamesWithPlatform=*/false); std::vector<cmake::GeneratorInfo>::const_iterator it; for (it = generators.begin(); it != generators.end(); ++it) { @@ -74,6 +85,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) cmState* state = this->CMakeInstance->GetState(); this->setGenerator(QString()); this->setToolset(QString()); + this->setPlatform(QString()); if (!this->CMakeInstance->LoadCache( this->BinaryDirectory.toLocal8Bit().data())) { QDir testDir(this->BinaryDirectory); @@ -102,6 +114,12 @@ void QCMake::setBinaryDirectory(const QString& _dir) this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); } + const char* platform = + state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM"); + if (platform) { + this->setPlatform(QString::fromLocal8Bit(platform)); + } + const char* toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET"); if (toolset) { this->setToolset(QString::fromLocal8Bit(toolset)); @@ -119,6 +137,14 @@ void QCMake::setGenerator(const QString& gen) } } +void QCMake::setPlatform(const QString& platform) +{ + if (this->Platform != platform) { + this->Platform = platform; + emit this->platformChanged(this->Platform); + } +} + void QCMake::setToolset(const QString& toolset) { if (this->Toolset != toolset) { @@ -140,7 +166,8 @@ void QCMake::configure() this->CMakeInstance->SetGlobalGenerator( this->CMakeInstance->CreateGlobalGenerator( this->Generator.toLocal8Bit().data())); - this->CMakeInstance->SetGeneratorPlatform(""); + this->CMakeInstance->SetGeneratorPlatform( + this->Platform.toLocal8Bit().data()); this->CMakeInstance->SetGeneratorToolset(this->Toolset.toLocal8Bit().data()); this->CMakeInstance->LoadCache(); this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode); @@ -313,46 +340,40 @@ void QCMake::interrupt() this->InterruptFlag.ref(); } -bool QCMake::interruptCallback(void* cd) +bool QCMake::interruptCallback() { - QCMake* self = reinterpret_cast<QCMake*>(cd); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - return self->InterruptFlag; + return this->InterruptFlag; #else - return self->InterruptFlag.load(); + return this->InterruptFlag.load(); #endif } -void QCMake::progressCallback(const char* msg, float percent, void* cd) +void QCMake::progressCallback(const char* msg, float percent) { - QCMake* self = reinterpret_cast<QCMake*>(cd); if (percent >= 0) { - emit self->progressChanged(QString::fromLocal8Bit(msg), percent); + emit this->progressChanged(QString::fromLocal8Bit(msg), percent); } else { - emit self->outputMessage(QString::fromLocal8Bit(msg)); + emit this->outputMessage(QString::fromLocal8Bit(msg)); } QCoreApplication::processEvents(); } -void QCMake::messageCallback(const char* msg, const char* /*title*/, - bool& /*stop*/, void* cd) +void QCMake::messageCallback(const char* msg, const char* /*title*/) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->errorMessage(QString::fromLocal8Bit(msg)); + emit this->errorMessage(QString::fromLocal8Bit(msg)); QCoreApplication::processEvents(); } -void QCMake::stdoutCallback(const char* msg, size_t len, void* cd) +void QCMake::stdoutCallback(const char* msg, size_t len) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->outputMessage(QString::fromLocal8Bit(msg, int(len))); + emit this->outputMessage(QString::fromLocal8Bit(msg, int(len))); QCoreApplication::processEvents(); } -void QCMake::stderrCallback(const char* msg, size_t len, void* cd) +void QCMake::stderrCallback(const char* msg, size_t len) { - QCMake* self = reinterpret_cast<QCMake*>(cd); - emit self->outputMessage(QString::fromLocal8Bit(msg, int(len))); + emit this->outputMessage(QString::fromLocal8Bit(msg, int(len))); QCoreApplication::processEvents(); } diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index 4b3920aaf6..4f2250587a 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -75,6 +75,8 @@ public slots: /// set the desired generator to use void setGenerator(const QString& generator); /// set the desired generator to use + void setPlatform(const QString& platform); + /// set the desired generator to use void setToolset(const QString& toolset); /// do the configure step void configure(); @@ -155,6 +157,8 @@ signals: void debugOutputChanged(bool); /// signal when the toolset changes void toolsetChanged(const QString& toolset); + /// signal when the platform changes + void platformChanged(const QString& platform); /// signal when open is done void openDone(bool successful); /// signal when open is done @@ -163,18 +167,19 @@ signals: protected: cmake* CMakeInstance; - static bool interruptCallback(void*); - static void progressCallback(const char* msg, float percent, void* cd); - static void messageCallback(const char* msg, const char* title, bool&, - void* cd); - static void stdoutCallback(const char* msg, size_t len, void* cd); - static void stderrCallback(const char* msg, size_t len, void* cd); + bool interruptCallback(); + void progressCallback(const char* msg, float percent); + void messageCallback(const char* msg, const char* title); + void stdoutCallback(const char* msg, size_t len); + void stderrCallback(const char* msg, size_t len); + bool WarnUninitializedMode; bool WarnUnusedMode; bool WarnUnusedAllMode; QString SourceDirectory; QString BinaryDirectory; QString Generator; + QString Platform; QString Toolset; std::vector<cmake::GeneratorInfo> AvailableGenerators; QString CMakeExecutable; diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 821c3f4178..78a2710247 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -186,9 +186,7 @@ QCMakeCacheModel::QCMakeCacheModel(QObject* p) this->setHorizontalHeaderLabels(labels); } -QCMakeCacheModel::~QCMakeCacheModel() -{ -} +QCMakeCacheModel::~QCMakeCacheModel() = default; static uint qHash(const QCMakeProperty& p) { diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index b544b8613b..eab418fe7c 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -7,10 +7,11 @@ #include <QFileInfo> #include <QResizeEvent> #include <QToolButton> +#include <utility> -QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var) +QCMakeFileEditor::QCMakeFileEditor(QWidget* p, QString var) : QLineEdit(p) - , Variable(var) + , Variable(std::move(var)) { this->ToolButton = new QToolButton(this); this->ToolButton->setText("..."); diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h index e63c197532..5d2368eab9 100644 --- a/Source/QtDialog/QCMakeWidgets.h +++ b/Source/QtDialog/QCMakeWidgets.h @@ -18,7 +18,7 @@ class QCMakeFileEditor : public QLineEdit { Q_OBJECT public: - QCMakeFileEditor(QWidget* p, const QString& var); + QCMakeFileEditor(QWidget* p, QString var); protected slots: virtual void chooseFile() = 0; signals: diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 2f8e675be2..9e3efd30ae 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -61,8 +61,8 @@ struct cmStrCmp : m_test(test) { } - cmStrCmp(const std::string& test) - : m_test(test) + cmStrCmp(std::string test) + : m_test(std::move(test)) { } diff --git a/Source/cmBase32.cxx b/Source/cmBase32.cxx index 1dac212c2d..80ada47660 100644 --- a/Source/cmBase32.cxx +++ b/Source/cmBase32.cxx @@ -34,13 +34,9 @@ void Base32Encode5(const unsigned char src[5], char dst[8]) // -- Class methods -cmBase32Encoder::cmBase32Encoder() -{ -} +cmBase32Encoder::cmBase32Encoder() = default; -cmBase32Encoder::~cmBase32Encoder() -{ -} +cmBase32Encoder::~cmBase32Encoder() = default; std::string cmBase32Encoder::encodeString(const unsigned char* input, size_t len, bool padding) diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 264c63c2b7..c0088ac5d4 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -181,7 +181,7 @@ void CCONV cmAddExecutable(void* arg, const char* exename, int numSrcs, std::vector<std::string> srcs2; int i; for (i = 0; i < numSrcs; ++i) { - srcs2.push_back(srcs[i]); + srcs2.emplace_back(srcs[i]); } cmTarget* tg = mf->AddExecutable(exename, srcs2); if (win32) { @@ -393,7 +393,7 @@ void CCONV cmAddLibrary(void* arg, const char* libname, int shared, std::vector<std::string> srcs2; int i; for (i = 0; i < numSrcs; ++i) { - srcs2.push_back(srcs[i]); + srcs2.emplace_back(srcs[i]); } mf->AddLibrary( libname, @@ -419,8 +419,7 @@ int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs, lff.Name = name; for (int i = 0; i < numArgs; ++i) { // Assume all arguments are quoted. - lff.Arguments.push_back( - cmListFileArgument(args[i], cmListFileArgument::Quoted, 0)); + lff.Arguments.emplace_back(args[i], cmListFileArgument::Quoted, 0); } cmExecutionStatus status; return mf->ExecuteCommand(lff, status); @@ -436,7 +435,7 @@ void CCONV cmExpandSourceListArguments(void* arg, int numArgs, std::vector<std::string> result; int i; for (i = 0; i < numArgs; ++i) { - result.push_back(args[i]); + result.emplace_back(args[i]); } int resargc = static_cast<int>(result.size()); char** resargv = nullptr; @@ -475,7 +474,6 @@ int CCONV cmGetTotalArgumentSize(int argc, char** argv) // API for source files. struct cmCPluginAPISourceFile { - cmCPluginAPISourceFile() {} cmSourceFile* RealSourceFile = nullptr; std::string SourceName; std::string SourceExtension; @@ -627,7 +625,7 @@ void CCONV cmSourceFileAddDepend(void* arg, const char* depend) if (cmSourceFile* rsf = sf->RealSourceFile) { rsf->AddDepend(depend); } else { - sf->Depends.push_back(depend); + sf->Depends.emplace_back(depend); } } @@ -647,10 +645,10 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir, std::vector<std::string> headerExts; int i; for (i = 0; i < numSourceExtensions; ++i) { - sourceExts.push_back(sourceExtensions[i]); + sourceExts.emplace_back(sourceExtensions[i]); } for (i = 0; i < numHeaderExtensions; ++i) { - headerExts.push_back(headerExtensions[i]); + headerExts.emplace_back(headerExtensions[i]); } // Save the original name given. @@ -721,7 +719,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir, ext != headerExts.end(); ++ext) { e << " ." << *ext; } - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); } void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 1c0d9f6be6..989c7ee452 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -640,7 +640,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) " Reading ctest configuration file: " << fname << std::endl, command->ShouldBeQuiet()); - bool readit = mf->ReadDependentFile(fname.c_str()); + bool readit = mf->ReadDependentFile(fname); if (!readit) { std::string m = "Could not find include file: "; m += fname; @@ -1176,12 +1176,12 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, if (strcmp(i, "--build-generator") == 0 && timeout != cmCTest::MaxDuration() && timeout > cmDuration::zero()) { - args.push_back("--test-timeout"); + args.emplace_back("--test-timeout"); std::ostringstream msg; msg << cmDurationTo<unsigned int>(timeout); args.push_back(msg.str()); } - args.push_back(i); + args.emplace_back(i); } } if (log) { @@ -1944,6 +1944,9 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, this->Quiet = true; this->OutputAsJson = true; this->OutputAsJsonVersion = 1; + } else if (format != "human") { + errormsg = "'--show-only=' given unknown value '" + format + "'"; + return false; } } @@ -2170,7 +2173,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output) // handle the simple commandline arguments std::string errormsg; if (!this->HandleCommandLineArguments(i, args, errormsg)) { - cmSystemTools::Error(errormsg.c_str()); + cmSystemTools::Error(errormsg); return 1; } @@ -2469,8 +2472,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) bool erroroc = cmSystemTools::GetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag(); - if (!mf->ReadListFile(fname.c_str()) || - cmSystemTools::GetErrorOccuredFlag()) { + if (!mf->ReadListFile(fname) || cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: " << fname << std::endl); @@ -2489,15 +2491,13 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) gl.RecurseOn(); gl.FindFiles(rexpr); std::vector<std::string>& files = gl.GetFiles(); - std::vector<std::string>::iterator fileIt; - for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) { + for (const std::string& file : files) { cmCTestLog(this, DEBUG, - "* Read custom CTest configuration file: " << *fileIt + "* Read custom CTest configuration file: " << file << std::endl); - if (!mf->ReadListFile(fileIt->c_str()) || - cmSystemTools::GetErrorOccuredFlag()) { + if (!mf->ReadListFile(file) || cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this, ERROR_MESSAGE, - "Problem reading custom configuration: " << *fileIt + "Problem reading custom configuration: " << file << std::endl); } } @@ -2626,6 +2626,32 @@ void cmCTest::SetCTestConfiguration(const char* name, const char* value, this->CTestConfiguration[name] = value; } +std::string cmCTest::GetSubmitURL() +{ + std::string url = this->GetCTestConfiguration("SubmitURL"); + if (url.empty()) { + std::string method = this->GetCTestConfiguration("DropMethod"); + std::string user = this->GetCTestConfiguration("DropSiteUser"); + std::string password = this->GetCTestConfiguration("DropSitePassword"); + std::string site = this->GetCTestConfiguration("DropSite"); + std::string location = this->GetCTestConfiguration("DropLocation"); + + url = method.empty() ? "http" : method; + url += "://"; + if (!user.empty()) { + url += user; + if (!password.empty()) { + url += ':'; + url += password; + } + url += '@'; + } + url += site; + url += location; + } + return url; +} + std::string cmCTest::GetCurrentTag() { return this->CurrentTag; @@ -2690,7 +2716,7 @@ void cmCTest::SetSpecificTrack(const char* track) void cmCTest::AddSubmitFile(Part part, const char* name) { - this->Parts[part].SubmitFiles.push_back(name); + this->Parts[part].SubmitFiles.emplace_back(name); } void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr) @@ -2781,13 +2807,13 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args, if ((res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) && this->ExtraVerbose) { processOutput.DecodeText(data, length, strdata); - cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + cmSystemTools::Stdout(strdata); } } if (this->ExtraVerbose) { processOutput.DecodeText(std::string(), strdata); if (!strdata.empty()) { - cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + cmSystemTools::Stdout(strdata); } } diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 2b40ca3e94..92a02c3169 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -57,8 +57,6 @@ public: /** Representation of one part. */ struct PartInfo { - PartInfo() {} - void SetName(const std::string& name) { this->Name = name; } const std::string& GetName() const { return this->Name; } @@ -176,6 +174,8 @@ public: bool suppress = false); void EmptyCTestConfiguration(); + std::string GetSubmitURL(); + /** * constructor and destructor */ diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index e1d312bbdb..2728f0f9a0 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -16,7 +16,6 @@ #include "cmState.h" #include "cmSystemTools.h" #include "cmVersion.h" -#include "cmake.h" cmCacheManager::cmCacheManager() { @@ -27,7 +26,7 @@ cmCacheManager::cmCacheManager() void cmCacheManager::CleanCMakeFiles(const std::string& path) { std::string glob = path; - glob += cmake::GetCMakeFilesDirectory(); + glob += "/CMakeFiles"; glob += "/*.cmake"; cmsys::Glob globIt; globIt.FindFiles(glob); @@ -123,7 +122,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, std::ostringstream error; error << "Parse error in cache file " << cacheFile; error << " on line " << lineno << ". Offending entry: " << realbuffer; - cmSystemTools::Error(error.str().c_str()); + cmSystemTools::Error(error.str()); } } this->CacheMajorVersion = 0; @@ -171,7 +170,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, << " where CMakeCache.txt was created. This may result " "in binaries being created in the wrong place. If you " "are not sure, reedit the CMakeCache.txt"; - cmSystemTools::Error(message.str().c_str()); + cmSystemTools::Error(message.str()); } } return true; @@ -360,7 +359,7 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger) fout << "\n"; fout.Close(); std::string checkCacheFile = path; - checkCacheFile += cmake::GetCMakeFilesDirectory(); + checkCacheFile += "/CMakeFiles"; cmSystemTools::MakeDirectory(checkCacheFile); checkCacheFile += "/cmake.check_cache"; cmsys::ofstream checkCache(checkCacheFile.c_str()); @@ -384,7 +383,7 @@ bool cmCacheManager::DeleteCache(const std::string& path) cmSystemTools::RemoveFile(cacheFile); // now remove the files in the CMakeFiles directory // this cleans up language cache files - cmakeFiles += cmake::GetCMakeFilesDirectory(); + cmakeFiles += "/CMakeFiles"; if (cmSystemTools::FileIsDirectory(cmakeFiles)) { cmSystemTools::RemoveADirectory(cmakeFiles); } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index b39856ee97..0c70ed27ff 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -42,7 +42,6 @@ private: void AppendProperty(const std::string& property, const char* value, bool asString = false); bool Initialized = false; - CacheEntry() {} }; public: diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index ecfcfb9657..ee5feee763 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -46,7 +46,7 @@ static bool LogErrorsAsMessages; << std::endl; \ _hresult_oss.flags(std::ios::dec); \ _hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \ - cmSystemTools::Message(_hresult_oss.str().c_str()); \ + cmSystemTools::Message(_hresult_oss.str()); \ } \ } @@ -446,7 +446,7 @@ int cmCallVisualStudioMacro::CallMacro(const std::string& slnFile, if (err && LogErrorsAsMessages) { std::ostringstream oss; oss << "cmCallVisualStudioMacro::CallMacro failed, err = " << err; - cmSystemTools::Message(oss.str().c_str()); + cmSystemTools::Message(oss.str()); } return 0; diff --git a/Source/cmCommand.h b/Source/cmCommand.h index dfc3e78f58..07333bbba9 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -30,12 +30,12 @@ public: /** * Construct the command. By default it has no makefile. */ - cmCommand() {} + cmCommand() = default; /** * Need virtual destructor to destroy real command type. */ - virtual ~cmCommand() {} + virtual ~cmCommand() = default; /** * Specify the makefile. diff --git a/Source/cmCommandArgumentsHelper.h b/Source/cmCommandArgumentsHelper.h index c68e64c109..9579861e61 100644 --- a/Source/cmCommandArgumentsHelper.h +++ b/Source/cmCommandArgumentsHelper.h @@ -39,7 +39,7 @@ class cmCommandArgument public: cmCommandArgument(cmCommandArgumentsHelper* args, const char* key, cmCommandArgumentGroup* group = nullptr); - virtual ~cmCommandArgument() {} + virtual ~cmCommandArgument() = default; /// this argument may follow after arg. 0 means it comes first. void Follows(const cmCommandArgument* arg); @@ -172,8 +172,6 @@ class cmCommandArgumentGroup friend class cmCommandArgument; public: - cmCommandArgumentGroup() {} - /// All members of this group may follow the given argument void Follows(const cmCommandArgument* arg); diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index a1df27107f..66250f3296 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -29,9 +29,7 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) { } -cmCommonTargetGenerator::~cmCommonTargetGenerator() -{ -} +cmCommonTargetGenerator::~cmCommonTargetGenerator() = default; std::string const& cmCommonTargetGenerator::GetConfigName() const { @@ -198,7 +196,7 @@ std::string cmCommonTargetGenerator::GetManifests() manifests.reserve(manifest_srcs.size()); for (cmSourceFile const* manifest_src : manifest_srcs) { manifests.push_back(this->LocalCommonGenerator->ConvertToOutputFormat( - this->LocalCommonGenerator->ConvertToRelativePath( + this->LocalCommonGenerator->MaybeConvertToRelativePath( this->LocalCommonGenerator->GetWorkingDirectory(), manifest_src->GetFullPath()), cmOutputConverter::SHELL)); diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx index 5820df6f09..113463f634 100644 --- a/Source/cmComputeComponentGraph.cxx +++ b/Source/cmComputeComponentGraph.cxx @@ -18,9 +18,7 @@ cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input) this->TransferEdges(); } -cmComputeComponentGraph::~cmComputeComponentGraph() -{ -} +cmComputeComponentGraph::~cmComputeComponentGraph() = default; void cmComputeComponentGraph::Tarjan() { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 32a2a628ac..252f8748ce 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -38,14 +38,6 @@ public: cmGeneratorTarget const* Target = nullptr; bool IsSharedDep = false; bool IsFlag = false; - LinkEntry() {} - LinkEntry(LinkEntry const& r) - : Item(r.Item) - , Target(r.Target) - , IsSharedDep(r.IsSharedDep) - , IsFlag(r.IsFlag) - { - } }; typedef std::vector<LinkEntry> EntryVector; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 4274cb46bd..3d61665fd3 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -884,12 +884,12 @@ void cmComputeLinkInformation::AddLinkExtension(const char* e, LinkType type) { if (e && *e) { if (type == LinkStatic) { - this->StaticLinkExtensions.push_back(e); + this->StaticLinkExtensions.emplace_back(e); } if (type == LinkShared) { - this->SharedLinkExtensions.push_back(e); + this->SharedLinkExtensions.emplace_back(e); } - this->LinkExtensions.push_back(e); + this->LinkExtensions.emplace_back(e); } } @@ -1237,7 +1237,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item) std::ostringstream e; e << "Could not parse framework path \"" << item << "\" " << "linked by target " << this->Target->GetName() << "."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } @@ -1282,7 +1282,7 @@ void cmComputeLinkInformation::DropDirectoryItem(std::string const& item) << "\" requests linking to directory \"" << item << "\". " << "Targets may link only to libraries. " << "CMake is dropping the item."; - cmSystemTools::Message(e.str().c_str()); + cmSystemTools::Message(e.str()); } void cmComputeLinkInformation::ComputeFrameworkInfo() diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index db7eb96cfb..863639c6ab 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -9,6 +9,7 @@ #include <iosfwd> #include <set> #include <string> +#include <utility> #include <vector> class cmGeneratorTarget; @@ -30,10 +31,9 @@ public: struct Item { - Item() {} - Item(std::string const& v, bool p, - cmGeneratorTarget const* target = nullptr) - : Value(v) + Item() = default; + Item(std::string v, bool p, cmGeneratorTarget const* target = nullptr) + : Value(std::move(v)) , IsPath(p) , Target(target) { diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index fde9750162..9b7b02f53d 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -103,9 +103,7 @@ cmComputeTargetDepends::cmComputeTargetDepends(cmGlobalGenerator* gg) cm->GetState()->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES"); } -cmComputeTargetDepends::~cmComputeTargetDepends() -{ -} +cmComputeTargetDepends::~cmComputeTargetDepends() = default; bool cmComputeTargetDepends::Compute() { @@ -495,7 +493,7 @@ void cmComputeTargetDepends::ComplainAboutBadComponent( e << "At least one of these targets is not a STATIC_LIBRARY. " << "Cyclic dependencies are allowed only among static libraries."; } - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); } bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap, diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 33b9cf197a..94ea529ea5 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <utility> #include "cmAlgorithms.h" #include "cmMakefile.h" @@ -53,11 +54,11 @@ static std::string const keyVERSION_LESS = "VERSION_LESS"; static std::string const keyVERSION_LESS_EQUAL = "VERSION_LESS_EQUAL"; cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile, - const cmListFileContext& context, - const cmListFileBacktrace& bt) + cmListFileContext context, + cmListFileBacktrace bt) : Makefile(makefile) - , ExecutionContext(context) - , Backtrace(bt) + , ExecutionContext(std::move(context)) + , Backtrace(std::move(bt)) , Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)) , Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)) , Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)) diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index fc87a2d256..59e1396f68 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -21,8 +21,8 @@ class cmConditionEvaluator public: typedef std::list<cmExpandedCommandArgument> cmArgumentList; - cmConditionEvaluator(cmMakefile& makefile, cmListFileContext const& context, - cmListFileBacktrace const& bt); + cmConditionEvaluator(cmMakefile& makefile, cmListFileContext context, + cmListFileBacktrace bt); // this is a shared function for both If and Else to determine if the // arguments were valid, and if so, was the response true. If there is diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index c80439b135..9d00c21196 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -20,6 +20,7 @@ #cmakedefine CMAKE_USE_ELF_PARSER #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE +#define CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@ #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx index 50e193668c..166426bfc6 100644 --- a/Source/cmConnection.cxx +++ b/Source/cmConnection.cxx @@ -127,9 +127,7 @@ void cmEventBasedConnection::OnDisconnect(int onerror) } } -cmConnection::~cmConnection() -{ -} +cmConnection::~cmConnection() = default; bool cmConnection::OnConnectionShuttingDown() { diff --git a/Source/cmConnection.h b/Source/cmConnection.h index ce2d2dc2aa..3a7f1b9044 100644 --- a/Source/cmConnection.h +++ b/Source/cmConnection.h @@ -63,7 +63,7 @@ class cmConnection CM_DISABLE_COPY(cmConnection) public: - cmConnection() {} + cmConnection() = default; virtual void WriteData(const std::string& data) = 0; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index a483fd17d6..bd110ecc58 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -57,6 +57,12 @@ static std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES = "CMAKE_TRY_COMPILE_PLATFORM_VARIABLES"; static std::string const kCMAKE_WARN_DEPRECATED = "CMAKE_WARN_DEPRECATED"; +/* GHS Multi platform variables */ +static std::set<std::string> ghs_platform_vars{ + "GHS_TARGET_PLATFORM", "GHS_PRIMARY_TARGET", "GHS_TOOLSET_ROOT", + "GHS_OS_ROOT", "GHS_OS_DIR", "GHS_BSP_NAME" +}; + static void writeProperty(FILE* fout, std::string const& targetName, std::string const& prop, std::string const& value) { @@ -394,7 +400,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, // compute the binary dir when TRY_COMPILE is called with a src file // signature if (this->SrcFileSignature) { - this->BinaryDirectory += cmake::GetCMakeFilesDirectory(); + this->BinaryDirectory += "/CMakeFiles"; this->BinaryDirectory += "/CMakeTmp"; } else { // only valid for srcfile signatures @@ -593,7 +599,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n"); // handle any compile flags we need to pass on if (!compileDefs.empty()) { - fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str()); + // Pass using bracket arguments to preserve content. + fprintf(fout, "add_definitions([==[%s]==])\n", + cmJoin(compileDefs, "]==] [==[").c_str()); } /* Use a random file name to avoid rapid creation and deletion @@ -869,6 +877,16 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, projectName = "CMAKE_TRY_COMPILE"; } + if (this->Makefile->GetState()->UseGhsMultiIDE()) { + // Forward the GHS variables to the inner project cache. + for (std::string const& var : ghs_platform_vars) { + if (const char* val = this->Makefile->GetDefinition(var)) { + std::string flag = "-D" + var + "=" + val; + cmakeFlags.push_back(std::move(flag)); + } + } + } + bool erroroc = cmSystemTools::GetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag(); std::string output; @@ -1005,12 +1023,12 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName, tmp += config; searchDirs.push_back(std::move(tmp)); } - searchDirs.push_back("/Debug"); + searchDirs.emplace_back("/Debug"); #if defined(__APPLE__) std::string app = "/Debug/" + targetName + ".app"; searchDirs.push_back(std::move(app)); #endif - searchDirs.push_back("/Development"); + searchDirs.emplace_back("/Development"); for (std::string const& sdir : searchDirs) { std::string command = this->BinaryDirectory; diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 9dcec2f85c..242ceaab47 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -4,17 +4,19 @@ #include "cmMakefile.h" +#include <utility> + cmCustomCommand::cmCustomCommand(cmMakefile const* mf, - const std::vector<std::string>& outputs, - const std::vector<std::string>& byproducts, - const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, + std::vector<std::string> outputs, + std::vector<std::string> byproducts, + std::vector<std::string> depends, + cmCustomCommandLines commandLines, const char* comment, const char* workingDirectory) - : Outputs(outputs) - , Byproducts(byproducts) - , Depends(depends) - , CommandLines(commandLines) + : Outputs(std::move(outputs)) + , Byproducts(std::move(byproducts)) + , Depends(std::move(depends)) + , CommandLines(std::move(commandLines)) , Comment(comment ? comment : "") , WorkingDirectory(workingDirectory ? workingDirectory : "") , HaveComment(comment != nullptr) diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index d82160bad9..50f15a46fd 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -23,12 +23,11 @@ class cmCustomCommand { public: /** Main constructor specifies all information for the command. */ - cmCustomCommand(cmMakefile const* mf, - const std::vector<std::string>& outputs, - const std::vector<std::string>& byproducts, - const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, - const char* comment, const char* workingDirectory); + cmCustomCommand(cmMakefile const* mf, std::vector<std::string> outputs, + std::vector<std::string> byproducts, + std::vector<std::string> depends, + cmCustomCommandLines commandLines, const char* comment, + const char* workingDirectory); /** Get the output file produced by the command. */ const std::vector<std::string>& GetOutputs() const; diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index d1c173670b..6bf99468ee 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -16,10 +16,10 @@ #include <utility> cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, - const std::string& config, + std::string config, cmLocalGenerator* lg) : CC(cc) - , Config(config) + , Config(std::move(config)) , LG(lg) , OldStyle(cc.GetEscapeOldStyle()) , MakeVars(cc.GetEscapeAllowMakeVars()) diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index b7e2a39248..9684cffa87 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -29,8 +29,8 @@ class cmCustomCommandGenerator const char* GetArgv0Location(unsigned int c) const; public: - cmCustomCommandGenerator(cmCustomCommand const& cc, - const std::string& config, cmLocalGenerator* lg); + cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config, + cmLocalGenerator* lg); ~cmCustomCommandGenerator(); cmCustomCommand const& GetCC() const { return this->CC; } unsigned int GetNumberOfCommands() const; diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index b2794fa9b7..6c252bee53 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -47,7 +47,7 @@ private: typedef std::string std_string; public: - Def() {} + Def() = default; Def(const char* v) : std_string(v ? v : "") , Exists(v ? true : false) diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 2acb01509f..7d1d316249 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -13,9 +13,9 @@ #include <string.h> #include <utility> -cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir) +cmDepends::cmDepends(cmLocalGenerator* lg, std::string targetDir) : LocalGenerator(lg) - , TargetDirectory(targetDir) + , TargetDirectory(std::move(targetDir)) , Dependee(new char[MaxPath]) , Depender(new char[MaxPath]) { @@ -65,12 +65,13 @@ bool cmDepends::Finalize(std::ostream& /*unused*/, std::ostream& /*unused*/) return true; } -bool cmDepends::Check(const char* makeFile, const char* internalFile, +bool cmDepends::Check(const std::string& makeFile, + const std::string& internalFile, std::map<std::string, DependencyVector>& validDeps) { // Check whether dependencies must be regenerated. bool okay = true; - cmsys::ifstream fin(internalFile); + cmsys::ifstream fin(internalFile.c_str()); if (!(fin && this->CheckDependencies(fin, internalFile, validDeps))) { // Clear all dependencies so they will be regenerated. this->Clear(makeFile); @@ -81,13 +82,13 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile, return okay; } -void cmDepends::Clear(const char* file) +void cmDepends::Clear(const std::string& file) { // Print verbose output. if (this->Verbose) { std::ostringstream msg; msg << "Clearing dependencies in \"" << file << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } // Write an empty dependency file. @@ -107,7 +108,7 @@ bool cmDepends::WriteDependencies(const std::set<std::string>& /*unused*/, } bool cmDepends::CheckDependencies( - std::istream& internalDepends, const char* internalDependsFileName, + std::istream& internalDepends, const std::string& internalDependsFileName, std::map<std::string, DependencyVector>& validDeps) { // Parse dependencies from the stream. If any dependee is missing @@ -155,8 +156,8 @@ bool cmDepends::CheckDependencies( // * if the depender does not exist, but the dependee is newer than the // depends file bool regenerate = false; - const char* dependee = this->Dependee + 1; - const char* depender = this->Depender; + const std::string dependee(this->Dependee + 1); + const std::string depender(this->Depender); if (currentDependencies != nullptr) { currentDependencies->push_back(dependee); } @@ -170,7 +171,7 @@ bool cmDepends::CheckDependencies( std::ostringstream msg; msg << "Dependee \"" << dependee << "\" does not exist for depender \"" << depender << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } } else { if (dependerExists) { @@ -187,7 +188,7 @@ bool cmDepends::CheckDependencies( std::ostringstream msg; msg << "Dependee \"" << dependee << "\" is newer than depender \"" << depender << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } } } else { @@ -206,7 +207,7 @@ bool cmDepends::CheckDependencies( msg << "Dependee \"" << dependee << "\" is newer than depends file \"" << internalDependsFileName << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } } } diff --git a/Source/cmDepends.h b/Source/cmDepends.h index 705d215522..c5e1d5bd9f 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -29,7 +29,7 @@ class cmDepends public: /** Instances need to know the build directory name and the relative path from the build directory to the target file. */ - cmDepends(cmLocalGenerator* lg = nullptr, const char* targetDir = ""); + cmDepends(cmLocalGenerator* lg = nullptr, std::string targetDir = ""); /** Set the local generator for the directory in which we are scanning dependencies. This is not a full local generator; it @@ -41,7 +41,10 @@ public: void SetLanguage(const std::string& lang) { this->Language = lang; } /** Set the target build directory. */ - void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; } + void SetTargetDirectory(const std::string& dir) + { + this->TargetDirectory = dir; + } /** should this be verbose in its output */ void SetVerbose(bool verb) { this->Verbose = verb; } @@ -61,11 +64,11 @@ public: they must be generated Clear has already been called to wipe out the old dependencies. Dependencies which are still valid will be stored in validDeps. */ - bool Check(const char* makeFile, const char* internalFile, + bool Check(const std::string& makeFile, const std::string& internalFile, std::map<std::string, DependencyVector>& validDeps); /** Clear dependencies for the target file so they will be regenerated. */ - void Clear(const char* file); + void Clear(const std::string& file); /** Set the file comparison object */ void SetFileComparison(cmFileTimeComparison* fc) @@ -85,7 +88,7 @@ protected: // Return false if dependencies must be regenerated and true // otherwise. virtual bool CheckDependencies( - std::istream& internalDepends, const char* internalDependsFileName, + std::istream& internalDepends, const std::string& internalDependsFileName, std::map<std::string, DependencyVector>& validDeps); // Finalize the dependency information for the target. diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 072d1161c5..b1630f9ae5 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -19,12 +19,10 @@ #define INCLUDE_REGEX_COMPLAIN_MARKER "#IncludeRegexComplain: " #define INCLUDE_REGEX_TRANSFORM_MARKER "#IncludeRegexTransform: " -cmDependsC::cmDependsC() -{ -} +cmDependsC::cmDependsC() = default; cmDependsC::cmDependsC( - cmLocalGenerator* lg, const char* targetDir, const std::string& lang, + cmLocalGenerator* lg, const std::string& targetDir, const std::string& lang, const std::map<std::string, DependencyVector>* validDeps) : cmDepends(lg, targetDir) , ValidDeps(validDeps) @@ -53,8 +51,8 @@ cmDependsC::cmDependsC( } this->IncludeRegexLine.compile(INCLUDE_REGEX_LINE); - this->IncludeRegexScan.compile(scanRegex.c_str()); - this->IncludeRegexComplain.compile(complainRegex.c_str()); + this->IncludeRegexScan.compile(scanRegex); + this->IncludeRegexComplain.compile(complainRegex); this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE; this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER; this->IncludeRegexScanString += scanRegex; @@ -100,7 +98,8 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, // Compute a path to the object file to write to the internal depend file. // Any existing content of the internal depend file has already been // loaded in ValidDeps with this path as a key. - std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj); + std::string obj_i = + this->LocalGenerator->MaybeConvertToRelativePath(binDir, obj); if (this->ValidDeps != nullptr) { std::map<std::string, DependencyVector>::const_iterator tmpIt = @@ -212,7 +211,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, // Scan this file for new dependencies. Pass the directory // containing the file to handle double-quote includes. std::string dir = cmSystemTools::GetFilenamePath(fullName); - this->Scan(fin, dir.c_str(), fullName); + this->Scan(fin, dir, fullName); } else { // Skip file with encoding we do not implement. } @@ -234,7 +233,8 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, for (std::string const& dep : dependencies) { makeDepends << obj_m << ": " << cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->ConvertToRelativePath(binDir, dep)) + this->LocalGenerator->MaybeConvertToRelativePath(binDir, + dep)) << std::endl; internalDepends << " " << dep << std::endl; } @@ -268,8 +268,7 @@ void cmDependsC::ReadCacheFile() haveFileName = true; int newer = 0; cmFileTimeComparison comp; - bool res = comp.FileTimeCompare(this->CacheFileName.c_str(), - line.c_str(), &newer); + bool res = comp.FileTimeCompare(this->CacheFileName, line, &newer); if (res && newer == 1) // cache is newer than the parsed file { @@ -342,7 +341,7 @@ void cmDependsC::WriteCacheFile() const } } -void cmDependsC::Scan(std::istream& is, const char* directory, +void cmDependsC::Scan(std::istream& is, const std::string& directory, const std::string& fullName) { cmIncludeLines* newCacheEntry = new cmIncludeLines; @@ -418,7 +417,7 @@ void cmDependsC::SetupTransforms() sep = "|"; } xform += ")[ \t]*\\(([^),]*)\\)"; - this->IncludeRegexTransform.compile(xform.c_str()); + this->IncludeRegexTransform.compile(xform); // Build a string that encodes all transformation rules and will // change when rules are changed. @@ -460,11 +459,11 @@ void cmDependsC::TransformLine(std::string& line) // Construct the transformed line. std::string newline = this->IncludeRegexTransform.match(1); std::string arg = this->IncludeRegexTransform.match(4); - for (const char* c = tri->second.c_str(); *c; ++c) { - if (*c == '%') { + for (char c : tri->second) { + if (c == '%') { newline += arg; } else { - newline += *c; + newline += c; } } diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index f833888b87..411458abf3 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -28,7 +28,7 @@ public: /** Checking instances need to know the build directory name and the relative path from the build directory to the target file. */ cmDependsC(); - cmDependsC(cmLocalGenerator* lg, const char* targetDir, + cmDependsC(cmLocalGenerator* lg, const std::string& targetDir, const std::string& lang, const std::map<std::string, DependencyVector>* validDeps); @@ -42,7 +42,7 @@ protected: std::ostream& internalDepends) override; // Method to scan a single file. - void Scan(std::istream& is, const char* directory, + void Scan(std::istream& is, const std::string& directory, const std::string& fullName); // Regular expression to identify C preprocessor include directives. @@ -75,7 +75,6 @@ public: struct cmIncludeLines { - cmIncludeLines() {} std::vector<UnscannedEntry> UnscannedEntries; bool Used = false; }; diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index e51f81e087..cae3ff600a 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -7,7 +7,6 @@ #include <iostream> #include <map> #include <stdlib.h> -#include <string.h> #include <utility> #include "cmAlgorithms.h" @@ -54,7 +53,8 @@ public: typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap; ObjectInfoMap ObjectInfo; - cmFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src) + cmFortranSourceInfo& CreateObjectInfo(const std::string& obj, + const std::string& src) { std::map<std::string, cmFortranSourceInfo>::iterator i = this->ObjectInfo.find(obj); @@ -68,9 +68,7 @@ public: } }; -cmDependsFortran::cmDependsFortran() -{ -} +cmDependsFortran::cmDependsFortran() = default; cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg) : cmDepends(lg) @@ -121,8 +119,7 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources, bool okay = true; for (std::string const& src : sources) { // Get the information object for this source. - cmFortranSourceInfo& info = - this->Internal->CreateObjectInfo(obj.c_str(), src.c_str()); + cmFortranSourceInfo& info = this->Internal->CreateObjectInfo(obj, src); // Create the parser object. The constructor takes info by reference, // so we may look into the resulting objects later. @@ -153,7 +150,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, this->LocateModules(); // Get the directory in which stamp files will be stored. - const char* stamp_dir = this->TargetDirectory.c_str(); + const std::string& stamp_dir = this->TargetDirectory; // Get the directory in which module files will be created. cmMakefile* mf = this->LocalGenerator->GetMakefile(); @@ -167,9 +164,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap; ObjectInfoMap const& objInfo = this->Internal->ObjectInfo; for (auto const& i : objInfo) { - if (!this->WriteDependenciesReal(i.first.c_str(), i.second, mod_dir, - stamp_dir, makeDepends, - internalDepends)) { + if (!this->WriteDependenciesReal(i.first, i.second, mod_dir, stamp_dir, + makeDepends, internalDepends)) { return false; } } @@ -256,22 +252,22 @@ void cmDependsFortran::LocateModules() std::string fname = targetDir + "/fortran.internal"; cmsys::ifstream fin(fname.c_str()); if (fin) { - this->MatchRemoteModules(fin, targetDir.c_str()); + this->MatchRemoteModules(fin, targetDir); } } } void cmDependsFortran::MatchLocalModules() { - const char* stampDir = this->TargetDirectory.c_str(); + std::string const& stampDir = this->TargetDirectory; std::set<std::string> const& provides = this->Internal->TargetProvides; for (std::string const& i : provides) { - this->ConsiderModule(i.c_str(), stampDir); + this->ConsiderModule(i, stampDir); } } void cmDependsFortran::MatchRemoteModules(std::istream& fin, - const char* stampDir) + const std::string& stampDir) { std::string line; bool doing_provides = false; @@ -300,7 +296,8 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin, } } -void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir) +void cmDependsFortran::ConsiderModule(const std::string& name, + const std::string& stampDir) { // Locate each required module. typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap; @@ -317,17 +314,17 @@ void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir) } } -bool cmDependsFortran::WriteDependenciesReal(const char* obj, +bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, cmFortranSourceInfo const& info, std::string const& mod_dir, - const char* stamp_dir, + std::string const& stamp_dir, std::ostream& makeDepends, std::ostream& internalDepends) { typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap; // Get the source file for this object. - const char* src = info.Source.c_str(); + std::string const& src = info.Source; // Write the include dependencies to the output stream. std::string binDir = this->LocalGenerator->GetBinaryDirectory(); @@ -502,8 +499,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) cmFortranModuleAppendUpperLower(cmSystemTools::GetFilenameName(mod), mod_upper, mod_lower); if (cmSystemTools::FileExists(mod_upper, true)) { - if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(), - compilerId.c_str())) { + if (cmDependsFortran::ModulesDiffer(mod_upper, stamp, compilerId)) { if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) { std::cerr << "Error copying Fortran module from \"" << mod_upper << "\" to \"" << stamp << "\".\n"; @@ -513,8 +509,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) return true; } if (cmSystemTools::FileExists(mod_lower, true)) { - if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(), - compilerId.c_str())) { + if (cmDependsFortran::ModulesDiffer(mod_lower, stamp, compilerId)) { if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) { std::cerr << "Error copying Fortran module from \"" << mod_lower << "\" to \"" << stamp << "\".\n"; @@ -581,9 +576,9 @@ static bool cmFortranStreamsDiffer(std::istream& ifs1, std::istream& ifs2) return true; } -bool cmDependsFortran::ModulesDiffer(const char* modFile, - const char* stampFile, - const char* compilerId) +bool cmDependsFortran::ModulesDiffer(const std::string& modFile, + const std::string& stampFile, + const std::string& compilerId) { /* gnu >= 4.9: @@ -617,16 +612,17 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, * source is compiled twice * -SunPro */ - if (strcmp(compilerId, "SunPro") == 0) { + if (compilerId == "SunPro") { return cmSystemTools::FilesDiffer(modFile, stampFile); } #if defined(_WIN32) || defined(__CYGWIN__) - cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary); - cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary); + cmsys::ifstream finModFile(modFile.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream finStampFile(stampFile.c_str(), + std::ios::in | std::ios::binary); #else - cmsys::ifstream finModFile(modFile); - cmsys::ifstream finStampFile(stampFile); + cmsys::ifstream finModFile(modFile.c_str()); + cmsys::ifstream finStampFile(stampFile.c_str()); #endif if (!finModFile || !finStampFile) { // At least one of the files does not exist. The modules differ. @@ -641,7 +637,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, * Eat the stream content until all recompile only related changes * are left behind. */ - if (strcmp(compilerId, "GNU") == 0) { + if (compilerId == "GNU") { // GNU Fortran 4.9 and later compress .mod files with gzip // but also do not include a date so we can fall through to // compare them without skipping any prefix. @@ -664,7 +660,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, return true; } } - } else if (strcmp(compilerId, "Intel") == 0) { + } else if (compilerId == "Intel") { const char seq[2] = { '\n', '\0' }; const int seqlen = 2; diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index 5d96dd49ce..f5f5be2d23 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -44,8 +44,9 @@ public: /** Determine if a mod file and the corresponding mod.stamp file are representing different module information. */ - static bool ModulesDiffer(const char* modFile, const char* stampFile, - const char* compilerId); + static bool ModulesDiffer(const std::string& modFile, + const std::string& stampFile, + const std::string& compilerId); protected: // Finalize the dependency information for the target. @@ -55,8 +56,8 @@ protected: // Find all the modules required by the target. void LocateModules(); void MatchLocalModules(); - void MatchRemoteModules(std::istream& fin, const char* stampDir); - void ConsiderModule(const char* name, const char* stampDir); + void MatchRemoteModules(std::istream& fin, const std::string& stampDir); + void ConsiderModule(const std::string& name, const std::string& stampDir); bool FindModule(std::string const& name, std::string& module); // Implement writing/checking methods required by superclass. @@ -65,8 +66,10 @@ protected: std::ostream& internalDepends) override; // Actually write the dependencies to the streams. - bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info, - std::string const& mod_dir, const char* stamp_dir, + bool WriteDependenciesReal(std::string const& obj, + cmFortranSourceInfo const& info, + std::string const& mod_dir, + std::string const& stamp_dir, std::ostream& makeDepends, std::ostream& internalDepends); diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx index 29938ba36d..2485e15fd7 100644 --- a/Source/cmDependsJava.cxx +++ b/Source/cmDependsJava.cxx @@ -4,13 +4,9 @@ #include "cmSystemTools.h" -cmDependsJava::cmDependsJava() -{ -} +cmDependsJava::cmDependsJava() = default; -cmDependsJava::~cmDependsJava() -{ -} +cmDependsJava::~cmDependsJava() = default; bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources, const std::string& /*obj*/, @@ -27,7 +23,8 @@ bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources, } bool cmDependsJava::CheckDependencies( - std::istream& /*internalDepends*/, const char* /*internalDependsFileName*/, + std::istream& /*internalDepends*/, + const std::string& /*internalDependsFileName*/, std::map<std::string, DependencyVector>& /*validDeps*/) { return true; diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h index d070840ad0..1928c512bc 100644 --- a/Source/cmDependsJava.h +++ b/Source/cmDependsJava.h @@ -33,7 +33,7 @@ protected: const std::string& file, std::ostream& makeDepends, std::ostream& internalDepends) override; bool CheckDependencies( - std::istream& internalDepends, const char* internalDependsFileName, + std::istream& internalDepends, const std::string& internalDependsFileName, std::map<std::string, DependencyVector>& validDeps) override; }; diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 02db119785..792db48a47 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -68,7 +68,7 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass) return; } } - this->ClassesFound.push_back(sclass); + this->ClassesFound.emplace_back(sclass); } void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass) @@ -78,7 +78,7 @@ void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass) return; } } - this->PackagesImport.push_back(sclass); + this->PackagesImport.emplace_back(sclass); } void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line, diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 6a817b4106..d4628fa7ef 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -43,11 +43,18 @@ static const char* cmDocumentationStandardOptions[][2] = { { nullptr, nullptr } }; -static const char* cmDocumentationGeneratorsHeader[][2] = { +static const char* cmDocumentationCPackGeneratorsHeader[][2] = { { nullptr, "The following generators are available on this platform:" }, { nullptr, nullptr } }; +static const char* cmDocumentationCMakeGeneratorsHeader[][2] = { + { nullptr, + "The following generators are available on this platform (* marks " + "default):" }, + { nullptr, nullptr } +}; + cmDocumentation::cmDocumentation() { this->addCommonStandardDocSections(); @@ -178,7 +185,7 @@ void cmDocumentation::addCommonStandardDocSections() void cmDocumentation::addCMakeStandardDocSections() { cmDocumentationSection sec{ "Generators" }; - sec.Append(cmDocumentationGeneratorsHeader); + sec.Append(cmDocumentationCMakeGeneratorsHeader); this->AllSections.emplace("Generators", std::move(sec)); } @@ -191,7 +198,9 @@ void cmDocumentation::addCTestStandardDocSections() void cmDocumentation::addCPackStandardDocSections() { - addCMakeStandardDocSections(); + cmDocumentationSection sec{ "Generators" }; + sec.Append(cmDocumentationCPackGeneratorsHeader); + this->AllSections.emplace("Generators", std::move(sec)); } bool cmDocumentation::CheckOptions(int argc, const char* const* argv, diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index b2ff01a52e..cf74b800d1 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -115,7 +115,6 @@ private: struct RequestedHelpItem { - RequestedHelpItem() {} cmDocumentationEnums::Type HelpType = None; std::string Filename; std::string Argument; diff --git a/Source/cmDocumentationEntry.h b/Source/cmDocumentationEntry.h index ea43b88c3b..afbca5e4bb 100644 --- a/Source/cmDocumentationEntry.h +++ b/Source/cmDocumentationEntry.h @@ -12,7 +12,8 @@ struct cmDocumentationEntry { std::string Name; std::string Brief; - cmDocumentationEntry() {} + char CustomNamePrefix = ' '; + cmDocumentationEntry() = default; cmDocumentationEntry(const char* doc[2]) { if (doc[0]) { diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index 678e4087dc..3e7f9897eb 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -5,18 +5,15 @@ #include "cmDocumentationEntry.h" #include "cmDocumentationSection.h" +#include <iomanip> #include <ostream> #include <string.h> #include <string> #include <vector> -cmDocumentationFormatter::cmDocumentationFormatter() -{ -} +cmDocumentationFormatter::cmDocumentationFormatter() = default; -cmDocumentationFormatter::~cmDocumentationFormatter() -{ -} +cmDocumentationFormatter::~cmDocumentationFormatter() = default; void cmDocumentationFormatter::PrintFormatted(std::ostream& os, const char* text) @@ -168,7 +165,7 @@ void cmDocumentationFormatter::PrintSection( const std::vector<cmDocumentationEntry>& entries = section.GetEntries(); for (cmDocumentationEntry const& entry : entries) { if (!entry.Name.empty()) { - os << " " << entry.Name; + os << std::setw(2) << std::left << entry.CustomNamePrefix << entry.Name; this->TextIndent = " "; int align = static_cast<int>(strlen(this->TextIndent)) - 4; for (int i = static_cast<int>(entry.Name.size()); i < align; ++i) { diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx index 7da6ff54b7..0549cf916d 100644 --- a/Source/cmDynamicLoader.cxx +++ b/Source/cmDynamicLoader.cxx @@ -24,9 +24,7 @@ private: cmDynamicLoaderCache* cmDynamicLoaderCache::Instance = nullptr; -cmDynamicLoaderCache::~cmDynamicLoaderCache() -{ -} +cmDynamicLoaderCache::~cmDynamicLoaderCache() = default; void cmDynamicLoaderCache::CacheFile(const char* path, cmsys::DynamicLoader::LibraryHandle p) diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h index 61d3b468bb..e9fe97ad09 100644 --- a/Source/cmDynamicLoader.h +++ b/Source/cmDynamicLoader.h @@ -28,8 +28,8 @@ public: static void FlushCache(); protected: - cmDynamicLoader() {} - ~cmDynamicLoader() {} + cmDynamicLoader() = default; + ~cmDynamicLoader() = default; }; #endif diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index ea4cd40718..75a7786a43 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -217,11 +217,11 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output, int p; cmProcessOutput processOutput(encoding); std::string strdata; - while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) { + while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) { if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) { if (verbose) { processOutput.DecodeText(data, length, strdata); - cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + cmSystemTools::Stdout(strdata); } output.append(data, length); } @@ -230,7 +230,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output, if (verbose) { processOutput.DecodeText(std::string(), strdata); if (!strdata.empty()) { - cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + cmSystemTools::Stdout(strdata); } } @@ -270,7 +270,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output, } msg += "\n"; if (verbose) { - cmSystemTools::Stdout(msg.c_str()); + cmSystemTools::Stdout(msg); } output += msg; #else diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 679a648140..8c67cdb4ef 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -54,7 +54,7 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, if (args[i] == "COMMAND") { doing_command = true; command_index = cmds.size(); - cmds.push_back(std::vector<const char*>()); + cmds.emplace_back(); } else if (args[i] == "OUTPUT_VARIABLE") { doing_command = false; if (++i < args.size()) { @@ -244,19 +244,19 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, int p; cmProcessOutput processOutput(encoding); std::string strdata; - while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) { + while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) { // Put the output in the right place. if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) { if (output_variable.empty()) { processOutput.DecodeText(data, length, strdata, 1); - cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + cmSystemTools::Stdout(strdata); } else { cmExecuteProcessCommandAppend(tempOutput, data, length); } } else if (p == cmsysProcess_Pipe_STDERR && !error_quiet) { if (error_variable.empty()) { processOutput.DecodeText(data, length, strdata, 2); - cmSystemTools::Stderr(strdata.c_str(), strdata.size()); + cmSystemTools::Stderr(strdata); } else { cmExecuteProcessCommandAppend(tempError, data, length); } @@ -265,13 +265,13 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, if (!output_quiet && output_variable.empty()) { processOutput.DecodeText(std::string(), strdata, 1); if (!strdata.empty()) { - cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + cmSystemTools::Stdout(strdata); } } if (!error_quiet && error_variable.empty()) { processOutput.DecodeText(std::string(), strdata, 2); if (!strdata.empty()) { - cmSystemTools::Stderr(strdata.c_str(), strdata.size()); + cmSystemTools::Stderr(strdata); } } @@ -327,15 +327,15 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, cmsysProcess_GetExitValueByIndex(cp, static_cast<int>(i)); char buf[16]; sprintf(buf, "%d", exitCode); - res.push_back(buf); + res.emplace_back(buf); } break; case kwsysProcess_StateByIndex_Exception: - res.push_back(cmsysProcess_GetExceptionStringByIndex( + res.emplace_back(cmsysProcess_GetExceptionStringByIndex( cp, static_cast<int>(i))); break; case kwsysProcess_StateByIndex_Error: default: - res.push_back("Error getting the child return code"); + res.emplace_back("Error getting the child return code"); break; } } diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h index 19462313d5..56199dd935 100644 --- a/Source/cmExecutionStatus.h +++ b/Source/cmExecutionStatus.h @@ -11,8 +11,6 @@ class cmExecutionStatus { public: - cmExecutionStatus() {} - void Clear() { this->ReturnInvoked = false; diff --git a/Source/cmExpandedCommandArgument.cxx b/Source/cmExpandedCommandArgument.cxx index 650a5ad617..43f648bc3a 100644 --- a/Source/cmExpandedCommandArgument.cxx +++ b/Source/cmExpandedCommandArgument.cxx @@ -2,13 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExpandedCommandArgument.h" -cmExpandedCommandArgument::cmExpandedCommandArgument() -{ -} +#include <utility> + +cmExpandedCommandArgument::cmExpandedCommandArgument() = default; -cmExpandedCommandArgument::cmExpandedCommandArgument(std::string const& value, +cmExpandedCommandArgument::cmExpandedCommandArgument(std::string value, bool quoted) - : Value(value) + : Value(std::move(value)) , Quoted(quoted) { } diff --git a/Source/cmExpandedCommandArgument.h b/Source/cmExpandedCommandArgument.h index d71fc92c10..69d35debed 100644 --- a/Source/cmExpandedCommandArgument.h +++ b/Source/cmExpandedCommandArgument.h @@ -18,7 +18,7 @@ class cmExpandedCommandArgument { public: cmExpandedCommandArgument(); - cmExpandedCommandArgument(std::string const& value, bool quoted); + cmExpandedCommandArgument(std::string value, bool quoted); std::string const& GetValue() const; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index c6b66a3694..c8f743acd5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -83,7 +83,7 @@ bool cmExportFileGenerator::GenerateImportFile() std::string se = cmSystemTools::GetLastSystemError(); std::ostringstream e; e << "cannot write to file \"" << this->MainImportFile << "\": " << se; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } std::ostream& os = *foutPtr; diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 41c6538d17..747503e6d0 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -42,7 +42,7 @@ class cmExportFileGenerator { public: cmExportFileGenerator(); - virtual ~cmExportFileGenerator() {} + virtual ~cmExportFileGenerator() = default; /** Set the full path to the export file to generate. */ void SetExportFile(const char* mainFile); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 3821144afc..f8bc0ab0b9 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -54,7 +54,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) << "\" ...) " << "includes target \"" << te->Target->GetName() << "\" more than once in the export set."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } } @@ -112,7 +112,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) std::string errorMessage; if (!this->PopulateExportProperties(gt, properties, errorMessage)) { - cmSystemTools::Error(errorMessage.c_str()); + cmSystemTools::Error(errorMessage); return false; } @@ -294,7 +294,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig( std::string se = cmSystemTools::GetLastSystemError(); std::ostringstream e; e << "cannot write to file \"" << fileName << "\": " << se; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } std::ostream& os = exportFileStream; @@ -518,7 +518,7 @@ void cmExportInstallFileGenerator::ComplainAboutMissingTarget( e << "that is not in this export set, but " << occurrences << " times in others."; } - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); } std::string cmExportInstallFileGenerator::InstallNameDir( diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h index 58ad617d4e..0ef306f639 100644 --- a/Source/cmExportSet.h +++ b/Source/cmExportSet.h @@ -6,6 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <string> +#include <utility> #include <vector> class cmInstallExportGenerator; @@ -17,8 +18,8 @@ class cmExportSet { public: /// Construct an empty export set named \a name - cmExportSet(const std::string& name) - : Name(name) + cmExportSet(std::string name) + : Name(std::move(name)) { } /// Destructor diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx index 8d3dad73e1..80c78a38c8 100644 --- a/Source/cmExprParserHelper.cxx +++ b/Source/cmExprParserHelper.cxx @@ -18,9 +18,7 @@ cmExprParserHelper::cmExprParserHelper() this->Result = 0; } -cmExprParserHelper::~cmExprParserHelper() -{ -} +cmExprParserHelper::~cmExprParserHelper() = default; int cmExprParserHelper::ParseString(const char* str, int verb) { diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index fecd8216ed..ac548112a9 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExternalMakefileProjectGenerator.h" +#include <utility> + class cmMakefile; void cmExternalMakefileProjectGenerator::EnableLanguage( @@ -32,17 +34,14 @@ bool cmExternalMakefileProjectGenerator::Open( } cmExternalMakefileProjectGeneratorFactory:: - cmExternalMakefileProjectGeneratorFactory(const std::string& n, - const std::string& doc) - : Name(n) - , Documentation(doc) + cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc) + : Name(std::move(n)) + , Documentation(std::move(doc)) { } cmExternalMakefileProjectGeneratorFactory:: - ~cmExternalMakefileProjectGeneratorFactory() -{ -} + ~cmExternalMakefileProjectGeneratorFactory() = default; std::string cmExternalMakefileProjectGeneratorFactory::GetName() const { diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index d48abca789..4438f2803b 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -26,7 +26,7 @@ class cmMakefile; class cmExternalMakefileProjectGenerator { public: - virtual ~cmExternalMakefileProjectGenerator() {} + virtual ~cmExternalMakefileProjectGenerator() = default; virtual void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, bool optional); @@ -70,8 +70,7 @@ protected: class cmExternalMakefileProjectGeneratorFactory { public: - cmExternalMakefileProjectGeneratorFactory(const std::string& n, - const std::string& doc); + cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc); virtual ~cmExternalMakefileProjectGeneratorFactory(); std::string GetName() const; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index d70352f24b..397508c61d 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -32,9 +32,7 @@ Discussion: http://forums.codeblocks.org/index.php/topic,6789.0.html */ -cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() -{ -} +cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() = default; cmExternalMakefileProjectGeneratorFactory* cmExtraCodeBlocksGenerator::GetFactory() diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 5833631052..30067b75b6 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -899,7 +899,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const for (cmLocalGenerator* lgen : this->GlobalGenerator->GetLocalGenerators()) { const std::vector<cmGeneratorTarget*>& targets = lgen->GetGeneratorTargets(); - std::string subdir = lgen->ConvertToRelativePath( + std::string subdir = lgen->MaybeConvertToRelativePath( this->HomeOutputDirectory, lgen->GetCurrentBinaryDirectory()); if (subdir == ".") { subdir.clear(); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index a9ed7fe49a..e28a8658df 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -16,9 +16,7 @@ #include <string.h> #include <vector> -cmExtraKateGenerator::cmExtraKateGenerator() -{ -} +cmExtraKateGenerator::cmExtraKateGenerator() = default; cmExternalMakefileProjectGeneratorFactory* cmExtraKateGenerator::GetFactory() { diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index effb4460a9..4b14d26d07 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -117,7 +117,7 @@ void cmFLTKWrapUICommand::FinalPass() msg += ". The problem was found while processing the source directory: "; msg += this->Makefile->GetCurrentSourceDirectory(); msg += ". This FLTK_WRAP_UI call will be ignored."; - cmSystemTools::Message(msg.c_str(), "Warning"); + cmSystemTools::Message(msg, "Warning"); return; } } diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index 89bd25864a..34b6b330d3 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -169,7 +169,7 @@ std::string cmFileAPI::WriteJsonFile( // If the final name already exists then assume it has proper content. // Otherwise, atomically place the reply file at its final name if (cmSystemTools::FileExists(file, true) || - !cmSystemTools::RenameFile(tmpFile.c_str(), file.c_str())) { + !cmSystemTools::RenameFile(tmpFile, file)) { cmSystemTools::RemoveFile(tmpFile); } diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 078d1d51df..4597d4f414 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -166,13 +166,13 @@ class BacktraceData } public: - BacktraceData(std::string const& topSource); + BacktraceData(std::string topSource); bool Add(cmListFileBacktrace const& bt, Json::ArrayIndex& index); Json::Value Dump(); }; -BacktraceData::BacktraceData(std::string const& topSource) - : TopSource(topSource) +BacktraceData::BacktraceData(std::string topSource) + : TopSource(std::move(topSource)) { } @@ -727,7 +727,7 @@ void Target::ProcessLanguage(std::string const& lang) lg->GetTargetDefines(this->GT, this->Config, lang); cd.SetDefines(defines); std::vector<BT<std::string>> includePathList = - lg->GetIncludeDirectories(this->GT, lang, this->Config, true); + lg->GetIncludeDirectories(this->GT, lang, this->Config); for (BT<std::string> const& i : includePathList) { cd.Includes.emplace_back( i, this->GT->IsSystemIncludeDirectory(i.Value, this->Config, lang)); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index db2fde825e..0f911c1700 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -185,6 +185,9 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args, if (subCommand == "READ_SYMLINK") { return this->HandleReadSymlinkCommand(args); } + if (subCommand == "CREATE_LINK") { + return this->HandleCreateLinkCommand(args); + } std::string e = "does not recognize sub-command " + subCommand; this->SetError(e); @@ -558,7 +561,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) if (hex_conversion_enabled) { // TODO: should work without temp file, but just on a memory buffer std::string binaryFileName = this->Makefile->GetCurrentBinaryDirectory(); - binaryFileName += cmake::GetCMakeFilesDirectory(); + binaryFileName += "/CMakeFiles"; binaryFileName += "/FileCommandStringsBinaryFile"; if (cmHexFileConverter::TryConvert(fileName.c_str(), binaryFileName.c_str())) { @@ -1076,7 +1079,7 @@ struct cmFileCopier , Doing(DoingNone) { } - virtual ~cmFileCopier() {} + virtual ~cmFileCopier() = default; bool Run(std::vector<std::string> const& args); @@ -1099,7 +1102,6 @@ protected: { bool Exclude = false; mode_t Permissions = 0; - MatchProperties() {} }; struct MatchRule { @@ -2458,7 +2460,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args) newname += "/" + args[2]; } - if (!cmSystemTools::RenameFile(oldname.c_str(), newname.c_str())) { + if (!cmSystemTools::RenameFile(oldname, newname)) { std::string err = cmSystemTools::GetLastSystemError(); std::ostringstream e; /* clang-format off */ @@ -2913,10 +2915,6 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); check_curl_result(res, "DOWNLOAD cannot set url: "); - // enable auth - res = ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); - check_curl_result(res, "DOWNLOAD cannot set httpauth: "); - // enable HTTP ERROR parsing res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); check_curl_result(res, "DOWNLOAD cannot set http failure option: "); @@ -3216,10 +3214,6 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); check_curl_result(res, "UPLOAD cannot set url: "); - // enable auth - res = ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); - check_curl_result(res, "UPLOAD cannot set httpauth: "); - res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToMemoryCallback); check_curl_result(res, "UPLOAD cannot set write function: "); @@ -3670,3 +3664,118 @@ bool cmFileCommand::HandleReadSymlinkCommand( return true; } + +bool cmFileCommand::HandleCreateLinkCommand( + std::vector<std::string> const& args) +{ + if (args.size() < 3) { + this->SetError("CREATE_LINK must be called with at least two additional " + "arguments"); + return false; + } + + cmCommandArgumentsHelper argHelper; + cmCommandArgumentGroup group; + + cmCAString linkArg(&argHelper, "CREATE_LINK"); + cmCAString fileArg(&argHelper, nullptr); + cmCAString newFileArg(&argHelper, nullptr); + + cmCAString resultArg(&argHelper, "RESULT", &group); + cmCAEnabler copyOnErrorArg(&argHelper, "COPY_ON_ERROR", &group); + cmCAEnabler symbolicArg(&argHelper, "SYMBOLIC", &group); + + linkArg.Follows(nullptr); + fileArg.Follows(&linkArg); + newFileArg.Follows(&fileArg); + group.Follows(&newFileArg); + + std::vector<std::string> unconsumedArgs; + argHelper.Parse(&args, &unconsumedArgs); + + if (!unconsumedArgs.empty()) { + this->SetError("unknown argument: \"" + unconsumedArgs.front() + '\"'); + return false; + } + + std::string fileName = fileArg.GetString(); + std::string newFileName = newFileArg.GetString(); + + // Output variable for storing the result. + const std::string& resultVar = resultArg.GetString(); + + // The system error message generated in the operation. + std::string result; + + // Check if the paths are distinct. + if (fileName == newFileName) { + result = "CREATE_LINK cannot use same file and newfile"; + if (!resultVar.empty()) { + this->Makefile->AddDefinition(resultVar, result.c_str()); + return true; + } + this->SetError(result); + return false; + } + + // Hard link requires original file to exist. + if (!symbolicArg.IsEnabled() && !cmSystemTools::FileExists(fileName)) { + result = "Cannot hard link \'" + fileName + "\' as it does not exist."; + if (!resultVar.empty()) { + this->Makefile->AddDefinition(resultVar, result.c_str()); + return true; + } + this->SetError(result); + return false; + } + + // Check if the new file already exists and remove it. + if ((cmSystemTools::FileExists(newFileName) || + cmSystemTools::FileIsSymlink(newFileName)) && + !cmSystemTools::RemoveFile(newFileName)) { + std::ostringstream e; + e << "Failed to create link '" << newFileName + << "' because existing path cannot be removed: " + << cmSystemTools::GetLastSystemError() << "\n"; + + if (!resultVar.empty()) { + this->Makefile->AddDefinition(resultVar, e.str().c_str()); + return true; + } + this->SetError(e.str()); + return false; + } + + // Whether the operation completed successfully. + bool completed = false; + + // Check if the command requires a symbolic link. + if (symbolicArg.IsEnabled()) { + completed = cmSystemTools::CreateSymlink(fileName, newFileName, &result); + } else { + completed = cmSystemTools::CreateLink(fileName, newFileName, &result); + } + + // Check if copy-on-error is enabled in the arguments. + if (!completed && copyOnErrorArg.IsEnabled()) { + completed = cmSystemTools::cmCopyFile(fileName, newFileName); + if (!completed) { + result = "Copy failed: " + cmSystemTools::GetLastSystemError(); + } + } + + // Check if the operation was successful. + if (completed) { + result = "0"; + } else if (resultVar.empty()) { + // The operation failed and the result is not reported in a variable. + this->SetError(result); + return false; + } + + if (!resultVar.empty()) { + this->Makefile->AddDefinition(resultVar, result.c_str()); + } + + return true; +} diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index fe05c98499..12c511514d 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -61,6 +61,7 @@ protected: bool HandleLockCommand(std::vector<std::string> const& args); bool HandleSizeCommand(std::vector<std::string> const& args); bool HandleReadSymlinkCommand(std::vector<std::string> const& args); + bool HandleCreateLinkCommand(std::vector<std::string> const& args); private: void AddEvaluationFile(const std::string& inputName, diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx index 5dc9243a11..d700a79c37 100644 --- a/Source/cmFileLockPool.cxx +++ b/Source/cmFileLockPool.cxx @@ -8,9 +8,7 @@ #include "cmFileLock.h" #include "cmFileLockResult.h" -cmFileLockPool::cmFileLockPool() -{ -} +cmFileLockPool::cmFileLockPool() = default; cmFileLockPool::~cmFileLockPool() { @@ -111,9 +109,7 @@ bool cmFileLockPool::IsAlreadyLocked(const std::string& filename) const return this->ProcessScope.IsAlreadyLocked(filename); } -cmFileLockPool::ScopePool::ScopePool() -{ -} +cmFileLockPool::ScopePool::ScopePool() = default; cmFileLockPool::ScopePool::~ScopePool() { diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx index 9b653e8076..1bf5013add 100644 --- a/Source/cmFileLockUnix.cxx +++ b/Source/cmFileLockUnix.cxx @@ -8,9 +8,7 @@ #include <stdio.h> // SEEK_SET #include <unistd.h> -cmFileLock::cmFileLock() -{ -} +cmFileLock::cmFileLock() = default; cmFileLockResult cmFileLock::Release() { diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index b36ac7805a..56ee739b06 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -19,7 +19,6 @@ void on_fs_close(uv_handle_t* handle); class cmIBaseWatcher { public: - cmIBaseWatcher() = default; virtual ~cmIBaseWatcher() = default; virtual void Trigger(const std::string& pathSegment, int events, @@ -150,11 +149,6 @@ public: p->AddChildWatcher(ps, this); } - ~cmRealDirectoryWatcher() override - { - // Handle is freed via uv_handle_close callback! - } - void StartWatching() final { if (!this->Handle) { diff --git a/Source/cmFilePathChecksum.cxx b/Source/cmFilePathChecksum.cxx index f84360e7f7..2cffa7c5b3 100644 --- a/Source/cmFilePathChecksum.cxx +++ b/Source/cmFilePathChecksum.cxx @@ -9,9 +9,7 @@ #include <vector> -cmFilePathChecksum::cmFilePathChecksum() -{ -} +cmFilePathChecksum::cmFilePathChecksum() = default; cmFilePathChecksum::cmFilePathChecksum(std::string const& currentSrcDir, std::string const& currentBinDir, diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 8f6993d1eb..8b3911e4b7 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -21,9 +21,10 @@ class cmFileTimeComparisonInternal { public: // Internal comparison method. - inline bool FileTimeCompare(const char* f1, const char* f2, int* result); + inline bool FileTimeCompare(const std::string& f1, const std::string& f2, + int* result); - bool FileTimesDiffer(const char* f1, const char* f2); + bool FileTimesDiffer(const std::string& f1, const std::string& f2); private: typedef std::unordered_map<std::string, cmFileTimeComparison_Type> @@ -31,14 +32,14 @@ private: FileStatsMap Files; // Internal methods to lookup and compare modification times. - inline bool Stat(const char* fname, cmFileTimeComparison_Type* st); + inline bool Stat(const std::string& fname, cmFileTimeComparison_Type* st); inline int Compare(cmFileTimeComparison_Type* st1, cmFileTimeComparison_Type* st2); inline bool TimesDiffer(cmFileTimeComparison_Type* st1, cmFileTimeComparison_Type* st2); }; -bool cmFileTimeComparisonInternal::Stat(const char* fname, +bool cmFileTimeComparisonInternal::Stat(const std::string& fname, cmFileTimeComparison_Type* st) { // Use the stored time if available. @@ -51,7 +52,7 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname, #if !defined(_WIN32) || defined(__CYGWIN__) // POSIX version. Use the stat function. - int res = ::stat(fname, st); + int res = ::stat(fname.c_str(), st); if (res != 0) { return false; } @@ -83,13 +84,14 @@ cmFileTimeComparison::~cmFileTimeComparison() delete this->Internals; } -bool cmFileTimeComparison::FileTimeCompare(const char* f1, const char* f2, - int* result) +bool cmFileTimeComparison::FileTimeCompare(const std::string& f1, + const std::string& f2, int* result) { return this->Internals->FileTimeCompare(f1, f2, result); } -bool cmFileTimeComparison::FileTimesDiffer(const char* f1, const char* f2) +bool cmFileTimeComparison::FileTimesDiffer(const std::string& f1, + const std::string& f2) { return this->Internals->FileTimesDiffer(f1, f2); } @@ -199,8 +201,9 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1, #endif } -bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1, - const char* f2, int* result) +bool cmFileTimeComparisonInternal::FileTimeCompare(const std::string& f1, + const std::string& f2, + int* result) { // Get the modification time for each file. cmFileTimeComparison_Type s1; @@ -215,8 +218,8 @@ bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1, return false; } -bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1, - const char* f2) +bool cmFileTimeComparisonInternal::FileTimesDiffer(const std::string& f1, + const std::string& f2) { // Get the modification time for each file. cmFileTimeComparison_Type s1; diff --git a/Source/cmFileTimeComparison.h b/Source/cmFileTimeComparison.h index 114989b51d..5f74e34990 100644 --- a/Source/cmFileTimeComparison.h +++ b/Source/cmFileTimeComparison.h @@ -5,6 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <string> + class cmFileTimeComparisonInternal; /** \class cmFileTimeComparison @@ -24,13 +26,14 @@ public: * When true is returned, result has -1, 0, +1 for * f1 older, same, or newer than f2. */ - bool FileTimeCompare(const char* f1, const char* f2, int* result); + bool FileTimeCompare(const std::string& f1, const std::string& f2, + int* result); /** * Compare file modification times. Return true unless both files * exist and have modification times less than 1 second apart. */ - bool FileTimesDiffer(const char* f1, const char* f2); + bool FileTimesDiffer(const std::string& f1, const std::string& f2); protected: cmFileTimeComparisonInternal* Internals; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 009f0e3e3e..78be64e09a 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -48,9 +48,7 @@ cmFindCommon::cmFindCommon() this->InitializeSearchPathGroups(); } -cmFindCommon::~cmFindCommon() -{ -} +cmFindCommon::~cmFindCommon() = default; void cmFindCommon::InitializeSearchPathGroups() { @@ -178,13 +176,13 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) cmSystemTools::ExpandListArgument(rootPath, roots); } if (sysrootCompile) { - roots.push_back(sysrootCompile); + roots.emplace_back(sysrootCompile); } if (sysrootLink) { - roots.push_back(sysrootLink); + roots.emplace_back(sysrootLink); } if (sysroot) { - roots.push_back(sysroot); + roots.emplace_back(sysroot); } for (std::string& r : roots) { cmSystemTools::ConvertToUnixSlashes(r); diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index bcf876d776..73d602de71 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -202,7 +202,6 @@ struct cmFindLibraryHelper bool TryRaw = false; std::string Raw; cmsys::RegularExpression Regex; - Name() {} }; std::vector<Name> Names; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8dc7ca2c51..f9ac310d9c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -95,6 +95,7 @@ cmFindPackageCommand::cmFindPackageCommand() this->UseLib32Paths = false; this->UseLib64Paths = false; this->UseLibx32Paths = false; + this->UseRealPath = false; this->PolicyScope = true; this->VersionMajor = 0; this->VersionMinor = 0; @@ -195,6 +196,11 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args, this->NoSystemRegistry = true; } + // Check whether we should resolve symlinks when finding packages + if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS")) { + this->UseRealPath = true; + } + // Check if Sorting should be enabled if (const char* so = this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_SORT_ORDER")) { @@ -657,7 +663,7 @@ bool cmFindPackageCommand::FindModule(bool& found) module += this->Name; module += ".cmake"; bool system = false; - std::string mfile = this->Makefile->GetModulesFile(module.c_str(), system); + std::string mfile = this->Makefile->GetModulesFile(module, system); if (!mfile.empty()) { if (system) { auto it = this->DeprecatedFindModules.find(this->Name); @@ -1502,6 +1508,10 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir, fprintf(stderr, "Checking file [%s]\n", file.c_str()); } if (cmSystemTools::FileExists(file, true) && this->CheckVersion(file)) { + // Allow resolving symlinks when the config file is found through a link + if (this->UseRealPath) { + file = cmSystemTools::GetRealPath(file); + } return true; } } @@ -1661,7 +1671,7 @@ void cmFindPackageCommand::StoreVersionFound() class cmFileListGeneratorBase { public: - virtual ~cmFileListGeneratorBase() {} + virtual ~cmFileListGeneratorBase() = default; protected: bool Consider(std::string const& fullPath, cmFileList& listing); @@ -1678,8 +1688,7 @@ private: class cmFileList { public: - cmFileList() {} - virtual ~cmFileList() {} + virtual ~cmFileList() = default; cmFileList& operator/(cmFileListGeneratorBase const& rhs) { if (this->Last) { @@ -1750,8 +1759,8 @@ bool cmFileListGeneratorBase::Consider(std::string const& fullPath, class cmFileListGeneratorFixed : public cmFileListGeneratorBase { public: - cmFileListGeneratorFixed(std::string const& str) - : String(str) + cmFileListGeneratorFixed(std::string str) + : String(std::move(str)) { } cmFileListGeneratorFixed(cmFileListGeneratorFixed const& r) @@ -1848,7 +1857,7 @@ private: } for (std::string const& n : this->Names) { if (cmsysString_strncasecmp(fname, n.c_str(), n.length()) == 0) { - matches.push_back(fname); + matches.emplace_back(fname); } } } @@ -1907,7 +1916,7 @@ private: for (std::string name : this->Names) { name += this->Extension; if (cmsysString_strcasecmp(fname, name.c_str()) == 0) { - matches.push_back(fname); + matches.emplace_back(fname); } } } @@ -1930,8 +1939,8 @@ private: class cmFileListGeneratorCaseInsensitive : public cmFileListGeneratorBase { public: - cmFileListGeneratorCaseInsensitive(std::string const& str) - : String(str) + cmFileListGeneratorCaseInsensitive(std::string str) + : String(std::move(str)) { } cmFileListGeneratorCaseInsensitive( @@ -1972,8 +1981,8 @@ private: class cmFileListGeneratorGlob : public cmFileListGeneratorBase { public: - cmFileListGeneratorGlob(std::string const& str) - : Pattern(str) + cmFileListGeneratorGlob(std::string str) + : Pattern(std::move(str)) { } cmFileListGeneratorGlob(cmFileListGeneratorGlob const& r) @@ -2070,16 +2079,16 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) common.push_back("lib/" + this->LibraryArchitecture); } if (this->UseLib32Paths) { - common.push_back("lib32"); + common.emplace_back("lib32"); } if (this->UseLib64Paths) { - common.push_back("lib64"); + common.emplace_back("lib64"); } if (this->UseLibx32Paths) { - common.push_back("libx32"); + common.emplace_back("libx32"); } - common.push_back("lib"); - common.push_back("share"); + common.emplace_back("lib"); + common.emplace_back("share"); // PREFIX/(lib/ARCH|lib*|share)/cmake/(Foo|foo|FOO).*/ { diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 05bad4991d..83d8431860 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -178,6 +178,7 @@ private: bool UseLib32Paths; bool UseLib64Paths; bool UseLibx32Paths; + bool UseRealPath; bool PolicyScope; std::string LibraryArchitecture; std::vector<std::string> Names; diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 3047167ca1..e359deff9e 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -164,7 +164,7 @@ bool cmForEachCommand::InitialPass(std::vector<std::string> const& args, break; } sprintf(buffer, "%d", cc); - range.push_back(buffer); + range.emplace_back(buffer); if (cc == stop) { break; } diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h index 132b3e684a..8d4c90b7d9 100644 --- a/Source/cmFortranParser.h +++ b/Source/cmFortranParser.h @@ -8,6 +8,7 @@ # include <set> # include <string> +# include <utility> # include <vector> #endif @@ -114,10 +115,10 @@ int cmFortran_yyparse(yyscan_t); // Define parser object internal structure. struct cmFortranFile { - cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, const std::string& dir) + cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, std::string dir) : File(file) , Buffer(buffer) - , Directory(dir) + , Directory(std::move(dir)) , LastCharWasNewline(false) { } @@ -129,9 +130,8 @@ struct cmFortranFile struct cmFortranParser_s { - cmFortranParser_s(std::vector<std::string> const& includes, - std::set<std::string> const& defines, - cmFortranSourceInfo& info); + cmFortranParser_s(std::vector<std::string> includes, + std::set<std::string> defines, cmFortranSourceInfo& info); ~cmFortranParser_s(); bool FindIncludeFile(const char* dir, const char* includeName, diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index 01cbb7843c..45481a4136 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -8,6 +8,7 @@ #include <stack> #include <stdio.h> #include <string> +#include <utility> #include <vector> bool cmFortranParser_s::FindIncludeFile(const char* dir, @@ -42,11 +43,11 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir, return false; } -cmFortranParser_s::cmFortranParser_s(std::vector<std::string> const& includes, - std::set<std::string> const& defines, +cmFortranParser_s::cmFortranParser_s(std::vector<std::string> includes, + std::set<std::string> defines, cmFortranSourceInfo& info) - : IncludePath(includes) - , PPDefinitions(defines) + : IncludePath(std::move(includes)) + , PPDefinitions(std::move(defines)) , Info(info) { this->InInterface = false; diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h index b3450b3f27..cd6b05db47 100644 --- a/Source/cmFunctionBlocker.h +++ b/Source/cmFunctionBlocker.h @@ -26,7 +26,7 @@ public: return false; } - virtual ~cmFunctionBlocker() {} + virtual ~cmFunctionBlocker() = default; /** Set/Get the context in which this blocker is created. */ void SetStartingContext(cmListFileContext const& lfc) diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 67c9e9a5de..264a3385cb 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -14,11 +14,6 @@ class cmFunctionHelperCommand : public cmCommand { public: - cmFunctionHelperCommand() {} - - ///! clean up any memory allocated by the function - ~cmFunctionHelperCommand() override {} - /** * This is a virtual constructor for the command. */ diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index 3352b9235c..8b37df032b 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -18,15 +18,13 @@ class cmMakefile; class cmFunctionFunctionBlocker : public cmFunctionBlocker { public: - cmFunctionFunctionBlocker() { this->Depth = 0; } - ~cmFunctionFunctionBlocker() override {} bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, cmExecutionStatus&) override; bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; std::vector<std::string> Args; std::vector<cmListFileFunction> Functions; - int Depth; + int Depth = 0; }; /// Starts function() ... endfunction() block diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index bf53dbf02b..4fe15874d3 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -102,9 +102,7 @@ void cmGeneratedFileStream::SetCompressionExtraExtension(bool ext) this->CompressExtraExtension = ext; } -cmGeneratedFileStreamBase::cmGeneratedFileStreamBase() -{ -} +cmGeneratedFileStreamBase::cmGeneratedFileStreamBase() = default; cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(std::string const& name) { @@ -210,7 +208,7 @@ int cmGeneratedFileStreamBase::CompressFile(std::string const&, int cmGeneratedFileStreamBase::RenameFile(std::string const& oldname, std::string const& newname) { - return cmSystemTools::RenameFile(oldname.c_str(), newname.c_str()); + return cmSystemTools::RenameFile(oldname, newname); } void cmGeneratedFileStream::SetName(const std::string& fname) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 96d4ad6a65..175a26d2e8 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -15,9 +15,8 @@ #include "cmGeneratorExpressionParser.h" #include "cmSystemTools.h" -cmGeneratorExpression::cmGeneratorExpression( - const cmListFileBacktrace& backtrace) - : Backtrace(backtrace) +cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace) + : Backtrace(std::move(backtrace)) { } @@ -34,9 +33,7 @@ std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse( return this->Parse(std::string(input ? input : "")); } -cmGeneratorExpression::~cmGeneratorExpression() -{ -} +cmGeneratorExpression::~cmGeneratorExpression() = default; const std::string& cmCompiledGeneratorExpression::Evaluate( cmLocalGenerator* lg, const std::string& config, bool quiet, @@ -96,9 +93,9 @@ const std::string& cmCompiledGeneratorExpression::EvaluateWithContext( } cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( - cmListFileBacktrace const& backtrace, const std::string& input) - : Backtrace(backtrace) - , Input(input) + cmListFileBacktrace backtrace, std::string input) + : Backtrace(std::move(backtrace)) + , Input(std::move(input)) , HadContextSensitiveCondition(false) , HadHeadSensitiveCondition(false) , EvaluateForBuildsystem(false) diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 9c05f60c82..e5463a7e81 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -11,6 +11,7 @@ #include <memory> // IWYU pragma: keep #include <set> #include <string> +#include <utility> #include <vector> class cmCompiledGeneratorExpression; @@ -35,8 +36,7 @@ class cmGeneratorExpression public: /** Construct. */ - cmGeneratorExpression( - cmListFileBacktrace const& backtrace = cmListFileBacktrace()); + cmGeneratorExpression(cmListFileBacktrace backtrace = cmListFileBacktrace()); ~cmGeneratorExpression(); std::unique_ptr<cmCompiledGeneratorExpression> Parse( @@ -140,8 +140,8 @@ private: cmGeneratorExpressionContext& context, cmGeneratorExpressionDAGChecker* dagChecker) const; - cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, - const std::string& input); + cmCompiledGeneratorExpression(cmListFileBacktrace backtrace, + std::string input); friend class cmGeneratorExpression; @@ -169,13 +169,13 @@ class cmGeneratorExpressionInterpreter public: cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator, - std::string const& config, + std::string config, cmGeneratorTarget const* headTarget, - std::string const& lang = std::string()) + std::string lang = std::string()) : LocalGenerator(localGenerator) - , Config(config) + , Config(std::move(config)) , HeadTarget(headTarget) - , Language(lang) + , Language(std::move(lang)) { } diff --git a/Source/cmGeneratorExpressionContext.cxx b/Source/cmGeneratorExpressionContext.cxx index a6dde5d39d..6d973310cf 100644 --- a/Source/cmGeneratorExpressionContext.cxx +++ b/Source/cmGeneratorExpressionContext.cxx @@ -2,15 +2,17 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGeneratorExpressionContext.h" +#include <utility> + cmGeneratorExpressionContext::cmGeneratorExpressionContext( - cmLocalGenerator* lg, std::string const& config, bool quiet, + cmLocalGenerator* lg, std::string config, bool quiet, cmGeneratorTarget const* headTarget, const cmGeneratorTarget* currentTarget, - bool evaluateForBuildsystem, cmListFileBacktrace const& backtrace, - std::string const& language) - : Backtrace(backtrace) + bool evaluateForBuildsystem, cmListFileBacktrace backtrace, + std::string language) + : Backtrace(std::move(backtrace)) , LG(lg) - , Config(config) - , Language(language) + , Config(std::move(config)) + , Language(std::move(language)) , HeadTarget(headTarget) , CurrentTarget(currentTarget) , Quiet(quiet) diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h index 5b0123ec81..6e076bf542 100644 --- a/Source/cmGeneratorExpressionContext.h +++ b/Source/cmGeneratorExpressionContext.h @@ -14,12 +14,12 @@ class cmLocalGenerator; struct cmGeneratorExpressionContext { - cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string const& config, + cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string config, bool quiet, const cmGeneratorTarget* headTarget, cmGeneratorTarget const* currentTarget, bool evaluateForBuildsystem, - cmListFileBacktrace const& backtrace, - std::string const& language); + cmListFileBacktrace backtrace, + std::string language); cmListFileBacktrace Backtrace; std::set<cmGeneratorTarget*> DependTargets; diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 61b798bb5b..0f26e70cad 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -15,26 +15,26 @@ #include <utility> cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( - const cmListFileBacktrace& backtrace, cmGeneratorTarget const* target, - const std::string& property, const GeneratorExpressionContent* content, + cmListFileBacktrace backtrace, cmGeneratorTarget const* target, + std::string property, const GeneratorExpressionContent* content, cmGeneratorExpressionDAGChecker* parent) : Parent(parent) , Target(target) - , Property(property) + , Property(std::move(property)) , Content(content) - , Backtrace(backtrace) + , Backtrace(std::move(backtrace)) , TransitivePropertiesOnly(false) { Initialize(); } cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( - cmGeneratorTarget const* target, const std::string& property, + cmGeneratorTarget const* target, std::string property, const GeneratorExpressionContent* content, cmGeneratorExpressionDAGChecker* parent) : Parent(parent) , Target(target) - , Property(property) + , Property(std::move(property)) , Content(content) , Backtrace() , TransitivePropertiesOnly(false) diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 1525c39de2..e1fba5e5cf 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -42,13 +42,13 @@ class cmGeneratorTarget; struct cmGeneratorExpressionDAGChecker { - cmGeneratorExpressionDAGChecker(const cmListFileBacktrace& backtrace, + cmGeneratorExpressionDAGChecker(cmListFileBacktrace backtrace, cmGeneratorTarget const* target, - const std::string& property, + std::string property, const GeneratorExpressionContent* content, cmGeneratorExpressionDAGChecker* parent); cmGeneratorExpressionDAGChecker(cmGeneratorTarget const* target, - const std::string& property, + std::string property, const GeneratorExpressionContent* content, cmGeneratorExpressionDAGChecker* parent); diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 1c33a6ef0b..326cb0e555 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -18,11 +18,11 @@ #include "cmSystemTools.h" cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( - const std::string& input, + std::string input, std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr, std::unique_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070) - : Input(input) + : Input(std::move(input)) , OutputFileExpr(std::move(outputFileExpr)) , Condition(std::move(condition)) , InputIsContent(inputIsContent) diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 2a790697f5..89a2390571 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -20,7 +20,7 @@ class cmGeneratorExpressionEvaluationFile { public: cmGeneratorExpressionEvaluationFile( - const std::string& input, + std::string input, std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr, std::unique_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070); diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 0561799504..0f553f2c0b 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -16,8 +16,8 @@ struct cmGeneratorExpressionNode; struct cmGeneratorExpressionEvaluator { - cmGeneratorExpressionEvaluator() {} - virtual ~cmGeneratorExpressionEvaluator() {} + cmGeneratorExpressionEvaluator() = default; + virtual ~cmGeneratorExpressionEvaluator() = default; enum Type { diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx index 242915dcff..a7f090ac7e 100644 --- a/Source/cmGeneratorExpressionLexer.cxx +++ b/Source/cmGeneratorExpressionLexer.cxx @@ -2,9 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGeneratorExpressionLexer.h" -cmGeneratorExpressionLexer::cmGeneratorExpressionLexer() -{ -} +cmGeneratorExpressionLexer::cmGeneratorExpressionLexer() = default; static void InsertText(const char* upto, const char* c, std::vector<cmGeneratorExpressionToken>& result) @@ -20,8 +18,8 @@ std::vector<cmGeneratorExpressionToken> cmGeneratorExpressionLexer::Tokenize( std::vector<cmGeneratorExpressionToken> result; if (input.find('$') == std::string::npos) { - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::Text, input.c_str(), input.size())); + result.emplace_back(cmGeneratorExpressionToken::Text, input.c_str(), + input.size()); return result; } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index fe1b05578a..eb66ed5546 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -56,7 +56,7 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression( static const struct ZeroNode : public cmGeneratorExpressionNode { - ZeroNode() {} + ZeroNode() {} // NOLINT(modernize-use-equals-default) bool GeneratesContent() const override { return false; } @@ -74,7 +74,7 @@ static const struct ZeroNode : public cmGeneratorExpressionNode static const struct OneNode : public cmGeneratorExpressionNode { - OneNode() {} + OneNode() {} // NOLINT(modernize-use-equals-default) bool AcceptsArbitraryContentParameter() const override { return true; } @@ -127,7 +127,7 @@ BOOLEAN_OP_NODE(orNode, OR, 0, 1) static const struct NotNode : public cmGeneratorExpressionNode { - NotNode() {} + NotNode() {} // NOLINT(modernize-use-equals-default) std::string Evaluate( const std::vector<std::string>& parameters, @@ -147,7 +147,7 @@ static const struct NotNode : public cmGeneratorExpressionNode static const struct BoolNode : public cmGeneratorExpressionNode { - BoolNode() {} + BoolNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 1; } @@ -163,7 +163,7 @@ static const struct BoolNode : public cmGeneratorExpressionNode static const struct IfNode : public cmGeneratorExpressionNode { - IfNode() {} + IfNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 3; } @@ -184,7 +184,7 @@ static const struct IfNode : public cmGeneratorExpressionNode static const struct StrEqualNode : public cmGeneratorExpressionNode { - StrEqualNode() {} + StrEqualNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -200,7 +200,7 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode static const struct EqualNode : public cmGeneratorExpressionNode { - EqualNode() {} + EqualNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -278,7 +278,7 @@ static const struct EqualNode : public cmGeneratorExpressionNode static const struct InListNode : public cmGeneratorExpressionNode { - InListNode() {} + InListNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -328,7 +328,7 @@ static const struct InListNode : public cmGeneratorExpressionNode static const struct TargetExistsNode : public cmGeneratorExpressionNode { - TargetExistsNode() {} + TargetExistsNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 1; } @@ -359,7 +359,7 @@ static const struct TargetExistsNode : public cmGeneratorExpressionNode static const struct TargetNameIfExistsNode : public cmGeneratorExpressionNode { - TargetNameIfExistsNode() {} + TargetNameIfExistsNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 1; } @@ -393,7 +393,7 @@ static const struct TargetNameIfExistsNode : public cmGeneratorExpressionNode struct GenexEvaluator : public cmGeneratorExpressionNode { - GenexEvaluator() {} + GenexEvaluator() {} // NOLINT(modernize-use-equals-default) protected: std::string EvaluateExpression( @@ -430,7 +430,7 @@ protected: static const struct TargetGenexEvalNode : public GenexEvaluator { - TargetGenexEvalNode() {} + TargetGenexEvalNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -476,7 +476,7 @@ static const struct TargetGenexEvalNode : public GenexEvaluator static const struct GenexEvalNode : public GenexEvaluator { - GenexEvalNode() {} + GenexEvalNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 1; } @@ -500,7 +500,7 @@ static const struct GenexEvalNode : public GenexEvaluator static const struct LowerCaseNode : public cmGeneratorExpressionNode { - LowerCaseNode() {} + LowerCaseNode() {} // NOLINT(modernize-use-equals-default) bool AcceptsArbitraryContentParameter() const override { return true; } @@ -516,7 +516,7 @@ static const struct LowerCaseNode : public cmGeneratorExpressionNode static const struct UpperCaseNode : public cmGeneratorExpressionNode { - UpperCaseNode() {} + UpperCaseNode() {} // NOLINT(modernize-use-equals-default) bool AcceptsArbitraryContentParameter() const override { return true; } @@ -532,7 +532,7 @@ static const struct UpperCaseNode : public cmGeneratorExpressionNode static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode { - MakeCIdentifierNode() {} + MakeCIdentifierNode() {} // NOLINT(modernize-use-equals-default) bool AcceptsArbitraryContentParameter() const override { return true; } @@ -548,7 +548,7 @@ static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode static const struct Angle_RNode : public cmGeneratorExpressionNode { - Angle_RNode() {} + Angle_RNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 0; } @@ -564,7 +564,7 @@ static const struct Angle_RNode : public cmGeneratorExpressionNode static const struct CommaNode : public cmGeneratorExpressionNode { - CommaNode() {} + CommaNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 0; } @@ -580,7 +580,7 @@ static const struct CommaNode : public cmGeneratorExpressionNode static const struct SemicolonNode : public cmGeneratorExpressionNode { - SemicolonNode() {} + SemicolonNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 0; } @@ -596,7 +596,7 @@ static const struct SemicolonNode : public cmGeneratorExpressionNode struct CompilerIdNode : public cmGeneratorExpressionNode { - CompilerIdNode() {} + CompilerIdNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return OneOrZeroParameters; } @@ -650,7 +650,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode static const struct CCompilerIdNode : public CompilerIdNode { - CCompilerIdNode() {} + CCompilerIdNode() {} // NOLINT(modernize-use-equals-default) std::string Evaluate( const std::vector<std::string>& parameters, @@ -672,7 +672,7 @@ static const struct CCompilerIdNode : public CompilerIdNode static const struct CXXCompilerIdNode : public CompilerIdNode { - CXXCompilerIdNode() {} + CXXCompilerIdNode() {} // NOLINT(modernize-use-equals-default) std::string Evaluate( const std::vector<std::string>& parameters, @@ -692,9 +692,31 @@ static const struct CXXCompilerIdNode : public CompilerIdNode } } cxxCompilerIdNode; +static const struct FortranCompilerIdNode : public CompilerIdNode +{ + FortranCompilerIdNode() {} // NOLINT(modernize-use-equals-default) + + std::string Evaluate( + const std::vector<std::string>& parameters, + cmGeneratorExpressionContext* context, + const GeneratorExpressionContent* content, + cmGeneratorExpressionDAGChecker* dagChecker) const override + { + if (!context->HeadTarget) { + reportError( + context, content->GetOriginalExpression(), + "$<Fortran_COMPILER_ID> may only be used with binary targets. It may " + "not be used with add_custom_command or add_custom_target."); + return std::string(); + } + return this->EvaluateWithLanguage(parameters, context, content, dagChecker, + "Fortran"); + } +} fortranCompilerIdNode; + struct CompilerVersionNode : public cmGeneratorExpressionNode { - CompilerVersionNode() {} + CompilerVersionNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return OneOrZeroParameters; } @@ -731,7 +753,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode static const struct CCompilerVersionNode : public CompilerVersionNode { - CCompilerVersionNode() {} + CCompilerVersionNode() {} // NOLINT(modernize-use-equals-default) std::string Evaluate( const std::vector<std::string>& parameters, @@ -753,7 +775,7 @@ static const struct CCompilerVersionNode : public CompilerVersionNode static const struct CxxCompilerVersionNode : public CompilerVersionNode { - CxxCompilerVersionNode() {} + CxxCompilerVersionNode() {} // NOLINT(modernize-use-equals-default) std::string Evaluate( const std::vector<std::string>& parameters, @@ -773,9 +795,31 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode } } cxxCompilerVersionNode; +static const struct FortranCompilerVersionNode : public CompilerVersionNode +{ + FortranCompilerVersionNode() {} // NOLINT(modernize-use-equals-default) + + std::string Evaluate( + const std::vector<std::string>& parameters, + cmGeneratorExpressionContext* context, + const GeneratorExpressionContent* content, + cmGeneratorExpressionDAGChecker* dagChecker) const override + { + if (!context->HeadTarget) { + reportError( + context, content->GetOriginalExpression(), + "$<Fortran_COMPILER_VERSION> may only be used with binary targets. " + "It may not be used with add_custom_command or add_custom_target."); + return std::string(); + } + return this->EvaluateWithLanguage(parameters, context, content, dagChecker, + "Fortran"); + } +} fortranCompilerVersionNode; + struct PlatformIdNode : public cmGeneratorExpressionNode { - PlatformIdNode() {} + PlatformIdNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return OneOrZeroParameters; } @@ -804,7 +848,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode static const struct VersionGreaterNode : public cmGeneratorExpressionNode { - VersionGreaterNode() {} + VersionGreaterNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -824,7 +868,7 @@ static const struct VersionGreaterNode : public cmGeneratorExpressionNode static const struct VersionGreaterEqNode : public cmGeneratorExpressionNode { - VersionGreaterEqNode() {} + VersionGreaterEqNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -844,7 +888,7 @@ static const struct VersionGreaterEqNode : public cmGeneratorExpressionNode static const struct VersionLessNode : public cmGeneratorExpressionNode { - VersionLessNode() {} + VersionLessNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -864,7 +908,7 @@ static const struct VersionLessNode : public cmGeneratorExpressionNode static const struct VersionLessEqNode : public cmGeneratorExpressionNode { - VersionLessEqNode() {} + VersionLessEqNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -884,7 +928,7 @@ static const struct VersionLessEqNode : public cmGeneratorExpressionNode static const struct VersionEqualNode : public cmGeneratorExpressionNode { - VersionEqualNode() {} + VersionEqualNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -904,7 +948,7 @@ static const struct VersionEqualNode : public cmGeneratorExpressionNode static const struct LinkOnlyNode : public cmGeneratorExpressionNode { - LinkOnlyNode() {} + LinkOnlyNode() {} // NOLINT(modernize-use-equals-default) std::string Evaluate( const std::vector<std::string>& parameters, @@ -926,7 +970,7 @@ static const struct LinkOnlyNode : public cmGeneratorExpressionNode static const struct ConfigurationNode : public cmGeneratorExpressionNode { - ConfigurationNode() {} + ConfigurationNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 0; } @@ -943,7 +987,7 @@ static const struct ConfigurationNode : public cmGeneratorExpressionNode static const struct ConfigurationTestNode : public cmGeneratorExpressionNode { - ConfigurationTestNode() {} + ConfigurationTestNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return OneOrZeroParameters; } @@ -1002,7 +1046,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode static const struct JoinNode : public cmGeneratorExpressionNode { - JoinNode() {} + JoinNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 2; } @@ -1022,7 +1066,7 @@ static const struct JoinNode : public cmGeneratorExpressionNode static const struct CompileLanguageNode : public cmGeneratorExpressionNode { - CompileLanguageNode() {} + CompileLanguageNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return OneOrZeroParameters; } @@ -1102,7 +1146,7 @@ std::string getLinkedTargetsContent( static const struct TargetPropertyNode : public cmGeneratorExpressionNode { - TargetPropertyNode() {} + TargetPropertyNode() {} // NOLINT(modernize-use-equals-default) // This node handles errors on parameter count itself. int NumExpectedParameters() const override { return OneOrMoreParameters; } @@ -1398,7 +1442,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode static const struct TargetNameNode : public cmGeneratorExpressionNode { - TargetNameNode() {} + TargetNameNode() {} // NOLINT(modernize-use-equals-default) bool GeneratesContent() const override { return true; } @@ -1420,7 +1464,7 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode static const struct TargetObjectsNode : public cmGeneratorExpressionNode { - TargetObjectsNode() {} + TargetObjectsNode() {} // NOLINT(modernize-use-equals-default) std::string Evaluate( const std::vector<std::string>& parameters, @@ -1502,7 +1546,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode static const struct CompileFeaturesNode : public cmGeneratorExpressionNode { - CompileFeaturesNode() {} + CompileFeaturesNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return OneOrMoreParameters; } @@ -1627,7 +1671,7 @@ cmPolicies::PolicyID policyForString(const char* policy_id) static const struct TargetPolicyNode : public cmGeneratorExpressionNode { - TargetPolicyNode() {} + TargetPolicyNode() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 1; } @@ -1688,7 +1732,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode static const struct InstallPrefixNode : public cmGeneratorExpressionNode { - InstallPrefixNode() {} + InstallPrefixNode() {} // NOLINT(modernize-use-equals-default) bool GeneratesContent() const override { return true; } int NumExpectedParameters() const override { return 0; } @@ -1909,7 +1953,7 @@ struct TargetFilesystemArtifactResultGetter<ArtifactPathTag> template <typename ArtifactT, typename ComponentT> struct TargetFilesystemArtifact : public cmGeneratorExpressionNode { - TargetFilesystemArtifact() {} + TargetFilesystemArtifact() {} // NOLINT(modernize-use-equals-default) int NumExpectedParameters() const override { return 1; } @@ -1965,7 +2009,9 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode template <typename ArtifactT> struct TargetFilesystemArtifactNodeGroup { - TargetFilesystemArtifactNodeGroup() {} + TargetFilesystemArtifactNodeGroup() // NOLINT(modernize-use-equals-default) + { + } TargetFilesystemArtifact<ArtifactT, ArtifactPathTag> File; TargetFilesystemArtifact<ArtifactT, ArtifactNameTag> FileName; @@ -1993,7 +2039,7 @@ static const TargetFilesystemArtifact<ArtifactBundleContentDirTag, static const struct ShellPathNode : public cmGeneratorExpressionNode { - ShellPathNode() {} + ShellPathNode() {} // NOLINT(modernize-use-equals-default) std::string Evaluate( const std::vector<std::string>& parameters, @@ -2024,6 +2070,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( nodeMap["NOT"] = ¬Node; nodeMap["C_COMPILER_ID"] = &cCompilerIdNode; nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode; + nodeMap["Fortran_COMPILER_ID"] = &fortranCompilerIdNode; nodeMap["VERSION_GREATER"] = &versionGreaterNode; nodeMap["VERSION_GREATER_EQUAL"] = &versionGreaterEqNode; nodeMap["VERSION_LESS"] = &versionLessNode; @@ -2031,6 +2078,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( nodeMap["VERSION_EQUAL"] = &versionEqualNode; nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode; nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode; + nodeMap["Fortran_COMPILER_VERSION"] = &fortranCompilerVersionNode; nodeMap["PLATFORM_ID"] = &platformIdNode; nodeMap["COMPILE_FEATURES"] = &compileFeaturesNode; nodeMap["CONFIGURATION"] = &configurationNode; diff --git a/Source/cmGeneratorExpressionNode.h b/Source/cmGeneratorExpressionNode.h index ece1c113ce..3dbfc6e5e5 100644 --- a/Source/cmGeneratorExpressionNode.h +++ b/Source/cmGeneratorExpressionNode.h @@ -22,7 +22,7 @@ struct cmGeneratorExpressionNode OneOrMoreParameters = -1, OneOrZeroParameters = -2 }; - virtual ~cmGeneratorExpressionNode() {} + virtual ~cmGeneratorExpressionNode() = default; virtual bool GeneratesContent() const { return true; } diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index 489970ce34..949a86d81f 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -9,8 +9,8 @@ #include <utility> cmGeneratorExpressionParser::cmGeneratorExpressionParser( - const std::vector<cmGeneratorExpressionToken>& tokens) - : Tokens(tokens) + std::vector<cmGeneratorExpressionToken> tokens) + : Tokens(std::move(tokens)) , NestingLevel(0) { } diff --git a/Source/cmGeneratorExpressionParser.h b/Source/cmGeneratorExpressionParser.h index 633381c8a9..e663496dae 100644 --- a/Source/cmGeneratorExpressionParser.h +++ b/Source/cmGeneratorExpressionParser.h @@ -13,8 +13,7 @@ struct cmGeneratorExpressionEvaluator; struct cmGeneratorExpressionParser { - cmGeneratorExpressionParser( - const std::vector<cmGeneratorExpressionToken>& tokens); + cmGeneratorExpressionParser(std::vector<cmGeneratorExpressionToken> tokens); void Parse(std::vector<cmGeneratorExpressionEvaluator*>& result); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6515dfa4e5..86f10dcf86 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -14,6 +14,7 @@ #include <stdlib.h> #include <string.h> #include <unordered_set> +#include <utility> #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" @@ -202,7 +203,7 @@ std::string cmGeneratorTarget::GetExportName() const std::ostringstream e; e << "EXPORT_NAME property \"" << exportName << "\" for \"" << this->GetName() << "\": is not valid."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return ""; } return exportName; @@ -319,7 +320,7 @@ std::string cmGeneratorTarget::GetOutputName( props.push_back(configUpper + "_OUTPUT_NAME"); } // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); + props.emplace_back("OUTPUT_NAME"); std::string outName; for (std::string const& p : props) { @@ -355,20 +356,22 @@ void cmGeneratorTarget::ClearSourcesCache() this->Objects.clear(); } -void cmGeneratorTarget::AddSourceCommon(const std::string& src) +void cmGeneratorTarget::AddSourceCommon(const std::string& src, bool before) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(lfbt); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src); cge->SetEvaluateForBuildsystem(true); - this->SourceEntries.push_back(new TargetPropertyEntry(std::move(cge))); + this->SourceEntries.insert(before ? this->SourceEntries.begin() + : this->SourceEntries.end(), + new TargetPropertyEntry(std::move(cge))); this->ClearSourcesCache(); } -void cmGeneratorTarget::AddSource(const std::string& src) +void cmGeneratorTarget::AddSource(const std::string& src, bool before) { - this->Target->AddSource(src); - this->AddSourceCommon(src); + this->Target->AddSource(src, before); + this->AddSourceCommon(src, before); } void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs) @@ -387,12 +390,10 @@ void cmGeneratorTarget::AddIncludeDirectory(const std::string& src, cmGeneratorExpression ge(lfbt); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src); cge->SetEvaluateForBuildsystem(true); - // Insert before begin/end - std::vector<TargetPropertyEntry*>::iterator pos = before - ? this->IncludeDirectoriesEntries.begin() - : this->IncludeDirectoriesEntries.end(); this->IncludeDirectoriesEntries.insert( - pos, new TargetPropertyEntry(std::move(cge))); + before ? this->IncludeDirectoriesEntries.begin() + : this->IncludeDirectoriesEntries.end(), + new TargetPropertyEntry(std::move(cge))); } std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends( @@ -988,7 +989,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths( item.back() == '>') { continue; } - files.push_back(item); + files.emplace_back(item); } } return files; @@ -1805,10 +1806,10 @@ class cmTargetCollectLinkLanguages { public: cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, - const std::string& config, + std::string config, std::unordered_set<std::string>& languages, cmGeneratorTarget const* head) - : Config(config) + : Config(std::move(config)) , Languages(languages) , HeadTarget(head) , Target(target) @@ -3260,7 +3261,7 @@ void processLinkDirectories( // in case projects set the LINK_DIRECTORIES property directly. cmSystemTools::ConvertToUnixSlashes(entryDirectory); if (uniqueDirectories.insert(entryDirectory).second) { - directories.push_back(entryDirectory); + directories.emplace_back(entryDirectory); if (debugDirectories) { usedDirectories += " * " + entryDirectory + "\n"; } @@ -3838,7 +3839,7 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const } // PDB_NAME - props.push_back("PDB_NAME"); + props.emplace_back("PDB_NAME"); for (std::string const& p : props) { if (const char* outName = this->GetProperty(p)) { @@ -4586,7 +4587,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, << " property requirement\nof " "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); break; } propContent = consistent.second; @@ -4611,7 +4612,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, "already. The INTERFACE_" << p << " property on\ndependency \"" << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); break; } propContent = consistent.second; @@ -4631,7 +4632,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, e << "The INTERFACE_" << p << " property of \"" << theTarget->GetName() << "\" does\nnot agree with the value of " << p << " already determined\nfor \"" << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); break; } propContent = consistent.second; @@ -6140,7 +6141,7 @@ bool cmGeneratorTarget::HasImportLibrary(std::string const& config) const std::string cmGeneratorTarget::GetSupportDirectory() const { std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory(); - dir += cmake::GetCMakeFilesDirectory(); + dir += "/CMakeFiles"; dir += "/"; dir += this->GetName(); #if defined(__VMS) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index cfd1df0785..d72e0515a6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -111,7 +111,6 @@ public: std::set<std::string> ExpectedXamlHeaders; std::set<std::string> ExpectedXamlSources; bool Initialized = false; - KindedSources() {} }; /** Get all sources needed for a configuration with kinds assigned. */ @@ -536,7 +535,7 @@ public: */ void ClearSourcesCache(); - void AddSource(const std::string& src); + void AddSource(const std::string& src, bool before = false); void AddTracedSources(std::vector<std::string> const& srcs); /** @@ -562,7 +561,6 @@ public: }; struct SourceFileFlags { - SourceFileFlags() {} SourceFileType Type = SourceFileTypeNormal; const char* MacFolder = nullptr; // location inside Mac content folders }; @@ -694,7 +692,7 @@ public: const char* GetSourcesProperty() const; private: - void AddSourceCommon(const std::string& src); + void AddSourceCommon(const std::string& src, bool before = false); std::string CreateFortranModuleDirectory( std::string const& working_dir) const; @@ -750,7 +748,6 @@ private: struct CompatibleInterfaces : public CompatibleInterfacesBase { - CompatibleInterfaces() {} bool Done = false; }; mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap; @@ -764,7 +761,6 @@ private: struct LinkImplClosure : public std::vector<cmGeneratorTarget const*> { - LinkImplClosure() {} bool Done = false; }; mutable std::map<std::string, LinkImplClosure> LinkImplClosureMap; @@ -784,7 +780,6 @@ private: // Cache import information from properties for each configuration. struct ImportInfo { - ImportInfo() {} bool NoSOName = false; ManagedType Managed = Native; unsigned int Multiplicity = 0; diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index ffb895e535..163b4c8abc 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -88,6 +88,10 @@ bool cmGetFilenameComponentCommand::InitialPass( result = cmSystemTools::GetFilenameExtension(filename); } else if (args[2] == "NAME_WE") { result = cmSystemTools::GetFilenameWithoutExtension(filename); + } else if (args[2] == "LAST_EXT") { + result = cmSystemTools::GetFilenameLastExtension(filename); + } else if (args[2] == "NAME_WLE") { + result = cmSystemTools::GetFilenameWithoutLastExtension(filename); } else if (args[2] == "ABSOLUTE" || args[2] == "REALPATH") { // If the path given is relative, evaluate it relative to the // current source directory unless the user passes a different diff --git a/Source/cmGhsMultiGpj.cxx b/Source/cmGhsMultiGpj.cxx index f58cfc1e55..c1f0742f2c 100644 --- a/Source/cmGhsMultiGpj.cxx +++ b/Source/cmGhsMultiGpj.cxx @@ -4,31 +4,34 @@ #include "cmGeneratedFileStream.h" -void GhsMultiGpj::WriteGpjTag(Types const gpjType, - cmGeneratedFileStream* const filestream) +static const char* GHS_TAG[] = { "[INTEGRITY Application]", + "[Library]", + "[Project]", + "[Program]", + "[Reference]", + "[Subproject]" }; + +const char* GhsMultiGpj::GetGpjTag(Types const gpjType) { char const* tag; switch (gpjType) { case INTERGRITY_APPLICATION: - tag = "INTEGRITY Application"; - break; case LIBRARY: - tag = "Library"; - break; case PROJECT: - tag = "Project"; - break; case PROGRAM: - tag = "Program"; - break; case REFERENCE: - tag = "Reference"; - break; case SUBPROJECT: - tag = "Subproject"; + tag = GHS_TAG[gpjType]; break; default: tag = ""; } - *filestream << "[" << tag << "]" << std::endl; + return tag; +} + +void GhsMultiGpj::WriteGpjTag(Types const gpjType, std::ostream& fout) +{ + char const* tag; + tag = GhsMultiGpj::GetGpjTag(gpjType); + fout << tag << std::endl; } diff --git a/Source/cmGhsMultiGpj.h b/Source/cmGhsMultiGpj.h index b1eead1016..6d59225daa 100644 --- a/Source/cmGhsMultiGpj.h +++ b/Source/cmGhsMultiGpj.h @@ -4,6 +4,7 @@ #define cmGhsMultiGpj_h #include "cmConfigure.h" // IWYU pragma: keep +#include <iosfwd> class cmGeneratedFileStream; @@ -20,8 +21,9 @@ public: SUBPROJECT }; - static void WriteGpjTag(Types const gpjType, - cmGeneratedFileStream* filestream); + static void WriteGpjTag(Types const gpjType, std::ostream& fout); + + static const char* GetGpjTag(Types const gpjType); }; #endif // ! cmGhsMultiGpjType_h diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 1a25633201..04a8b3c50d 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGhsMultiTargetGenerator.h" +#include "cmComputeLinkInformation.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalGhsMultiGenerator.h" @@ -9,177 +10,128 @@ #include "cmLocalGhsMultiGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" +#include "cmSourceGroup.h" #include "cmTarget.h" -#include <assert.h> - -std::string const cmGhsMultiTargetGenerator::DDOption("-dynamic"); cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target) : GeneratorTarget(target) , LocalGenerator( static_cast<cmLocalGhsMultiGenerator*>(target->GetLocalGenerator())) , Makefile(target->Target->GetMakefile()) - , TargetGroup(DetermineIfTargetGroup(target)) - , DynamicDownload(false) -{ - this->RelBuildFilePath = this->GetRelBuildFilePath(target); - - this->RelOutputFileName = this->RelBuildFilePath + target->GetName() + ".a"; - - this->RelBuildFileName = this->RelBuildFilePath; - this->RelBuildFileName += this->GetBuildFileName(target); - - std::string absPathToRoot = this->GetAbsPathToRoot(target); - absPathToRoot = this->AddSlashIfNeededToPath(absPathToRoot); - this->AbsBuildFilePath = absPathToRoot + this->RelBuildFilePath; - this->AbsBuildFileName = absPathToRoot + this->RelBuildFileName; - this->AbsOutputFileName = absPathToRoot + this->RelOutputFileName; -} - -cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator() + , Name(target->GetName()) { - cmDeleteAll(this->FolderBuildStreams); -} - -std::string cmGhsMultiTargetGenerator::GetRelBuildFilePath( - const cmGeneratorTarget* target) -{ - std::string output = target->GetEffectiveFolderName(); - cmSystemTools::ConvertToUnixSlashes(output); - if (!output.empty()) { - output += "/"; + // Store the configuration name that is being used + if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) { + // Use the build type given by the user. + this->ConfigName = config; + } else { + // No configuration type given. + this->ConfigName.clear(); } - output += target->GetName() + "/"; - return output; -} - -std::string cmGhsMultiTargetGenerator::GetAbsPathToRoot( - const cmGeneratorTarget* target) -{ - return target->GetLocalGenerator()->GetBinaryDirectory(); } -std::string cmGhsMultiTargetGenerator::GetAbsBuildFilePath( - const cmGeneratorTarget* target) -{ - std::string output; - output = cmGhsMultiTargetGenerator::GetAbsPathToRoot(target); - output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output); - output += cmGhsMultiTargetGenerator::GetRelBuildFilePath(target); - return output; -} - -std::string cmGhsMultiTargetGenerator::GetRelBuildFileName( - const cmGeneratorTarget* target) -{ - std::string output; - output = cmGhsMultiTargetGenerator::GetRelBuildFilePath(target); - output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output); - output += cmGhsMultiTargetGenerator::GetBuildFileName(target); - return output; -} - -std::string cmGhsMultiTargetGenerator::GetBuildFileName( - const cmGeneratorTarget* target) -{ - std::string output; - output = target->GetName(); - output += cmGlobalGhsMultiGenerator::FILE_EXTENSION; - return output; -} - -std::string cmGhsMultiTargetGenerator::AddSlashIfNeededToPath( - std::string const& input) +cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator() { - std::string output(input); - if (!cmHasLiteralSuffix(output, "/")) { - output += "/"; - } - return output; } void cmGhsMultiTargetGenerator::Generate() { - std::vector<cmSourceFile*> objectSources = this->GetSources(); - if (!objectSources.empty() && this->IncludeThisTarget()) { - if (!cmSystemTools::FileExists(this->AbsBuildFilePath.c_str())) { - cmSystemTools::MakeDirectory(this->AbsBuildFilePath.c_str()); + // Determine type of target for this project + switch (this->GeneratorTarget->GetType()) { + case cmStateEnums::EXECUTABLE: { + // Get the name of the executable to generate. + std::string targetName; + std::string targetNameImport; + std::string targetNamePDB; + this->GeneratorTarget->GetExecutableNames( + targetName, this->TargetNameReal, targetNameImport, targetNamePDB, + this->ConfigName); + if (cmGhsMultiTargetGenerator::DetermineIfIntegrityApp()) { + this->TagType = GhsMultiGpj::INTERGRITY_APPLICATION; + } else { + this->TagType = GhsMultiGpj::PROGRAM; + } + break; + } + case cmStateEnums::STATIC_LIBRARY: { + std::string targetName; + std::string targetNameSO; + std::string targetNameImport; + std::string targetNamePDB; + this->GeneratorTarget->GetLibraryNames( + targetName, targetNameSO, this->TargetNameReal, targetNameImport, + targetNamePDB, this->ConfigName); + this->TagType = GhsMultiGpj::LIBRARY; + break; + } + case cmStateEnums::SHARED_LIBRARY: { + std::string msg = "add_library(<name> SHARED ...) not supported: "; + msg += this->Name; + cmSystemTools::Message(msg); + return; } - cmGlobalGhsMultiGenerator::Open(std::string(""), this->AbsBuildFileName, - &this->FolderBuildStreams); - cmGlobalGhsMultiGenerator::OpenBuildFileStream( - this->GetFolderBuildStreams()); - std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - if (0 == config.length()) { - config = "RELEASE"; + case cmStateEnums::OBJECT_LIBRARY: { + std::string targetName; + std::string targetNameSO; + std::string targetNameImport; + std::string targetNamePDB; + this->GeneratorTarget->GetLibraryNames( + targetName, targetNameSO, this->TargetNameReal, targetNameImport, + targetNamePDB, this->ConfigName); + this->TagType = GhsMultiGpj::SUBPROJECT; + break; } - const std::string language( - this->GeneratorTarget->GetLinkerLanguage(config)); - config = cmSystemTools::UpperCase(config); - this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); - if (this->DynamicDownload) { - *this->GetFolderBuildStreams() - << "#component integrity_dynamic_download" << std::endl; + case cmStateEnums::MODULE_LIBRARY: { + std::string msg = "add_library(<name> MODULE ...) not supported: "; + msg += this->Name; + cmSystemTools::Message(msg); + return; } - GhsMultiGpj::WriteGpjTag(this->GetGpjTag(), this->GetFolderBuildStreams()); - cmGlobalGhsMultiGenerator::WriteDisclaimer(this->GetFolderBuildStreams()); - - bool const notKernel = this->IsNotKernel(config, language); - this->WriteTypeSpecifics(config, notKernel); - this->SetCompilerFlags(config, language, notKernel); - this->WriteCompilerFlags(config, language); - this->WriteCompilerDefinitions(config, language); - this->WriteIncludes(config, language); - if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { - this->WriteTargetLinkLibraries(config, language); + case cmStateEnums::UTILITY: { + std::string msg = "add_custom_target(<name> ...) not supported: "; + msg += this->Name; + cmSystemTools::Message(msg); + return; } - this->WriteCustomCommands(); + default: + return; + } - std::map<const cmSourceFile*, std::string> objectNames = - cmGhsMultiTargetGenerator::GetObjectNames( - &objectSources, this->LocalGenerator, this->GeneratorTarget); + // Tell the global generator the name of the project file + this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME", + this->Name.c_str()); + this->GeneratorTarget->Target->SetProperty( + "GENERATOR_FILE_NAME_EXT", GhsMultiGpj::GetGpjTag(this->TagType)); - this->WriteSources(objectSources, objectNames); - } + this->GenerateTarget(); } -bool cmGhsMultiTargetGenerator::IncludeThisTarget() +void cmGhsMultiTargetGenerator::GenerateTarget() { - bool output = true; - char const* excludeFromAll = - this->GeneratorTarget->GetProperty("EXCLUDE_FROM_ALL"); - if (NULL != excludeFromAll && '1' == excludeFromAll[0] && - '\0' == excludeFromAll[1]) { - output = false; - } - return output; -} + // Open the filestream in copy-if-different mode. + std::string fname = this->LocalGenerator->GetCurrentBinaryDirectory(); + fname += "/"; + fname += this->Name; + fname += cmGlobalGhsMultiGenerator::FILE_EXTENSION; + cmGeneratedFileStream fout(fname.c_str()); + fout.SetCopyIfDifferent(true); -std::vector<cmSourceFile*> cmGhsMultiTargetGenerator::GetSources() const -{ - std::vector<cmSourceFile*> output; - std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->GeneratorTarget->GetSourceFiles(output, config); - return output; -} + this->GetGlobalGenerator()->WriteFileHeader(fout); + GhsMultiGpj::WriteGpjTag(this->TagType, fout); -GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag() const -{ - return cmGhsMultiTargetGenerator::GetGpjTag(this->GeneratorTarget); -} + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName)); -GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag( - const cmGeneratorTarget* target) -{ - GhsMultiGpj::Types output; - if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target)) { - output = GhsMultiGpj::INTERGRITY_APPLICATION; - } else if (target->GetType() == cmStateEnums::STATIC_LIBRARY) { - output = GhsMultiGpj::LIBRARY; - } else { - output = GhsMultiGpj::PROGRAM; - } - return output; + this->WriteTargetSpecifics(fout, this->ConfigName); + this->SetCompilerFlags(this->ConfigName, language); + this->WriteCompilerFlags(fout, this->ConfigName, language); + this->WriteCompilerDefinitions(fout, this->ConfigName, language); + this->WriteIncludes(fout, this->ConfigName, language); + this->WriteTargetLinkLine(fout, this->ConfigName); + this->WriteCustomCommands(fout); + this->WriteSources(fout); + this->WriteReferences(fout); + fout.Close(); } cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator() @@ -189,41 +141,28 @@ cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator() this->LocalGenerator->GetGlobalGenerator()); } -void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string& config, - bool const notKernel) +void cmGhsMultiTargetGenerator::WriteTargetSpecifics(std::ostream& fout, + const std::string& config) { - std::string outputDir(this->GetOutputDirectory(config)); - std::string outputFilename(this->GetOutputFilename(config)); - - if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { - std::string const& static_library_suffix = - this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); - *this->GetFolderBuildStreams() - << " -o \"" << outputDir << outputFilename << static_library_suffix - << "\"" << std::endl; - } else if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { - if (notKernel && !this->IsTargetGroup()) { - *this->GetFolderBuildStreams() << " -relprog" << std::endl; - } - if (this->IsTargetGroup()) { - *this->GetFolderBuildStreams() - << " -o \"" << outputDir << outputFilename << ".elf\"" << std::endl; - *this->GetFolderBuildStreams() - << " :extraOutputFile=\"" << outputDir << outputFilename - << ".elf.ael\"" << std::endl; - } else { - std::string const executable_suffix = - this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX"); - *this->GetFolderBuildStreams() - << " -o \"" << outputDir << outputFilename << executable_suffix - << "\"" << std::endl; - } + std::string outpath; + std::string rootpath = this->LocalGenerator->GetCurrentBinaryDirectory(); + + if (this->TagType != GhsMultiGpj::SUBPROJECT) { + // set target binary file destination + outpath = this->GeneratorTarget->GetDirectory(config); + outpath = + this->LocalGenerator->MaybeConvertToRelativePath(rootpath, outpath); + fout << " :binDirRelative=\"" << outpath << "\"" << std::endl; + fout << " -o \"" << this->TargetNameReal << "\"" << std::endl; } + + // set target object file destination + outpath = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); + fout << " :outputDirRelative=\"" << outpath << "\"" << std::endl; } void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config, - const std::string& language, - bool const notKernel) + const std::string& language) { std::map<std::string, std::string>::iterator i = this->FlagsByLanguage.find(language); @@ -231,14 +170,9 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config, std::string flags; const char* lang = language.c_str(); - if (notKernel) { - this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, - lang, config); - } else { - this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, - lang + std::string("_GHS_KERNEL"), - config); - } + this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, lang, + config); + this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang, config); this->LocalGenerator->AddVisibilityPresetFlags( @@ -281,21 +215,25 @@ std::string cmGhsMultiTargetGenerator::GetDefines(const std::string& language, return i->second; } -void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::string const&, +void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::ostream& fout, + std::string const&, const std::string& language) { std::map<std::string, std::string>::iterator flagsByLangI = this->FlagsByLanguage.find(language); if (flagsByLangI != this->FlagsByLanguage.end()) { if (!flagsByLangI->second.empty()) { - *this->GetFolderBuildStreams() - << " " << flagsByLangI->second << std::endl; + std::vector<std::string> ghsCompFlags = + cmSystemTools::ParseArguments(flagsByLangI->second.c_str()); + for (auto& f : ghsCompFlags) { + fout << " " << f << std::endl; + } } } } void cmGhsMultiTargetGenerator::WriteCompilerDefinitions( - const std::string& config, const std::string& language) + std::ostream& fout, const std::string& config, const std::string& language) { std::vector<std::string> compileDefinitions; this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, config, @@ -303,11 +241,12 @@ void cmGhsMultiTargetGenerator::WriteCompilerDefinitions( for (std::vector<std::string>::const_iterator cdI = compileDefinitions.begin(); cdI != compileDefinitions.end(); ++cdI) { - *this->GetFolderBuildStreams() << " -D" << (*cdI) << std::endl; + fout << " -D" << (*cdI) << std::endl; } } -void cmGhsMultiTargetGenerator::WriteIncludes(const std::string& config, +void cmGhsMultiTargetGenerator::WriteIncludes(std::ostream& fout, + const std::string& config, const std::string& language) { std::vector<std::string> includes; @@ -316,80 +255,73 @@ void cmGhsMultiTargetGenerator::WriteIncludes(const std::string& config, for (std::vector<std::string>::const_iterator includes_i = includes.begin(); includes_i != includes.end(); ++includes_i) { - *this->GetFolderBuildStreams() - << " -I\"" << *includes_i << "\"" << std::endl; + fout << " -I\"" << *includes_i << "\"" << std::endl; } } -void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries( - std::string const& config, std::string const& language) +void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout, + std::string const& config) { - // library directories - cmTargetDependSet tds = - this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget); - for (cmTargetDependSet::iterator tdsI = tds.begin(); tdsI != tds.end(); - ++tdsI) { - const cmGeneratorTarget* tg = *tdsI; - *this->GetFolderBuildStreams() - << " -L\"" << GetAbsBuildFilePath(tg) << "\"" << std::endl; + if (this->TagType == GhsMultiGpj::INTERGRITY_APPLICATION) { + return; } - // library targets - cmTarget::LinkLibraryVectorType llv = - this->GeneratorTarget->Target->GetOriginalLinkLibraries(); - for (cmTarget::LinkLibraryVectorType::const_iterator llvI = llv.begin(); - llvI != llv.end(); ++llvI) { - std::string libName = llvI->first; - // if it is a user defined target get the full path to the lib - cmTarget* tg(GetGlobalGenerator()->FindTarget(libName)); - if (NULL != tg) { - libName = tg->GetName() + ".a"; - } - *this->GetFolderBuildStreams() - << " -l\"" << libName << "\"" << std::endl; + + std::string linkLibraries; + std::string flags; + std::string linkFlags; + std::string frameworkPath; + std::string linkPath; + + std::unique_ptr<cmLinkLineComputer> linkLineComputer( + this->GetGlobalGenerator()->CreateLinkLineComputer( + this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory())); + + this->LocalGenerator->GetTargetFlags( + linkLineComputer.get(), config, linkLibraries, flags, linkFlags, + frameworkPath, linkPath, this->GeneratorTarget); + + // write out link options + std::vector<std::string> lopts = + cmSystemTools::ParseArguments(linkFlags.c_str()); + for (auto& l : lopts) { + fout << " " << l << std::endl; } - if (!this->TargetGroup) { - std::string linkLibraries; - std::string flags; - std::string linkFlags; - std::string frameworkPath; - std::string linkPath; - std::string createRule = - this->GeneratorTarget->GetCreateRuleVariable(language, config); - bool useWatcomQuote = - this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE"); - std::unique_ptr<cmLinkLineComputer> linkLineComputer( - this->GetGlobalGenerator()->CreateLinkLineComputer( - this->LocalGenerator, - this->LocalGenerator->GetStateSnapshot().GetDirectory())); - linkLineComputer->SetUseWatcomQuote(useWatcomQuote); - - this->LocalGenerator->GetTargetFlags( - linkLineComputer.get(), config, linkLibraries, flags, linkFlags, - frameworkPath, linkPath, this->GeneratorTarget); - linkFlags = cmSystemTools::TrimWhitespace(linkFlags); - - if (!linkPath.empty()) { - linkPath = " " + linkPath.substr(0U, linkPath.size() - 1U); - *this->GetFolderBuildStreams() << linkPath; - } + // write out link search paths + // must be quoted for paths that contain spaces + std::vector<std::string> lpath = + cmSystemTools::ParseArguments(linkPath.c_str()); + for (auto& l : lpath) { + fout << " -L\"" << l << "\"" << std::endl; + } + + // write out link libs + // must be quoted for filepaths that contains spaces + std::string cbd = this->LocalGenerator->GetCurrentBinaryDirectory(); - if (!linkFlags.empty()) { - *this->GetFolderBuildStreams() << " " << linkFlags << std::endl; + std::vector<std::string> llibs = + cmSystemTools::ParseArguments(linkLibraries.c_str()); + for (auto& l : llibs) { + if (l.compare(0, 2, "-l") == 0) { + fout << " \"" << l << "\"" << std::endl; + } else { + std::string rl = cmSystemTools::CollapseCombinedPath(cbd, l); + fout << " -l\"" << rl << "\"" << std::endl; } } } -void cmGhsMultiTargetGenerator::WriteCustomCommands() +void cmGhsMultiTargetGenerator::WriteCustomCommands(std::ostream& fout) { - WriteCustomCommandsHelper(this->GeneratorTarget->GetPreBuildCommands(), + WriteCustomCommandsHelper(fout, this->GeneratorTarget->GetPreBuildCommands(), cmTarget::PRE_BUILD); - WriteCustomCommandsHelper(this->GeneratorTarget->GetPostBuildCommands(), - cmTarget::POST_BUILD); + WriteCustomCommandsHelper( + fout, this->GeneratorTarget->GetPostBuildCommands(), cmTarget::POST_BUILD); } void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper( - std::vector<cmCustomCommand> const& commandsSet, + std::ostream& fout, std::vector<cmCustomCommand> const& commandsSet, cmTarget::CustomCommandType const commandType) { for (std::vector<cmCustomCommand>::const_iterator commandsSetI = @@ -400,10 +332,10 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper( commandI != commands.end(); ++commandI) { switch (commandType) { case cmTarget::PRE_BUILD: - *this->GetFolderBuildStreams() << " :preexecShellSafe="; + fout << " :preexecShellSafe="; break; case cmTarget::POST_BUILD: - *this->GetFolderBuildStreams() << " :postexecShellSafe="; + fout << " :postexecShellSafe="; break; default: assert("Only pre and post are supported"); @@ -414,242 +346,237 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper( std::string subCommandE = this->LocalGenerator->EscapeForShell(*commandLineI, true); if (!command.empty()) { - *this->GetFolderBuildStreams() - << (command.begin() == commandLineI ? "'" : " "); + fout << (command.begin() == commandLineI ? "'" : " "); // Need to double escape backslashes cmSystemTools::ReplaceString(subCommandE, "\\", "\\\\"); } - *this->GetFolderBuildStreams() << subCommandE; + fout << subCommandE; } if (!command.empty()) { - *this->GetFolderBuildStreams() << "'" << std::endl; + fout << "'" << std::endl; } } } } -std::map<const cmSourceFile*, std::string> -cmGhsMultiTargetGenerator::GetObjectNames( - std::vector<cmSourceFile*>* const objectSources, - cmLocalGhsMultiGenerator* const localGhsMultiGenerator, - cmGeneratorTarget* const generatorTarget) +void cmGhsMultiTargetGenerator::WriteSourceProperty(std::ostream& fout, + const cmSourceFile* sf, + std::string propName, + std::string propFlag) { - std::map<std::string, std::vector<cmSourceFile*>> filenameToSource; - std::map<cmSourceFile*, std::string> sourceToFilename; - for (std::vector<cmSourceFile*>::const_iterator sf = objectSources->begin(); - sf != objectSources->end(); ++sf) { - const std::string filename = - cmSystemTools::GetFilenameName((*sf)->GetFullPath()); - const std::string lower_filename = cmSystemTools::LowerCase(filename); - filenameToSource[lower_filename].push_back(*sf); - sourceToFilename[*sf] = lower_filename; - } - - std::vector<cmSourceFile*> duplicateSources; - for (std::map<std::string, std::vector<cmSourceFile*>>::const_iterator - msvSourceI = filenameToSource.begin(); - msvSourceI != filenameToSource.end(); ++msvSourceI) { - if (msvSourceI->second.size() > 1) { - duplicateSources.insert(duplicateSources.end(), - msvSourceI->second.begin(), - msvSourceI->second.end()); + const char* prop = sf->GetProperty(propName); + if (prop) { + std::vector<std::string> list; + cmSystemTools::ExpandListArgument(prop, list); + for (auto& p : list) { + fout << " " << propFlag << p << std::endl; } } - - std::map<const cmSourceFile*, std::string> objectNamesCorrected; - - for (std::vector<cmSourceFile*>::const_iterator sf = - duplicateSources.begin(); - sf != duplicateSources.end(); ++sf) { - std::string const longestObjectDirectory( - cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory( - localGhsMultiGenerator, generatorTarget, *sf)); - std::string objFilenameName = - localGhsMultiGenerator->GetObjectFileNameWithoutTarget( - **sf, longestObjectDirectory); - cmsys::SystemTools::ReplaceString(objFilenameName, "/", "_"); - objectNamesCorrected[*sf] = objFilenameName; - } - - return objectNamesCorrected; } -void cmGhsMultiTargetGenerator::WriteSources( - std::vector<cmSourceFile*> const& objectSources, - std::map<const cmSourceFile*, std::string> const& objectNames) +void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj) { - for (const cmSourceFile* sf : objectSources) { - std::vector<cmSourceGroup> sourceGroups(this->Makefile->GetSourceGroups()); - std::string const& sourceFullPath = sf->GetFullPath(); - cmSourceGroup* sourceGroup = - this->Makefile->FindSourceGroup(sourceFullPath, sourceGroups); - std::string sgPath = sourceGroup->GetFullName(); - cmSystemTools::ConvertToUnixSlashes(sgPath); - cmGlobalGhsMultiGenerator::AddFilesUpToPath( - this->GetFolderBuildStreams(), &this->FolderBuildStreams, - this->LocalGenerator->GetBinaryDirectory().c_str(), sgPath, - GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath); - - std::string fullSourcePath(sf->GetFullPath()); - if (sf->GetExtension() == "int" || sf->GetExtension() == "bsp") { - *this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl; - } else { - // WORKAROUND: GHS MULTI needs the path to use backslashes without quotes - // to open files in search as of version 6.1.6 - cmsys::SystemTools::ReplaceString(fullSourcePath, "/", "\\"); - *this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl; - } + /* vector of all sources for this target */ + std::vector<cmSourceFile*> sources; + this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName); - if ("ld" != sf->GetExtension() && "int" != sf->GetExtension() && - "bsp" != sf->GetExtension()) { - this->WriteObjectLangOverride(this->FolderBuildStreams[sgPath], sf); - if (objectNames.end() != objectNames.find(sf)) { - *this->FolderBuildStreams[sgPath] - << " -o \"" << objectNames.find(sf)->second << "\"" << std::endl; - } + /* vector of all groups defined for this target + * -- but the vector is not expanded with sub groups or in any useful order + */ + std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); - this->WriteObjectDir(this->FolderBuildStreams[sgPath], - this->AbsBuildFilePath + sgPath); - } + /* for each source file assign it to its group */ + std::map<std::string, std::vector<cmSourceFile*>> groupFiles; + std::set<std::string> groupNames; + for (auto& sf : sources) { + cmSourceGroup* sourceGroup = + this->Makefile->FindSourceGroup(sf->GetFullPath(), sourceGroups); + std::string gn = sourceGroup->GetFullName(); + groupFiles[gn].push_back(sf); + groupNames.insert(gn); } -} -void cmGhsMultiTargetGenerator::WriteObjectLangOverride( - cmGeneratedFileStream* fileStream, const cmSourceFile* sourceFile) -{ - const char* rawLangProp = sourceFile->GetProperty("LANGUAGE"); - if (NULL != rawLangProp) { - std::string sourceLangProp(rawLangProp); - std::string extension(sourceFile->GetExtension()); - if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) { - *fileStream << " -dotciscxx" << std::endl; + /* list of known groups and the order they are displayed in a project file */ + const std::vector<std::string> standardGroups = { + "Header Files", "Source Files", "CMake Rules", + "Object Files", "Object Libraries", "Resources" + }; + + /* list of groups in the order they are displayed in a project file*/ + std::vector<std::string> groupFilesList(groupFiles.size()); + + /* put the groups in the order they should be listed + * - standard groups first, and then everything else + * in the order used by std::map. + */ + int i = 0; + for (const std::string& gn : standardGroups) { + auto n = groupNames.find(gn); + if (n != groupNames.end()) { + groupFilesList[i] = *n; + i += 1; + groupNames.erase(gn); } } -} -void cmGhsMultiTargetGenerator::WriteObjectDir( - cmGeneratedFileStream* fileStream, std::string const& dir) -{ - std::string workingDir(dir); - cmSystemTools::ConvertToUnixSlashes(workingDir); - if (!workingDir.empty()) { - workingDir += "/"; + { /* catch-all group - is last item */ + std::string gn = ""; + auto n = groupNames.find(gn); + if (n != groupNames.end()) { + groupFilesList.back() = *n; + groupNames.erase(gn); + } } - workingDir += "Objs"; - *fileStream << " -object_dir=\"" << workingDir << "\"" << std::endl; -} -std::string cmGhsMultiTargetGenerator::GetOutputDirectory( - const std::string& config) const -{ - std::string outputDir(AbsBuildFilePath); - - const char* runtimeOutputProp = - this->GeneratorTarget->GetProperty("RUNTIME_OUTPUT_DIRECTORY"); - if (NULL != runtimeOutputProp) { - outputDir = runtimeOutputProp; + for (auto& n : groupNames) { + groupFilesList[i] = n; + i += 1; } - std::string configCapped(cmSystemTools::UpperCase(config)); - const char* runtimeOutputSProp = this->GeneratorTarget->GetProperty( - "RUNTIME_OUTPUT_DIRECTORY_" + configCapped); - if (NULL != runtimeOutputSProp) { - outputDir = runtimeOutputSProp; + /* sort the files within each group */ + for (auto& n : groupFilesList) { + std::sort(groupFiles[n].begin(), groupFiles[n].end(), + [](cmSourceFile* l, cmSourceFile* r) { + return l->GetFullPath() < r->GetFullPath(); + }); } - cmSystemTools::ConvertToUnixSlashes(outputDir); - if (!outputDir.empty()) { - outputDir += "/"; - } + /* list of open project files */ + std::vector<cmGeneratedFileStream*> gfiles; + + /* write files into the proper project file + * -- groups go into main project file + * unless FOLDER property or variable is set. + */ + for (auto& sg : groupFilesList) { + std::ostream* fout; + bool useProjectFile = + cmSystemTools::IsOn( + this->GeneratorTarget->GetProperty("GHS_NO_SOURCE_GROUP_FILE")) || + cmSystemTools::IsOn( + this->Makefile->GetDefinition("GHS_NO_SOURCE_GROUP_FILE")); + if (useProjectFile || sg.empty()) { + fout = &fout_proj; + } else { + // Open the filestream in copy-if-different mode. + std::string gname = sg; + cmsys::SystemTools::ReplaceString(gname, "\\", "_"); + std::string lpath = + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); + lpath += "/"; + lpath += gname; + lpath += cmGlobalGhsMultiGenerator::FILE_EXTENSION; + std::string fpath = this->LocalGenerator->GetCurrentBinaryDirectory(); + fpath += "/"; + fpath += lpath; + cmGeneratedFileStream* f = new cmGeneratedFileStream(fpath.c_str()); + f->SetCopyIfDifferent(true); + gfiles.push_back(f); + fout = f; + this->GetGlobalGenerator()->WriteFileHeader(*f); + GhsMultiGpj::WriteGpjTag(GhsMultiGpj::SUBPROJECT, *f); + fout_proj << lpath << " "; + GhsMultiGpj::WriteGpjTag(GhsMultiGpj::SUBPROJECT, fout_proj); + } - return outputDir; -} + if (useProjectFile) { + if (sg.empty()) { + *fout << "{comment} Others" << std::endl; + } else { + *fout << "{comment} " << sg << std::endl; + } + } -std::string cmGhsMultiTargetGenerator::GetOutputFilename( - const std::string& config) const -{ - std::string outputFilename(this->GeneratorTarget->GetName()); + /* output rule for each source file */ + for (const cmSourceFile* si : groupFiles[sg]) { - const char* outputNameProp = - this->GeneratorTarget->GetProperty("OUTPUT_NAME"); - if (NULL != outputNameProp) { - outputFilename = outputNameProp; - } + // Convert filename to native system + // WORKAROUND: GHS MULTI 6.1.4 and 6.1.6 are known to need backslash on + // windows when opening some files from the search window. + std::string fname(si->GetFullPath()); + cmSystemTools::ConvertToOutputSlashes(fname); + *fout << fname << std::endl; + + if ("ld" != si->GetExtension() && "int" != si->GetExtension() && + "bsp" != si->GetExtension()) { + this->WriteObjectLangOverride(*fout, si); + } + + this->WriteSourceProperty(*fout, si, "INCLUDE_DIRECTORIES", "-I"); + this->WriteSourceProperty(*fout, si, "COMPILE_DEFINITIONS", "-D"); + this->WriteSourceProperty(*fout, si, "COMPILE_OPTIONS", ""); - std::string configCapped(cmSystemTools::UpperCase(config)); - const char* outputNameSProp = - this->GeneratorTarget->GetProperty(configCapped + "_OUTPUT_NAME"); - if (NULL != outputNameSProp) { - outputFilename = outputNameSProp; + /* to avoid clutter in the gui only print out the objectName if it has + * been renamed */ + std::string objectName = this->GeneratorTarget->GetObjectName(si); + if (!objectName.empty() && + this->GeneratorTarget->HasExplicitObjectName(si)) { + *fout << " -o " << objectName << std::endl; + } + } } - return outputFilename; + for (cmGeneratedFileStream* f : gfiles) { + f->Close(); + } } -std::string cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory( - cmLocalGhsMultiGenerator const* localGhsMultiGenerator, - cmGeneratorTarget* const generatorTarget, cmSourceFile* const sourceFile) +void cmGhsMultiTargetGenerator::WriteObjectLangOverride( + std::ostream& fout, const cmSourceFile* sourceFile) { - std::string dir_max; - dir_max += - localGhsMultiGenerator->GetMakefile()->GetCurrentBinaryDirectory(); - dir_max += "/"; - dir_max += generatorTarget->Target->GetName(); - dir_max += "/"; - std::vector<cmSourceGroup> sourceGroups( - localGhsMultiGenerator->GetMakefile()->GetSourceGroups()); - std::string const& sourceFullPath = sourceFile->GetFullPath(); - cmSourceGroup* sourceGroup = - localGhsMultiGenerator->GetMakefile()->FindSourceGroup(sourceFullPath, - sourceGroups); - std::string const& sgPath = sourceGroup->GetFullName(); - dir_max += sgPath; - dir_max += "/Objs/libs/"; - dir_max += generatorTarget->Target->GetName(); - dir_max += "/"; - return dir_max; + const char* rawLangProp = sourceFile->GetProperty("LANGUAGE"); + if (NULL != rawLangProp) { + std::string sourceLangProp(rawLangProp); + std::string extension(sourceFile->GetExtension()); + if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) { + fout << " -dotciscxx" << std::endl; + } + } } -bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const& config, - const std::string& language) +void cmGhsMultiTargetGenerator::WriteReferences(std::ostream& fout) { - bool output; - std::vector<std::string> options; - this->GeneratorTarget->GetCompileOptions(options, config, language); - output = - options.end() == std::find(options.begin(), options.end(), "-kernel"); - return output; -} + // This only applies to INTEGRITY Applications + if (this->TagType != GhsMultiGpj::INTERGRITY_APPLICATION) { + return; + } -bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup( - const cmGeneratorTarget* target) -{ - bool output = false; - std::vector<cmSourceFile*> sources; - std::string config = - target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); - target->GetSourceFiles(sources, config); - for (std::vector<cmSourceFile*>::const_iterator sources_i = sources.begin(); - sources.end() != sources_i; ++sources_i) { - if ("int" == (*sources_i)->GetExtension()) { - output = true; - } + // Get the targets that this one depends upon + cmTargetDependSet unordered = + this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget); + cmGlobalGhsMultiGenerator::OrderedTargetDependSet ordered(unordered, + this->Name); + for (auto& t : ordered) { + std::string tname = t->GetName(); + std::string tpath = t->LocalGenerator->GetCurrentBinaryDirectory(); + std::string rootpath = this->LocalGenerator->GetCurrentBinaryDirectory(); + std::string outpath = + this->LocalGenerator->MaybeConvertToRelativePath(rootpath, tpath) + "/" + + tname + "REF" + cmGlobalGhsMultiGenerator::FILE_EXTENSION; + + fout << outpath; + fout << " "; + GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fout); + + // Tell the global generator that a refernce project needs to be created + t->Target->SetProperty("GHS_REFERENCE_PROJECT", "ON"); } - return output; } -bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload( - std::string const& config, const std::string& language) +bool cmGhsMultiTargetGenerator::DetermineIfIntegrityApp(void) { - std::vector<std::string> options; - bool output = false; - this->GeneratorTarget->GetCompileOptions(options, config, language); - for (std::vector<std::string>::const_iterator options_i = options.begin(); - options_i != options.end(); ++options_i) { - std::string option = *options_i; - if (this->DDOption == option) { - output = true; + const char* p = this->GeneratorTarget->GetProperty("ghs_integrity_app"); + if (p) { + return cmSystemTools::IsOn( + this->GeneratorTarget->GetProperty("ghs_integrity_app")); + } else { + std::vector<cmSourceFile*> sources; + this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName); + for (auto& sf : sources) { + if ("int" == sf->GetExtension()) { + return true; + } } + return false; } - return output; } diff --git a/Source/cmGhsMultiTargetGenerator.h b/Source/cmGhsMultiTargetGenerator.h index e936b08376..a241cc6bda 100644 --- a/Source/cmGhsMultiTargetGenerator.h +++ b/Source/cmGhsMultiTargetGenerator.h @@ -24,97 +24,49 @@ public: virtual void Generate(); - bool IncludeThisTarget(); - std::vector<cmSourceFile*> GetSources() const; - GhsMultiGpj::Types GetGpjTag() const; - static GhsMultiGpj::Types GetGpjTag(const cmGeneratorTarget* target); - const char* GetAbsBuildFilePath() const - { - return this->AbsBuildFilePath.c_str(); - } - const char* GetRelBuildFileName() const - { - return this->RelBuildFileName.c_str(); - } - const char* GetAbsBuildFileName() const - { - return this->AbsBuildFileName.c_str(); - } - const char* GetAbsOutputFileName() const - { - return this->AbsOutputFileName.c_str(); - } - - static std::string GetRelBuildFilePath(const cmGeneratorTarget* target); - static std::string GetAbsPathToRoot(const cmGeneratorTarget* target); - static std::string GetAbsBuildFilePath(const cmGeneratorTarget* target); - static std::string GetRelBuildFileName(const cmGeneratorTarget* target); - static std::string GetBuildFileName(const cmGeneratorTarget* target); - static std::string AddSlashIfNeededToPath(std::string const& input); - private: cmGlobalGhsMultiGenerator* GetGlobalGenerator() const; - cmGeneratedFileStream* GetFolderBuildStreams() - { - return this->FolderBuildStreams[""]; - }; - bool IsTargetGroup() const { return this->TargetGroup; } - - void WriteTypeSpecifics(const std::string& config, bool notKernel); - void WriteCompilerFlags(const std::string& config, + + void GenerateTarget(); + + void WriteTargetSpecifics(std::ostream& fout, const std::string& config); + + void WriteCompilerFlags(std::ostream& fout, const std::string& config, const std::string& language); - void WriteCompilerDefinitions(const std::string& config, + void WriteCompilerDefinitions(std::ostream& fout, const std::string& config, const std::string& language); - void SetCompilerFlags(std::string const& config, const std::string& language, - bool const notKernel); + void SetCompilerFlags(std::string const& config, + const std::string& language); + std::string GetDefines(const std::string& langugae, std::string const& config); - void WriteIncludes(const std::string& config, const std::string& language); - void WriteTargetLinkLibraries(std::string const& config, - std::string const& language); - void WriteCustomCommands(); + void WriteIncludes(std::ostream& fout, const std::string& config, + const std::string& language); + void WriteTargetLinkLine(std::ostream& fout, std::string const& config); + void WriteCustomCommands(std::ostream& fout); void WriteCustomCommandsHelper( - std::vector<cmCustomCommand> const& commandsSet, + std::ostream& fout, std::vector<cmCustomCommand> const& commandsSet, cmTarget::CustomCommandType commandType); - void WriteSources( - std::vector<cmSourceFile*> const& objectSources, - std::map<const cmSourceFile*, std::string> const& objectNames); - static std::map<const cmSourceFile*, std::string> GetObjectNames( - std::vector<cmSourceFile*>* objectSources, - cmLocalGhsMultiGenerator* localGhsMultiGenerator, - cmGeneratorTarget* generatorTarget); - static void WriteObjectLangOverride(cmGeneratedFileStream* fileStream, + void WriteSources(std::ostream& fout_proj); + void WriteSourceProperty(std::ostream& fout, const cmSourceFile* sf, + std::string propName, std::string propFlag); + void WriteReferences(std::ostream& fout); + static void WriteObjectLangOverride(std::ostream& fout, const cmSourceFile* sourceFile); - static void WriteObjectDir(cmGeneratedFileStream* fileStream, - std::string const& dir); - std::string GetOutputDirectory(const std::string& config) const; - std::string GetOutputFilename(const std::string& config) const; - static std::string ComputeLongestObjectDirectory( - cmLocalGhsMultiGenerator const* localGhsMultiGenerator, - cmGeneratorTarget* generatorTarget, cmSourceFile* const sourceFile); - - bool IsNotKernel(std::string const& config, const std::string& language); - static bool DetermineIfTargetGroup(const cmGeneratorTarget* target); - bool DetermineIfDynamicDownload(std::string const& config, - const std::string& language); + bool DetermineIfIntegrityApp(void); cmGeneratorTarget* GeneratorTarget; cmLocalGhsMultiGenerator* LocalGenerator; cmMakefile* Makefile; - std::string AbsBuildFilePath; - std::string RelBuildFilePath; - std::string AbsBuildFileName; - std::string RelBuildFileName; - std::string RelOutputFileName; - std::string AbsOutputFileName; - std::map<std::string, cmGeneratedFileStream*> FolderBuildStreams; - bool TargetGroup; - bool DynamicDownload; - static std::string const DDOption; std::map<std::string, std::string> FlagsByLanguage; std::map<std::string, std::string> DefinesByLanguage; + + std::string TargetNameReal; + GhsMultiGpj::Types TagType; + std::string const Name; + std::string ConfigName; /* CMAKE_BUILD_TYPE */ }; #endif // ! cmGhsMultiTargetGenerator_h diff --git a/Source/cmGlobVerificationManager.cxx b/Source/cmGlobVerificationManager.cxx index e8959f2a06..5fd890eab7 100644 --- a/Source/cmGlobVerificationManager.cxx +++ b/Source/cmGlobVerificationManager.cxx @@ -9,7 +9,6 @@ #include "cmListFileCache.h" #include "cmSystemTools.h" #include "cmVersion.h" -#include "cmake.h" bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path) { @@ -18,7 +17,7 @@ bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path) } std::string scriptFile = path; - scriptFile += cmake::GetCMakeFilesDirectory(); + scriptFile += "/CMakeFiles"; std::string stampFile = scriptFile; cmSystemTools::MakeDirectory(scriptFile); scriptFile += "/VerifyGlobs.cmake"; @@ -165,7 +164,7 @@ void cmGlobVerificationManager::AddCacheEntry( message << "\n " << std::get<0>(bt); std::get<1>(bt).PrintTitle(message); } - cmSystemTools::Error(message.str().c_str()); + cmSystemTools::Error(message.str()); } else { value.Backtraces.emplace_back(variable, backtrace); } diff --git a/Source/cmGlobVerificationManager.h b/Source/cmGlobVerificationManager.h index cdbd27510a..f7146bec09 100644 --- a/Source/cmGlobVerificationManager.h +++ b/Source/cmGlobVerificationManager.h @@ -21,9 +21,6 @@ */ class cmGlobVerificationManager { -public: - cmGlobVerificationManager() {} - protected: ///! Save verification script for given makefile. ///! Saves to output <path>/<CMakeFilesDirectory>/VerifyGlobs.cmake @@ -55,13 +52,13 @@ private: const bool FollowSymlinks; const std::string Relative; const std::string Expression; - CacheEntryKey(const bool rec, const bool l, const bool s, - const std::string& rel, const std::string& e) + CacheEntryKey(const bool rec, const bool l, const bool s, std::string rel, + std::string e) : Recurse(rec) , ListDirectories(l) , FollowSymlinks(s) - , Relative(rel) - , Expression(e) + , Relative(std::move(rel)) + , Expression(std::move(e)) { } bool operator<(const CacheEntryKey& r) const; @@ -73,7 +70,6 @@ private: bool Initialized = false; std::vector<std::string> Files; std::vector<std::pair<std::string, cmListFileBacktrace>> Backtraces; - CacheEntryValue() {} }; typedef std::map<CacheEntryKey, CacheEntryValue> CacheEntryMap; diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 56714b1501..c2eb583a93 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -54,7 +54,7 @@ void cmGlobalBorlandMakefileGenerator::GetDocumentation( } void cmGlobalBorlandMakefileGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, int /*jobs*/, bool verbose, std::vector<std::string> const& makeOptions) diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 27de6cc6c8..ca04b7b739 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -46,7 +46,7 @@ public: bool AllowDeleteOnError() const override { return false; } protected: - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx index 3b7de4b9c4..bf992b48be 100644 --- a/Source/cmGlobalCommonGenerator.cxx +++ b/Source/cmGlobalCommonGenerator.cxx @@ -9,6 +9,4 @@ cmGlobalCommonGenerator::cmGlobalCommonGenerator(cmake* cm) { } -cmGlobalCommonGenerator::~cmGlobalCommonGenerator() -{ -} +cmGlobalCommonGenerator::~cmGlobalCommonGenerator() = default; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 85c2345afa..386a3f716c 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -33,7 +33,6 @@ #include "cmMSVC60LinkLineComputer.h" #include "cmMakefile.h" #include "cmMessageType.h" -#include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmSourceFile.h" #include "cmState.h" @@ -98,6 +97,8 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) this->ConfigureDoneCMP0026AndCMP0024 = false; this->FirstTimeProgress = 0.0f; + this->RecursionDepth = 0; + cm->GetState()->SetIsGeneratorMultiConfig(false); cm->GetState()->SetMinGWMake(false); cm->GetState()->SetMSYSShell(false); @@ -302,7 +303,8 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const for (cmGeneratorTarget* target : targets) { if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET || target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY || - target->GetType() == cmStateEnums::TargetType::UTILITY) { + target->GetType() == cmStateEnums::TargetType::UTILITY || + cmSystemTools::IsOn(target->GetProperty("ghs_integrity_app"))) { continue; } @@ -352,10 +354,9 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) } if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") || cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { - std::string setMakeProgram = - mf->GetModulesFile(this->FindMakeProgramFile.c_str()); + std::string setMakeProgram = mf->GetModulesFile(this->FindMakeProgramFile); if (!setMakeProgram.empty()) { - mf->ReadListFile(setMakeProgram.c_str()); + mf->ReadListFile(setMakeProgram); } } if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") || @@ -364,7 +365,7 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) err << "CMake was unable to find a build program corresponding to \"" << this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You " << "probably need to select a different build tool."; - cmSystemTools::Error(err.str().c_str()); + cmSystemTools::Error(err.str()); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -463,11 +464,10 @@ void cmGlobalGenerator::EnableLanguage( if (this->TryCompileOuterMakefile) { // In a try-compile we can only enable languages provided by caller. - for (std::string const& li : languages) { - if (li == "NONE") { + for (std::string const& lang : languages) { + if (lang == "NONE") { this->SetLanguageEnabled("NONE", mf); } else { - const char* lang = li.c_str(); if (this->LanguagesReady.find(lang) == this->LanguagesReady.end()) { std::ostringstream e; e << "The test project needs language " << lang @@ -485,7 +485,7 @@ void cmGlobalGenerator::EnableLanguage( mf->AddDefinition("RUN_CONFIGURE", true); std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory(); - rootBin += cmake::GetCMakeFilesDirectory(); + rootBin += "/CMakeFiles"; // If the configuration files path has been set, // then we are in a try compile and need to copy the enable language @@ -522,7 +522,7 @@ void cmGlobalGenerator::EnableLanguage( if (readCMakeSystem) { fpath += "/CMakeSystem.cmake"; if (cmSystemTools::FileExists(fpath)) { - mf->ReadListFile(fpath.c_str()); + mf->ReadListFile(fpath); } } // Load the CMakeDetermineSystem.cmake file and find out @@ -551,12 +551,12 @@ void cmGlobalGenerator::EnableLanguage( #endif // Read the DetermineSystem file std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake"); - mf->ReadListFile(systemFile.c_str()); + mf->ReadListFile(systemFile); // load the CMakeSystem.cmake from the binary directory // this file is configured by the CMakeDetermineSystem.cmake file fpath = rootBin; fpath += "/CMakeSystem.cmake"; - mf->ReadListFile(fpath.c_str()); + mf->ReadListFile(fpath); } if (readCMakeSystem) { @@ -567,11 +567,6 @@ void cmGlobalGenerator::EnableLanguage( return; } - // Find the native build tool for this generator. - if (!this->FindMakeProgram(mf)) { - return; - } - // Tell the generator about the target system. std::string system = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); if (!this->SetSystemName(system, mf)) { @@ -592,6 +587,11 @@ void cmGlobalGenerator::EnableLanguage( cmSystemTools::SetFatalErrorOccured(); return; } + + // Find the native build tool for this generator. + if (!this->FindMakeProgram(mf)) { + return; + } } // Check that the languages are supported by the generator and its @@ -603,7 +603,7 @@ void cmGlobalGenerator::EnableLanguage( // **** Load the system specific initialization if not yet loaded if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED")) { fpath = mf->GetModulesFile("CMakeSystemSpecificInitialize.cmake"); - if (!mf->ReadListFile(fpath.c_str())) { + if (!mf->ReadListFile(fpath)) { cmSystemTools::Error("Could not find cmake module file: " "CMakeSystemSpecificInitialize.cmake"); } @@ -615,10 +615,9 @@ void cmGlobalGenerator::EnableLanguage( // load the CMakeDetermine(LANG)Compiler.cmake file to find // the compiler - for (std::string const& l : languages) { - const char* lang = l.c_str(); + for (std::string const& lang : languages) { needSetLanguageEnabledMaps[lang] = false; - if (l == "NONE") { + if (lang == "NONE") { this->SetLanguageEnabled("NONE", mf); continue; } @@ -635,7 +634,7 @@ void cmGlobalGenerator::EnableLanguage( // version of CMake then try to load the configured file first // to avoid duplicate compiler tests. if (cmSystemTools::FileExists(fpath)) { - if (!mf->ReadListFile(fpath.c_str())) { + if (!mf->ReadListFile(fpath)) { cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); } @@ -660,9 +659,8 @@ void cmGlobalGenerator::EnableLanguage( std::string determineCompiler = "CMakeDetermine"; determineCompiler += lang; determineCompiler += "Compiler.cmake"; - std::string determineFile = - mf->GetModulesFile(determineCompiler.c_str()); - if (!mf->ReadListFile(determineFile.c_str())) { + std::string determineFile = mf->GetModulesFile(determineCompiler); + if (!mf->ReadListFile(determineFile)) { cmSystemTools::Error("Could not find cmake module file: ", determineCompiler.c_str()); } @@ -696,7 +694,7 @@ void cmGlobalGenerator::EnableLanguage( fpath += "/CMake"; fpath += lang; fpath += "Compiler.cmake"; - if (!mf->ReadListFile(fpath.c_str())) { + if (!mf->ReadListFile(fpath)) { cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); } @@ -713,16 +711,15 @@ void cmGlobalGenerator::EnableLanguage( // **** Load the system specific information if not yet loaded if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED")) { fpath = mf->GetModulesFile("CMakeSystemSpecificInformation.cmake"); - if (!mf->ReadListFile(fpath.c_str())) { + if (!mf->ReadListFile(fpath)) { cmSystemTools::Error("Could not find cmake module file: " "CMakeSystemSpecificInformation.cmake"); } } // loop over languages again loading CMake(LANG)Information.cmake // - for (std::string const& l : languages) { - const char* lang = l.c_str(); - if (l == "NONE") { + for (std::string const& lang : languages) { + if (lang == "NONE") { this->SetLanguageEnabled("NONE", mf); continue; } @@ -743,7 +740,7 @@ void cmGlobalGenerator::EnableLanguage( "No " << compilerName << " could be found.\n" ; /* clang-format on */ - } else if (strcmp(lang, "RC") != 0 && strcmp(lang, "ASM_MASM") != 0) { + } else if ((lang != "RC") && (lang != "ASM_MASM")) { if (!cmSystemTools::FileIsFullPath(compilerFile)) { /* clang-format off */ noCompiler << @@ -789,11 +786,11 @@ void cmGlobalGenerator::EnableLanguage( fpath = "CMake"; fpath += lang; fpath += "Information.cmake"; - std::string informationFile = mf->GetModulesFile(fpath.c_str()); + std::string informationFile = mf->GetModulesFile(fpath); if (informationFile.empty()) { cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); - } else if (!mf->ReadListFile(informationFile.c_str())) { + } else if (!mf->ReadListFile(informationFile)) { cmSystemTools::Error("Could not process cmake module file: ", informationFile.c_str()); } @@ -813,8 +810,8 @@ void cmGlobalGenerator::EnableLanguage( std::string testLang = "CMakeTest"; testLang += lang; testLang += "Compiler.cmake"; - std::string ifpath = mf->GetModulesFile(testLang.c_str()); - if (!mf->ReadListFile(ifpath.c_str())) { + std::string ifpath = mf->GetModulesFile(testLang); + if (!mf->ReadListFile(ifpath)) { cmSystemTools::Error("Could not find cmake module file: ", testLang.c_str()); } @@ -852,7 +849,7 @@ void cmGlobalGenerator::EnableLanguage( projectCompatibility += mf->GetSafeDefinition("PROJECT_NAME"); projectCompatibility += "Compatibility.cmake"; if (cmSystemTools::FileExists(projectCompatibility)) { - mf->ReadListFile(projectCompatibility.c_str()); + mf->ReadListFile(projectCompatibility); } // Inform any extra generator of the new language. if (this->ExtraGenerator) { @@ -1062,7 +1059,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, if (preference < 0) { std::string msg = linkerPrefVar; msg += " is negative, adjusting it to 0"; - cmSystemTools::Message(msg.c_str(), "Warning"); + cmSystemTools::Message(msg, "Warning"); preference = 0; } @@ -1170,6 +1167,7 @@ void cmGlobalGenerator::Configure() this->CMakeInstance->GetHomeOutputDirectory()); cmMakefile* dirMf = new cmMakefile(this, snapshot); + dirMf->SetRecursionDepth(this->RecursionDepth); this->Makefiles.push_back(dirMf); this->IndexMakefile(dirMf); @@ -1214,7 +1212,7 @@ void cmGlobalGenerator::Configure() const char* logs[] = { "CMakeOutput.log", "CMakeError.log", nullptr }; for (const char** log = logs; *log; ++log) { std::string f = this->CMakeInstance->GetHomeOutputDirectory(); - f += cmake::GetCMakeFilesDirectory(); + f += "/CMakeFiles"; f += "/"; f += *log; if (cmSystemTools::FileExists(f)) { @@ -1286,7 +1284,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const << "duplicate custom targets. " << "Consider using a Makefiles generator or fix the project to not " << "use duplicate target names."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } @@ -1755,14 +1753,13 @@ int cmGlobalGenerator::TryCompile(int jobs, const std::string& srcdir, } void cmGlobalGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& /*unused*/, + GeneratedMakeCommand& makeCommand, const std::string& /*unused*/, const std::string& /*unused*/, const std::string& /*unused*/, const std::string& /*unused*/, const std::string& /*unused*/, bool /*unused*/, int /*unused*/, bool /*unused*/, std::vector<std::string> const& /*unused*/) { - makeCommand.push_back( - "cmGlobalGenerator::GenerateBuildCommand not implemented"); + makeCommand.add("cmGlobalGenerator::GenerateBuildCommand not implemented"); } void cmGlobalGenerator::PrintBuildCommandAdvice(std::ostream& /*os*/, @@ -1806,31 +1803,29 @@ int cmGlobalGenerator::Build(int jobs, const std::string& /*unused*/, std::string outputBuffer; std::string* outputPtr = &outputBuffer; - std::vector<std::string> makeCommand; + GeneratedMakeCommand makeCommand; this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName, bindir, target, config, fast, jobs, verbose, nativeOptions); - // Workaround to convince VCExpress.exe to produce output. + // Workaround to convince some commands to produce output. if (outputflag == cmSystemTools::OUTPUT_PASSTHROUGH && - !makeCommand.empty() && - cmSystemTools::LowerCase( - cmSystemTools::GetFilenameName(makeCommand[0])) == "vcexpress.exe") { + makeCommand.RequiresOutputForward) { outputflag = cmSystemTools::OUTPUT_FORWARD; } // should we do a clean first? if (clean) { - std::vector<std::string> cleanCommand; + GeneratedMakeCommand cleanCommand; this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName, bindir, "clean", config, fast, jobs, verbose); output += "\nRun Clean Command:"; - output += cmSystemTools::PrintSingleCommand(cleanCommand); + output += cleanCommand.printable(); output += "\n"; - if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, outputPtr, - &retVal, nullptr, outputflag, - timeout)) { + if (!cmSystemTools::RunSingleCommand(cleanCommand.PrimaryCommand, + outputPtr, outputPtr, &retVal, + nullptr, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::Error("Generator: execution of make clean failed."); output += *outputPtr; @@ -1842,13 +1837,13 @@ int cmGlobalGenerator::Build(int jobs, const std::string& /*unused*/, } // now build - std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand); - output += "\nRun Build Command:"; + std::string makeCommandStr = makeCommand.printable(); + output += "\nRun Build Command(s):"; output += makeCommandStr; output += "\n"; - if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, outputPtr, - &retVal, nullptr, outputflag, + if (!cmSystemTools::RunSingleCommand(makeCommand.PrimaryCommand, outputPtr, + outputPtr, &retVal, nullptr, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::Error( @@ -2000,7 +1995,7 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) this->ConfiguredFilesPath = gen->ConfiguredFilesPath; } else { this->ConfiguredFilesPath = gen->CMakeInstance->GetHomeOutputDirectory(); - this->ConfiguredFilesPath += cmake::GetCMakeFilesDirectory(); + this->ConfiguredFilesPath += "/CMakeFiles"; } } @@ -2034,17 +2029,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, return this->IsExcluded(rootSnp, snp); } -bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmGeneratorTarget* target) const +bool cmGlobalGenerator::IsExcluded(cmGeneratorTarget* target) const { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY || - target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { - // This target is excluded from its directory. - return true; - } - // This target is included in its directory. Check whether the - // directory is excluded. - return this->IsExcluded(root, target->GetLocalGenerator()); + return target->GetType() == cmStateEnums::INTERFACE_LIBRARY || + target->GetPropertyAsBool("EXCLUDE_FROM_ALL"); } void cmGlobalGenerator::GetEnabledLanguages( @@ -2313,12 +2301,12 @@ void cmGlobalGenerator::AddGlobalTarget_Package( singleLine.push_back("./CPackConfig.cmake"); gti.CommandLines.push_back(std::move(singleLine)); if (this->GetPreinstallTargetName()) { - gti.Depends.push_back(this->GetPreinstallTargetName()); + gti.Depends.emplace_back(this->GetPreinstallTargetName()); } else { const char* noPackageAll = mf->GetDefinition("CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY"); if (!noPackageAll || cmSystemTools::IsOff(noPackageAll)) { - gti.Depends.push_back(this->GetAllTargetName()); + gti.Depends.emplace_back(this->GetAllTargetName()); } } targets.push_back(std::move(gti)); @@ -2483,12 +2471,12 @@ void cmGlobalGenerator::AddGlobalTarget_Install( gti.UsesTerminal = true; cmCustomCommandLine singleLine; if (this->GetPreinstallTargetName()) { - gti.Depends.push_back(this->GetPreinstallTargetName()); + gti.Depends.emplace_back(this->GetPreinstallTargetName()); } else { const char* noall = mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); if (!noall || cmSystemTools::IsOff(noall)) { - gti.Depends.push_back(this->GetAllTargetName()); + gti.Depends.emplace_back(this->GetAllTargetName()); } } if (mf->GetDefinition("CMake_BINARY_DIR") && @@ -2618,8 +2606,7 @@ std::string cmGlobalGenerator::GenerateRuleFile( ruleFile += ".rule"; const char* dir = this->GetCMakeCFGIntDir(); if (dir && dir[0] == '$') { - cmSystemTools::ReplaceString(ruleFile, dir, - cmake::GetCMakeFilesDirectory()); + cmSystemTools::ReplaceString(ruleFile, dir, "/CMakeFiles"); } return ruleFile; } @@ -2803,8 +2790,9 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs, } // Shorten the output name (in expected use case). - cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot()); - std::string fname = converter.ConvertToRelativePath( + cmStateDirectory cmDir = + this->GetMakefiles()[0]->GetStateSnapshot().GetDirectory(); + std::string fname = cmDir.ConvertToRelPathIfNotContained( this->GetMakefiles()[0]->GetState()->GetBinaryDirectory(), outputs[0]); // Associate the hash with this output. @@ -2820,7 +2808,7 @@ void cmGlobalGenerator::CheckRuleHashes() #if defined(CMAKE_BUILD_WITH_CMAKE) std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory(); std::string pfile = home; - pfile += cmake::GetCMakeFilesDirectory(); + pfile += "/CMakeFiles"; pfile += "/CMakeRuleHashes.txt"; this->CheckRuleHashes(pfile, home); this->WriteRuleHashes(pfile); @@ -2860,7 +2848,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, if (strncmp(line.c_str(), rhi->second.Data, 32) != 0) { // The rule has changed. Delete the output so it will be // built again. - fname = cmSystemTools::CollapseFullPath(fname, home.c_str()); + fname = cmSystemTools::CollapseFullPath(fname, home); cmSystemTools::RemoveFile(fname); } } else { @@ -2870,7 +2858,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, // Instead, we keep the rule hash as long as the file exists so // that if the feature is turned back on and the rule has // changed the file is still rebuilt. - std::string fpath = cmSystemTools::CollapseFullPath(fname, home.c_str()); + std::string fpath = cmSystemTools::CollapseFullPath(fname, home); if (cmSystemTools::FileExists(fpath)) { RuleHash hash; memcpy(hash.Data, line.c_str(), 32); @@ -2899,7 +2887,7 @@ void cmGlobalGenerator::WriteSummary() { // Record all target directories in a central location. std::string fname = this->CMakeInstance->GetHomeOutputDirectory(); - fname += cmake::GetCMakeFilesDirectory(); + fname += "/CMakeFiles"; fname += "/TargetDirectories.txt"; cmGeneratedFileStream fout(fname); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 36d3d107e4..ac013268ce 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -41,6 +41,54 @@ class cmSourceFile; class cmStateDirectory; class cmake; +namespace detail { +inline void AppendStrs(std::vector<std::string>&) +{ +} +template <typename T, typename... Ts> +inline void AppendStrs(std::vector<std::string>& command, T&& s, Ts&&... ts) +{ + command.emplace_back(std::forward<T>(s)); + AppendStrs(command, std::forward<Ts>(ts)...); +} + +struct GeneratedMakeCommand +{ + // Add each argument as a separate element to the vector + template <typename... T> + void add(T&&... args) + { + // iterate the args and append each one + AppendStrs(PrimaryCommand, std::forward<T>(args)...); + } + + // Add each value in the iterators as a separate element to the vector + void add(std::vector<std::string>::const_iterator start, + std::vector<std::string>::const_iterator end) + { + PrimaryCommand.insert(PrimaryCommand.end(), start, end); + } + + std::string printable() const + { + std::size_t size = PrimaryCommand.size(); + for (auto&& i : PrimaryCommand) { + size += i.size(); + } + std::string buffer; + buffer.reserve(size); + for (auto&& i : PrimaryCommand) { + buffer.append(i); + buffer.append(1, ' '); + } + return buffer; + } + + std::vector<std::string> PrimaryCommand; + bool RequiresOutputForward = false; +}; +} + /** \class cmGlobalGenerator * \brief Responsible for overseeing the generation process for the entire tree * @@ -182,8 +230,12 @@ public: virtual bool Open(const std::string& bindir, const std::string& projectName, bool dryRun); + struct GeneratedMakeCommand final : public detail::GeneratedMakeCommand + { + }; + virtual void GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, int jobs, bool verbose, @@ -432,6 +484,8 @@ public: std::string MakeSilentFlag; + int RecursionDepth; + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend @@ -468,7 +522,7 @@ protected: bool IsExcluded(cmStateSnapshot const& root, cmStateSnapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; + bool IsExcluded(cmGeneratorTarget* target) const; virtual void InitializeProgressMarks() {} struct GlobalTargetInfo @@ -479,7 +533,6 @@ protected: std::vector<std::string> Depends; std::string WorkingDir; bool UsesTerminal = false; - GlobalTargetInfo() {} }; void CreateDefaultGlobalTargets(std::vector<GlobalTargetInfo>& targets); @@ -608,7 +661,6 @@ private: long LastDiskTime = -1; std::set<std::string> All; std::set<std::string> Generated; - DirectoryContent() {} }; std::map<std::string, DirectoryContent> DirectoryContentMap; diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index 4e3e7705b8..bb5f74cca3 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -20,7 +20,7 @@ struct cmDocumentationEntry; class cmGlobalGeneratorFactory { public: - virtual ~cmGlobalGeneratorFactory() {} + virtual ~cmGlobalGeneratorFactory() = default; /** Create a GlobalGenerator */ virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& n, @@ -30,13 +30,20 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0; /** Get the names of the current registered generators */ - virtual void GetGenerators(std::vector<std::string>& names) const = 0; + virtual std::vector<std::string> GetGeneratorNames() const = 0; + virtual std::vector<std::string> GetGeneratorNamesWithPlatform() const = 0; /** Determine whether or not this generator supports toolsets */ virtual bool SupportsToolset() const = 0; /** Determine whether or not this generator supports platforms */ virtual bool SupportsPlatform() const = 0; + + /** Get the list of supported platforms name for this generator */ + virtual std::vector<std::string> GetKnownPlatforms() const = 0; + + /** If the generator suports platforms, get its default. */ + virtual std::string GetDefaultPlatformName() const = 0; }; template <class T> @@ -60,9 +67,15 @@ public: } /** Get the names of the current registered generators */ - void GetGenerators(std::vector<std::string>& names) const override + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(T::GetActualName()); + return names; + } + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + return std::vector<std::string>(); } /** Determine whether or not this generator supports toolsets */ @@ -70,6 +83,15 @@ public: /** Determine whether or not this generator supports platforms */ bool SupportsPlatform() const override { return T::SupportsPlatform(); } + + /** Get the list of supported platforms name for this generator */ + std::vector<std::string> GetKnownPlatforms() const override + { + // default is no platform supported + return std::vector<std::string>(); + } + + std::string GetDefaultPlatformName() const override { return std::string(); } }; #endif diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 831c4a9e07..45fa0529fa 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -11,6 +11,7 @@ #include "cmGhsMultiTargetGenerator.h" #include "cmLocalGhsMultiGenerator.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmVersion.h" #include "cmake.h" @@ -20,13 +21,12 @@ const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "C:/ghs"; cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm) : cmGlobalGenerator(cm) - , OSDirRelative(false) { + cm->GetState()->SetGhsMultiIDE(true); } cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() { - cmDeleteAll(TargetFolderBuildStreams); } cmLocalGenerator* cmGlobalGhsMultiGenerator::CreateLocalGenerator( @@ -42,46 +42,59 @@ void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry& entry) "Generates Green Hills MULTI files (experimental, work-in-progress)."; } +void cmGlobalGhsMultiGenerator::ComputeTargetObjectDirectory( + cmGeneratorTarget* gt) const +{ + // Compute full path to object file directory for this target. + std::string dir; + dir += gt->LocalGenerator->GetCurrentBinaryDirectory(); + dir += "/"; + dir += gt->LocalGenerator->GetTargetDirectory(gt); + dir += "/"; + gt->ObjectDirectory = dir; +} + bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts, cmMakefile* mf) { - std::string tsp; /* toolset path */ - std::string tsn = ts; /* toolset name */ + std::string tsp; /* toolset path */ - GetToolset(mf, tsp, tsn); + this->GetToolset(mf, tsp, ts); /* no toolset was found */ - if (tsn.empty()) { + if (tsp.empty()) { return false; } else if (ts.empty()) { std::string message; message = "Green Hills MULTI: -T <toolset> not specified; defaulting to \""; - message += tsn; + message += tsp; message += "\""; - cmSystemTools::Message(message.c_str()); + cmSystemTools::Message(message); - /* store the toolset for later use + /* store the full toolset for later use * -- already done if -T<toolset> was specified */ - mf->AddCacheDefinition("CMAKE_GENERATOR_TOOLSET", tsn.c_str(), - "Name of generator toolset.", + mf->AddCacheDefinition("CMAKE_GENERATOR_TOOLSET", tsp.c_str(), + "Location of generator toolset.", cmStateEnums::INTERNAL); } /* set the build tool to use */ + std::string gbuild(tsp + ((tsp.back() == '/') ? "" : "/") + + DEFAULT_BUILD_PROGRAM); const char* prevTool = mf->GetDefinition("CMAKE_MAKE_PROGRAM"); - std::string gbuild(tsp + "/" + tsn + "/" + DEFAULT_BUILD_PROGRAM); /* check if the toolset changed from last generate */ if (prevTool != NULL && (gbuild != prevTool)) { - std::string message = "generator toolset: "; + std::string message = "toolset build tool: "; message += gbuild; - message += "\nDoes not match the toolset used previously: "; + message += "\nDoes not match the previously used build tool: "; message += prevTool; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); + return false; } else { /* store the toolset that is being used for this build */ mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild.c_str(), @@ -89,25 +102,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts, true); } - mf->AddDefinition("CMAKE_SYSTEM_VERSION", tsn.c_str()); - - // FIXME: compiler detection not implemented - // gbuild uses the primaryTarget setting in the top-level project - // file to determine which compiler to use. Because compiler - // detection is not implemented these variables must be - // set to skip past these tests. However cmake will verify that - // the executable pointed to by CMAKE_<LANG>_COMPILER exists. - // To pass this additional check gbuild is used as a place holder for the - // actual compiler. - mf->AddDefinition("CMAKE_C_COMPILER", gbuild.c_str()); - mf->AddDefinition("CMAKE_C_COMPILER_ID_RUN", "TRUE"); - mf->AddDefinition("CMAKE_C_COMPILER_ID", "GHS"); - mf->AddDefinition("CMAKE_C_COMPILER_FORCED", "TRUE"); - - mf->AddDefinition("CMAKE_CXX_COMPILER", gbuild.c_str()); - mf->AddDefinition("CMAKE_CXX_COMPILER_ID_RUN", "TRUE"); - mf->AddDefinition("CMAKE_CXX_COMPILER_ID", "GHS"); - mf->AddDefinition("CMAKE_CXX_COMPILER_FORCED", "TRUE"); + mf->AddDefinition("CMAKE_SYSTEM_VERSION", tsp.c_str()); return true; } @@ -130,6 +125,8 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p, const char* tgtPlatform = mf->GetDefinition("GHS_TARGET_PLATFORM"); if (tgtPlatform == nullptr) { + cmSystemTools::Message("Green Hills MULTI: GHS_TARGET_PLATFORM not " + "specified; defaulting to \"integrity\""); tgtPlatform = "integrity"; } @@ -160,11 +157,11 @@ bool cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* /*mf*/) } void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd, - std::string& ts) + const std::string& ts) { const char* ghsRoot = mf->GetDefinition("GHS_TOOLSET_ROOT"); - if (!ghsRoot) { + if (!ghsRoot || ghsRoot[0] == '\0') { ghsRoot = DEFAULT_TOOLSET_ROOT; } tsd = ghsRoot; @@ -173,156 +170,250 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd, std::vector<std::string> output; // Use latest? version + if (tsd.back() != '/') { + tsd += "/"; + } cmSystemTools::Glob(tsd, "comp_[^;]+", output); if (output.empty()) { - cmSystemTools::Error("GHS toolset not found in ", tsd.c_str()); - ts = ""; + std::string msg = + "No GHS toolsets found in GHS_TOOLSET_ROOT \"" + tsd + "\"."; + cmSystemTools::Error(msg); + tsd = ""; } else { - ts = output.back(); + tsd += output.back(); } } else { - std::string tryPath = tsd + std::string("/") + ts; + std::string tryPath; + /* CollapseCombinedPath will check if ts is an absolute path */ + tryPath = cmSystemTools::CollapseCombinedPath(tsd, ts); if (!cmSystemTools::FileExists(tryPath)) { - cmSystemTools::Error("GHS toolset \"", ts.c_str(), "\" not found in ", - tsd.c_str()); - ts = ""; + std::string msg = "GHS toolset \"" + tryPath + "\" not found."; + cmSystemTools::Error(msg); + tsd = ""; + } else { + tsd = tryPath; } } } -void cmGlobalGhsMultiGenerator::OpenBuildFileStream( - std::string const& filepath, cmGeneratedFileStream** filestream) +void cmGlobalGhsMultiGenerator::WriteFileHeader(std::ostream& fout) { - // Get a stream where to generate things. - if (NULL == *filestream) { - *filestream = new cmGeneratedFileStream(filepath.c_str()); - if (NULL != *filestream) { - OpenBuildFileStream(*filestream); - } - } + fout << "#!gbuild" << std::endl; + fout << "#" << std::endl + << "# CMAKE generated file: DO NOT EDIT!" << std::endl + << "# Generated by \"" << this->GetActualName() << "\"" + << " Generator, CMake Version " << cmVersion::GetMajorVersion() << "." + << cmVersion::GetMinorVersion() << std::endl + << "#" << std::endl + << std::endl; } -void cmGlobalGhsMultiGenerator::OpenBuildFileStream( - cmGeneratedFileStream* filestream) +void cmGlobalGhsMultiGenerator::WriteTopLevelProject( + std::ostream& fout, cmLocalGenerator* root, + std::vector<cmLocalGenerator*>& generators) { - *filestream << "#!gbuild" << std::endl; -} + WriteFileHeader(fout); -void cmGlobalGhsMultiGenerator::OpenBuildFileStream() -{ - // Compute GHS MULTI's build file path. - std::string buildFilePath = - this->GetCMakeInstance()->GetHomeOutputDirectory(); - buildFilePath += "/"; - buildFilePath += "default"; - buildFilePath += FILE_EXTENSION; - - this->Open(std::string(""), buildFilePath, &this->TargetFolderBuildStreams); - OpenBuildFileStream(GetBuildFileStream()); - - char const* osDir = - this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR"); - if (NULL == osDir) { - osDir = ""; - cmSystemTools::Error("GHS_OS_DIR cache variable must be set"); - } else { - this->GetCMakeInstance()->MarkCliAsUsed("GHS_OS_DIR"); - } - std::string fOSDir(this->trimQuotes(osDir)); - std::replace(fOSDir.begin(), fOSDir.end(), '\\', '/'); - if (!fOSDir.empty() && ('c' == fOSDir[0] || 'C' == fOSDir[0])) { - this->OSDirRelative = false; - } else { - this->OSDirRelative = true; + this->WriteMacros(fout); + this->WriteHighLevelDirectives(fout); + GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fout); + + fout << "# Top Level Project File" << std::endl; + + // Specify BSP option if supplied by user + // -- not all platforms require this entry in the project file + // integrity platforms require this field; use default if needed + std::string platform; + if (const char* p = + this->GetCMakeInstance()->GetCacheDefinition("GHS_TARGET_PLATFORM")) { + platform = p; } std::string bspName; - char const* bspCache = - this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME"); - if (bspCache) { + if (char const* bspCache = + this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME")) { bspName = bspCache; this->GetCMakeInstance()->MarkCliAsUsed("GHS_BSP_NAME"); + } else { + bspName = "IGNORE"; } - if (bspName.empty() || bspName.compare("IGNORE") == 0) { + + if (platform.find("integrity") != std::string::npos && + cmSystemTools::IsOff(bspName.c_str())) { const char* a = this->GetCMakeInstance()->GetCacheDefinition("CMAKE_GENERATOR_PLATFORM"); bspName = "sim"; bspName += (a ? a : ""); } - this->WriteMacros(); - this->WriteHighLevelDirectives(); + if (!cmSystemTools::IsOff(bspName.c_str())) { + fout << " -bsp " << bspName << std::endl; + } + + // Specify OS DIR if supplied by user + // -- not all platforms require this entry in the project file + std::string osDir; + std::string osDirOption; + if (char const* osDirCache = + this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR")) { + osDir = osDirCache; + } + + if (char const* osDirOptionCache = + this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION")) { + osDirOption = osDirOptionCache; + } - GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, this->GetBuildFileStream()); - this->WriteDisclaimer(this->GetBuildFileStream()); - *this->GetBuildFileStream() << "# Top Level Project File" << std::endl; - *this->GetBuildFileStream() << " -bsp " << bspName << std::endl; + if (!cmSystemTools::IsOff(osDir.c_str()) || + platform.find("integrity") != std::string::npos) { + std::replace(osDir.begin(), osDir.end(), '\\', '/'); + fout << " " << osDirOption << "\"" << osDir << "\"" << std::endl; + } - this->WriteCompilerOptions(fOSDir); + WriteSubProjects(fout, root, generators); } -void cmGlobalGhsMultiGenerator::CloseBuildFileStream( - cmGeneratedFileStream** filestream) +void cmGlobalGhsMultiGenerator::WriteSubProjects( + std::ostream& fout, cmLocalGenerator* root, + std::vector<cmLocalGenerator*>& generators) { - if (filestream) { - delete *filestream; - *filestream = NULL; - } else { - cmSystemTools::Error("Build file stream was not open."); + // Collect all targets under this root generator and the transitive + // closure of their dependencies. + TargetDependSet projectTargets; + TargetDependSet originalTargets; + this->GetTargetSets(projectTargets, originalTargets, root, generators); + OrderedTargetDependSet orderedProjectTargets(projectTargets, ""); + + // write out all the sub-projects + std::string rootBinaryDir = root->GetCurrentBinaryDirectory(); + for (cmGeneratorTarget const* target : orderedProjectTargets) { + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + continue; + } + + const char* projName = target->GetProperty("GENERATOR_FILE_NAME"); + const char* projType = target->GetProperty("GENERATOR_FILE_NAME_EXT"); + if (projName && projType) { + cmLocalGenerator* lg = target->GetLocalGenerator(); + std::string dir = lg->GetCurrentBinaryDirectory(); + dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str()); + if (dir == ".") { + dir.clear(); + } else { + if (dir.back() != '/') { + dir += "/"; + } + } + + if (cmSystemTools::IsOn(target->GetProperty("EXCLUDE_FROM_ALL"))) { + fout << "{comment} "; + } + std::string projFile = dir + projName + FILE_EXTENSION; + fout << projFile; + fout << " " << projType << std::endl; + + if (cmSystemTools::IsOn(target->GetProperty("GHS_REFERENCE_PROJECT"))) { + // create reference project + std::string fname = dir; + fname += target->GetName(); + fname += "REF"; + fname += FILE_EXTENSION; + + cmGeneratedFileStream fref(fname.c_str()); + fref.SetCopyIfDifferent(true); + + this->WriteFileHeader(fref); + GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fref); + fref << " :reference=" << projFile << std::endl; + + fref.Close(); + } + } } } void cmGlobalGhsMultiGenerator::Generate() { + // first do the superclass method this->cmGlobalGenerator::Generate(); - if (!this->LocalGenerators.empty()) { - this->OpenBuildFileStream(); + // output top-level projects + for (auto& it : this->ProjectMap) { + this->OutputTopLevelProject(it.second[0], it.second); + } +} - // Build all the folder build files - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - cmLocalGhsMultiGenerator* lg = - static_cast<cmLocalGhsMultiGenerator*>(this->LocalGenerators[i]); - const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); - this->UpdateBuildFiles(tgts); - } +void cmGlobalGhsMultiGenerator::OutputTopLevelProject( + cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators) +{ + if (generators.empty()) { + return; } - cmDeleteAll(TargetFolderBuildStreams); - this->TargetFolderBuildStreams.clear(); + /* Name top-level projects as filename.top.gpj to avoid name clashes + * with target projects. This avoid the issue where the project has + * the same name as the executable target. + */ + std::string fname = root->GetCurrentBinaryDirectory(); + fname += "/"; + fname += root->GetProjectName(); + fname += ".top"; + fname += FILE_EXTENSION; + + cmGeneratedFileStream fout(fname.c_str()); + fout.SetCopyIfDifferent(true); + + this->WriteTopLevelProject(fout, root, generators); + + fout.Close(); } void cmGlobalGhsMultiGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, - const std::string& /*projectName*/, const std::string& /*projectDir*/, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& /*config*/, bool /*fast*/, int jobs, bool /*verbose*/, std::vector<std::string> const& makeOptions) { const char* gbuild = this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); - makeCommand.push_back( - this->SelectMakeProgram(makeProgram, (std::string)gbuild)); + makeCommand.add(this->SelectMakeProgram(makeProgram, (std::string)gbuild)); if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back("-parallel"); + makeCommand.add("-parallel"); if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back(std::to_string(jobs)); + makeCommand.add(std::to_string(jobs)); } } - makeCommand.insert(makeCommand.end(), makeOptions.begin(), - makeOptions.end()); + makeCommand.add(makeOptions.begin(), makeOptions.end()); + + /* determine which top-project file to use */ + std::string proj = projectName + ".top" + FILE_EXTENSION; + std::vector<std::string> files; + cmSystemTools::Glob(projectDir, ".*\\.top\\.gpj", files); + if (!files.empty()) { + auto p = std::find(files.begin(), files.end(), proj); + if (p == files.end()) { + proj = files.at(0); + } + } + + makeCommand.add("-top", proj); if (!targetName.empty()) { if (targetName == "clean") { - makeCommand.push_back("-clean"); + makeCommand.add("-clean"); } else { - makeCommand.push_back(targetName); + if (targetName.compare(targetName.size() - 4, 4, ".gpj") == 0) { + makeCommand.add(targetName); + } else { + makeCommand.add(targetName + ".gpj"); + } } } } -void cmGlobalGhsMultiGenerator::WriteMacros() +void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout) { char const* ghsGpjMacros = this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS"); @@ -332,12 +423,12 @@ void cmGlobalGhsMultiGenerator::WriteMacros() for (std::vector<std::string>::const_iterator expandedListI = expandedList.begin(); expandedListI != expandedList.end(); ++expandedListI) { - *this->GetBuildFileStream() << "macro " << *expandedListI << std::endl; + fout << "macro " << *expandedListI << std::endl; } } } -void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives() +void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(std::ostream& fout) { /* set primary target */ std::string tgt; @@ -357,183 +448,46 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives() tgt += ".tgt"; } - *this->GetBuildFileStream() << "primaryTarget=" << tgt << std::endl; + fout << "primaryTarget=" << tgt << std::endl; char const* const customization = this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION"); if (NULL != customization && strlen(customization) > 0) { - *this->GetBuildFileStream() - << "customization=" << trimQuotes(customization) << std::endl; + fout << "customization=" << trimQuotes(customization) << std::endl; this->GetCMakeInstance()->MarkCliAsUsed("GHS_CUSTOMIZATION"); } } -void cmGlobalGhsMultiGenerator::WriteCompilerOptions(std::string const& fOSDir) -{ - *this->GetBuildFileStream() - << " -os_dir=\"" << fOSDir << "\"" << std::endl; -} - -void cmGlobalGhsMultiGenerator::WriteDisclaimer(std::ostream* os) -{ - (*os) << "#" << std::endl - << "# CMAKE generated file: DO NOT EDIT!" << std::endl - << "# Generated by \"" << GetActualName() << "\"" - << " Generator, CMake Version " << cmVersion::GetMajorVersion() << "." - << cmVersion::GetMinorVersion() << std::endl - << "#" << std::endl; -} - -void cmGlobalGhsMultiGenerator::AddFilesUpToPath( - cmGeneratedFileStream* mainBuildFile, - std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams, - char const* homeOutputDirectory, std::string const& path, - GhsMultiGpj::Types projType, std::string const& relPath) +std::string cmGlobalGhsMultiGenerator::trimQuotes(std::string const& str) { - std::string workingPath(path); - cmSystemTools::ConvertToUnixSlashes(workingPath); - std::vector<std::string> splitPath = cmSystemTools::SplitString(workingPath); - std::string workingRelPath(relPath); - cmSystemTools::ConvertToUnixSlashes(workingRelPath); - if (!workingRelPath.empty()) { - workingRelPath += "/"; - } - std::string pathUpTo; - for (std::vector<std::string>::const_iterator splitPathI = splitPath.begin(); - splitPath.end() != splitPathI; ++splitPathI) { - pathUpTo += *splitPathI; - if (targetFolderBuildStreams->end() == - targetFolderBuildStreams->find(pathUpTo)) { - AddFilesUpToPathNewBuildFile( - mainBuildFile, targetFolderBuildStreams, homeOutputDirectory, pathUpTo, - splitPath.begin() == splitPathI, workingRelPath, projType); + std::string result; + result.reserve(str.size()); + for (const char* ch = str.c_str(); *ch != '\0'; ++ch) { + if (*ch != '"') { + result += *ch; } - AddFilesUpToPathAppendNextFile(targetFolderBuildStreams, pathUpTo, - splitPathI, splitPath.end(), projType); - pathUpTo += "/"; - } -} - -void cmGlobalGhsMultiGenerator::Open( - std::string const& mapKeyName, std::string const& fileName, - std::map<std::string, cmGeneratedFileStream*>* fileMap) -{ - if (fileMap->end() == fileMap->find(fileName)) { - cmGeneratedFileStream* temp(new cmGeneratedFileStream); - temp->open(fileName.c_str()); - (*fileMap)[mapKeyName] = temp; - } -} - -void cmGlobalGhsMultiGenerator::AddFilesUpToPathNewBuildFile( - cmGeneratedFileStream* mainBuildFile, - std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams, - char const* homeOutputDirectory, std::string const& pathUpTo, - bool const isFirst, std::string const& relPath, - GhsMultiGpj::Types const projType) -{ - // create folders up to file path - std::string absPath = std::string(homeOutputDirectory) + "/" + relPath; - std::string newPath = absPath + pathUpTo; - if (!cmSystemTools::FileExists(newPath.c_str())) { - cmSystemTools::MakeDirectory(newPath.c_str()); - } - - // Write out to filename for first time - std::string relFilename(GetFileNameFromPath(pathUpTo)); - std::string absFilename = absPath + relFilename; - Open(pathUpTo, absFilename, targetFolderBuildStreams); - OpenBuildFileStream((*targetFolderBuildStreams)[pathUpTo]); - GhsMultiGpj::WriteGpjTag(projType, (*targetFolderBuildStreams)[pathUpTo]); - WriteDisclaimer((*targetFolderBuildStreams)[pathUpTo]); - - // Add to main build file - if (isFirst) { - *mainBuildFile << relFilename << " "; - GhsMultiGpj::WriteGpjTag(projType, mainBuildFile); - } -} - -void cmGlobalGhsMultiGenerator::AddFilesUpToPathAppendNextFile( - std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams, - std::string const& pathUpTo, - std::vector<std::string>::const_iterator splitPathI, - std::vector<std::string>::const_iterator end, - GhsMultiGpj::Types const projType) -{ - std::vector<std::string>::const_iterator splitPathNextI = splitPathI + 1; - if (end != splitPathNextI && - targetFolderBuildStreams->end() == - targetFolderBuildStreams->find(pathUpTo + "/" + *splitPathNextI)) { - std::string nextFilename(*splitPathNextI); - nextFilename = GetFileNameFromPath(nextFilename); - *(*targetFolderBuildStreams)[pathUpTo] << nextFilename << " "; - GhsMultiGpj::WriteGpjTag(projType, (*targetFolderBuildStreams)[pathUpTo]); } + return result; } -std::string cmGlobalGhsMultiGenerator::GetFileNameFromPath( - std::string const& path) +bool cmGlobalGhsMultiGenerator::TargetCompare::operator()( + cmGeneratorTarget const* l, cmGeneratorTarget const* r) const { - std::string output(path); - if (!path.empty()) { - cmSystemTools::ConvertToUnixSlashes(output); - std::vector<std::string> splitPath = cmSystemTools::SplitString(output); - output += "/" + splitPath.back() + FILE_EXTENSION; + // Make sure a given named target is ordered first, + // e.g. to set ALL_BUILD as the default active project. + // When the empty string is named this is a no-op. + if (r->GetName() == this->First) { + return false; } - return output; -} - -void cmGlobalGhsMultiGenerator::UpdateBuildFiles( - const std::vector<cmGeneratorTarget*>& tgts) -{ - for (std::vector<cmGeneratorTarget*>::const_iterator tgtsI = tgts.begin(); - tgtsI != tgts.end(); ++tgtsI) { - const cmGeneratorTarget* tgt = *tgtsI; - if (IsTgtForBuild(tgt)) { - std::string folderName = tgt->GetEffectiveFolderName(); - if (this->TargetFolderBuildStreams.end() == - this->TargetFolderBuildStreams.find(folderName)) { - this->AddFilesUpToPath( - GetBuildFileStream(), &this->TargetFolderBuildStreams, - this->GetCMakeInstance()->GetHomeOutputDirectory().c_str(), - folderName, GhsMultiGpj::PROJECT); - } - std::vector<std::string> splitPath = cmSystemTools::SplitString( - cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt)); - std::string foldNameRelBuildFile(*(splitPath.end() - 2) + "/" + - splitPath.back()); - *this->TargetFolderBuildStreams[folderName] << foldNameRelBuildFile - << " "; - GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag(tgt), - this->TargetFolderBuildStreams[folderName]); - } + if (l->GetName() == this->First) { + return true; } + return l->GetName() < r->GetName(); } -bool cmGlobalGhsMultiGenerator::IsTgtForBuild(const cmGeneratorTarget* tgt) +cmGlobalGhsMultiGenerator::OrderedTargetDependSet::OrderedTargetDependSet( + TargetDependSet const& targets, std::string const& first) + : derived(TargetCompare(first)) { - const std::string config = - tgt->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); - std::vector<cmSourceFile*> tgtSources; - tgt->GetSourceFiles(tgtSources, config); - bool tgtInBuild = true; - char const* excludeFromAll = tgt->GetProperty("EXCLUDE_FROM_ALL"); - if (NULL != excludeFromAll && '1' == excludeFromAll[0] && - '\0' == excludeFromAll[1]) { - tgtInBuild = false; - } - return !tgtSources.empty() && tgtInBuild; -} - -std::string cmGlobalGhsMultiGenerator::trimQuotes(std::string const& str) -{ - std::string result; - result.reserve(str.size()); - for (const char* ch = str.c_str(); *ch != '\0'; ++ch) { - if (*ch != '"') { - result += *ch; - } - } - return result; + this->insert(targets.begin(), targets.end()); } diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index a5aff73dbe..bc2b199a00 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -13,7 +13,7 @@ class cmGeneratedFileStream; class cmGlobalGhsMultiGenerator : public cmGlobalGenerator { public: - /// The default name of GHS MULTI's build file. Typically: monolith.gpj. + // The default filename extension of GHS MULTI's build files. static const char* FILE_EXTENSION; cmGlobalGhsMultiGenerator(cmake* cm); @@ -63,33 +63,32 @@ public: */ bool FindMakeProgram(cmMakefile* mf) override; - cmGeneratedFileStream* GetBuildFileStream() - { - return this->TargetFolderBuildStreams[""]; - } + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override; - static void OpenBuildFileStream(std::string const& filepath, - cmGeneratedFileStream** filestream); - static void OpenBuildFileStream(cmGeneratedFileStream* filestream); - static void CloseBuildFileStream(cmGeneratedFileStream** filestream); - /// Write the common disclaimer text at the top of each build file. - static void WriteDisclaimer(std::ostream* os); - std::vector<std::string> GetLibDirs() { return this->LibDirs; } - - static void AddFilesUpToPath( - cmGeneratedFileStream* mainBuildFile, - std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams, - char const* homeOutputDirectory, std::string const& path, - GhsMultiGpj::Types projType, std::string const& relPath = ""); - static void Open(std::string const& mapKeyName, std::string const& fileName, - std::map<std::string, cmGeneratedFileStream*>* fileMap); - - static std::string trimQuotes(std::string const& str); - inline bool IsOSDirRelative() { return this->OSDirRelative; } + // Write the common disclaimer text at the top of each build file. + void WriteFileHeader(std::ostream& fout); + + // Target dependency sorting + class TargetSet : public std::set<cmGeneratorTarget const*> + { + }; + class TargetCompare + { + std::string First; + + public: + TargetCompare(std::string const& first) + : First(first) + { + } + bool operator()(cmGeneratorTarget const* l, + cmGeneratorTarget const* r) const; + }; + class OrderedTargetDependSet; protected: void Generate() override; - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, @@ -100,35 +99,35 @@ protected: std::vector<std::string>()) override; private: - void GetToolset(cmMakefile* mf, std::string& tsd, std::string& ts); - void OpenBuildFileStream(); - - void WriteMacros(); - void WriteHighLevelDirectives(); - void WriteCompilerOptions(std::string const& fOSDir); - - static void AddFilesUpToPathNewBuildFile( - cmGeneratedFileStream* mainBuildFile, - std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams, - char const* homeOutputDirectory, std::string const& pathUpTo, bool isFirst, - std::string const& relPath, GhsMultiGpj::Types projType); - static void AddFilesUpToPathAppendNextFile( - std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams, - std::string const& pathUpTo, - std::vector<std::string>::const_iterator splitPathI, - std::vector<std::string>::const_iterator end, GhsMultiGpj::Types projType); - static std::string GetFileNameFromPath(std::string const& path); - void UpdateBuildFiles(const std::vector<cmGeneratorTarget*>& tgts); - bool IsTgtForBuild(const cmGeneratorTarget* tgt); - - std::vector<cmGeneratedFileStream*> TargetSubProjects; - std::map<std::string, cmGeneratedFileStream*> TargetFolderBuildStreams; - - std::vector<std::string> LibDirs; - - bool OSDirRelative; + void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts); + + /* top-level project */ + void OutputTopLevelProject(cmLocalGenerator* root, + std::vector<cmLocalGenerator*>& generators); + void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root, + std::vector<cmLocalGenerator*>& generators); + void WriteMacros(std::ostream& fout); + void WriteHighLevelDirectives(std::ostream& fout); + void WriteSubProjects(std::ostream& fout, cmLocalGenerator* root, + std::vector<cmLocalGenerator*>& generators); + + std::string trimQuotes(std::string const& str); + static const char* DEFAULT_BUILD_PROGRAM; static const char* DEFAULT_TOOLSET_ROOT; }; +class cmGlobalGhsMultiGenerator::OrderedTargetDependSet + : public std::multiset<cmTargetDepend, + cmGlobalGhsMultiGenerator::TargetCompare> +{ + typedef std::multiset<cmTargetDepend, + cmGlobalGhsMultiGenerator::TargetCompare> + derived; + +public: + typedef cmGlobalGenerator::TargetDependSet TargetDependSet; + OrderedTargetDependSet(TargetDependSet const&, std::string const& first); +}; + #endif diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 9c805a8381..2b7f486955 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -55,7 +55,7 @@ void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice( } void cmGlobalJOMMakefileGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, int jobs, bool verbose, std::vector<std::string> const& makeOptions) diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index bcf46d0316..aa8b5fbb02 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -40,7 +40,7 @@ public: bool optional) override; protected: - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 5235be732b..ffe95f905c 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -55,7 +55,7 @@ void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice( } void cmGlobalNMakeMakefileGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, int /*jobs*/, bool verbose, std::vector<std::string> const& makeOptions) diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 62dea6ebc1..06c48e22ba 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -45,7 +45,7 @@ public: bool optional) override; protected: - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e7b0981e28..4fd0673f8d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -550,7 +550,7 @@ bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf) this->NinjaCommand = ninjaCommand; std::vector<std::string> command; command.push_back(this->NinjaCommand); - command.push_back("--version"); + command.emplace_back("--version"); std::string version; std::string error; if (!cmSystemTools::RunSingleCommand(command, &version, &error, nullptr, @@ -673,31 +673,28 @@ void cmGlobalNinjaGenerator::EnableLanguage( // Called by: // cmGlobalGenerator::Build() void cmGlobalNinjaGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& /*projectName*/, const std::string& /*projectDir*/, const std::string& targetName, const std::string& /*config*/, bool /*fast*/, int jobs, bool verbose, std::vector<std::string> const& makeOptions) { - makeCommand.push_back(this->SelectMakeProgram(makeProgram)); + makeCommand.add(this->SelectMakeProgram(makeProgram)); if (verbose) { - makeCommand.push_back("-v"); + makeCommand.add("-v"); } if ((jobs != cmake::NO_BUILD_PARALLEL_LEVEL) && (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL)) { - makeCommand.push_back("-j"); - makeCommand.push_back(std::to_string(jobs)); + makeCommand.add("-j", std::to_string(jobs)); } - makeCommand.insert(makeCommand.end(), makeOptions.begin(), - makeOptions.end()); + makeCommand.add(makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { if (targetName == "clean") { - makeCommand.push_back("-t"); - makeCommand.push_back("clean"); + makeCommand.add("-t", "clean"); } else { - makeCommand.push_back(targetName); + makeCommand.add(targetName); } } } @@ -861,7 +858,7 @@ std::string const& cmGlobalNinjaGenerator::ConvertToNinjaPath( cmLocalNinjaGenerator* ng = static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]); std::string const& bin_dir = ng->GetState()->GetBinaryDirectory(); - std::string convPath = ng->ConvertToRelativePath(bin_dir, path); + std::string convPath = ng->MaybeConvertToRelativePath(bin_dir, path); convPath = this->NinjaOutputPath(convPath); #ifdef _WIN32 std::replace(convPath.begin(), convPath.end(), '/', '\\'); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 00fa348c0c..b3aa88f901 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -183,8 +183,6 @@ public: return new cmGlobalGeneratorSimpleFactory<cmGlobalNinjaGenerator>(); } - ~cmGlobalNinjaGenerator() override {} - cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; std::string GetName() const override @@ -202,7 +200,7 @@ public: void EnableLanguage(std::vector<std::string> const& languages, cmMakefile* mf, bool optional) override; - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, @@ -331,9 +329,9 @@ public: return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) + bool IsExcluded(cmGeneratorTarget* target) { - return cmGlobalGenerator::IsExcluded(root, target); + return cmGlobalGenerator::IsExcluded(target); } int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ceee5002be..dac6ea606f 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -146,7 +146,7 @@ void cmGlobalUnixMakefileGenerator3::Generate() for (cmLocalGenerator* lg : this->LocalGenerators) { std::string markFileName = lg->GetCurrentBinaryDirectory(); markFileName += "/"; - markFileName += cmake::GetCMakeFilesDirectory(); + markFileName += "/CMakeFiles"; markFileName += "/progress.marks"; cmGeneratedFileStream markFile(markFileName); markFile << this->CountProgressMarksInAll(lg) << "\n"; @@ -196,7 +196,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() // see if the build system must be regenerated. std::string makefileName = this->GetCMakeInstance()->GetHomeOutputDirectory(); - makefileName += cmake::GetCMakeFilesDirectory(); + makefileName += "/CMakeFiles"; makefileName += "/Makefile2"; cmGeneratedFileStream makefileStream(makefileName, false, this->GetMakefileEncoding()); @@ -216,7 +216,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() // Just depend on the all target to drive the build. std::vector<std::string> depends; std::vector<std::string> no_commands; - depends.push_back("all"); + depends.emplace_back("all"); // Write the rule. lg->WriteMakeRule(makefileStream, @@ -268,7 +268,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // see if the build system must be regenerated. std::string cmakefileName = this->GetCMakeInstance()->GetHomeOutputDirectory(); - cmakefileName += cmake::GetCMakeFilesDirectory(); + cmakefileName += "/CMakeFiles"; cmakefileName += "/Makefile.cmake"; cmGeneratedFileStream cmakefileStream(cmakefileName); if (!cmakefileStream) { @@ -325,23 +325,26 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() << "set(CMAKE_MAKEFILE_DEPENDS\n" << " \"CMakeCache.txt\"\n"; for (std::string const& f : lfiles) { - cmakefileStream << " \"" << lg->ConvertToRelativePath(currentBinDir, f) + cmakefileStream << " \"" + << lg->MaybeConvertToRelativePath(currentBinDir, f) << "\"\n"; } cmakefileStream << " )\n\n"; // Build the path to the cache check file. std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory(); - check += cmake::GetCMakeFilesDirectory(); + check += "/CMakeFiles"; check += "/cmake.check_cache"; // Set the corresponding makefile in the cmake file. cmakefileStream << "# The corresponding makefile is:\n" << "set(CMAKE_MAKEFILE_OUTPUTS\n" << " \"" - << lg->ConvertToRelativePath(currentBinDir, makefileName) + << lg->MaybeConvertToRelativePath(currentBinDir, + makefileName) << "\"\n" - << " \"" << lg->ConvertToRelativePath(currentBinDir, check) + << " \"" + << lg->MaybeConvertToRelativePath(currentBinDir, check) << "\"\n"; cmakefileStream << " )\n\n"; @@ -354,7 +357,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() const std::vector<std::string>& outfiles = lg->GetMakefile()->GetOutputFiles(); for (std::string const& outfile : outfiles) { - cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, outfile) + cmakefileStream << " \"" + << lg->MaybeConvertToRelativePath(binDir, outfile) << "\"\n"; } @@ -363,9 +367,10 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() for (cmLocalGenerator* localGen : this->LocalGenerators) { lg = static_cast<cmLocalUnixMakefileGenerator3*>(localGen); tmpStr = lg->GetCurrentBinaryDirectory(); - tmpStr += cmake::GetCMakeFilesDirectory(); + tmpStr += "/CMakeFiles"; tmpStr += "/CMakeDirectoryInformation.cmake"; - cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, tmpStr) + cmakefileStream << " \"" + << lg->MaybeConvertToRelativePath(binDir, tmpStr) << "\"\n"; } cmakefileStream << " )\n\n"; @@ -474,7 +479,7 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2( // Begin the directory-level rules section. std::string dir = - cmSystemTools::ConvertToOutputPath(lg->ConvertToRelativePath( + cmSystemTools::ConvertToOutputPath(lg->MaybeConvertToRelativePath( lg->GetBinaryDirectory(), lg->GetCurrentBinaryDirectory())); lg->WriteDivider(ruleFileStream); ruleFileStream << "# Directory level rules for directory " << dir << "\n\n"; @@ -490,10 +495,10 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2( } void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& /*projectName*/, const std::string& /*projectDir*/, const std::string& targetName, const std::string& /*config*/, bool fast, - int jobs, bool /*verbose*/, std::vector<std::string> const& makeOptions) + int jobs, bool verbose, std::vector<std::string> const& makeOptions) { std::unique_ptr<cmMakefile> mfu; cmMakefile* mf; @@ -510,27 +515,33 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( mf = mfu.get(); } - makeCommand.push_back(this->SelectMakeProgram(makeProgram)); + // Make it possible to set verbosity also from command line + if (verbose) { + makeCommand.add(cmSystemTools::GetCMakeCommand()); + makeCommand.add("-E"); + makeCommand.add("env"); + makeCommand.add("VERBOSE=1"); + } + makeCommand.add(this->SelectMakeProgram(makeProgram)); if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back("-j"); + makeCommand.add("-j"); if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back(std::to_string(jobs)); + makeCommand.add(std::to_string(jobs)); } } - makeCommand.insert(makeCommand.end(), makeOptions.begin(), - makeOptions.end()); + makeCommand.add(makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { std::string tname = targetName; if (fast) { tname += "/fast"; } - cmOutputConverter conv(mf->GetStateSnapshot()); tname = - conv.ConvertToRelativePath(mf->GetState()->GetBinaryDirectory(), tname); + mf->GetStateSnapshot().GetDirectory().ConvertToRelPathIfNotContained( + mf->GetState()->GetBinaryDirectory(), tname); cmSystemTools::ConvertToOutputSlashes(tname); - makeCommand.push_back(std::move(tname)); + makeCommand.add(std::move(tname)); } } @@ -542,7 +553,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( bool regenerate = !this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION"); if (regenerate) { - depends.push_back("cmake_check_build_system"); + depends.emplace_back("cmake_check_build_system"); } // write the target convenience rules @@ -572,12 +583,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( // Write the rule. commands.clear(); - std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string tmp = "CMakeFiles/"; tmp += "Makefile2"; - commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), name)); + commands.push_back(lg->GetRecursiveMakeCall(tmp, name)); depends.clear(); if (regenerate) { - depends.push_back("cmake_check_build_system"); + depends.emplace_back("cmake_check_build_system"); } lg->WriteMakeRule(ruleFileStream, "Build rule for target.", name, depends, commands, true); @@ -594,7 +605,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( localName = name; localName += "/fast"; commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); lg->WriteMakeRule(ruleFileStream, "fast build rule for target.", localName, depends, commands, true); @@ -608,7 +619,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( depends.clear(); commands.clear(); commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); lg->WriteMakeRule(ruleFileStream, "Manual pre-install relink rule for target.", localName, depends, commands, true); @@ -631,7 +642,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( bool regenerate = !this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION"); if (regenerate) { - depends.push_back("cmake_check_build_system"); + depends.emplace_back("cmake_check_build_system"); } // for each target Generate the rule files for each target. @@ -659,12 +670,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( makeTargetName = localName; makeTargetName += "/depend"; commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); makeTargetName = localName; makeTargetName += "/build"; commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); // Write the rule. localName += "/all"; @@ -672,7 +683,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( cmLocalUnixMakefileGenerator3::EchoProgress progress; progress.Dir = lg->GetBinaryDirectory(); - progress.Dir += cmake::GetCMakeFilesDirectory(); + progress.Dir += "/CMakeFiles"; { std::ostringstream progressArg; const char* sep = ""; @@ -702,7 +713,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( localName, depends, commands, true); // add the all/all dependency - if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) { + if (!this->IsExcluded(gtarget)) { depends.clear(); depends.push_back(localName); commands.clear(); @@ -726,9 +737,9 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( progCmd << " " << this->CountProgressMarksInTarget(gtarget, emitted); commands.push_back(progCmd.str()); } - std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string tmp = "CMakeFiles/"; tmp += "Makefile2"; - commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), localName)); + commands.push_back(lg->GetRecursiveMakeCall(tmp, localName)); { std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 @@ -740,7 +751,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( } depends.clear(); if (regenerate) { - depends.push_back("cmake_check_build_system"); + depends.emplace_back("cmake_check_build_system"); } localName = lg->GetRelativeTargetDirectory(gtarget); localName += "/rule"; @@ -761,13 +772,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( localName += "/preinstall"; depends.clear(); commands.clear(); - commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), localName)); + commands.push_back(lg->GetRecursiveMakeCall(makefileName, localName)); lg->WriteMakeRule(ruleFileStream, "Pre-install relink rule for target.", localName, depends, commands, true); - if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) { + if (!this->IsExcluded(gtarget)) { depends.clear(); depends.push_back(localName); commands.clear(); @@ -783,7 +793,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( depends.clear(); commands.clear(); commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", makeTargetName, depends, commands, true); commands.clear(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 6199586476..8a80acc057 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -127,7 +127,7 @@ public: std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; } // change the build command for speed - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, @@ -217,7 +217,6 @@ protected: // Store per-target progress counters. struct TargetProgress { - TargetProgress() {} unsigned long NumberOfActions = 0; std::string VariableFile; std::vector<unsigned long> Marks; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 79757a8751..07656ed67b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -74,15 +74,34 @@ public: "Optional [arch] can be \"Win64\" or \"IA64\"."; } - void GetGenerators(std::vector<std::string>& names) const override + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(vs10generatorName); + return names; + } + + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + std::vector<std::string> names; names.push_back(vs10generatorName + std::string(" IA64")); names.push_back(vs10generatorName + std::string(" Win64")); + return names; } bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector<std::string> GetKnownPlatforms() const override + { + std::vector<std::string> platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("Itanium"); + return platforms; + } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() @@ -588,10 +607,26 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetVersionString() const const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const { + std::string const& hostArch = + this->GetPlatformToolsetHostArchitectureString(); + if (hostArch.empty()) { + return nullptr; + } + return hostArch.c_str(); +} + +std::string const& +cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitectureString() + const +{ if (!this->GeneratorToolsetHostArchitecture.empty()) { - return this->GeneratorToolsetHostArchitecture.c_str(); + return this->GeneratorToolsetHostArchitecture; } - return nullptr; + if (!this->DefaultPlatformToolsetHostArchitecture.empty()) { + return this->DefaultPlatformToolsetHostArchitecture; + } + static std::string const empty; + return empty; } const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const @@ -687,7 +722,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) wd = this->ConfiguredFilesPath; } else { wd = this->GetCMakeInstance()->GetHomeOutputDirectory(); - wd += cmake::GetCMakeFilesDirectory(); + wd += "/CMakeFiles"; } wd += "/"; wd += cmVersion::GetCMakeVersion(); @@ -767,10 +802,9 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) } cmXMLElement(eprj, "Import") .Attribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); - if (!this->GeneratorToolsetHostArchitecture.empty()) { + if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) { cmXMLElement epg(eprj, "PropertyGroup"); - cmXMLElement(epg, "PreferredToolArchitecture") - .Content(this->GeneratorToolsetHostArchitecture); + cmXMLElement(epg, "PreferredToolArchitecture").Content(hostArch); } { cmXMLElement epg(eprj, "PropertyGroup"); @@ -845,7 +879,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) } void cmGlobalVisualStudio10Generator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, int jobs, bool verbose, std::vector<std::string> const& makeOptions) @@ -860,6 +894,10 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( bool useDevEnv = (makeProgramLower.find("devenv") != std::string::npos || makeProgramLower.find("vcexpress") != std::string::npos); + // Workaround to convince VCExpress.exe to produce output. + makeCommand.RequiresOutputForward = + (makeProgramLower.find("vcexpress") != std::string::npos); + // MSBuild is preferred (and required for VS Express), but if the .sln has // an Intel Fortran .vfproj then we have to use devenv. Parse it to find out. cmSlnData slnData; @@ -893,7 +931,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( return; } - makeCommand.push_back(makeProgramSelected); + makeCommand.add(makeProgramSelected); std::string realTarget = targetName; // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD @@ -902,8 +940,8 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( realTarget = "ALL_BUILD"; } if (realTarget == "clean") { - makeCommand.push_back(std::string(projectName) + ".sln"); - makeCommand.push_back("/t:Clean"); + makeCommand.add(std::string(projectName) + ".sln"); + makeCommand.add("/t:Clean"); } else { std::string targetProject(realTarget); targetProject += ".vcxproj"; @@ -915,7 +953,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( cmSystemTools::ConvertToUnixSlashes(targetProject); } } - makeCommand.push_back(targetProject); + makeCommand.add(std::move(targetProject)); } std::string configArg = "/p:Configuration="; if (!config.empty()) { @@ -923,23 +961,26 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( } else { configArg += "Debug"; } - makeCommand.push_back(configArg); - makeCommand.push_back("/p:Platform=" + this->GetPlatformName()); - makeCommand.push_back(std::string("/p:VisualStudioVersion=") + - this->GetIDEVersion()); + makeCommand.add(configArg); + makeCommand.add(std::string("/p:Platform=") + this->GetPlatformName()); + makeCommand.add(std::string("/p:VisualStudioVersion=") + + this->GetIDEVersion()); if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back("/m"); + makeCommand.add("/m"); } else { - makeCommand.push_back(std::string("/m:") + std::to_string(jobs)); + makeCommand.add(std::string("/m:") + std::to_string(jobs)); } // Having msbuild.exe and cl.exe using multiple jobs is discouraged - makeCommand.push_back("/p:CL_MPCount=1"); + makeCommand.add("/p:CL_MPCount=1"); } - makeCommand.insert(makeCommand.end(), makeOptions.begin(), - makeOptions.end()); + // Respect the verbosity: 'n' normal will show build commands + // 'm' minimal only the build step's title + makeCommand.add(std::string("/v:") + ((verbose) ? "n" : "m")); + + makeCommand.add(makeOptions.begin(), makeOptions.end()); } bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf) @@ -986,7 +1027,7 @@ std::string cmGlobalVisualStudio10Generator::GenerateRuleFile( // The VS 10 generator needs to create the .rule files on disk. // Hide them away under the CMakeFiles directory. std::string ruleDir = this->GetCMakeInstance()->GetHomeOutputDirectory(); - ruleDir += cmake::GetCMakeFilesDirectory(); + ruleDir += "/CMakeFiles"; ruleDir += "/"; ruleDir += cmSystemTools::ComputeStringMD5( cmSystemTools::GetFilenamePath(output).c_str()); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 7c8918ac98..3ef7abfd05 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -22,7 +22,7 @@ public: bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override; bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) override; - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, @@ -58,6 +58,7 @@ public: /** The toolset host architecture name (e.g. x64 for 64-bit host tools). */ const char* GetPlatformToolsetHostArchitecture() const; + std::string const& GetPlatformToolsetHostArchitectureString() const; /** The cuda toolset version. */ const char* GetPlatformToolsetCuda() const; @@ -152,6 +153,7 @@ protected: std::string GeneratorToolsetHostArchitecture; std::string GeneratorToolsetCuda; std::string DefaultPlatformToolset; + std::string DefaultPlatformToolsetHostArchitecture; std::string WindowsTargetPlatformVersion; std::string SystemName; std::string SystemVersion; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 36eb492e14..4eb78ba9c4 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -69,9 +69,16 @@ public: "Optional [arch] can be \"Win64\" or \"ARM\"."; } - void GetGenerators(std::vector<std::string>& names) const override + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(vs11generatorName); + return names; + } + + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + std::vector<std::string> names; names.push_back(vs11generatorName + std::string(" ARM")); names.push_back(vs11generatorName + std::string(" Win64")); @@ -80,10 +87,30 @@ public: for (std::string const& i : installedSDKs) { names.push_back(std::string(vs11generatorName) + " " + i); } + + return names; } bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector<std::string> GetKnownPlatforms() const override + { + std::vector<std::string> platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + + std::set<std::string> installedSDKs = + cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs(); + for (std::string const& i : installedSDKs) { + platforms.emplace_back(i); + } + + return platforms; + } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 61034a7fa0..d9702c9eed 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -58,15 +58,34 @@ public: "Optional [arch] can be \"Win64\" or \"ARM\"."; } - void GetGenerators(std::vector<std::string>& names) const override + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(vs12generatorName); + return names; + } + + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + std::vector<std::string> names; names.push_back(vs12generatorName + std::string(" ARM")); names.push_back(vs12generatorName + std::string(" Win64")); + return names; } bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector<std::string> GetKnownPlatforms() const override + { + std::vector<std::string> platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + return platforms; + } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() @@ -107,8 +126,8 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName( bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField( std::string const& key, std::string const& value) { - if (key == "host" && value == "x64") { - this->GeneratorToolsetHostArchitecture = "x64"; + if (key == "host" && (value == "x64" || value == "x86")) { + this->GeneratorToolsetHostArchitecture = value; return true; } return this->cmGlobalVisualStudio11Generator::ProcessGeneratorToolsetField( diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 5ea5e6766d..a0a955861c 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -58,15 +58,34 @@ public: "Optional [arch] can be \"Win64\" or \"ARM\"."; } - void GetGenerators(std::vector<std::string>& names) const override + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(vs14generatorName); + return names; + } + + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + std::vector<std::string> names; names.push_back(vs14generatorName + std::string(" ARM")); names.push_back(vs14generatorName + std::string(" Win64")); + return names; } bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector<std::string> GetKnownPlatforms() const override + { + std::vector<std::string> platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + return platforms; + } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 16796cf651..8e67fad89c 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -149,7 +149,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends( m += target->GetName(); m += " depends on unknown target: "; m += name; - cmSystemTools::Error(m.c_str()); + cmSystemTools::Error(m); } fout << "\t\t{" << guid << "} = {" << guid << "}\n"; } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index cae46e1d8c..d457f60d1e 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -191,7 +191,7 @@ const char* cmGlobalVisualStudio7Generator::ExternalProjectType( return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"; } void cmGlobalVisualStudio7Generator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& /*projectDir*/, const std::string& targetName, const std::string& config, bool /*fast*/, int /*jobs*/, bool /*verbose*/, std::vector<std::string> const& makeOptions) @@ -209,35 +209,25 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( makeProgramSelected = this->GetDevEnvCommand(); } - makeCommand.push_back(makeProgramSelected); + // Workaround to convince VCExpress.exe to produce output. + makeCommand.RequiresOutputForward = + (makeProgramLower.find("vcexpress") != std::string::npos); - makeCommand.push_back(std::string(projectName) + ".sln"); + makeCommand.add(makeProgramSelected); + + makeCommand.add(std::string(projectName) + ".sln"); std::string realTarget = targetName; bool clean = false; if (realTarget == "clean") { clean = true; realTarget = "ALL_BUILD"; } - if (clean) { - makeCommand.push_back("/clean"); - } else { - makeCommand.push_back("/build"); - } - - if (!config.empty()) { - makeCommand.push_back(config); - } else { - makeCommand.push_back("Debug"); - } - makeCommand.push_back("/project"); - if (!realTarget.empty()) { - makeCommand.push_back(realTarget); - } else { - makeCommand.push_back("ALL_BUILD"); - } - makeCommand.insert(makeCommand.end(), makeOptions.begin(), - makeOptions.end()); + makeCommand.add((clean ? "/clean" : "/build")); + makeCommand.add((config.empty() ? "Debug" : config)); + makeCommand.add("/project"); + makeCommand.add((realTarget.empty() ? "ALL_BUILD" : realTarget)); + makeCommand.add(makeOptions.begin(), makeOptions.end()); } ///! Create a local generator appropriate to this Global Generator @@ -367,7 +357,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( if (vcprojName) { cmLocalGenerator* lg = target->GetLocalGenerator(); std::string dir = lg->GetCurrentBinaryDirectory(); - dir = root->ConvertToRelativePath(rootBinaryDir, dir.c_str()); + dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str()); if (dir == ".") { dir.clear(); // msbuild cannot handle ".\" prefix } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index d2a2a38d2f..3f1c1732d1 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -52,7 +52,7 @@ public: * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 4d165c2e71..f6db018ea8 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -117,7 +117,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Create a list of all stamp files for this project. std::vector<std::string> stamps; - std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string stampList = "CMakeFiles/"; stampList += cmGlobalVisualStudio8Generator::GetGenerateStampList(); { std::string stampListFile = @@ -129,7 +129,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() for (cmLocalGenerator const* gi : generators) { stampFile = gi->GetMakefile()->GetCurrentBinaryDirectory(); stampFile += "/"; - stampFile += cmake::GetCMakeFilesDirectoryPostSlash(); + stampFile += "CMakeFiles/"; stampFile += "generate.stamp"; fout << stampFile << "\n"; stamps.push_back(stampFile); diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 445b40ce01..6e61d2681c 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -59,9 +59,16 @@ public: "Optional [arch] can be \"Win64\" or \"IA64\"."; } - void GetGenerators(std::vector<std::string>& names) const override + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(vs9generatorName); + return names; + } + + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + std::vector<std::string> names; names.push_back(vs9generatorName + std::string(" Win64")); names.push_back(vs9generatorName + std::string(" IA64")); cmVisualStudioWCEPlatformParser parser; @@ -71,10 +78,29 @@ public: for (std::string const& i : availablePlatforms) { names.push_back("Visual Studio 9 2008 " + i); } + return names; } bool SupportsToolset() const override { return false; } bool SupportsPlatform() const override { return true; } + + std::vector<std::string> GetKnownPlatforms() const override + { + std::vector<std::string> platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("Itanium"); + cmVisualStudioWCEPlatformParser parser; + parser.ParseVersion("9.0"); + const std::vector<std::string>& availablePlatforms = + parser.GetAvailablePlatforms(); + for (std::string const& i : availablePlatforms) { + platforms.emplace_back(i); + } + return platforms; + } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 41d961c9d8..77be592e82 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -201,7 +201,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() tgt->IsImported()) { continue; } - if (!this->IsExcluded(gen[0], tgt)) { + if (!this->IsExcluded(tgt)) { allBuild->AddUtility(tgt->GetName()); } } @@ -262,13 +262,12 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros() // purposes but newer versions distributed with CMake will replace // older versions in user directories. int res; - if (!cmSystemTools::FileTimeCompare(src.c_str(), dst.c_str(), &res) || - res > 0) { - if (!cmSystemTools::CopyFileAlways(src.c_str(), dst.c_str())) { + if (!cmSystemTools::FileTimeCompare(src, dst, &res) || res > 0) { + if (!cmSystemTools::CopyFileAlways(src, dst)) { std::ostringstream oss; oss << "Could not copy from: " << src << std::endl; oss << " to: " << dst << std::endl; - cmSystemTools::Message(oss.str().c_str(), "Warning"); + cmSystemTools::Message(oss.str(), "Warning"); } } @@ -783,7 +782,7 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, << "CMake needs to register Visual Studio macros when its macros" << " file is updated or when it detects that its current macros file" << " is no longer registered with Visual Studio." << std::endl; - cmSystemTools::Message(oss.str().c_str(), "Warning"); + cmSystemTools::Message(oss.str(), "Warning"); // Count them again now that the warning is over. In the case of a GUI // warning, the user may have gone to close Visual Studio and then come diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 99f9503874..12d9304ef3 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -10,15 +10,46 @@ #include "cmake.h" #if defined(_M_ARM64) -# define HOST_PLATFORM_NAME "ARM64"; +# define HOST_PLATFORM_NAME "ARM64" +# define HOST_TOOLS_ARCH "" #elif defined(_M_ARM) -# define HOST_PLATFORM_NAME "ARM"; +# define HOST_PLATFORM_NAME "ARM" +# define HOST_TOOLS_ARCH "" #elif defined(_M_IA64) -# define HOST_PLATFORM_NAME "Itanium"; +# define HOST_PLATFORM_NAME "Itanium" +# define HOST_TOOLS_ARCH "" #else # include "cmsys/SystemInformation.hxx" #endif +static std::string VSHostPlatformName() +{ +#ifdef HOST_PLATFORM_NAME + return HOST_PLATFORM_NAME; +#else + cmsys::SystemInformation info; + if (info.Is64Bits()) { + return "x64"; + } else { + return "Win32"; + } +#endif +} + +static std::string VSHostArchitecture() +{ +#ifdef HOST_TOOLS_ARCH + return HOST_TOOLS_ARCH; +#else + cmsys::SystemInformation info; + if (info.Is64Bits()) { + return "x64"; + } else { + return "x86"; + } +#endif +} + static unsigned int VSVersionToMajor( cmGlobalVisualStudioGenerator::VSVersion v) { @@ -58,8 +89,7 @@ static const char* VSVersionToToolset( case cmGlobalVisualStudioGenerator::VS15: return "v141"; case cmGlobalVisualStudioGenerator::VS16: - // FIXME: VS 2019 Preview 1.1 uses v141 but preview 2 will use v142. - return "v141"; + return "v142"; } return ""; } @@ -118,15 +148,35 @@ public: "Optional [arch] can be \"Win64\" or \"ARM\"."; } - void GetGenerators(std::vector<std::string>& names) const override + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(vs15generatorName); + return names; + } + + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + std::vector<std::string> names; names.push_back(vs15generatorName + std::string(" ARM")); names.push_back(vs15generatorName + std::string(" Win64")); + return names; } bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector<std::string> GetKnownPlatforms() const override + { + std::vector<std::string> platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + platforms.emplace_back("ARM64"); + return platforms; + } + + std::string GetDefaultPlatformName() const override { return "Win32"; } }; cmGlobalGeneratorFactory* @@ -178,13 +228,35 @@ public: "Use -A option to specify architecture."; } - virtual void GetGenerators(std::vector<std::string>& names) const + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(vs16generatorName); + return names; + } + + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + return std::vector<std::string>(); } bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return true; } + + std::vector<std::string> GetKnownPlatforms() const override + { + std::vector<std::string> platforms; + platforms.emplace_back("x64"); + platforms.emplace_back("Win32"); + platforms.emplace_back("ARM"); + platforms.emplace_back("ARM64"); + return platforms; + } + + std::string GetDefaultPlatformName() const override + { + return VSHostPlatformName(); + } }; cmGlobalGeneratorFactory* @@ -206,16 +278,8 @@ cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator( this->DefaultCSharpFlagTableName = VSVersionToToolset(this->Version); this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version); if (this->Version >= cmGlobalVisualStudioGenerator::VS16) { -#ifdef HOST_PLATFORM_NAME - this->DefaultPlatformName = HOST_PLATFORM_NAME; -#else - cmsys::SystemInformation info; - if (info.Is64Bits()) { - this->DefaultPlatformName = "x64"; - } else { - this->DefaultPlatformName = "Win32"; - } -#endif + this->DefaultPlatformName = VSHostPlatformName(); + this->DefaultPlatformToolsetHostArchitecture = VSHostArchitecture(); } } @@ -407,6 +471,18 @@ std::string cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommand() // Ask Visual Studio Installer tool. std::string vs; if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) { + std::string const& hostArch = + this->GetPlatformToolsetHostArchitectureString(); + if (hostArch == "x64") { + msbuild = vs + "/MSBuild/Current/Bin/amd64/MSBuild.exe"; + if (cmSystemTools::FileExists(msbuild)) { + return msbuild; + } + msbuild = vs + "/MSBuild/15.0/Bin/amd64/MSBuild.exe"; + if (cmSystemTools::FileExists(msbuild)) { + return msbuild; + } + } msbuild = vs + "/MSBuild/Current/Bin/MSBuild.exe"; if (cmSystemTools::FileExists(msbuild)) { return msbuild; diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 558ef15859..c02c4711aa 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -51,7 +51,7 @@ void cmGlobalWatcomWMakeGenerator::GetDocumentation( } void cmGlobalWatcomWMakeGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, int /*jobs*/, bool verbose, std::vector<std::string> const& makeOptions) diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index 0d10d58f4e..6680b193f0 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -50,7 +50,7 @@ public: bool AllowDeleteOnError() const override { return false; } protected: - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6618351493..6d15b8c966 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -133,13 +133,27 @@ public: cmGlobalXCodeGenerator::GetDocumentation(entry); } - void GetGenerators(std::vector<std::string>& names) const override + std::vector<std::string> GetGeneratorNames() const override { + std::vector<std::string> names; names.push_back(cmGlobalXCodeGenerator::GetActualName()); + return names; + } + + std::vector<std::string> GetGeneratorNamesWithPlatform() const override + { + return std::vector<std::string>(); } bool SupportsToolset() const override { return true; } bool SupportsPlatform() const override { return false; } + + std::vector<std::string> GetKnownPlatforms() const override + { + return std::vector<std::string>(); + } + + std::string GetDefaultPlatformName() const override { return std::string(); } }; cmGlobalXCodeGenerator::cmGlobalXCodeGenerator( @@ -177,12 +191,14 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator( std::string versionFile; { std::string out; - std::string::size_type pos = 0; - if (cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, - nullptr, nullptr, nullptr, - cmSystemTools::OUTPUT_NONE) && - (pos = out.find(".app/"), pos != std::string::npos)) { - versionFile = out.substr(0, pos + 5) + "Contents/version.plist"; + bool commandResult = cmSystemTools::RunSingleCommand( + "xcode-select --print-path", &out, nullptr, nullptr, nullptr, + cmSystemTools::OUTPUT_NONE); + if (commandResult) { + std::string::size_type pos = out.find(".app/"); + if (pos != std::string::npos) { + versionFile = out.substr(0, pos + 5) + "Contents/version.plist"; + } } } if (!versionFile.empty() && cmSystemTools::FileExists(versionFile.c_str())) { @@ -323,20 +339,22 @@ bool cmGlobalXCodeGenerator::Open(const std::string& bindir, } void cmGlobalXCodeGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, + GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& /*projectDir*/, const std::string& targetName, const std::string& config, bool /*fast*/, int jobs, bool /*verbose*/, std::vector<std::string> const& makeOptions) { // now build the test - makeCommand.push_back( + makeCommand.add( this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand())); - makeCommand.push_back("-project"); - std::string projectArg = projectName; - projectArg += ".xcode"; - projectArg += "proj"; - makeCommand.push_back(projectArg); + if (!projectName.empty()) { + makeCommand.add("-project"); + std::string projectArg = projectName; + projectArg += ".xcode"; + projectArg += "proj"; + makeCommand.add(projectArg); + } bool clean = false; std::string realTarget = targetName; @@ -344,29 +362,22 @@ void cmGlobalXCodeGenerator::GenerateBuildCommand( clean = true; realTarget = "ALL_BUILD"; } - if (clean) { - makeCommand.push_back("clean"); - } else { - makeCommand.push_back("build"); - } - makeCommand.push_back("-target"); - if (!realTarget.empty()) { - makeCommand.push_back(realTarget); - } else { - makeCommand.push_back("ALL_BUILD"); - } - makeCommand.push_back("-configuration"); - makeCommand.push_back(!config.empty() ? config : "Debug"); + + makeCommand.add((clean ? "clean" : "build")); + makeCommand.add("-target", (realTarget.empty() ? "ALL_BUILD" : realTarget)); + makeCommand.add("-configuration", (config.empty() ? "Debug" : config)); if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back("-jobs"); + makeCommand.add("-jobs"); if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back(std::to_string(jobs)); + makeCommand.add(std::to_string(jobs)); } } - makeCommand.insert(makeCommand.end(), makeOptions.begin(), - makeOptions.end()); + if (this->XcodeVersion >= 70) { + makeCommand.add("-hideShellScriptEnvironment"); + } + makeCommand.add(makeOptions.begin(), makeOptions.end()); } ///! Create a local generator appropriate to this Global Generator @@ -522,10 +533,6 @@ void cmGlobalXCodeGenerator::AddExtraTargets( // now make the allbuild depend on all the non-utility targets // in the project for (auto& gen : gens) { - if (this->IsExcluded(root, gen)) { - continue; - } - for (auto target : gen->GetGeneratorTargets()) { if (target->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; @@ -558,8 +565,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( false, "", false, cmMakefile::AcceptObjectLibraryCommands); } - if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY && - !target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + if (!this->IsExcluded(target)) { allbuild->AddUtility(target->GetName()); } } @@ -607,7 +613,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( std::string checkCache = root->GetBinaryDirectory(); checkCache += "/"; - checkCache += cmake::GetCMakeFilesDirectoryPostSlash(); + checkCache += "CMakeFiles/"; checkCache += "cmake.check_cache"; if (cm->DoWriteGlobVerifyTarget()) { @@ -1051,7 +1057,7 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) this->CurrentConfigurationTypes.clear(); this->CurrentMakefile->GetConfigurations(this->CurrentConfigurationTypes); if (this->CurrentConfigurationTypes.empty()) { - this->CurrentConfigurationTypes.push_back(""); + this->CurrentConfigurationTypes.emplace_back(); } } @@ -1397,7 +1403,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt) // language. cmMakefile* mf = gtgt->Target->GetMakefile(); std::string fname = gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fname += cmake::GetCMakeFilesDirectory(); + fname += "/CMakeFiles"; fname += "/"; fname += gtgt->GetName(); fname += "-CMakeForceLinker"; @@ -3570,7 +3576,7 @@ std::string cmGlobalXCodeGenerator::RelativeToSource(const char* p) std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p) { - return this->CurrentLocalGenerator->ConvertToRelativePath( + return this->CurrentLocalGenerator->MaybeConvertToRelativePath( cmSystemTools::JoinPath(this->ProjectOutputDirectoryComponents), p); } @@ -3705,7 +3711,7 @@ std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation( cmGeneratorTarget* target) { std::string plist = target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - plist += cmake::GetCMakeFilesDirectory(); + plist += "/CMakeFiles"; plist += "/"; plist += target->GetName(); plist += ".dir/Info.plist"; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 9b0d4fef9c..92ff25867d 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -66,7 +66,7 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - void GenerateBuildCommand(std::vector<std::string>& makeCommand, + void GenerateBuildCommand(GeneratedMakeCommand& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, diff --git a/Source/cmGraphAdjacencyList.h b/Source/cmGraphAdjacencyList.h index fb2eee23b1..5ca9269ed7 100644 --- a/Source/cmGraphAdjacencyList.h +++ b/Source/cmGraphAdjacencyList.h @@ -7,6 +7,7 @@ #include "cmListFileCache.h" +#include <utility> #include <vector> /** @@ -17,10 +18,10 @@ class cmGraphEdge { public: - cmGraphEdge(int n, bool s, cmListFileBacktrace const& bt) + cmGraphEdge(int n, bool s, cmListFileBacktrace bt) : Dest(n) , Strong(s) - , Backtrace(bt) + , Backtrace(std::move(bt)) { } operator int() const { return this->Dest; } diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index e3d30ddbd3..d34ed02c8b 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -19,13 +19,6 @@ class cmMakefile; class cmIfFunctionBlocker : public cmFunctionBlocker { public: - cmIfFunctionBlocker() - { - this->HasRun = false; - this->ElseSeen = false; - this->ScopeDepth = 0; - } - ~cmIfFunctionBlocker() override {} bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&) override; bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; @@ -33,9 +26,9 @@ public: std::vector<cmListFileArgument> Args; std::vector<cmListFileFunction> Functions; bool IsBlocking; - bool HasRun; - bool ElseSeen; - unsigned int ScopeDepth; + bool HasRun = false; + bool ElseSeen = false; + unsigned int ScopeDepth = 0; }; /// Starts an if block diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 594c310275..0d608bb9d0 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -67,7 +67,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args, // Not a path. Maybe module. std::string module = fname; module += ".cmake"; - std::string mfile = this->Makefile->GetModulesFile(module.c_str()); + std::string mfile = this->Makefile->GetModulesFile(module); if (!mfile.empty()) { fname = mfile; } @@ -120,8 +120,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args, return true; } - bool readit = - this->Makefile->ReadDependentFile(listFile.c_str(), noPolicyScope); + bool readit = this->Makefile->ReadDependentFile(listFile, noPolicyScope); // add the location of the included file if a result variable was given if (!resultVarName.empty()) { diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c6f40641ed..8ef644141b 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -712,7 +712,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) std::ostringstream e; e << "INSTALL TARGETS - target " << target.GetName() << " has " << "RESOURCE files but no RESOURCE DESTINATION."; - cmSystemTools::Message(e.str().c_str(), "Warning"); + cmSystemTools::Message(e.str(), "Warning"); } } } diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 538aa9f75c..155f0559b9 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -16,7 +16,7 @@ const char* cmInstallCommandArguments::PermissionsTable[] = { const std::string cmInstallCommandArguments::EmptyString; cmInstallCommandArguments::cmInstallCommandArguments( - const std::string& defaultComponent) + std::string defaultComponent) : Destination(&Parser, "DESTINATION", &ArgumentGroup) , Component(&Parser, "COMPONENT", &ArgumentGroup) , NamelinkComponent(&Parser, "NAMELINK_COMPONENT", &ArgumentGroup) @@ -29,7 +29,7 @@ cmInstallCommandArguments::cmInstallCommandArguments( , NamelinkSkip(&Parser, "NAMELINK_SKIP", &ArgumentGroup) , Type(&Parser, "TYPE", &ArgumentGroup) , GenericArguments(nullptr) - , DefaultComponentName(defaultComponent) + , DefaultComponentName(std::move(defaultComponent)) { } @@ -206,9 +206,7 @@ bool cmInstallCommandArguments::CheckPermissions( return false; } -cmInstallCommandIncludesArgument::cmInstallCommandIncludesArgument() -{ -} +cmInstallCommandIncludesArgument::cmInstallCommandIncludesArgument() = default; const std::vector<std::string>& cmInstallCommandIncludesArgument::GetIncludeDirs() const diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 425e58a2cb..8e974af6e7 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -13,7 +13,7 @@ class cmInstallCommandArguments { public: - cmInstallCommandArguments(const std::string& defaultComponent); + cmInstallCommandArguments(std::string defaultComponent); void SetGenericArguments(cmInstallCommandArguments* args) { this->GenericArguments = args; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index c9b50a3b62..a88c7af3b9 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -39,9 +39,7 @@ cmInstallDirectoryGenerator::cmInstallDirectoryGenerator( } } -cmInstallDirectoryGenerator::~cmInstallDirectoryGenerator() -{ -} +cmInstallDirectoryGenerator::~cmInstallDirectoryGenerator() = default; void cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg) { diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 4cc081c84a..47b9785e5c 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -15,7 +15,6 @@ #include "cmInstallType.h" #include "cmLocalGenerator.h" #include "cmSystemTools.h" -#include "cmake.h" cmInstallExportGenerator::cmInstallExportGenerator( cmExportSet* exportSet, const char* destination, @@ -57,7 +56,7 @@ void cmInstallExportGenerator::ComputeTempDir() // Choose a temporary directory in which to generate the import // files to be installed. this->TempDir = this->LocalGenerator->GetCurrentBinaryDirectory(); - this->TempDir += cmake::GetCMakeFilesDirectory(); + this->TempDir += "/CMakeFiles"; this->TempDir += "/Export"; if (this->Destination.empty()) { return; @@ -127,7 +126,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) std::ostringstream e; e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName() << "\""; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 68e3f86d1b..07094cb686 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -38,9 +38,7 @@ cmInstallFilesGenerator::cmInstallFilesGenerator( } } -cmInstallFilesGenerator::~cmInstallFilesGenerator() -{ -} +cmInstallFilesGenerator::~cmInstallFilesGenerator() = default; void cmInstallFilesGenerator::Compute(cmLocalGenerator* lg) { diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 2b236584a4..d139190a4f 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -18,9 +18,7 @@ cmInstallGenerator::cmInstallGenerator( { } -cmInstallGenerator::~cmInstallGenerator() -{ -} +cmInstallGenerator::~cmInstallGenerator() = default; bool cmInstallGenerator::HaveInstall() { diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index 12e87c765d..a513958edf 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -27,9 +27,7 @@ cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script, } } -cmInstallScriptGenerator::~cmInstallScriptGenerator() -{ -} +cmInstallScriptGenerator::~cmInstallScriptGenerator() = default; void cmInstallScriptGenerator::Compute(cmLocalGenerator* lg) { diff --git a/Source/cmInstallSubdirectoryGenerator.cxx b/Source/cmInstallSubdirectoryGenerator.cxx index ca9f13454c..ad7121f2ec 100644 --- a/Source/cmInstallSubdirectoryGenerator.cxx +++ b/Source/cmInstallSubdirectoryGenerator.cxx @@ -20,9 +20,7 @@ cmInstallSubdirectoryGenerator::cmInstallSubdirectoryGenerator( { } -cmInstallSubdirectoryGenerator::~cmInstallSubdirectoryGenerator() -{ -} +cmInstallSubdirectoryGenerator::~cmInstallSubdirectoryGenerator() = default; bool cmInstallSubdirectoryGenerator::HaveInstall() { diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 86c6a582b3..10df70badb 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -19,29 +19,26 @@ #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include "cmake.h" cmInstallTargetGenerator::cmInstallTargetGenerator( - const std::string& targetName, const char* dest, bool implib, + std::string targetName, const char* dest, bool implib, const char* file_permissions, std::vector<std::string> const& configurations, const char* component, MessageLevel message, bool exclude_from_all, - bool optional, cmListFileBacktrace const& backtrace) + bool optional, cmListFileBacktrace backtrace) : cmInstallGenerator(dest, configurations, component, message, exclude_from_all) - , TargetName(targetName) + , TargetName(std::move(targetName)) , Target(nullptr) , FilePermissions(file_permissions) , ImportLibrary(implib) , Optional(optional) - , Backtrace(backtrace) + , Backtrace(std::move(backtrace)) { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; } -cmInstallTargetGenerator::~cmInstallTargetGenerator() -{ -} +cmInstallTargetGenerator::~cmInstallTargetGenerator() = default; void cmInstallTargetGenerator::GenerateScript(std::ostream& os) { @@ -52,7 +49,7 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) << "\" has EXCLUDE_FROM_ALL set and will not be built by default " << "but an install rule has been provided for it. CMake does " << "not define behavior for this case."; - cmSystemTools::Message(msg.str().c_str(), "Warning"); + cmSystemTools::Message(msg.str(), "Warning"); } // Perform the main install script generation. @@ -102,7 +99,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( if (this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fromDirConfig += cmake::GetCMakeFilesDirectory(); + fromDirConfig += "/CMakeFiles"; fromDirConfig += "/CMakeRelink.dir/"; } else { cmStateEnums::ArtifactType artifact = this->ImportLibrary diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index bf625d18cf..715b4ae69f 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -23,11 +23,11 @@ class cmInstallTargetGenerator : public cmInstallGenerator { public: cmInstallTargetGenerator( - std::string const& targetName, const char* dest, bool implib, + std::string targetName, const char* dest, bool implib, const char* file_permissions, std::vector<std::string> const& configurations, const char* component, MessageLevel message, bool exclude_from_all, bool optional, - cmListFileBacktrace const& backtrace = cmListFileBacktrace()); + cmListFileBacktrace backtrace = cmListFileBacktrace()); ~cmInstallTargetGenerator() override; /** Select the policy for installing shared library linkable name diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 9f61e5b707..537b4ecec6 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -9,18 +9,14 @@ #include <utility> -cmInstalledFile::cmInstalledFile() -{ -} +cmInstalledFile::cmInstalledFile() = default; cmInstalledFile::~cmInstalledFile() { delete NameExpression; } -cmInstalledFile::Property::Property() -{ -} +cmInstalledFile::Property::Property() = default; cmInstalledFile::Property::~Property() { diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index bb56714b63..4b6b4d58c7 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -49,7 +49,7 @@ std::vector<std::string> getConfigurations(const cmake* cm) makefiles[0]->GetConfigurations(configurations); if (configurations.empty()) { - configurations.push_back(""); + configurations.emplace_back(); } return configurations; } @@ -292,10 +292,10 @@ static Json::Value DumpSourceFilesList( lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file); for (const auto& include : includes) { - fileData.IncludePathList.push_back( - std::make_pair(include, - target->IsSystemIncludeDirectory( - include, config, fileData.Language))); + fileData.IncludePathList.emplace_back( + include, + target->IsSystemIncludeDirectory(include, config, + fileData.Language)); } } @@ -578,10 +578,10 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, lg->GetTargetDefines(target, config, lang, defines); ld.SetDefines(defines); std::vector<std::string> includePathList; - lg->GetIncludeDirectories(includePathList, target, lang, config, true); + lg->GetIncludeDirectories(includePathList, target, lang, config); for (std::string const& i : includePathList) { - ld.IncludePathList.push_back( - std::make_pair(i, target->IsSystemIncludeDirectory(i, config, lang))); + ld.IncludePathList.emplace_back( + i, target->IsSystemIncludeDirectory(i, config, lang)); } } diff --git a/Source/cmLinkItem.cxx b/Source/cmLinkItem.cxx index 12a07f6765..9b03ad011e 100644 --- a/Source/cmLinkItem.cxx +++ b/Source/cmLinkItem.cxx @@ -6,20 +6,17 @@ #include <utility> // IWYU pragma: keep -cmLinkItem::cmLinkItem() -{ -} +cmLinkItem::cmLinkItem() = default; -cmLinkItem::cmLinkItem(std::string const& n, cmListFileBacktrace const& bt) - : String(n) - , Backtrace(bt) +cmLinkItem::cmLinkItem(std::string n, cmListFileBacktrace bt) + : String(std::move(n)) + , Backtrace(std::move(bt)) { } -cmLinkItem::cmLinkItem(cmGeneratorTarget const* t, - cmListFileBacktrace const& bt) +cmLinkItem::cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace bt) : Target(t) - , Backtrace(bt) + , Backtrace(std::move(bt)) { } diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index b841509e84..5b635b5b31 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -24,8 +24,8 @@ class cmLinkItem public: cmLinkItem(); - cmLinkItem(std::string const& s, cmListFileBacktrace const& bt); - cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace const& bt); + cmLinkItem(std::string s, cmListFileBacktrace bt); + cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace bt); std::string const& AsStr() const; cmGeneratorTarget const* Target = nullptr; cmListFileBacktrace Backtrace; @@ -77,13 +77,10 @@ struct cmLinkInterface : public cmLinkInterfaceLibraries std::vector<cmLinkItem> WrongConfigLibraries; bool ImplementationIsInterface = false; - - cmLinkInterface() {} }; struct cmOptionalLinkInterface : public cmLinkInterface { - cmOptionalLinkInterface() {} bool LibrariesDone = false; bool AllDone = false; bool Exists = false; @@ -105,7 +102,6 @@ struct cmLinkImplementation : public cmLinkImplementationLibraries // Cache link implementation computation from each configuration. struct cmOptionalLinkImplementation : public cmLinkImplementation { - cmOptionalLinkImplementation() {} bool LibrariesDone = false; bool LanguagesDone = false; bool HadHeadSensitiveCondition = false; diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 6643990ac6..2a8bee6e5a 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -23,9 +23,7 @@ cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter, { } -cmLinkLineComputer::~cmLinkLineComputer() -{ -} +cmLinkLineComputer::~cmLinkLineComputer() = default; void cmLinkLineComputer::SetUseWatcomQuote(bool useWatcomQuote) { diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index a93ec1271d..a403dc9282 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -21,9 +21,7 @@ cmLinkLineDeviceComputer::cmLinkLineDeviceComputer( { } -cmLinkLineDeviceComputer::~cmLinkLineDeviceComputer() -{ -} +cmLinkLineDeviceComputer::~cmLinkLineDeviceComputer() = default; static bool cmLinkItemValidForDevice(std::string const& item) { diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index b826795d07..297babfd8e 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -426,7 +426,7 @@ public: class TransformSelector { public: - virtual ~TransformSelector() {} + virtual ~TransformSelector() = default; std::string Tag; @@ -580,7 +580,7 @@ private: class TransformAction { public: - virtual ~TransformAction() {} + virtual ~TransformAction() = default; virtual std::string Transform(const std::string& input) = 0; }; @@ -659,15 +659,19 @@ bool cmListCommand::HandleTransformCommand( // Transform: lambda function implementing the action struct ActionDescriptor { - ActionDescriptor(const std::string& name) - : Name(name) + ActionDescriptor(std::string name) + : Name(std::move(name)) { } - ActionDescriptor(const std::string& name, int arity, - const transform_type& transform) - : Name(name) + ActionDescriptor(std::string name, int arity, transform_type transform) + : Name(std::move(name)) , Arity(arity) +#if defined(__GNUC__) && __GNUC__ == 6 && defined(__aarch64__) + // std::function move constructor miscompiles on this architecture , Transform(transform) +#else + , Transform(std::move(transform)) +#endif { } diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 9aa1f32e3b..f85511964a 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -5,8 +5,8 @@ #include "cmListFileLexer.h" #include "cmMessageType.h" #include "cmMessenger.h" -#include "cmOutputConverter.h" #include "cmState.h" +#include "cmStateDirectory.h" #include "cmSystemTools.h" #include <assert.h> @@ -24,7 +24,7 @@ cmCommandContext::cmCommandName& cmCommandContext::cmCommandName::operator=( struct cmListFileParser { - cmListFileParser(cmListFile* lf, cmListFileBacktrace const& lfbt, + cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt, cmMessenger* messenger, const char* filename); ~cmListFileParser(); void IssueFileOpenError(std::string const& text) const; @@ -47,12 +47,11 @@ struct cmListFileParser } Separation; }; -cmListFileParser::cmListFileParser(cmListFile* lf, - cmListFileBacktrace const& lfbt, +cmListFileParser::cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt, cmMessenger* messenger, const char* filename) : ListFile(lf) - , Backtrace(lfbt) + , Backtrace(std::move(lfbt)) , Messenger(messenger) , FileName(filename) , Lexer(cmListFileLexer_New()) @@ -194,8 +193,9 @@ bool cmListFileParser::ParseFunction(const char* name, long line) unsigned long lastLine; unsigned long parenDepth = 0; this->Separation = SeparationOkay; - while ((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer), - token = cmListFileLexer_Scan(this->Lexer))) { + while ( + (static_cast<void>(lastLine = cmListFileLexer_GetCurrentLine(this->Lexer)), + token = cmListFileLexer_Scan(this->Lexer))) { if (token->type == cmListFileLexer_Token_Space || token->type == cmListFileLexer_Token_Newline) { this->Separation = SeparationOkay; @@ -390,9 +390,8 @@ void cmListFileBacktrace::PrintTitle(std::ostream& out) const } cmListFileContext lfc = this->TopEntry->Context; cmStateSnapshot bottom = this->GetBottom(); - cmOutputConverter converter(bottom); if (!bottom.GetState()->GetIsInTryCompile()) { - lfc.FilePath = converter.ConvertToRelativePath( + lfc.FilePath = bottom.GetDirectory().ConvertToRelPathIfNotContained( bottom.GetState()->GetSourceDirectory(), lfc.FilePath); } out << (lfc.Line ? " at " : " in ") << lfc; @@ -409,7 +408,6 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const bool first = true; cmStateSnapshot bottom = this->GetBottom(); - cmOutputConverter converter(bottom); for (Entry const* cur = this->TopEntry->Parent.get(); !cur->IsBottom(); cur = cur->Parent.get()) { if (cur->Context.Name.empty()) { @@ -423,7 +421,7 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const } cmListFileContext lfc = cur->Context; if (!bottom.GetState()->GetIsInTryCompile()) { - lfc.FilePath = converter.ConvertToRelativePath( + lfc.FilePath = bottom.GetDirectory().ConvertToRelPathIfNotContained( bottom.GetState()->GetSourceDirectory(), lfc.FilePath); } out << " " << lfc << "\n"; diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 4a247bad1f..945741540b 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -29,12 +29,12 @@ struct cmCommandContext { std::string Lower; std::string Original; - cmCommandName() {} + cmCommandName() = default; cmCommandName(std::string const& name) { *this = name; } cmCommandName& operator=(std::string const& name); } Name; long Line = 0; - cmCommandContext() {} + cmCommandContext() = default; cmCommandContext(const char* name, int line) : Name(name) , Line(line) @@ -50,9 +50,9 @@ struct cmListFileArgument Quoted, Bracket }; - cmListFileArgument() {} - cmListFileArgument(const std::string& v, Delimiter d, long line) - : Value(v) + cmListFileArgument() = default; + cmListFileArgument(std::string v, Delimiter d, long line) + : Value(std::move(v)) , Delim(d) , Line(line) { @@ -73,7 +73,6 @@ public: std::string Name; std::string FilePath; long Line = 0; - cmListFileContext() {} static cmListFileContext FromCommandContext(cmCommandContext const& lfcc, std::string const& fileName) @@ -110,15 +109,6 @@ public: // indicated by the given valid snapshot. cmListFileBacktrace(cmStateSnapshot const& snapshot); - // Backtraces may be copied, moved, and assigned as values. - cmListFileBacktrace(cmListFileBacktrace const&) = default; - cmListFileBacktrace(cmListFileBacktrace&&) // NOLINT(clang-tidy) - noexcept = default; - cmListFileBacktrace& operator=(cmListFileBacktrace const&) = default; - cmListFileBacktrace& operator=(cmListFileBacktrace&&) // NOLINT(clang-tidy) - noexcept = default; - ~cmListFileBacktrace() = default; - cmStateSnapshot GetBottom() const; // Get a backtrace with the given file scope added to the top. diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 7ce2c828fa..75ad2a6581 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -12,10 +12,9 @@ class cmGlobalGenerator; cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmMakefile* mf, - std::string const& wd) + cmMakefile* mf, std::string wd) : cmLocalGenerator(gg, mf) - , WorkingDirectory(wd) + , WorkingDirectory(std::move(wd)) { // Store the configuration name that will be generated. if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) { @@ -27,9 +26,7 @@ cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, } } -cmLocalCommonGenerator::~cmLocalCommonGenerator() -{ -} +cmLocalCommonGenerator::~cmLocalCommonGenerator() = default; std::string cmLocalCommonGenerator::GetTargetFortranFlags( cmGeneratorTarget const* target, std::string const& config) @@ -47,7 +44,7 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags( target->GetFortranModuleDirectory(this->WorkingDirectory); if (!mod_dir.empty()) { mod_dir = this->ConvertToOutputFormat( - this->ConvertToRelativePath(this->WorkingDirectory, mod_dir), + this->MaybeConvertToRelativePath(this->WorkingDirectory, mod_dir), cmOutputConverter::SHELL); } else { mod_dir = diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index 7b8e6fe8ad..abebbc2a75 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -22,7 +22,7 @@ class cmLocalCommonGenerator : public cmLocalGenerator { public: cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf, - std::string const& wd); + std::string wd); ~cmLocalCommonGenerator() override; std::string const& GetConfigName() { return this->ConfigName; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 797add990f..252aa4c213 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -316,7 +316,7 @@ void cmLocalGenerator::GenerateTestFiles() for (cmStateSnapshot const& i : children) { // TODO: Use add_subdirectory instead? std::string outP = i.GetDirectory().GetCurrentBinary(); - outP = this->ConvertToRelativePath(parentBinDir, outP); + outP = this->MaybeConvertToRelativePath(parentBinDir, outP); outP = cmOutputConverter::EscapeForCMake(outP); fout << "subdirs(" << outP << ")" << std::endl; } @@ -881,31 +881,27 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, this->AddCompilerRequirementFlag(flags, target, lang); } -void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, - cmGeneratorTarget const* target, - const std::string& lang, - const std::string& config, - bool stripImplicitDirs, - bool appendAllImplicitDirs) const -{ - std::vector<BT<std::string>> tmp = this->GetIncludeDirectories( - target, lang, config, stripImplicitDirs, appendAllImplicitDirs); - dirs.reserve(tmp.size()); - for (BT<std::string>& v : tmp) { - dirs.emplace_back(std::move(v.Value)); - } -} - -std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories( +std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( cmGeneratorTarget const* target, std::string const& lang, std::string const& config, bool stripImplicitDirs, bool appendAllImplicitDirs) const { std::vector<BT<std::string>> result; - // Do not repeat an include path. std::set<std::string> emitted; + auto emitDir = [&result, &emitted](std::string const& dir) { + if (emitted.insert(dir).second) { + result.emplace_back(dir); + } + }; + + auto emitBT = [&result, &emitted](BT<std::string> const& dir) { + if (emitted.insert(dir.Value).second) { + result.emplace_back(dir); + } + }; + // When automatic include directories are requested for a build then // include the source and binary directories at the beginning of the // include path to approximate include file behavior for an @@ -915,21 +911,9 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories( // per-source-file include paths. if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR")) { // Current binary directory - { - std::string binDir = - this->StateSnapshot.GetDirectory().GetCurrentBinary(); - if (emitted.insert(binDir).second) { - result.emplace_back(std::move(binDir)); - } - } + emitDir(this->StateSnapshot.GetDirectory().GetCurrentBinary()); // Current source directory - { - std::string srcDir = - this->StateSnapshot.GetDirectory().GetCurrentSource(); - if (emitted.insert(srcDir).second) { - result.emplace_back(std::move(srcDir)); - } - } + emitDir(this->StateSnapshot.GetDirectory().GetCurrentSource()); } if (!target) { @@ -938,6 +922,11 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories( // Implicit include directories std::vector<std::string> implicitDirs; + std::set<std::string> implicitSet; + // Checks if this is not an implicit include directory + auto notImplicit = [&implicitSet](std::string const& dir) { + return (implicitSet.find(dir) == implicitSet.end()); + }; { std::string rootPath; if (const char* sysrootCompile = @@ -947,20 +936,28 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories( rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); } + // Raw list of implicit include directories + std::vector<std::string> impDirVec; + + // Get platform-wide implicit directories. + if (const char* implicitIncludes = (this->Makefile->GetDefinition( + "CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES"))) { + cmSystemTools::ExpandListArgument(implicitIncludes, impDirVec); + } + // Load implicit include directories for this language. std::string key = "CMAKE_"; key += lang; key += "_IMPLICIT_INCLUDE_DIRECTORIES"; if (const char* value = this->Makefile->GetDefinition(key)) { - std::vector<std::string> impDirVec; cmSystemTools::ExpandListArgument(value, impDirVec); - for (std::string const& i : impDirVec) { - { - std::string d = rootPath + i; - cmSystemTools::ConvertToUnixSlashes(d); - emitted.insert(std::move(d)); - } - implicitDirs.push_back(i); + } + + for (std::string const& i : impDirVec) { + std::string imd = rootPath + i; + cmSystemTools::ConvertToUnixSlashes(imd); + if (implicitSet.insert(imd).second) { + implicitDirs.emplace_back(std::move(imd)); } } } @@ -974,30 +971,31 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories( if (this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) { std::string const &topSourceDir = this->GetState()->GetSourceDirectory(), &topBinaryDir = this->GetState()->GetBinaryDirectory(); - for (BT<std::string> const& i : userDirs) { + for (BT<std::string> const& udr : userDirs) { // Emit this directory only if it is a subdirectory of the // top-level source or binary tree. - if (cmSystemTools::ComparePath(i.Value, topSourceDir) || - cmSystemTools::ComparePath(i.Value, topBinaryDir) || - cmSystemTools::IsSubDirectory(i.Value, topSourceDir) || - cmSystemTools::IsSubDirectory(i.Value, topBinaryDir)) { - if (emitted.insert(i.Value).second) { - result.push_back(i); + if (cmSystemTools::ComparePath(udr.Value, topSourceDir) || + cmSystemTools::ComparePath(udr.Value, topBinaryDir) || + cmSystemTools::IsSubDirectory(udr.Value, topSourceDir) || + cmSystemTools::IsSubDirectory(udr.Value, topBinaryDir)) { + if (notImplicit(udr.Value)) { + emitBT(udr); } } } } - // Construct the final ordered include directory list. - for (BT<std::string> const& i : userDirs) { - if (emitted.insert(i.Value).second) { - result.push_back(i); + // Emit remaining non implicit user direcories. + for (BT<std::string> const& udr : userDirs) { + if (notImplicit(udr.Value)) { + emitBT(udr); } } + // Sort result MoveSystemIncludesToEnd(result, config, lang, target); - // Add standard include directories for this language. + // Append standard include directories for this language. { std::vector<std::string> userStandardDirs; { @@ -1008,26 +1006,27 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories( cmSystemTools::ExpandListArgument(value, userStandardDirs); } userDirs.reserve(userDirs.size() + userStandardDirs.size()); - for (std::string& d : userStandardDirs) { - cmSystemTools::ConvertToUnixSlashes(d); - result.emplace_back(d); - userDirs.emplace_back(std::move(d)); + for (std::string& usd : userStandardDirs) { + cmSystemTools::ConvertToUnixSlashes(usd); + if (notImplicit(usd)) { + emitDir(usd); + } + userDirs.emplace_back(std::move(usd)); } } + // Append compiler implicit include directories if (!stripImplicitDirs) { - // Append only implicit directories that were requested by the user - for (std::string const& i : implicitDirs) { - if (std::find(userDirs.begin(), userDirs.end(), i) != userDirs.end()) { - result.emplace_back(i); + // Append implicit directories that were requested by the user only + for (BT<std::string> const& udr : userDirs) { + if (!notImplicit(udr.Value)) { + emitBT(udr); } } - // Append remaining implicit directories on demand + // Append remaining implicit directories (on demand) if (appendAllImplicitDirs) { - for (std::string const& i : implicitDirs) { - if (std::find(result.begin(), result.end(), i) == result.end()) { - result.emplace_back(i); - } + for (std::string& imd : implicitDirs) { + emitDir(imd); } } } @@ -1035,6 +1034,34 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories( return result; } +void cmLocalGenerator::GetIncludeDirectoriesImplicit( + std::vector<std::string>& dirs, cmGeneratorTarget const* target, + const std::string& lang, const std::string& config, bool stripImplicitDirs, + bool appendAllImplicitDirs) const +{ + std::vector<BT<std::string>> tmp = this->GetIncludeDirectoriesImplicit( + target, lang, config, stripImplicitDirs, appendAllImplicitDirs); + dirs.reserve(dirs.size() + tmp.size()); + for (BT<std::string>& v : tmp) { + dirs.emplace_back(std::move(v.Value)); + } +} + +std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories( + cmGeneratorTarget const* target, std::string const& lang, + std::string const& config) const +{ + return this->GetIncludeDirectoriesImplicit(target, lang, config); +} + +void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, + cmGeneratorTarget const* target, + const std::string& lang, + const std::string& config) const +{ + this->GetIncludeDirectoriesImplicit(dirs, target, lang, config); +} + void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, std::string const& config, std::string const& linkLanguage, @@ -1684,19 +1711,19 @@ void cmLocalGenerator::AddCompilerRequirementFlag( static std::map<std::string, std::vector<std::string>> langStdMap; if (langStdMap.empty()) { // Maintain sorted order, most recent first. - langStdMap["CXX"].push_back("20"); - langStdMap["CXX"].push_back("17"); - langStdMap["CXX"].push_back("14"); - langStdMap["CXX"].push_back("11"); - langStdMap["CXX"].push_back("98"); + langStdMap["CXX"].emplace_back("20"); + langStdMap["CXX"].emplace_back("17"); + langStdMap["CXX"].emplace_back("14"); + langStdMap["CXX"].emplace_back("11"); + langStdMap["CXX"].emplace_back("98"); - langStdMap["C"].push_back("11"); - langStdMap["C"].push_back("99"); - langStdMap["C"].push_back("90"); + langStdMap["C"].emplace_back("11"); + langStdMap["C"].emplace_back("99"); + langStdMap["C"].emplace_back("90"); - langStdMap["CUDA"].push_back("14"); - langStdMap["CUDA"].push_back("11"); - langStdMap["CUDA"].push_back("98"); + langStdMap["CUDA"].emplace_back("14"); + langStdMap["CUDA"].emplace_back("11"); + langStdMap["CUDA"].emplace_back("98"); } std::string standard(standardProp); @@ -1786,7 +1813,7 @@ static void AddVisibilityCompileOption(std::string& flags, std::ostringstream e; e << "Target " << target->GetName() << " uses unsupported value \"" << prop << "\" for " << flagDefine << "."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } std::string option = std::string(opt) + prop; @@ -2294,7 +2321,7 @@ std::string cmLocalGenerator::ConstructComment( std::string currentBinaryDir = this->GetCurrentBinaryDirectory(); for (std::string const& o : ccg.GetOutputs()) { comment += sep; - comment += this->ConvertToRelativePath(currentBinaryDir, o); + comment += this->MaybeConvertToRelativePath(currentBinaryDir, o); sep = ", "; } return comment; @@ -2551,15 +2578,15 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( std::string const& fullPath = source.GetFullPath(); // Try referencing the source relative to the source tree. - std::string relFromSource = - this->ConvertToRelativePath(this->GetCurrentSourceDirectory(), fullPath); + std::string relFromSource = this->MaybeConvertToRelativePath( + this->GetCurrentSourceDirectory(), fullPath); assert(!relFromSource.empty()); bool relSource = !cmSystemTools::FileIsFullPath(relFromSource); bool subSource = relSource && relFromSource[0] != '.'; // Try referencing the source relative to the binary tree. - std::string relFromBinary = - this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), fullPath); + std::string relFromBinary = this->MaybeConvertToRelativePath( + this->GetCurrentBinaryDirectory(), fullPath); assert(!relFromBinary.empty()); bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary); bool subBinary = relBinary && relFromBinary[0] != '.'; @@ -2658,6 +2685,13 @@ std::string const& cmLocalGenerator::GetCurrentSourceDirectory() const return this->StateSnapshot.GetDirectory().GetCurrentSource(); } +std::string cmLocalGenerator::MaybeConvertToRelativePath( + std::string const& local_path, std::string const& remote_path) const +{ + return this->StateSnapshot.GetDirectory().ConvertToRelPathIfNotContained( + local_path, remote_path); +} + std::string cmLocalGenerator::GetTargetDirectory( const cmGeneratorTarget* /*unused*/) const { @@ -2744,7 +2778,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const << "CMake is dropping a preprocessor definition: " << define << "\n" << "Consider defining the macro in a (configured) header file.\n"; /* clang-format on */ - cmSystemTools::Message(e.str().c_str()); + cmSystemTools::Message(e.str()); return false; } } @@ -2759,7 +2793,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const << "CMake is dropping a preprocessor definition: " << define << "\n" << "Consider defining the macro in a (configured) header file.\n"; /* clang-format on */ - cmSystemTools::Message(e.str().c_str()); + cmSystemTools::Message(e.str()); return false; } @@ -2783,7 +2817,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST"); std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in"; if (!cmSystemTools::FileIsFullPath(inFile)) { - std::string inMod = this->Makefile->GetModulesFile(inFile.c_str()); + std::string inMod = this->Makefile->GetModulesFile(inFile); if (!inMod.empty()) { inFile = inMod; } @@ -2792,7 +2826,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, std::ostringstream e; e << "Target " << target->GetName() << " Info.plist template \"" << inFile << "\" could not be found."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } @@ -2821,7 +2855,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList( const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in"; if (!cmSystemTools::FileIsFullPath(inFile)) { - std::string inMod = this->Makefile->GetModulesFile(inFile.c_str()); + std::string inMod = this->Makefile->GetModulesFile(inFile); if (!inMod.empty()) { inFile = inMod; } @@ -2830,7 +2864,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList( std::ostringstream e; e << "Target " << target->GetName() << " Info.plist template \"" << inFile << "\" could not be found."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index dc5431451d..f9839f6c19 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -233,28 +233,52 @@ public: virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {} /** Called from command-line hook to update dependencies. */ - virtual bool UpdateDependencies(const char* /* tgtInfo */, bool /*verbose*/, - bool /*color*/) + virtual bool UpdateDependencies(const std::string& /* tgtInfo */, + bool /*verbose*/, bool /*color*/) { return true; } - /** @brief Get the include directories for the current makefile and language. + /** @brief Get the include directories for the current makefile and language + * and optional the compiler implicit include directories. + * * @arg stripImplicitDirs Strip all directories found in * CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES from the result. * @arg appendAllImplicitDirs Append all directories found in * CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES to the result. */ + std::vector<BT<std::string>> GetIncludeDirectoriesImplicit( + cmGeneratorTarget const* target, std::string const& lang = "C", + std::string const& config = "", bool stripImplicitDirs = true, + bool appendAllImplicitDirs = false) const; + + /** @brief Get the include directories for the current makefile and language + * and optional the compiler implicit include directories. + * + * @arg dirs Directories are appended to this list + */ + void GetIncludeDirectoriesImplicit(std::vector<std::string>& dirs, + cmGeneratorTarget const* target, + const std::string& lang = "C", + const std::string& config = "", + bool stripImplicitDirs = true, + bool appendAllImplicitDirs = false) const; + + /** @brief Get the include directories for the current makefile and language. + * @arg dirs Include directories are appended to this list + */ void GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget const* target, const std::string& lang = "C", - const std::string& config = "", - bool stripImplicitDirs = true, - bool appendAllImplicitDirs = false) const; + const std::string& config = "") const; + + /** @brief Get the include directories for the current makefile and language. + * @return The include directory list + */ std::vector<BT<std::string>> GetIncludeDirectories( cmGeneratorTarget const* target, std::string const& lang = "C", - std::string const& config = "", bool stripImplicitDirs = true, - bool appendAllImplicitDirs = false) const; + std::string const& config = "") const; + void AddCompileOptions(std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config); @@ -302,6 +326,16 @@ public: std::string const& GetCurrentSourceDirectory() const; /** + * Convert the given remote path to a relative path with respect to + * the given local path. Both paths must use forward slashes and not + * already be escaped or quoted. + * The conversion is skipped if the paths are not both in the source + * or both in the binary tree. + */ + std::string MaybeConvertToRelativePath(std::string const& local_path, + std::string const& remote_path) const; + + /** * Generate a macOS application bundle Info.plist file. */ void GenerateAppleInfoPList(cmGeneratorTarget* target, diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index ab6774e00a..125e8b5308 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -7,6 +7,7 @@ #include "cmGhsMultiTargetGenerator.h" #include "cmGlobalGhsMultiGenerator.h" #include "cmMakefile.h" +#include "cmSourceFile.h" cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf) @@ -18,16 +19,82 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() { } +std::string cmLocalGhsMultiGenerator::GetTargetDirectory( + cmGeneratorTarget const* target) const +{ + std::string dir; + dir += target->GetName(); + dir += ".dir"; + return dir; +} + +void cmLocalGhsMultiGenerator::GenerateTargetsDepthFirst( + cmGeneratorTarget* target, std::vector<cmGeneratorTarget*>& remaining) +{ + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + return; + } + // Find this target in the list of remaining targets. + auto it = std::find(remaining.begin(), remaining.end(), target); + if (it == remaining.end()) { + // This target was already handled. + return; + } + // Remove this target from the list of remaining targets because + // we are handling it now. + *it = nullptr; + + cmGhsMultiTargetGenerator tg(target); + tg.Generate(); +} + void cmLocalGhsMultiGenerator::Generate() { - const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets(); + std::vector<cmGeneratorTarget*> remaining = this->GetGeneratorTargets(); + for (auto& t : remaining) { + if (t) { + GenerateTargetsDepthFirst(t, remaining); + } + } +} + +void cmLocalGhsMultiGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt) +{ + std::string dir_max; + dir_max += this->GetCurrentBinaryDirectory(); + dir_max += "/"; + dir_max += this->GetTargetDirectory(gt); + dir_max += "/"; + + // Count the number of object files with each name. Note that + // filesystem may not be case sensitive. + std::map<std::string, int> counts; + + for (auto const& si : mapping) { + cmSourceFile const* sf = si.first; + std::string objectNameLower = cmSystemTools::LowerCase( + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); + objectNameLower += this->GlobalGenerator->GetLanguageOutputExtension(*sf); + counts[objectNameLower] += 1; + } + + // For all source files producing duplicate names we need unique + // object name computation. + for (auto& si : mapping) { + cmSourceFile const* sf = si.first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); - for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); - l != tgts.end(); ++l) { - if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { - continue; + if (counts[cmSystemTools::LowerCase(objectName)] > 1) { + const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf); + bool keptSourceExtension; + objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max, + &keptSourceExtension); + cmsys::SystemTools::ReplaceString(objectName, "/", "_"); } - cmGhsMultiTargetGenerator tg(*l); - tg.Generate(); + si.second = objectName; } } diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h index aa842d74b5..d5bec42008 100644 --- a/Source/cmLocalGhsMultiGenerator.h +++ b/Source/cmLocalGhsMultiGenerator.h @@ -24,6 +24,17 @@ public: * Generate the makefile for this directory. */ virtual void Generate(); + + std::string GetTargetDirectory( + cmGeneratorTarget const* target) const override; + + void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = nullptr) override; + +private: + void GenerateTargetsDepthFirst(cmGeneratorTarget* target, + std::vector<cmGeneratorTarget*>& remaining); }; #endif diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index a8647b189b..c0afc25423 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -46,15 +46,13 @@ cmLocalNinjaGenerator::CreateRulePlaceholderExpander() const return ret; } -cmLocalNinjaGenerator::~cmLocalNinjaGenerator() -{ -} +cmLocalNinjaGenerator::~cmLocalNinjaGenerator() = default; void cmLocalNinjaGenerator::Generate() { // Compute the path to use when referencing the current output // directory from the top output directory. - this->HomeRelativeOutputPath = this->ConvertToRelativePath( + this->HomeRelativeOutputPath = this->MaybeConvertToRelativePath( this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); if (this->HomeRelativeOutputPath == ".") { this->HomeRelativeOutputPath.clear(); @@ -90,9 +88,7 @@ void cmLocalNinjaGenerator::Generate() if (tg) { tg->Generate(); // Add the target to "all" if required. - if (!this->GetGlobalNinjaGenerator()->IsExcluded( - this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - target)) { + if (!this->GetGlobalNinjaGenerator()->IsExcluded(target)) { this->GetGlobalNinjaGenerator()->AddDependencyToAll(target); } delete tg; @@ -106,7 +102,7 @@ void cmLocalNinjaGenerator::Generate() std::string cmLocalNinjaGenerator::GetTargetDirectory( cmGeneratorTarget const* target) const { - std::string dir = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string dir = "CMakeFiles/"; dir += target->GetName(); #if defined(__VMS) dir += "_dir"; @@ -141,7 +137,8 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference( format); } return this->ConvertToOutputFormat( - this->ConvertToRelativePath(this->GetBinaryDirectory(), path), format); + this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), path), + format); } // Private methods. @@ -305,7 +302,7 @@ std::string cmLocalNinjaGenerator::WriteCommandScript( scriptPath = target->GetSupportDirectory(); } else { scriptPath = this->GetCurrentBinaryDirectory(); - scriptPath += cmake::GetCMakeFilesDirectory(); + scriptPath += "/CMakeFiles"; } cmSystemTools::MakeDirectory(scriptPath); scriptPath += '/'; @@ -584,8 +581,8 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( if (!outputs.empty()) { output = outputs[0]; if (ccg.GetWorkingDirectory().empty()) { - output = - this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), output); + output = this->MaybeConvertToRelativePath( + this->GetCurrentBinaryDirectory(), output); } output = this->ConvertToOutputFormat(output, cmOutputConverter::SHELL); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 707a1b5c9b..d6f71d320d 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -98,9 +98,7 @@ cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3( this->BorlandMakeCurlyHack = false; } -cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3() -{ -} +cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3() = default; void cmLocalUnixMakefileGenerator3::Generate() { @@ -248,8 +246,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() for (auto& localObjectFile : localObjectFiles) { // Add a convenience rule for building the object file. this->WriteObjectConvenienceRule( - ruleFileStream, "target to build an object file", - localObjectFile.first.c_str(), localObjectFile.second); + ruleFileStream, "target to build an object file", localObjectFile.first, + localObjectFile.second); // Check whether preprocessing and assembly rules make sense. // They make sense only for C and C++ sources. @@ -271,9 +269,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() if (lang_has_preprocessor && do_preprocess_rules) { std::string::size_type dot_pos = localObjectFile.first.rfind("."); std::string base = localObjectFile.first.substr(0, dot_pos); - this->WriteObjectConvenienceRule( - ruleFileStream, "target to preprocess a source file", - (base + ".i").c_str(), localObjectFile.second); + this->WriteObjectConvenienceRule(ruleFileStream, + "target to preprocess a source file", + (base + ".i"), localObjectFile.second); localObjectFile.second.HasPreprocessRule = true; } @@ -282,7 +280,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() std::string base = localObjectFile.first.substr(0, dot_pos); this->WriteObjectConvenienceRule( ruleFileStream, "target to generate assembly for a file", - (base + ".s").c_str(), localObjectFile.second); + (base + ".s"), localObjectFile.second); localObjectFile.second.HasAssembleRule = true; } } @@ -298,7 +296,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() } void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule( - std::ostream& ruleFileStream, const char* comment, const char* output, + std::ostream& ruleFileStream, const char* comment, const std::string& output, LocalObjectInfo const& info) { // If the rule includes the source file extension then create a @@ -318,7 +316,7 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule( // Add a rule to drive the rule below. std::vector<std::string> depends; - depends.push_back(output); + depends.emplace_back(output); std::vector<std::string> no_commands; this->WriteMakeRule(ruleFileStream, nullptr, outNoExt, depends, no_commands, true, true); @@ -334,7 +332,7 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule( targetName += "/"; targetName += output; commands.push_back( - this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName)); + this->GetRecursiveMakeCall(tgtMakefileName, targetName)); } this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); @@ -371,10 +369,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( depends.clear(); // Build the target for this pass. - std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string makefile2 = "CMakeFiles/"; makefile2 += "Makefile2"; - commands.push_back( - this->GetRecursiveMakeCall(makefile2.c_str(), localName)); + commands.push_back(this->GetRecursiveMakeCall(makefile2, localName)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", @@ -399,7 +396,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( depends.clear(); commands.clear(); commands.push_back( - this->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + this->GetRecursiveMakeCall(makefileName, makeTargetName)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, "fast build rule for target.", @@ -415,7 +412,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( depends.clear(); commands.clear(); commands.push_back( - this->GetRecursiveMakeCall(makefile2.c_str(), makeTargetName)); + this->GetRecursiveMakeCall(makefile2, makeTargetName)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, @@ -429,7 +426,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() { std::string infoFileName = this->GetCurrentBinaryDirectory(); - infoFileName += cmake::GetCMakeFilesDirectory(); + infoFileName += "/CMakeFiles"; infoFileName += "/CMakeDirectoryInformation.cmake"; // Open the output file. @@ -685,7 +682,7 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsTop( } // Add a fake suffix to keep HP happy. Must be max 32 chars for SGI make. std::vector<std::string> depends; - depends.push_back(".hpux_make_needs_suffix_list"); + depends.emplace_back(".hpux_make_needs_suffix_list"); this->WriteMakeRule(makefileStream, nullptr, ".SUFFIXES", depends, no_commands, false); if (this->IsWatcomWMake()) { @@ -771,7 +768,7 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom( cmOutputConverter::SHELL); commands.push_back(rescanRule); } - std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string cmakefileName = "CMakeFiles/"; cmakefileName += "Makefile.cmake"; std::string runRule = "$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; @@ -852,7 +849,7 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepend( const char* nodep = this->Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY"); if (!nodep || cmSystemTools::IsOff(nodep)) { - depends.push_back(ruleFileName); + depends.emplace_back(ruleFileName); } } @@ -1254,9 +1251,8 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable( return ret; } -bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, - bool verbose, - bool color) +bool cmLocalUnixMakefileGenerator3::UpdateDependencies( + const std::string& tgtInfo, bool verbose, bool color) { // read in the target info file if (!this->Makefile->ReadListFile(tgtInfo) || @@ -1280,13 +1276,13 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, this->GlobalGenerator->GetCMakeInstance()->GetFileComparison(); { int result; - if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo, &result) || + if (!ftc->FileTimeCompare(internalDependFile, tgtInfo, &result) || result < 0) { if (verbose) { std::ostringstream msg; msg << "Dependee \"" << tgtInfo << "\" is newer than depender \"" << internalDependFile << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } needRescanDependInfo = true; } @@ -1296,18 +1292,17 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, // may have changed. In this case discard all old dependencies. bool needRescanDirInfo = false; std::string dirInfoFile = this->GetCurrentBinaryDirectory(); - dirInfoFile += cmake::GetCMakeFilesDirectory(); + dirInfoFile += "/CMakeFiles"; dirInfoFile += "/CMakeDirectoryInformation.cmake"; { int result; - if (!ftc->FileTimeCompare(internalDependFile.c_str(), dirInfoFile.c_str(), - &result) || + if (!ftc->FileTimeCompare(internalDependFile, dirInfoFile, &result) || result < 0) { if (verbose) { std::ostringstream msg; msg << "Dependee \"" << dirInfoFile << "\" is newer than depender \"" << internalDependFile << "\"." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } needRescanDirInfo = true; } @@ -1333,8 +1328,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, // dependency vector. This means that in the normal case, when only // few or one file have been edited, then also only this one file is // actually scanned again, instead of all files for this target. - needRescanDependencies = !checker.Check( - dependFile.c_str(), internalDependFile.c_str(), validDependencies); + needRescanDependencies = + !checker.Check(dependFile, internalDependFile, validDependencies); } if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) { @@ -1347,7 +1342,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, cmsysTerminal_Color_ForegroundBold, message.c_str(), true, color); - return this->ScanDependencies(dir.c_str(), validDependencies); + return this->ScanDependencies(dir, validDependencies); } // The dependencies are already up-to-date. @@ -1355,17 +1350,16 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, } bool cmLocalUnixMakefileGenerator3::ScanDependencies( - const char* targetDir, + const std::string& targetDir, std::map<std::string, cmDepends::DependencyVector>& validDeps) { // Read the directory information file. cmMakefile* mf = this->Makefile; bool haveDirectoryInfo = false; std::string dirInfoFile = this->GetCurrentBinaryDirectory(); - dirInfoFile += cmake::GetCMakeFilesDirectory(); + dirInfoFile += "/CMakeFiles"; dirInfoFile += "/CMakeDirectoryInformation.cmake"; - if (mf->ReadListFile(dirInfoFile.c_str()) && - !cmSystemTools::GetErrorOccuredFlag()) { + if (mf->ReadListFile(dirInfoFile) && !cmSystemTools::GetErrorOccuredFlag()) { haveDirectoryInfo = true; } @@ -1393,12 +1387,9 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( cmSystemTools::Error("Directory Information file not found"); } - // create the file stream for the depends file - std::string dir = targetDir; - // Open the make depends file. This should be copy-if-different // because the make tool may try to reload it needlessly otherwise. - std::string ruleFileNameFull = dir; + std::string ruleFileNameFull = targetDir; ruleFileNameFull += "/depend.make"; cmGeneratedFileStream ruleFileStream( ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); @@ -1410,7 +1401,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // Open the cmake dependency tracking file. This should not be // copy-if-different because dependencies are re-scanned when it is // older than the DependInfo.cmake. - std::string internalRuleFileNameFull = dir; + std::string internalRuleFileNameFull = targetDir; internalRuleFileNameFull += "/depend.internal"; cmGeneratedFileStream internalRuleFileStream( internalRuleFileNameFull, false, @@ -1451,7 +1442,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( scanner->SetFileComparison( this->GlobalGenerator->GetCMakeInstance()->GetFileComparison()); scanner->SetLanguage(lang); - scanner->SetTargetDirectory(dir.c_str()); + scanner->SetTargetDirectory(targetDir); scanner->Write(ruleFileStream, internalRuleFileStream); // free the scanner for this language @@ -1489,7 +1480,7 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose) msg << "Deleting primary custom command output \"" << dependee << "\" because another output \"" << depender << "\" does not exist." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } cmSystemTools::RemoveFile(dependee); } @@ -1507,7 +1498,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( // Just depend on the all target to drive the build. std::vector<std::string> depends; std::vector<std::string> no_commands; - depends.push_back("all"); + depends.emplace_back("all"); // Write the rule. this->WriteMakeRule(ruleFileStream, @@ -1571,7 +1562,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( (targetName == "install/strip")) { // Provide a fast install target that does not depend on all // but has the same command. - depends.push_back("preinstall/fast"); + depends.emplace_back("preinstall/fast"); } else { // Just forward to the real target so at least it will work. depends.push_back(targetName); @@ -1593,18 +1584,18 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( bool regenerate = !this->GlobalGenerator->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION"); if (regenerate) { - depends.push_back("cmake_check_build_system"); + depends.emplace_back("cmake_check_build_system"); } std::string progressDir = this->GetBinaryDirectory(); - progressDir += cmake::GetCMakeFilesDirectory(); + progressDir += "/CMakeFiles"; { std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; progCmd << this->ConvertToOutputFormat( cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL); - std::string progressFile = cmake::GetCMakeFilesDirectory(); + std::string progressFile = "/CMakeFiles"; progressFile += "/progress.marks"; std::string progressFileNameFull = this->ConvertToFullPath(progressFile); progCmd << " " @@ -1613,10 +1604,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( cmOutputConverter::SHELL); commands.push_back(progCmd.str()); } - std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string mf2Dir = "CMakeFiles/"; mf2Dir += "Makefile2"; - commands.push_back( - this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); + commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); { @@ -1635,15 +1625,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( recursiveTarget += "/clean"; commands.clear(); depends.clear(); - commands.push_back( - this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); + commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", depends, commands, true); commands.clear(); depends.clear(); - depends.push_back("clean"); + depends.emplace_back("clean"); this->WriteMakeRule(ruleFileStream, "The main clean target", "clean/fast", depends, commands, true); @@ -1656,13 +1645,12 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( this->Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); if (!noall || cmSystemTools::IsOff(noall)) { // Drive the build before installing. - depends.push_back("all"); + depends.emplace_back("all"); } else if (regenerate) { // At least make sure the build system is up to date. - depends.push_back("cmake_check_build_system"); + depends.emplace_back("cmake_check_build_system"); } - commands.push_back( - this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); + commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", @@ -1682,7 +1670,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( cmOutputConverter::SHELL); commands.push_back(rescanRule); } - std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string cmakefileName = "CMakeFiles/"; cmakefileName += "Makefile.cmake"; { std::string runRule = @@ -1720,7 +1708,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, // Clear the implicit dependency makefile. std::string dependFile = dir + "/depend.make"; - clearer.Clear(dependFile.c_str()); + clearer.Clear(dependFile); // Remove the internal dependency check file to force // regeneration. @@ -1737,9 +1725,9 @@ class NotInProjectDir { public: // Constructor with the source and binary directory's path - NotInProjectDir(const std::string& sourceDir, const std::string& binaryDir) - : SourceDir(sourceDir) - , BinaryDir(binaryDir) + NotInProjectDir(std::string sourceDir, std::string binaryDir) + : SourceDir(std::move(sourceDir)) + , BinaryDir(std::move(binaryDir)) { } @@ -1890,7 +1878,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os) } std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall( - const char* makefile, const std::string& tgt) + const std::string& makefile, const std::string& tgt) { // Call make on the given file. std::string cmd; @@ -1960,7 +1948,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os, } std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( - const char* p, bool useWatcomQuote) + const std::string& p, bool useWatcomQuote) { // Split the path into its components. std::vector<std::string> components; @@ -2027,7 +2015,7 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( std::string cmLocalUnixMakefileGenerator3::GetTargetDirectory( cmGeneratorTarget const* target) const { - std::string dir = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string dir = "CMakeFiles/"; dir += target->GetName(); #if defined(__VMS) dir += "_dir"; @@ -2044,8 +2032,8 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(const cmGeneratorTarget* tgt) } void cmLocalUnixMakefileGenerator3::AddImplicitDepends( - const cmGeneratorTarget* tgt, const std::string& lang, const char* obj, - const char* src) + const cmGeneratorTarget* tgt, const std::string& lang, + const std::string& obj, const std::string& src) { this->ImplicitDepends[tgt->GetName()][lang][obj].push_back(src); } @@ -2089,12 +2077,3 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand( [&prefix](std::string const& s) { return prefix + s; }); } } - -std::string cmLocalUnixMakefileGenerator3::MaybeConvertToRelativePath( - std::string const& base, std::string const& path) -{ - if (!this->GetStateSnapshot().GetDirectory().ContainsBoth(base, path)) { - return path; - } - return cmSystemTools::ForceToRelativePath(base, path); -} diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index ee6b37b003..ced2dbd461 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -12,6 +12,7 @@ #include <map> #include <set> #include <string> +#include <utility> #include <vector> class cmCustomCommand; @@ -83,7 +84,7 @@ public: void WriteDivider(std::ostream& os); /** used to create a recursive make call */ - std::string GetRecursiveMakeCall(const char* makefile, + std::string GetRecursiveMakeCall(const std::string& makefile, const std::string& tgt); // append flags to a string @@ -120,7 +121,7 @@ public: std::string const& targetDir, std::string const& relDir); - static std::string ConvertToQuotedOutputPath(const char* p, + static std::string ConvertToQuotedOutputPath(const std::string& p, bool useWatcomQuote); std::string CreateMakeVariable(const std::string& sin, @@ -128,7 +129,7 @@ public: /** Called from command-line hook to bring dependencies up to date for a target. */ - bool UpdateDependencies(const char* tgtInfo, bool verbose, + bool UpdateDependencies(const std::string& tgtInfo, bool verbose, bool color) override; /** Called from command-line hook to clear dependencies. */ @@ -158,8 +159,8 @@ public: cmGeneratorTarget const* tgt); void AddImplicitDepends(cmGeneratorTarget const* tgt, - const std::string& lang, const char* obj, - const char* src); + const std::string& lang, const std::string& obj, + const std::string& src); // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); @@ -183,9 +184,6 @@ public: // Eclipse generator. void GetIndividualFileTargets(std::vector<std::string>& targets); - std::string MaybeConvertToRelativePath(std::string const& base, - std::string const& path); - protected: void WriteLocalMakefile(); @@ -200,9 +198,6 @@ protected: void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmGeneratorTarget* tgt); - // write the local help rule - void WriteHelpRule(std::ostream& ruleFileStream); - // this converts a file name that is relative to the StartOuputDirectory // into a full path std::string ConvertToFullPath(const std::string& localPath); @@ -211,15 +206,6 @@ protected: const std::string& realTarget, const std::string& helpTarget); - void WriteTargetDependRule(std::ostream& ruleFileStream, - cmGeneratorTarget* target); - void WriteTargetCleanRule(std::ostream& ruleFileStream, - cmGeneratorTarget* target, - const std::vector<std::string>& files); - void WriteTargetRequiresRule(std::ostream& ruleFileStream, - cmGeneratorTarget* target, - const std::vector<std::string>& objects); - void AppendRuleDepend(std::vector<std::string>& depends, const char* ruleFileName); void AppendRuleDepends(std::vector<std::string>& depends, @@ -245,7 +231,7 @@ protected: // Helper methods for dependency updates. bool ScanDependencies( - const char* targetDir, + const std::string& targetDir, std::map<std::string, cmDepends::DependencyVector>& validDeps); void CheckMultipleOutputs(bool verbose); @@ -266,10 +252,10 @@ private: { cmGeneratorTarget* Target = nullptr; std::string Language; - LocalObjectEntry() {} - LocalObjectEntry(cmGeneratorTarget* t, const std::string& lang) + LocalObjectEntry() = default; + LocalObjectEntry(cmGeneratorTarget* t, std::string lang) : Target(t) - , Language(lang) + , Language(std::move(lang)) { } }; @@ -278,13 +264,13 @@ private: bool HasSourceExtension = false; bool HasPreprocessRule = false; bool HasAssembleRule = false; - LocalObjectInfo() {} }; void GetLocalObjectFiles( std::map<std::string, LocalObjectInfo>& localObjectFiles); void WriteObjectConvenienceRule(std::ostream& ruleFileStream, - const char* comment, const char* output, + const char* comment, + const std::string& output, LocalObjectInfo const& info); std::vector<std::string> LocalHelp; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 677d033732..7019552c3a 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -97,7 +97,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force_commands.push_back(force_command); std::string no_main_dependency; std::string force = this->GetCurrentBinaryDirectory(); - force += cmake::GetCMakeFilesDirectory(); + force += "/CMakeFiles"; force += "/"; force += l->GetName(); force += "_force"; @@ -144,7 +144,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() // Touch a timestamp file used to determine when the project file is // out of date. std::string stampName = this->GetCurrentBinaryDirectory(); - stampName += cmake::GetCMakeFilesDirectory(); + stampName += "/CMakeFiles"; cmSystemTools::MakeDirectory(stampName.c_str()); stampName += "/"; stampName += "generate.stamp"; @@ -254,7 +254,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() std::string stampName = this->GetCurrentBinaryDirectory(); stampName += "/"; - stampName += cmake::GetCMakeFilesDirectoryPostSlash(); + stampName += "CMakeFiles/"; stampName += "generate.stamp"; cmCustomCommandLine commandLine; commandLine.push_back(cmSystemTools::GetCMakeCommand()); @@ -803,8 +803,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( target->GetProperty("Fortran_MODULE_DIRECTORY"); std::string modDir; if (target_mod_dir) { - modDir = this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), - target_mod_dir); + modDir = this->MaybeConvertToRelativePath( + this->GetCurrentBinaryDirectory(), target_mod_dir); } else { modDir = "."; } @@ -1306,7 +1306,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries( for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) { if (l->IsPath) { std::string rel = - lg->ConvertToRelativePath(currentBinDir, l->Value.c_str()); + lg->MaybeConvertToRelativePath(currentBinDir, l->Value.c_str()); fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " "; } else if (!l->Target || l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { @@ -1332,7 +1332,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects( i != objs.end(); ++i) { if (!(*i)->GetObjectLibrary().empty()) { std::string const& objFile = (*i)->GetFullPath(); - std::string rel = lg->ConvertToRelativePath(currentBinDir, objFile); + std::string rel = lg->MaybeConvertToRelativePath(currentBinDir, objFile); fout << sep << lg->ConvertToXMLOutputPath(rel.c_str()); sep = " "; } @@ -1358,7 +1358,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories( // Switch to a relative path specification if it is shorter. if (cmSystemTools::FileIsFullPath(dir.c_str())) { std::string rel = - this->ConvertToRelativePath(currentBinDir, dir.c_str()); + this->MaybeConvertToRelativePath(currentBinDir, dir.c_str()); if (rel.size() < dir.size()) { dir = rel; } diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 2237da75fb..660729c3ac 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -210,9 +210,10 @@ std::string cmLocalVisualStudioGenerator::ConstructScript( } if (workingDirectory.empty()) { - script += this->ConvertToOutputFormat( - this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), cmd), - cmOutputConverter::SHELL); + script += + this->ConvertToOutputFormat(this->MaybeConvertToRelativePath( + this->GetCurrentBinaryDirectory(), cmd), + cmOutputConverter::SHELL); } else { script += this->ConvertToOutputFormat(cmd.c_str(), SHELL); } diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 92c958d05e..9c36627b51 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -19,9 +19,7 @@ cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, this->EmitUniversalBinaryFlags = false; } -cmLocalXCodeGenerator::~cmLocalXCodeGenerator() -{ -} +cmLocalXCodeGenerator::~cmLocalXCodeGenerator() = default; std::string cmLocalXCodeGenerator::GetTargetDirectory( cmGeneratorTarget const*) const diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx index 7368812ec0..d4af1e0f32 100644 --- a/Source/cmMachO.cxx +++ b/Source/cmMachO.cxx @@ -91,7 +91,7 @@ public: : Swap(_swap) { } - virtual ~cmMachOHeaderAndLoadCommands() {} + virtual ~cmMachOHeaderAndLoadCommands() = default; virtual bool read_mach_o(cmsys::ifstream& fin) = 0; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 23d93a381a..7279d5fcf8 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -17,11 +17,6 @@ class cmMacroHelperCommand : public cmCommand { public: - cmMacroHelperCommand() {} - - ///! clean up any memory allocated by the macro - ~cmMacroHelperCommand() override {} - /** * This is a virtual constructor for the command. */ @@ -94,7 +89,7 @@ bool cmMacroHelperCommand::InvokeInitialPass( char argvName[60]; for (unsigned int j = 0; j < expandedArgs.size(); ++j) { sprintf(argvName, "${ARGV%u}", j); - argVs.push_back(argvName); + argVs.emplace_back(argvName); } // Invoke all the functions that were collected in the block. cmListFileFunction newLFF; diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index d967388bff..b54ed66050 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -18,15 +18,13 @@ class cmMakefile; class cmMacroFunctionBlocker : public cmFunctionBlocker { public: - cmMacroFunctionBlocker() { this->Depth = 0; } - ~cmMacroFunctionBlocker() override {} bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, cmExecutionStatus&) override; bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; std::vector<std::string> Args; std::vector<cmListFileFunction> Functions; - int Depth; + int Depth = 0; }; /// Starts macro() ... endmacro() block diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3ff576ec3a..ab139c0f1e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -45,6 +45,8 @@ #include "cm_sys_stat.h" #include "cmake.h" +#include "cmConfigure.h" // IWYU pragma: keep + #ifdef CMAKE_BUILD_WITH_CMAKE # include "cmVariableWatch.h" #endif @@ -83,6 +85,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, this->StateSnapshot = this->StateSnapshot.GetState()->CreatePolicyScopeSnapshot( this->StateSnapshot); + this->RecursionDepth = 0; // Enter a policy level for this directory. this->PushPolicy(); @@ -319,7 +322,7 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const msg << " "; } msg << ")"; - cmSystemTools::Message(msg.str().c_str()); + cmSystemTools::Message(msg.str()); } // Helper class to make sure the call stack is valid. @@ -333,12 +336,14 @@ public: cmListFileContext const& lfc = cmListFileContext::FromCommandContext( cc, this->Makefile->StateSnapshot.GetExecutionListFile()); this->Makefile->Backtrace = this->Makefile->Backtrace.Push(lfc); + ++this->Makefile->RecursionDepth; this->Makefile->ExecutionStatusStack.push_back(&status); } ~cmMakefileCall() { this->Makefile->ExecutionStatusStack.pop_back(); + --this->Makefile->RecursionDepth; this->Makefile->Backtrace = this->Makefile->Backtrace.Pop(); } @@ -361,6 +366,24 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, cmMakefileCall stack_manager(this, lff, status); static_cast<void>(stack_manager); + // Check for maximum recursion depth. + int depth = CMake_DEFAULT_RECURSION_LIMIT; + const char* depthStr = this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH"); + if (depthStr) { + std::istringstream s(depthStr); + int d; + if (s >> d) { + depth = d; + } + } + if (this->RecursionDepth > depth) { + std::ostringstream e; + e << "Maximum recursion depth of " << depth << " exceeded"; + this->IssueMessage(MessageType::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + // Lookup the command prototype. if (cmCommand* proto = this->GetState()->GetCommandByExactName(lff.Name.Lower)) { @@ -533,7 +556,8 @@ void cmMakefile::IncludeScope::EnforceCMP0011() } } -bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope) +bool cmMakefile::ReadDependentFile(const std::string& filename, + bool noPolicyScope) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->GetDefinition("CMAKE_CURRENT_LIST_FILE")); @@ -586,7 +610,7 @@ private: bool ReportError; }; -bool cmMakefile::ReadListFile(const char* filename) +bool cmMakefile::ReadListFile(const std::string& filename) { std::string filenametoread = cmSystemTools::CollapseFullPath( filename, this->GetCurrentSourceDirectory()); @@ -1127,7 +1151,7 @@ cmTarget* cmMakefile::AddUtilityCommand( // Create a target instance for this utility. cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); target->SetIsGeneratorProvided(origin == TargetOrigin::Generator); - if (excludeFromAll) { + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } if (!comment) { @@ -1138,7 +1162,7 @@ cmTarget* cmMakefile::AddUtilityCommand( // Store the custom command in the target. if (!commandLines.empty() || !depends.empty()) { std::string force = this->GetCurrentBinaryDirectory(); - force += cmake::GetCMakeFilesDirectory(); + force += "/CMakeFiles"; force += "/"; force += utilityName; std::vector<std::string> forced; @@ -1368,6 +1392,9 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) // Imported targets. this->ImportedTargets = parent->ImportedTargets; + + // Recursion depth. + this->RecursionDepth = parent->RecursionDepth; } void cmMakefile::PushFunctionScope(std::string const& fileName, @@ -1492,7 +1519,7 @@ void cmMakefile::Configure() // make sure the CMakeFiles dir is there std::string filesDir = this->StateSnapshot.GetDirectory().GetCurrentBinary(); - filesDir += cmake::GetCMakeFilesDirectory(); + filesDir += "/CMakeFiles"; cmSystemTools::MakeDirectory(filesDir); assert(cmSystemTools::FileExists(currentStart, true)); @@ -1595,7 +1622,7 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf) if (this->GetCMakeInstance()->GetDebugOutput()) { std::string msg = " Entering "; msg += currentStart; - cmSystemTools::Message(msg.c_str()); + cmSystemTools::Message(msg); } std::string const currentStartFile = currentStart + "/CMakeLists.txt"; @@ -1638,7 +1665,7 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf) if (this->GetCMakeInstance()->GetDebugOutput()) { std::string msg = " Returning to "; msg += this->GetCurrentSourceDirectory(); - cmSystemTools::Message(msg.c_str()); + cmSystemTools::Message(msg); } } @@ -1662,7 +1689,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); this->GetGlobalGenerator()->AddMakefile(subMf); - if (excludeFromAll) { + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } @@ -1958,7 +1985,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname, // over changes in CMakeLists.txt, making the information stale and // hence useless. target->ClearDependencyInformation(*this); - if (excludeFromAll) { + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); @@ -1971,7 +1998,7 @@ cmTarget* cmMakefile::AddExecutable(const std::string& exeName, bool excludeFromAll) { cmTarget* target = this->AddNewTarget(cmStateEnums::EXECUTABLE, exeName); - if (excludeFromAll) { + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); @@ -2099,7 +2126,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, if (i == -1) { // group does not exist nor belong to any existing group // add its first component - this->SourceGroups.push_back(cmSourceGroup(name[0], regex)); + this->SourceGroups.emplace_back(name[0], regex); sg = this->GetSourceGroup(currentName); i = 0; // last component found } @@ -2711,7 +2738,6 @@ typedef enum } t_domain; struct t_lookup { - t_lookup() {} t_domain domain = NORMAL; size_t loc = 0; }; @@ -2720,8 +2746,17 @@ bool cmMakefile::IsProjectFile(const char* filename) const { return cmSystemTools::IsSubDirectory(filename, this->GetHomeDirectory()) || (cmSystemTools::IsSubDirectory(filename, this->GetHomeOutputDirectory()) && - !cmSystemTools::IsSubDirectory(filename, - cmake::GetCMakeFilesDirectory())); + !cmSystemTools::IsSubDirectory(filename, "/CMakeFiles")); +} + +int cmMakefile::GetRecursionDepth() const +{ + return this->RecursionDepth; +} + +void cmMakefile::SetRecursionDepth(int recursionDepth) +{ + this->RecursionDepth = recursionDepth; } MessageType cmMakefile::ExpandVariablesInStringNew( @@ -3387,6 +3422,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, this->IsSourceFileTryCompile = false; return 1; } + gg->RecursionDepth = this->RecursionDepth; cm.SetGlobalGenerator(gg); // do a configure @@ -3406,6 +3442,12 @@ int cmMakefile::TryCompile(const std::string& srcdir, cmStateEnums::STRING); } } + const char* recursionDepth = + this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH"); + if (recursionDepth) { + cm.AddCacheEntry("CMAKE_MAXIMUM_RECURSION_DEPTH", recursionDepth, + "Maximum recursion depth", cmStateEnums::STRING); + } // if cmake args were provided then pass them in if (cmakeArgs) { // FIXME: Workaround to ignore unused CLI variables in try-compile. @@ -3515,7 +3557,7 @@ void cmMakefile::DisplayStatus(const char* message, float s) const cm->UpdateProgress(message, s); } -std::string cmMakefile::GetModulesFile(const char* filename, +std::string cmMakefile::GetModulesFile(const std::string& filename, bool& system) const { std::string result; @@ -3707,8 +3749,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, } if (copyonly) { - if (!cmSystemTools::CopyFileIfDifferent(sinfile.c_str(), - soutfile.c_str())) { + if (!cmSystemTools::CopyFileIfDifferent(sinfile, soutfile)) { return 0; } } else { @@ -3759,8 +3800,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, // close the files before attempting to copy fin.close(); fout.close(); - if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), - soutfile.c_str())) { + if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile, soutfile)) { res = 0; } else { cmSystemTools::SetPermissions(soutfile, perm); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index ec36972a9e..2bd44e2b60 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -86,11 +86,10 @@ public: cmDirectoryId GetDirectoryId() const; - bool ReadListFile(const char* filename); + bool ReadListFile(const std::string& filename); - bool ReadDependentFile(const char* filename, bool noPolicyScope = true); - - bool ProcessBuildsystemFile(const char* filename); + bool ReadDependentFile(const std::string& filename, + bool noPolicyScope = true); /** * Add a function blocker to this makefile @@ -690,13 +689,13 @@ public: /** * Return a location of a file in cmake or custom modules directory */ - std::string GetModulesFile(const char* name) const + std::string GetModulesFile(const std::string& name) const { bool system; return this->GetModulesFile(name, system); } - std::string GetModulesFile(const char* name, bool& system) const; + std::string GetModulesFile(const std::string& name, bool& system) const; ///! Set/Get a property of this directory void SetProperty(const std::string& prop, const char* value); @@ -871,6 +870,9 @@ public: const char* sourceFilename) const; bool IsProjectFile(const char* filename) const; + int GetRecursionDepth() const; + void SetRecursionDepth(int recursionDepth); + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(cmTarget& target); @@ -931,6 +933,7 @@ protected: private: cmStateSnapshot StateSnapshot; cmListFileBacktrace Backtrace; + int RecursionDepth; void ReadListFile(cmListFile const& listFile, const std::string& filenametoread); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 92eeb2e650..e576b5f8e6 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,6 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator( cmGeneratorTarget* target) @@ -317,7 +316,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string outpathImp; if (relink) { outpath = this->Makefile->GetCurrentBinaryDirectory(); - outpath += cmake::GetCMakeFilesDirectory(); + outpath += "/CMakeFiles"; outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); outpath += "/"; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 0c2d7b316e..72181ab99e 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -25,7 +25,6 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator( cmGeneratorTarget* target) @@ -499,7 +498,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( outpath += "/"; } else if (relink) { outpath = this->Makefile->GetCurrentBinaryDirectory(); - outpath += cmake::GetCMakeFilesDirectory(); + outpath += "/CMakeFiles"; outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); outpath += "/"; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d1dcd81825..af34169c39 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -403,7 +403,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( err << "Warning: Source file \"" << source.GetFullPath() << "\" is listed multiple times for target \"" << this->GeneratorTarget->GetName() << "\"."; - cmSystemTools::Message(err.str().c_str(), "Warning"); + cmSystemTools::Message(err.str(), "Warning"); return; } @@ -435,8 +435,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( objFullPath = cmSystemTools::CollapseFullPath(objFullPath); std::string srcFullPath = cmSystemTools::CollapseFullPath(source.GetFullPath()); - this->LocalGenerator->AddImplicitDepends( - this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str()); + this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang, + objFullPath, srcFullPath); } void cmMakefileTargetGenerator::WriteObjectBuildFile( @@ -816,7 +816,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( lang_has_assembly && this->LocalGenerator->GetCreateAssemblySourceRules(); if (do_preprocess_rules || do_assembly_rules) { std::vector<std::string> force_depends; - force_depends.push_back("cmake_force"); + force_depends.emplace_back("cmake_force"); std::string::size_type dot_pos = relativeObj.rfind('.'); std::string relativeObjBase = relativeObj.substr(0, dot_pos); dot_pos = obj.rfind('.'); @@ -1213,8 +1213,7 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile( std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]); std::string srcFullPath = cmSystemTools::CollapseFullPath(idi.second); this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi.first, - objFullPath.c_str(), - srcFullPath.c_str()); + objFullPath, srcFullPath); } } @@ -1222,7 +1221,7 @@ void cmMakefileTargetGenerator::MakeEchoProgress( cmLocalUnixMakefileGenerator3::EchoProgress& progress) const { progress.Dir = this->LocalGenerator->GetBinaryDirectory(); - progress.Dir += cmake::GetCMakeFilesDirectory(); + progress.Dir += "/CMakeFiles"; std::ostringstream progressArg; progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")"; progress.Arg = progressArg.str(); @@ -1249,7 +1248,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( *this->BuildFileStream << " " << lineContinue << "\n"; *this->BuildFileStream << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( - obj.c_str(), useWatcomQuote); + obj, useWatcomQuote); } *this->BuildFileStream << "\n"; @@ -1272,7 +1271,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( *this->BuildFileStream << " " << lineContinue << "\n"; *this->BuildFileStream << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( - obj.c_str(), useWatcomQuote); + obj, useWatcomQuote); } *this->BuildFileStream << "\n" << "\n"; diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 4c26c66686..95f5fcbbe9 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -70,7 +70,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args, if (status) { this->Makefile->DisplayStatus(message.c_str(), -1); } else { - cmSystemTools::Message(message.c_str()); + cmSystemTools::Message(message); } } if (fatal) { diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx index 3d788f6927..1d790e2e8f 100644 --- a/Source/cmMessenger.cxx +++ b/Source/cmMessenger.cxx @@ -124,9 +124,9 @@ void displayMessage(MessageType t, std::ostringstream& msg) if (t == MessageType::FATAL_ERROR || t == MessageType::INTERNAL_ERROR || t == MessageType::DEPRECATION_ERROR || t == MessageType::AUTHOR_ERROR) { cmSystemTools::SetErrorOccured(); - cmSystemTools::Message(msg.str().c_str(), "Error"); + cmSystemTools::Message(msg.str(), "Error"); } else { - cmSystemTools::Message(msg.str().c_str(), "Warning"); + cmSystemTools::Message(msg.str(), "Warning"); } } diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx index 12c18eea22..3f6523e09c 100644 --- a/Source/cmNewLineStyle.cxx +++ b/Source/cmNewLineStyle.cxx @@ -4,9 +4,7 @@ #include <stddef.h> -cmNewLineStyle::cmNewLineStyle() -{ -} +cmNewLineStyle::cmNewLineStyle() = default; bool cmNewLineStyle::IsValid() const { diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b62da66ff5..0d05782ce4 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -31,7 +31,6 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" class cmCustomCommand; @@ -377,7 +376,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands()); linkCmds.insert(linkCmds.begin(), "$PRE_LINK"); - linkCmds.push_back("$POST_BUILD"); + linkCmds.emplace_back("$POST_BUILD"); std::string linkCmd = this->GetLocalGenerator()->BuildCommandLine(linkCmds); @@ -405,7 +404,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) std::vector<std::string> commandLines; commandLines.push_back(cmakeCommand + " -E cmake_symlink_executable $in $out"); - commandLines.push_back("$POST_BUILD"); + commandLines.emplace_back("$POST_BUILD"); this->GetGlobalGenerator()->AddRule( "CMAKE_SYMLINK_EXECUTABLE", @@ -423,7 +422,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) std::vector<std::string> commandLines; commandLines.push_back(cmakeCommand + " -E cmake_symlink_library $in $SONAME $out"); - commandLines.push_back("$POST_BUILD"); + commandLines.emplace_back("$POST_BUILD"); this->GetGlobalGenerator()->AddRule( "CMAKE_SYMLINK_LIBRARY", @@ -718,8 +717,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule()); const std::string rspfile = this->ConvertToNinjaPath( - std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + - genTarget.GetName() + ".rsp"); + std::string("CMakeFiles/") + genTarget.GetName() + ".rsp"); // Gather order-only dependencies. cmNinjaDeps orderOnlyDeps; @@ -1004,8 +1002,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } const std::string rspfile = this->ConvertToNinjaPath( - std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + gt.GetName() + - ".rsp"); + std::string("CMakeFiles/") + gt.GetName() + ".rsp"); // Gather order-only dependencies. cmNinjaDeps orderOnlyDeps; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5013be5d46..edb0ef3ae8 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -433,6 +433,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) vars.ObjectFileDir = "$OBJECT_FILE_DIR"; if (lang == "Swift") { vars.SwiftAuxiliarySources = "$SWIFT_AUXILIARY_SOURCES"; + vars.SwiftModuleName = "$SWIFT_MODULE_NAME"; } // For some cases we do an explicit preprocessor invocation. @@ -904,9 +905,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["DEFINES"] = this->ComputeDefines(source, language); vars["INCLUDES"] = this->ComputeIncludes(source, language); - // The swift compiler needs all the sources besides the one being compiled in - // order to do the type checking. List all these "auxiliary" sources. if (language == "Swift") { + // The swift compiler needs all the sources besides the one being compiled + // in order to do the type checking. List all these "auxiliary" sources. std::string aux_sources; cmGeneratorTarget::KindedSources const& sources = this->GeneratorTarget->GetKindedSources(this->GetConfigName()); @@ -917,6 +918,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( aux_sources += " " + this->GetSourceFilePath(src.Source.Value); } vars["SWIFT_AUXILIARY_SOURCES"] = aux_sources; + + if (const char* name = + this->GeneratorTarget->GetProperty("SWIFT_MODULE_NAME")) { + vars["SWIFT_MODULE_NAME"] = name; + } else { + vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName(); + } } if (!this->NeedDepTypeMSVC(language)) { diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index cc6d4b9887..95fcf66f46 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -14,7 +14,6 @@ #include "cmSourceFile.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" #include <algorithm> #include <iterator> @@ -27,15 +26,13 @@ cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator( { } -cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() -{ -} +cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() = default; void cmNinjaUtilityTargetGenerator::Generate() { std::string utilCommandName = this->GetLocalGenerator()->GetCurrentBinaryDirectory(); - utilCommandName += cmake::GetCMakeFilesDirectory(); + utilCommandName += "/CMakeFiles"; utilCommandName += "/"; utilCommandName += this->GetTargetName() + ".util"; utilCommandName = this->ConvertToNinjaPath(utilCommandName); diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 2b9678596a..6857d5a27e 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -10,15 +10,16 @@ #include "cmTarget.h" #include <cassert> +#include <utility> class cmSourceFile; cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target, - const std::string& configName) + std::string configName) : GT(target) , Makefile(target->Target->GetMakefile()) , LocalGenerator(target->GetLocalGenerator()) - , ConfigName(configName) + , ConfigName(std::move(configName)) , MacContentFolders(nullptr) { if (this->MustSkip()) { diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index be7e932f93..3dea6cc8a8 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -17,8 +17,7 @@ class cmSourceFile; class cmOSXBundleGenerator { public: - cmOSXBundleGenerator(cmGeneratorTarget* target, - const std::string& configName); + cmOSXBundleGenerator(cmGeneratorTarget* target, std::string configName); // create an app bundle at a given root, and return // the directory within the bundle that contains the executable @@ -32,7 +31,7 @@ public: struct MacOSXContentGeneratorType { - virtual ~MacOSXContentGeneratorType() {} + virtual ~MacOSXContentGeneratorType() = default; virtual void operator()(cmSourceFile const& source, const char* pkgloc) = 0; }; diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 961e2b240d..2c28fc0b7d 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -48,7 +48,7 @@ public: this->FileName = cmSystemTools::GetFilenameName(file); } } - virtual ~cmOrderDirectoriesConstraint() {} + virtual ~cmOrderDirectoriesConstraint() = default; void AddDirectory() { diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 011c7d896b..7d88b088e8 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -10,7 +10,6 @@ #include <vector> #include "cmState.h" -#include "cmStateDirectory.h" #include "cmSystemTools.h" cmOutputConverter::cmOutputConverter(cmStateSnapshot const& snapshot) @@ -72,17 +71,6 @@ std::string cmOutputConverter::ConvertDirectorySeparatorsForShell( return result; } -std::string cmOutputConverter::ConvertToRelativePath( - std::string const& local_path, std::string const& remote_path) const -{ - if (!this->StateSnapshot.GetDirectory().ContainsBoth(local_path, - remote_path)) { - return remote_path; - } - - return cmSystemTools::ForceToRelativePath(local_path, remote_path); -} - static bool cmOutputConverterIsShellOperator(const std::string& str) { static std::set<std::string> shellOperators; diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 5a4f879813..6438c7bad4 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -91,16 +91,6 @@ public: }; static FortranFormat GetFortranFormat(const char* value); - /** - * Convert the given remote path to a relative path with respect to - * the given local path. Both paths must use forward slashes and not - * already be escaped or quoted. - * The conversion is skipped if the paths are not both in the source - * or both in the binary tree. - */ - std::string ConvertToRelativePath(std::string const& local_path, - std::string const& remote_path) const; - private: cmState* GetState() const; diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index ab1e699d4a..46d04a65f0 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -28,7 +28,7 @@ public: * Construct with dependency generation marked not done; instance * not placed in cmMakefile's list. */ - cmDependInformation() {} + cmDependInformation() = default; /** * The set of files on which this one depends. @@ -194,7 +194,7 @@ protected: message += includeFile; message += " for file "; message += info->FullPath; - cmSystemTools::Error(message.c_str(), nullptr); + cmSystemTools::Error(message); } continue; } diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index a2bf841594..796974cb32 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -151,7 +151,7 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, cmSystemTools::SetFatalErrorOccured(); return true; } - list.push_back(arg); + list.emplace_back(arg); } } diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx index 4793206f95..fb8135101b 100644 --- a/Source/cmPathLabel.cxx +++ b/Source/cmPathLabel.cxx @@ -2,8 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPathLabel.h" -cmPathLabel::cmPathLabel(const std::string& label) - : Label(label) +#include <utility> + +cmPathLabel::cmPathLabel(std::string label) + : Label(std::move(label)) , Hash(0) { // Use a Jenkins one-at-a-time hash with under/over-flow protection diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h index 97551fb463..55dffabe03 100644 --- a/Source/cmPathLabel.h +++ b/Source/cmPathLabel.h @@ -17,7 +17,7 @@ class cmPathLabel { public: - cmPathLabel(const std::string& label); + cmPathLabel(std::string label); // The comparison operators are only for quick sorting and searching and // in no way imply any lexicographical order of the label diff --git a/Source/cmPipeConnection.cxx b/Source/cmPipeConnection.cxx index 999d6f3c70..1eede13e01 100644 --- a/Source/cmPipeConnection.cxx +++ b/Source/cmPipeConnection.cxx @@ -6,10 +6,10 @@ #include "cmServer.h" -cmPipeConnection::cmPipeConnection(const std::string& name, +cmPipeConnection::cmPipeConnection(std::string name, cmConnectionBufferStrategy* bufferStrategy) : cmEventBasedConnection(bufferStrategy) - , PipeName(name) + , PipeName(std::move(name)) { } diff --git a/Source/cmPipeConnection.h b/Source/cmPipeConnection.h index 49f9fdf8ad..e67f15c57e 100644 --- a/Source/cmPipeConnection.h +++ b/Source/cmPipeConnection.h @@ -13,7 +13,7 @@ class cmPipeConnection : public cmEventBasedConnection { public: - cmPipeConnection(const std::string& name, + cmPipeConnection(std::string name, cmConnectionBufferStrategy* bufferStrategy = nullptr); bool OnServeStart(std::string* pString) override; diff --git a/Source/cmProcessOutput.cxx b/Source/cmProcessOutput.cxx index e4ca426cc8..e80ea5c8d6 100644 --- a/Source/cmProcessOutput.cxx +++ b/Source/cmProcessOutput.cxx @@ -48,9 +48,7 @@ cmProcessOutput::cmProcessOutput(Encoding encoding, unsigned int maxSize) #endif } -cmProcessOutput::~cmProcessOutput() -{ -} +cmProcessOutput::~cmProcessOutput() = default; bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded, size_t id) diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index facde5d22e..a2bc16ffb1 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -16,7 +16,7 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, cmProcessOutput processOutput(encoding); std::string strdata; while ((out || err) && - (p = cmsysProcess_WaitForData(cp, &data, &length, nullptr), p)) { + (p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) { if (out && p == cmsysProcess_Pipe_STDOUT) { processOutput.DecodeText(data, length, strdata, 1); if (!out->Process(strdata.c_str(), int(strdata.size()))) { diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h index da3693d1a7..76163167a6 100644 --- a/Source/cmProcessTools.h +++ b/Source/cmProcessTools.h @@ -34,7 +34,7 @@ public: return this->Process(data, static_cast<int>(strlen(data))); } - virtual ~OutputParser() {} + virtual ~OutputParser() = default; protected: /** Implement in a subclass to process a chunk of data. It should diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 14e92c690a..2fe9fe8b93 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -198,7 +198,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, return true; } if (haveLanguages && languages.empty()) { - languages.push_back("NONE"); + languages.emplace_back("NONE"); } cmPolicies::PolicyStatus cmp0048 = @@ -264,22 +264,22 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, } else if (cmp0048 != cmPolicies::OLD) { // Set project VERSION variables to empty std::vector<std::string> vv; - vv.push_back("PROJECT_VERSION"); - vv.push_back("PROJECT_VERSION_MAJOR"); - vv.push_back("PROJECT_VERSION_MINOR"); - vv.push_back("PROJECT_VERSION_PATCH"); - vv.push_back("PROJECT_VERSION_TWEAK"); + vv.emplace_back("PROJECT_VERSION"); + vv.emplace_back("PROJECT_VERSION_MAJOR"); + vv.emplace_back("PROJECT_VERSION_MINOR"); + vv.emplace_back("PROJECT_VERSION_PATCH"); + vv.emplace_back("PROJECT_VERSION_TWEAK"); vv.push_back(projectName + "_VERSION"); vv.push_back(projectName + "_VERSION_MAJOR"); vv.push_back(projectName + "_VERSION_MINOR"); vv.push_back(projectName + "_VERSION_PATCH"); vv.push_back(projectName + "_VERSION_TWEAK"); if (this->Makefile->IsRootMakefile()) { - vv.push_back("CMAKE_PROJECT_VERSION"); - vv.push_back("CMAKE_PROJECT_VERSION_MAJOR"); - vv.push_back("CMAKE_PROJECT_VERSION_MINOR"); - vv.push_back("CMAKE_PROJECT_VERSION_PATCH"); - vv.push_back("CMAKE_PROJECT_VERSION_TWEAK"); + vv.emplace_back("CMAKE_PROJECT_VERSION"); + vv.emplace_back("CMAKE_PROJECT_VERSION_MAJOR"); + vv.emplace_back("CMAKE_PROJECT_VERSION_MINOR"); + vv.emplace_back("CMAKE_PROJECT_VERSION_PATCH"); + vv.emplace_back("CMAKE_PROJECT_VERSION_TWEAK"); } std::string vw; for (std::string const& i : vv) { @@ -315,8 +315,8 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, if (languages.empty()) { // if no language is specified do c and c++ - languages.push_back("C"); - languages.push_back("CXX"); + languages.emplace_back("C"); + languages.emplace_back("CXX"); } this->Makefile->EnableLanguage(languages, false); std::string extraInclude = "CMAKE_PROJECT_" + projectName + "_INCLUDE"; diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index 431c5bc21a..95a297c4a1 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -129,9 +129,7 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( } } -cmQtAutoGenGlobalInitializer::~cmQtAutoGenGlobalInitializer() -{ -} +cmQtAutoGenGlobalInitializer::~cmQtAutoGenGlobalInitializer() = default; void cmQtAutoGenGlobalInitializer::GetOrCreateGlobalTarget( cmLocalGenerator* localGen, std::string const& name, diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 9fa8a89a4f..1d7f6d1f19 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -26,7 +26,6 @@ #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include "cmake.h" #include "cmsys/FStream.hxx" #include "cmsys/SystemInformation.hxx" @@ -111,7 +110,7 @@ static bool AddToSourceGroup(cmMakefile* makefile, std::string const& fileName, ost << ": " << property; ost << ": Could not find or create the source group "; ost << cmQtAutoGen::Quoted(groupName); - cmSystemTools::Error(ost.str().c_str()); + cmSystemTools::Error(ost.str()); return false; } } @@ -352,7 +351,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Info directory this->Dir.Info = cbd; - this->Dir.Info += cmake::GetCMakeFilesDirectory(); + this->Dir.Info += "/CMakeFiles"; this->Dir.Info += '/'; this->Dir.Info += this->Target->GetName(); this->Dir.Info += "_autogen"; @@ -521,19 +520,16 @@ bool cmQtAutoGenInitializer::InitMoc() // Moc includes { - // We need to disable this until we have all implicit includes available. - // See issue #18669. - // bool const appendImplicit = (this->QtVersion.Major >= 5); - + bool const appendImplicit = (this->QtVersion.Major >= 5); auto GetIncludeDirs = - [this, localGen](std::string const& cfg) -> std::vector<std::string> { - bool const appendImplicit = false; + [this, localGen, + appendImplicit](std::string const& cfg) -> std::vector<std::string> { // Get the include dirs for this target, without stripping the implicit // include dirs off, see // https://gitlab.kitware.com/cmake/cmake/issues/13667 std::vector<std::string> dirs; - localGen->GetIncludeDirectories(dirs, this->Target, "CXX", cfg, false, - appendImplicit); + localGen->GetIncludeDirectoriesImplicit(dirs, this->Target, "CXX", cfg, + false, appendImplicit); return dirs; }; @@ -941,7 +937,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() if (!qrc.Generated) { std::string error; if (!RccListInputs(qrc.QrcFile, qrc.Resources, error)) { - cmSystemTools::Error(error.c_str()); + cmSystemTools::Error(error); return false; } } @@ -963,7 +959,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // Files provided by the autogen target std::vector<std::string> autogenProvides; if (this->Moc.Enabled) { - this->AddGeneratedSource(this->Moc.MocsCompilation, GeneratorT::MOC); + this->AddGeneratedSource(this->Moc.MocsCompilation, GeneratorT::MOC, true); autogenProvides.push_back(this->Moc.MocsCompilation); } @@ -1219,7 +1215,7 @@ bool cmQtAutoGenInitializer::SetupCustomTargets() if (!cmSystemTools::MakeDirectory(this->Dir.Info)) { std::string emsg = ("AutoGen: Could not create directory: "); emsg += Quoted(this->Dir.Info); - cmSystemTools::Error(emsg.c_str()); + cmSystemTools::Error(emsg); return false; } @@ -1307,7 +1303,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() } else { std::string err = "AutoGen: Could not write file "; err += this->AutogenTarget.InfoFile; - cmSystemTools::Error(err.c_str()); + cmSystemTools::Error(err); return false; } @@ -1347,7 +1343,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() } else { std::string err = "AutoRcc: Could not write file "; err += qrc.InfoFile; - cmSystemTools::Error(err.c_str()); + cmSystemTools::Error(err); return false; } } @@ -1356,7 +1352,8 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() } void cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename, - GeneratorT genType) + GeneratorT genType, + bool prepend) { // Register source file in makefile cmMakefile* makefile = this->Target->Target->GetMakefile(); @@ -1370,7 +1367,7 @@ void cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename, AddToSourceGroup(makefile, filename, genType); // Add source file to target - this->Target->AddSource(filename); + this->Target->AddSource(filename, prepend); } static unsigned int CharPtrToInt(const char* const input) @@ -1482,7 +1479,7 @@ std::pair<bool, std::string> GetQtExecutable( if (cmSystemTools::FileExists(result, true)) { std::vector<std::string> command; command.push_back(result); - command.push_back("-h"); + command.emplace_back("-h"); std::string stdOut; std::string stdErr; int retVal = 0; @@ -1511,7 +1508,7 @@ std::pair<bool, std::string> GetQtExecutable( msg += target->GetName(); msg += "): "; msg += err; - cmSystemTools::Error(msg.c_str()); + cmSystemTools::Error(msg); return std::make_pair(false, ""); } @@ -1546,9 +1543,9 @@ bool cmQtAutoGenInitializer::GetRccExecutable() if (this->QtVersion.Major == 5 || this->QtVersion.Major == 6) { if (stdOut.find("--list") != std::string::npos) { - this->Rcc.ListOptions.push_back("--list"); + this->Rcc.ListOptions.emplace_back("--list"); } else { - this->Rcc.ListOptions.push_back("-list"); + this->Rcc.ListOptions.emplace_back("-list"); } } return true; diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 47f157c305..10f0bf316d 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -26,9 +26,6 @@ public: class Qrc { public: - Qrc() {} - - public: std::string LockFile; std::string QrcFile; std::string QrcName; @@ -102,7 +99,8 @@ private: bool SetupWriteAutogenInfo(); bool SetupWriteRccInfo(); - void AddGeneratedSource(std::string const& filename, GeneratorT genType); + void AddGeneratedSource(std::string const& filename, GeneratorT genType, + bool prepend = false); bool GetMocExecutable(); bool GetUicExecutable(); diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index c5d5d7c2fd..e2d7debed6 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -54,7 +54,7 @@ void cmQtAutoGenerator::Logger::Info(GeneratorT genType, } { std::lock_guard<std::mutex> lock(Mutex_); - cmSystemTools::Stdout(msg.c_str(), msg.size()); + cmSystemTools::Stdout(msg); } } @@ -78,7 +78,7 @@ void cmQtAutoGenerator::Logger::Warning(GeneratorT genType, msg.push_back('\n'); { std::lock_guard<std::mutex> lock(Mutex_); - cmSystemTools::Stdout(msg.c_str(), msg.size()); + cmSystemTools::Stdout(msg); } } @@ -107,7 +107,7 @@ void cmQtAutoGenerator::Logger::Error(GeneratorT genType, msg.push_back('\n'); { std::lock_guard<std::mutex> lock(Mutex_); - cmSystemTools::Stderr(msg.c_str(), msg.size()); + cmSystemTools::Stderr(msg); } } @@ -149,7 +149,7 @@ void cmQtAutoGenerator::Logger::ErrorCommand( msg.push_back('\n'); { std::lock_guard<std::mutex> lock(Mutex_); - cmSystemTools::Stderr(msg.c_str(), msg.size()); + cmSystemTools::Stderr(msg); } } diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 75143f5a64..2b9cbc6edc 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -206,9 +206,6 @@ public: bool MergedOutput = false; }; - // -- Constructor - ReadOnlyProcessT() = default; - // -- Const accessors const SetupT& Setup() const { return Setup_; } ProcessResultT* Result() const { return Setup_.Result; } diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 9658e972e4..bc496ac9c2 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -844,10 +844,10 @@ void cmQtAutoGeneratorMocUic::JobMocT::GenerateMoc(WorkerT& wrk) wrk.Moc().AllOptions.end()); // Add predefs include if (!wrk.Moc().PredefsFileAbs.empty()) { - cmd.push_back("--include"); + cmd.emplace_back("--include"); cmd.push_back(wrk.Moc().PredefsFileAbs); } - cmd.push_back("-o"); + cmd.emplace_back("-o"); cmd.push_back(BuildFile); cmd.push_back(SourceFile); @@ -963,7 +963,7 @@ void cmQtAutoGeneratorMocUic::JobUicT::GenerateUic(WorkerT& wrk) } cmd.insert(cmd.end(), allOpts.begin(), allOpts.end()); } - cmd.push_back("-o"); + cmd.emplace_back("-o"); cmd.push_back(BuildFile); cmd.push_back(SourceFile); @@ -1144,9 +1144,7 @@ cmQtAutoGeneratorMocUic::cmQtAutoGeneratorMocUic() UVRequest().init(*UVLoop(), &cmQtAutoGeneratorMocUic::UVPollStage, this); } -cmQtAutoGeneratorMocUic::~cmQtAutoGeneratorMocUic() -{ -} +cmQtAutoGeneratorMocUic::~cmQtAutoGeneratorMocUic() = default; bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) { @@ -1213,7 +1211,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) }; // -- Read info file - if (!makefile->ReadListFile(InfoFile().c_str())) { + if (!makefile->ReadListFile(InfoFile())) { Log().ErrorFile(GeneratorT::GEN, InfoFile(), "File processing failed"); return false; } @@ -1288,7 +1286,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) std::string& error) { if (!key.empty()) { if (!exp.empty()) { - Moc_.DependFilters.push_back(KeyExpT()); + Moc_.DependFilters.emplace_back(); KeyExpT& filter(Moc_.DependFilters.back()); if (filter.Exp.compile(exp)) { filter.Key = key; @@ -1506,7 +1504,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) } // Append framework includes for (std::string const& path : frameworkPaths) { - Moc_.Includes.push_back("-F"); + Moc_.Includes.emplace_back("-F"); Moc_.Includes.push_back(path); } } diff --git a/Source/cmQtAutoGeneratorMocUic.h b/Source/cmQtAutoGeneratorMocUic.h index 9ec1def350..0df2cffebd 100644 --- a/Source/cmQtAutoGeneratorMocUic.h +++ b/Source/cmQtAutoGeneratorMocUic.h @@ -49,8 +49,8 @@ public: { } - KeyExpT(std::string const& key, std::string const& exp) - : Key(key) + KeyExpT(std::string key, std::string const& exp) + : Key(std::move(key)) , Exp(exp) { } @@ -240,10 +240,10 @@ public: class JobMocT : public JobT { public: - JobMocT(std::string&& sourceFile, std::string const& includerFile, + JobMocT(std::string&& sourceFile, std::string includerFile, std::string&& includeString) : SourceFile(std::move(sourceFile)) - , IncluderFile(includerFile) + , IncluderFile(std::move(includerFile)) , IncludeString(std::move(includeString)) { } @@ -269,10 +269,10 @@ public: class JobUicT : public JobT { public: - JobUicT(std::string&& sourceFile, std::string const& includerFile, + JobUicT(std::string&& sourceFile, std::string includerFile, std::string&& includeString) : SourceFile(std::move(sourceFile)) - , IncluderFile(includerFile) + , IncluderFile(std::move(includerFile)) , IncludeString(std::move(includeString)) { } diff --git a/Source/cmQtAutoGeneratorRcc.cxx b/Source/cmQtAutoGeneratorRcc.cxx index 29dc7a0883..43ff17290d 100644 --- a/Source/cmQtAutoGeneratorRcc.cxx +++ b/Source/cmQtAutoGeneratorRcc.cxx @@ -20,9 +20,7 @@ cmQtAutoGeneratorRcc::cmQtAutoGeneratorRcc() UVRequest().init(*UVLoop(), &cmQtAutoGeneratorRcc::UVPollStage, this); } -cmQtAutoGeneratorRcc::~cmQtAutoGeneratorRcc() -{ -} +cmQtAutoGeneratorRcc::~cmQtAutoGeneratorRcc() = default; bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile) { @@ -58,7 +56,7 @@ bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile) }; // -- Read info file - if (!makefile->ReadListFile(InfoFile().c_str())) { + if (!makefile->ReadListFile(InfoFile())) { Log().ErrorFile(GeneratorT::RCC, InfoFile(), "File processing failed"); return false; } @@ -603,7 +601,7 @@ bool cmQtAutoGeneratorRcc::GenerateRcc() std::vector<std::string> cmd; cmd.push_back(RccExecutable_); cmd.insert(cmd.end(), Options_.begin(), Options_.end()); - cmd.push_back("-o"); + cmd.emplace_back("-o"); cmd.push_back(RccFileOutput_); cmd.push_back(QrcFile_); // We're done here if the process fails to start diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index f0f92aabfc..55204d708e 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -13,9 +13,9 @@ #include <stddef.h> #include <utility> -cmRST::cmRST(std::ostream& os, std::string const& docroot) +cmRST::cmRST(std::ostream& os, std::string docroot) : OS(os) - , DocRoot(docroot) + , DocRoot(std::move(docroot)) , IncludeDepth(0) , OutputLinePending(false) , LastLineEndedInColonColon(false) @@ -178,7 +178,7 @@ void cmRST::ProcessLine(std::string const& line) // Record the literal lines to output after whole block. // Ignore the language spec and record the opening line as blank. this->Directive = DirectiveCodeBlock; - this->MarkupLines.push_back(""); + this->MarkupLines.emplace_back(); } else if (this->ReplaceDirective.find(line)) { // Record the replace directive content. this->Directive = DirectiveReplace; @@ -221,7 +221,7 @@ void cmRST::ProcessLine(std::string const& line) // Record the literal lines to output after whole block. this->Markup = MarkupNormal; this->Directive = DirectiveLiteralBlock; - this->MarkupLines.push_back(""); + this->MarkupLines.emplace_back(); this->OutputLine("", false); } // Print non-markup lines. diff --git a/Source/cmRST.h b/Source/cmRST.h index ee478677d6..d8d2a0bab5 100644 --- a/Source/cmRST.h +++ b/Source/cmRST.h @@ -25,7 +25,7 @@ class cmRST { public: - cmRST(std::ostream& os, std::string const& docroot); + cmRST(std::ostream& os, std::string docroot); bool ProcessFile(std::string const& fname, bool isModule = false); private: diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 4b74ff0175..e347a2cf5e 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -10,13 +10,13 @@ #include "cmSystemTools.h" cmRulePlaceholderExpander::cmRulePlaceholderExpander( - std::map<std::string, std::string> const& compilers, - std::map<std::string, std::string> const& variableMappings, - std::string const& compilerSysroot, std::string const& linkerSysroot) - : Compilers(compilers) - , VariableMappings(variableMappings) - , CompilerSysroot(compilerSysroot) - , LinkerSysroot(linkerSysroot) + std::map<std::string, std::string> compilers, + std::map<std::string, std::string> variableMappings, + std::string compilerSysroot, std::string linkerSysroot) + : Compilers(std::move(compilers)) + , VariableMappings(std::move(variableMappings)) + , CompilerSysroot(std::move(compilerSysroot)) + , LinkerSysroot(std::move(linkerSysroot)) { } @@ -167,6 +167,11 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( return replaceValues.SwiftAuxiliarySources; } } + if (replaceValues.SwiftModuleName) { + if (variable == "SWIFT_MODULE_NAME") { + return replaceValues.SwiftModuleName; + } + } if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" || variable == "TARGET_INSTALLNAME_DIR") { // All these variables depend on TargetSOName diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h index a936747e2a..5c0363729a 100644 --- a/Source/cmRulePlaceholderExpander.h +++ b/Source/cmRulePlaceholderExpander.h @@ -15,9 +15,9 @@ class cmRulePlaceholderExpander { public: cmRulePlaceholderExpander( - std::map<std::string, std::string> const& compilers, - std::map<std::string, std::string> const& variableMappings, - std::string const& compilerSysroot, std::string const& linkerSysroot); + std::map<std::string, std::string> compilers, + std::map<std::string, std::string> variableMappings, + std::string compilerSysroot, std::string linkerSysroot); void SetTargetImpLib(std::string const& targetImpLib) { @@ -59,6 +59,7 @@ public: const char* DependencyFile; const char* FilterPrefix; const char* SwiftAuxiliarySources; + const char* SwiftModuleName; }; // Expand rule variables in CMake of the type found in language rules diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 2cae714369..9182b4165c 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -4,20 +4,19 @@ #include "cmSystemTools.h" -cmScriptGenerator::cmScriptGenerator( - const std::string& config_var, - std::vector<std::string> const& configurations) - : RuntimeConfigVariable(config_var) - , Configurations(configurations) +#include <utility> + +cmScriptGenerator::cmScriptGenerator(std::string config_var, + std::vector<std::string> configurations) + : RuntimeConfigVariable(std::move(config_var)) + , Configurations(std::move(configurations)) , ConfigurationName("") , ConfigurationTypes(nullptr) , ActionsPerConfig(false) { } -cmScriptGenerator::~cmScriptGenerator() -{ -} +cmScriptGenerator::~cmScriptGenerator() = default; void cmScriptGenerator::Generate( std::ostream& os, const std::string& config, diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index 0bb388e635..5792ba82a5 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -12,7 +12,7 @@ class cmScriptGeneratorIndent { public: - cmScriptGeneratorIndent() {} + cmScriptGeneratorIndent() = default; cmScriptGeneratorIndent(int level) : Level(level) { @@ -47,8 +47,8 @@ class cmScriptGenerator CM_DISABLE_COPY(cmScriptGenerator) public: - cmScriptGenerator(const std::string& config_var, - std::vector<std::string> const& configurations); + cmScriptGenerator(std::string config_var, + std::vector<std::string> configurations); virtual ~cmScriptGenerator(); void Generate(std::ostream& os, const std::string& config, diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 5dd4413c44..0f51e0eb6f 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -16,9 +16,7 @@ cmSearchPath::cmSearchPath(cmFindCommon* findCmd) { } -cmSearchPath::~cmSearchPath() -{ -} +cmSearchPath::~cmSearchPath() = default; void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore, std::vector<std::string>& outPaths, diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index f7d38799fa..e740c0519b 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -96,11 +96,16 @@ void cmServer::ProcessRequest(cmConnection* connection, return; } - cmSystemTools::SetMessageCallback(reportMessage, - const_cast<cmServerRequest*>(&request)); + cmSystemTools::SetMessageCallback( + [&request](const char* msg, const char* title) { + reportMessage(msg, title, request); + }); + if (this->Protocol) { this->Protocol->CMakeInstance()->SetProgressCallback( - reportProgress, const_cast<cmServerRequest*>(&request)); + [&request](const char* msg, float prog) { + reportProgress(msg, prog, request); + }); this->WriteResponse(connection, this->Protocol->Process(request), debug.get()); } else { @@ -150,28 +155,25 @@ void cmServer::PrintHello(cmConnection* connection) const this->WriteJsonObject(connection, hello, nullptr); } -void cmServer::reportProgress(const char* msg, float progress, void* data) +void cmServer::reportProgress(const char* msg, float progress, + const cmServerRequest& request) { - const cmServerRequest* request = static_cast<const cmServerRequest*>(data); - assert(request); if (progress < 0.0f || progress > 1.0f) { - request->ReportMessage(msg, ""); + request.ReportMessage(msg, ""); } else { - request->ReportProgress(0, static_cast<int>(progress * 1000), 1000, msg); + request.ReportProgress(0, static_cast<int>(progress * 1000), 1000, msg); } } void cmServer::reportMessage(const char* msg, const char* title, - bool& /* cancel */, void* data) + const cmServerRequest& request) { - const cmServerRequest* request = static_cast<const cmServerRequest*>(data); - assert(request); assert(msg); std::string titleString; if (title) { titleString = title; } - request->ReportMessage(std::string(msg), titleString); + request.ReportMessage(std::string(msg), titleString); } cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request) diff --git a/Source/cmServer.h b/Source/cmServer.h index ca37ce276d..bedf97ffdb 100644 --- a/Source/cmServer.h +++ b/Source/cmServer.h @@ -118,9 +118,10 @@ public: void OnConnected(cmConnection* connection) override; private: - static void reportProgress(const char* msg, float progress, void* data); - static void reportMessage(const char* msg, const char* title, bool& cancel, - void* data); + static void reportProgress(const char* msg, float progress, + const cmServerRequest& request); + static void reportMessage(const char* msg, const char* title, + const cmServerRequest& request); // Handle requests: cmServerResponse SetProtocolVersion(const cmServerRequest& request); diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx index 5caa019228..844a85890f 100644 --- a/Source/cmServerConnection.cxx +++ b/Source/cmServerConnection.cxx @@ -119,9 +119,7 @@ cmServerStdIoConnection::cmServerStdIoConnection() { } -cmConnectionBufferStrategy::~cmConnectionBufferStrategy() -{ -} +cmConnectionBufferStrategy::~cmConnectionBufferStrategy() = default; void cmConnectionBufferStrategy::clear() { diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 11a3f46e03..c3c81564ee 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -20,6 +20,7 @@ #include <functional> #include <memory> #include <string> +#include <utility> #include <vector> // Get rid of some windows macros: @@ -39,11 +40,10 @@ std::vector<std::string> toStringList(const Json::Value& in) } // namespace cmServerRequest::cmServerRequest(cmServer* server, cmConnection* connection, - const std::string& t, const std::string& c, - const Json::Value& d) - : Type(t) - , Cookie(c) - , Data(d) + std::string t, std::string c, Json::Value d) + : Type(std::move(t)) + , Cookie(std::move(c)) + , Data(std::move(d)) , Connection(connection) , m_Server(server) { @@ -707,15 +707,15 @@ cmServerResponse cmServerProtocol1::ProcessCTests( } cmServerProtocol1::GeneratorInformation::GeneratorInformation( - const std::string& generatorName, const std::string& extraGeneratorName, - const std::string& toolset, const std::string& platform, - const std::string& sourceDirectory, const std::string& buildDirectory) - : GeneratorName(generatorName) - , ExtraGeneratorName(extraGeneratorName) - , Toolset(toolset) - , Platform(platform) - , SourceDirectory(sourceDirectory) - , BuildDirectory(buildDirectory) + std::string generatorName, std::string extraGeneratorName, + std::string toolset, std::string platform, std::string sourceDirectory, + std::string buildDirectory) + : GeneratorName(std::move(generatorName)) + , ExtraGeneratorName(std::move(extraGeneratorName)) + , Toolset(std::move(toolset)) + , Platform(std::move(platform)) + , SourceDirectory(std::move(sourceDirectory)) + , BuildDirectory(std::move(buildDirectory)) { } diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h index df71cffc70..2d1507b43c 100644 --- a/Source/cmServerProtocol.h +++ b/Source/cmServerProtocol.h @@ -56,9 +56,8 @@ public: cmConnection* Connection; private: - cmServerRequest(cmServer* server, cmConnection* connection, - const std::string& t, const std::string& c, - const Json::Value& d); + cmServerRequest(cmServer* server, cmConnection* connection, std::string t, + std::string c, Json::Value d); void ReportProgress(int min, int current, int max, const std::string& message) const; @@ -140,12 +139,10 @@ private: { public: GeneratorInformation() = default; - GeneratorInformation(const std::string& generatorName, - const std::string& extraGeneratorName, - const std::string& toolset, - const std::string& platform, - const std::string& sourceDirectory, - const std::string& buildDirectory); + GeneratorInformation(std::string generatorName, + std::string extraGeneratorName, std::string toolset, + std::string platform, std::string sourceDirectory, + std::string buildDirectory); void SetupGenerator(cmake* cm, std::string* errorMessage); diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 8445b027ab..9388e7ccf7 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.cxx +++ b/Source/cmSetSourceFilesPropertiesCommand.cxx @@ -53,17 +53,17 @@ bool cmSetSourceFilesPropertiesCommand::RunCommand( for (j = propbeg; j != propend; ++j) { // old style allows for specifier before PROPERTIES keyword if (*j == "ABSTRACT") { - propertyPairs.push_back("ABSTRACT"); - propertyPairs.push_back("1"); + propertyPairs.emplace_back("ABSTRACT"); + propertyPairs.emplace_back("1"); } else if (*j == "WRAP_EXCLUDE") { - propertyPairs.push_back("WRAP_EXCLUDE"); - propertyPairs.push_back("1"); + propertyPairs.emplace_back("WRAP_EXCLUDE"); + propertyPairs.emplace_back("1"); } else if (*j == "GENERATED") { generated = true; - propertyPairs.push_back("GENERATED"); - propertyPairs.push_back("1"); + propertyPairs.emplace_back("GENERATED"); + propertyPairs.emplace_back("1"); } else if (*j == "COMPILE_FLAGS") { - propertyPairs.push_back("COMPILE_FLAGS"); + propertyPairs.emplace_back("COMPILE_FLAGS"); ++j; if (j == propend) { errors = "called with incorrect number of arguments " @@ -72,7 +72,7 @@ bool cmSetSourceFilesPropertiesCommand::RunCommand( } propertyPairs.push_back(*j); } else if (*j == "OBJECT_DEPENDS") { - propertyPairs.push_back("OBJECT_DEPENDS"); + propertyPairs.emplace_back("OBJECT_DEPENDS"); ++j; if (j == propend) { errors = "called with incorrect number of arguments " diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 7f33b7a330..01758ee3a0 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -19,12 +19,12 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args, return false; } std::vector<std::string> paths; - paths.push_back("/usr/bsd"); - paths.push_back("/usr/sbin"); - paths.push_back("/usr/bin"); - paths.push_back("/bin"); - paths.push_back("/sbin"); - paths.push_back("/usr/local/bin"); + paths.emplace_back("/usr/bsd"); + paths.emplace_back("/usr/sbin"); + paths.emplace_back("/usr/bin"); + paths.emplace_back("/bin"); + paths.emplace_back("/sbin"); + paths.emplace_back("/usr/local/bin"); const char* cacheValue = this->Makefile->GetDefinition(args[0]); if (cacheValue) { diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 3dab63894b..13d2d7ecfb 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -11,9 +11,7 @@ #include <assert.h> -cmSourceFileLocation::cmSourceFileLocation() -{ -} +cmSourceFileLocation::cmSourceFileLocation() = default; cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc) : Makefile(loc.Makefile) diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 12ef62bc28..7e1e836a0b 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -2,15 +2,17 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSourceGroup.h" +#include <utility> + class cmSourceGroupInternals { public: std::vector<cmSourceGroup> GroupChildren; }; -cmSourceGroup::cmSourceGroup(const std::string& name, const char* regex, +cmSourceGroup::cmSourceGroup(std::string name, const char* regex, const char* parentName) - : Name(name) + : Name(std::move(name)) { this->Internal = new cmSourceGroupInternals; this->SetGroupRegex(regex); diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index b39f8ddb13..7c65494463 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -26,7 +26,7 @@ class cmSourceGroupInternals; class cmSourceGroup { public: - cmSourceGroup(const std::string& name, const char* regex, + cmSourceGroup(std::string name, const char* regex, const char* parentName = nullptr); cmSourceGroup(cmSourceGroup const& r); ~cmSourceGroup(); diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 08f4d1ab07..34ded38906 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -105,7 +105,7 @@ bool addFilesToItsSourceGroups(const std::string& root, tokenizedPath.pop_back(); if (tokenizedPath.empty()) { - tokenizedPath.push_back(""); + tokenizedPath.emplace_back(); } sg = makefile.GetOrCreateSourceGroup(tokenizedPath); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index cf170b08a2..fdd7b3d509 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -545,10 +545,10 @@ const char* cmState::GetGlobalProperty(const std::string& prop) } #define STRING_LIST_ELEMENT(F) ";" #F if (prop == "CMAKE_C_KNOWN_FEATURES") { - return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1; + return &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1]; } if (prop == "CMAKE_CXX_KNOWN_FEATURES") { - return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; + return &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1]; } #undef STRING_LIST_ELEMENT return this->GlobalProperties.GetPropertyValue(prop); @@ -596,6 +596,16 @@ bool cmState::UseWindowsVSIDE() const return this->WindowsVSIDE; } +void cmState::SetGhsMultiIDE(bool ghsMultiIDE) +{ + this->GhsMultiIDE = ghsMultiIDE; +} + +bool cmState::UseGhsMultiIDE() const +{ + return this->GhsMultiIDE; +} + void cmState::SetWatcomWMake(bool watcomWMake) { this->WatcomWMake = watcomWMake; diff --git a/Source/cmState.h b/Source/cmState.h index dfd6d2ca68..e4474857b5 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -164,6 +164,8 @@ public: bool UseWindowsShell() const; void SetWindowsVSIDE(bool windowsVSIDE); bool UseWindowsVSIDE() const; + void SetGhsMultiIDE(bool ghsMultiIDE); + bool UseGhsMultiIDE() const; void SetWatcomWMake(bool watcomWMake); bool UseWatcomWMake() const; void SetMinGWMake(bool minGWMake); @@ -222,6 +224,7 @@ private: bool IsGeneratorMultiConfig = false; bool WindowsShell = false; bool WindowsVSIDE = false; + bool GhsMultiIDE = false; bool WatcomWMake = false; bool MinGWMake = false; bool NMake = false; diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 40f694c0d9..6752743a1f 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -155,6 +155,15 @@ bool cmStateDirectory::ContainsBoth(std::string const& local_path, return bothInBinary || bothInSource; } +std::string cmStateDirectory::ConvertToRelPathIfNotContained( + std::string const& local_path, std::string const& remote_path) const +{ + if (!this->ContainsBoth(local_path, remote_path)) { + return remote_path; + } + return cmSystemTools::ForceToRelativePath(local_path, remote_path); +} + cmStateDirectory::cmStateDirectory( cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator iter, const cmStateSnapshot& snapshot) diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h index c4b18adf16..69565940d6 100644 --- a/Source/cmStateDirectory.h +++ b/Source/cmStateDirectory.h @@ -35,6 +35,9 @@ public: bool ContainsBoth(std::string const& local_path, std::string const& remote_path) const; + std::string ConvertToRelPathIfNotContained( + std::string const& local_path, std::string const& remote_path) const; + cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesEntryBacktraces() const; void AppendIncludeDirectoriesEntry(std::string const& vec, diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index a4305e67dc..63bec710bd 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -16,7 +16,6 @@ #include "cmStateDirectory.h" #include "cmStatePrivate.h" #include "cmVersion.h" -#include "cmake.h" #if !defined(_WIN32) # include <sys/utsname.h> @@ -348,8 +347,7 @@ void cmStateSnapshot::SetDefaultDefinitions() std::to_string(cmVersion::GetTweakVersion())); this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion()); - this->SetDefinition("CMAKE_FILES_DIRECTORY", - cmake::GetCMakeFilesDirectory()); + this->SetDefinition("CMAKE_FILES_DIRECTORY", "/CMakeFiles"); // Setup the default include file regular expression (match everything). this->Position->BuildSystemDirectory->Properties.SetProperty( diff --git a/Source/cmStringReplaceHelper.cxx b/Source/cmStringReplaceHelper.cxx index 69b7cedd69..4a6298782d 100644 --- a/Source/cmStringReplaceHelper.cxx +++ b/Source/cmStringReplaceHelper.cxx @@ -5,13 +5,14 @@ #include "cmMakefile.h" #include <sstream> +#include <utility> cmStringReplaceHelper::cmStringReplaceHelper(const std::string& regex, - const std::string& replace_expr, + std::string replace_expr, cmMakefile* makefile) : RegExString(regex) , RegularExpression(regex) - , ReplaceExpression(replace_expr) + , ReplaceExpression(std::move(replace_expr)) , Makefile(makefile) { this->ParseReplaceExpression(); @@ -85,10 +86,12 @@ void cmStringReplaceHelper::ParseReplaceExpression() auto r = this->ReplaceExpression.find('\\', l); if (r == std::string::npos) { r = this->ReplaceExpression.length(); - this->Replacements.push_back(this->ReplaceExpression.substr(l, r - l)); + this->Replacements.emplace_back( + this->ReplaceExpression.substr(l, r - l)); } else { if (r - l > 0) { - this->Replacements.push_back(this->ReplaceExpression.substr(l, r - l)); + this->Replacements.emplace_back( + this->ReplaceExpression.substr(l, r - l)); } if (r == (this->ReplaceExpression.length() - 1)) { this->ValidReplaceExpression = false; @@ -97,11 +100,11 @@ void cmStringReplaceHelper::ParseReplaceExpression() } if ((this->ReplaceExpression[r + 1] >= '0') && (this->ReplaceExpression[r + 1] <= '9')) { - this->Replacements.push_back(this->ReplaceExpression[r + 1] - '0'); + this->Replacements.emplace_back(this->ReplaceExpression[r + 1] - '0'); } else if (this->ReplaceExpression[r + 1] == 'n') { - this->Replacements.push_back("\n"); + this->Replacements.emplace_back("\n"); } else if (this->ReplaceExpression[r + 1] == '\\') { - this->Replacements.push_back("\\"); + this->Replacements.emplace_back("\\"); } else { this->ValidReplaceExpression = false; std::ostringstream error; diff --git a/Source/cmStringReplaceHelper.h b/Source/cmStringReplaceHelper.h index 3e76d86d5d..b3e4704168 100644 --- a/Source/cmStringReplaceHelper.h +++ b/Source/cmStringReplaceHelper.h @@ -6,6 +6,7 @@ #include "cmsys/RegularExpression.hxx" #include <string> +#include <utility> #include <vector> class cmMakefile; @@ -13,8 +14,7 @@ class cmMakefile; class cmStringReplaceHelper { public: - cmStringReplaceHelper(const std::string& regex, - const std::string& replace_expr, + cmStringReplaceHelper(const std::string& regex, std::string replace_expr, cmMakefile* makefile = nullptr); bool IsRegularExpressionValid() const @@ -39,16 +39,16 @@ private: , Value(s) { } - RegexReplacement(const std::string& s) + RegexReplacement(std::string s) : Number(-1) - , Value(s) + , Value(std::move(s)) { } RegexReplacement(int n) : Number(n) { } - RegexReplacement() {} + RegexReplacement() = default; int Number; std::string Value; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index be65853eda..a9cf0c620e 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -76,6 +76,15 @@ # include <malloc.h> /* for malloc/free on QNX */ #endif +namespace { + +cmSystemTools::InterruptCallback s_InterruptCallback; +cmSystemTools::MessageCallback s_MessageCallback; +cmSystemTools::OutputCallback s_StderrCallback; +cmSystemTools::OutputCallback s_StdoutCallback; + +} // namespace + static bool cm_isspace(char c) { return ((c & 0x80) == 0) && isspace(c); @@ -161,15 +170,6 @@ bool cmSystemTools::s_FatalErrorOccured = false; bool cmSystemTools::s_DisableMessages = false; bool cmSystemTools::s_ForceUnixPaths = false; -cmSystemTools::MessageCallback cmSystemTools::s_MessageCallback; -cmSystemTools::OutputCallback cmSystemTools::s_StdoutCallback; -cmSystemTools::OutputCallback cmSystemTools::s_StderrCallback; -cmSystemTools::InterruptCallback cmSystemTools::s_InterruptCallback; -void* cmSystemTools::s_MessageCallbackClientData; -void* cmSystemTools::s_StdoutCallbackClientData; -void* cmSystemTools::s_StderrCallbackClientData; -void* cmSystemTools::s_InterruptCallbackClientData; - // replace replace with with as many times as it shows up in source. // write the result into source. #if defined(_WIN32) && !defined(__CYGWIN__) @@ -267,68 +267,59 @@ void cmSystemTools::Error(const char* m1, const char* m2, const char* m3, message += m4; } cmSystemTools::s_ErrorOccured = true; - cmSystemTools::Message(message.c_str(), "Error"); + cmSystemTools::Message(message, "Error"); +} + +void cmSystemTools::Error(const std::string& m) +{ + std::string message = "CMake Error: " + m; + cmSystemTools::s_ErrorOccured = true; + cmSystemTools::Message(message, "Error"); } -void cmSystemTools::SetInterruptCallback(InterruptCallback f, void* clientData) +void cmSystemTools::SetInterruptCallback(InterruptCallback f) { - s_InterruptCallback = f; - s_InterruptCallbackClientData = clientData; + s_InterruptCallback = std::move(f); } bool cmSystemTools::GetInterruptFlag() { if (s_InterruptCallback) { - return (*s_InterruptCallback)(s_InterruptCallbackClientData); + return s_InterruptCallback(); } return false; } -void cmSystemTools::SetMessageCallback(MessageCallback f, void* clientData) -{ - s_MessageCallback = f; - s_MessageCallbackClientData = clientData; -} - -void cmSystemTools::SetStdoutCallback(OutputCallback f, void* clientData) +void cmSystemTools::SetMessageCallback(MessageCallback f) { - s_StdoutCallback = f; - s_StdoutCallbackClientData = clientData; + s_MessageCallback = std::move(f); } -void cmSystemTools::SetStderrCallback(OutputCallback f, void* clientData) +void cmSystemTools::SetStdoutCallback(OutputCallback f) { - s_StderrCallback = f; - s_StderrCallbackClientData = clientData; + s_StdoutCallback = std::move(f); } -void cmSystemTools::Stdout(const char* s) +void cmSystemTools::SetStderrCallback(OutputCallback f) { - cmSystemTools::Stdout(s, strlen(s)); + s_StderrCallback = std::move(f); } -void cmSystemTools::Stderr(const char* s) -{ - cmSystemTools::Stderr(s, strlen(s)); -} - -void cmSystemTools::Stderr(const char* s, size_t length) +void cmSystemTools::Stderr(const std::string& s) { if (s_StderrCallback) { - (*s_StderrCallback)(s, length, s_StderrCallbackClientData); + s_StderrCallback(s.c_str(), s.length()); } else { - std::cerr.write(s, length); - std::cerr.flush(); + std::cerr << s << std::flush; } } -void cmSystemTools::Stdout(const char* s, size_t length) +void cmSystemTools::Stdout(const std::string& s) { if (s_StdoutCallback) { - (*s_StdoutCallback)(s, length, s_StdoutCallbackClientData); + s_StdoutCallback(s.c_str(), s.length()); } else { - std::cout.write(s, length); - std::cout.flush(); + std::cout << s << std::flush; } } @@ -338,8 +329,7 @@ void cmSystemTools::Message(const char* m1, const char* title) return; } if (s_MessageCallback) { - (*s_MessageCallback)(m1, title, s_DisableMessages, - s_MessageCallbackClientData); + s_MessageCallback(m1, title); return; } std::cerr << m1 << std::endl << std::flush; @@ -350,7 +340,7 @@ void cmSystemTools::ReportLastSystemError(const char* msg) std::string m = msg; m += ": System Error: "; m += Superclass::GetLastSystemError(); - cmSystemTools::Error(m.c_str()); + cmSystemTools::Error(m); } bool cmSystemTools::IsInternallyOn(const char* val) @@ -534,7 +524,7 @@ public: void Store(std::vector<std::string>& args) const { for (char** arg = this->ArgV; arg && *arg; ++arg) { - args.push_back(*arg); + args.emplace_back(*arg); } } }; @@ -561,7 +551,7 @@ std::vector<std::string> cmSystemTools::HandleResponseFile( error += cmSystemTools::GetLastSystemError(); error += "):\n "; error += arg.substr(1); - cmSystemTools::Error(error.c_str()); + cmSystemTools::Error(error); } else { std::string line; cmSystemTools::GetLineFromStream(responseFile, line); @@ -792,7 +782,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, if (pipe == cmsysProcess_Pipe_STDOUT) { if (outputflag != OUTPUT_NONE) { processOutput.DecodeText(data, length, strdata, 1); - cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + cmSystemTools::Stdout(strdata); } if (captureStdOut) { tempStdOut.insert(tempStdOut.end(), data, data + length); @@ -800,7 +790,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, } else if (pipe == cmsysProcess_Pipe_STDERR) { if (outputflag != OUTPUT_NONE) { processOutput.DecodeText(data, length, strdata, 2); - cmSystemTools::Stderr(strdata.c_str(), strdata.size()); + cmSystemTools::Stderr(strdata); } if (captureStdErr) { tempStdErr.insert(tempStdErr.end(), data, data + length); @@ -811,11 +801,11 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, if (outputflag != OUTPUT_NONE) { processOutput.DecodeText(std::string(), strdata, 1); if (!strdata.empty()) { - cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + cmSystemTools::Stdout(strdata); } processOutput.DecodeText(std::string(), strdata, 2); if (!strdata.empty()) { - cmSystemTools::Stderr(strdata.c_str(), strdata.size()); + cmSystemTools::Stderr(strdata); } } } @@ -945,17 +935,12 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname, return ""; } -bool cmSystemTools::cmCopyFile(const char* source, const char* destination) +bool cmSystemTools::cmCopyFile(const std::string& source, + const std::string& destination) { return Superclass::CopyFileAlways(source, destination); } -bool cmSystemTools::CopyFileIfDifferent(const char* source, - const char* destination) -{ - return Superclass::CopyFileIfDifferent(source, destination); -} - #ifdef _WIN32 cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry() { @@ -1040,7 +1025,8 @@ void cmSystemTools::InitializeLibUV() #endif } -bool cmSystemTools::RenameFile(const char* oldname, const char* newname) +bool cmSystemTools::RenameFile(const std::string& oldname, + const std::string& newname) { #ifdef _WIN32 # ifndef INVALID_FILE_ATTRIBUTES @@ -1078,7 +1064,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) return retry.Count > 0; #else /* On UNIX we have an OS-provided call to do this atomically. */ - return rename(oldname, newname) == 0; + return rename(oldname.c_str(), newname.c_str()) == 0; #endif } @@ -1586,7 +1572,7 @@ std::vector<std::string> cmSystemTools::GetEnvironmentVariables() std::vector<std::string> env; int cc; for (cc = 0; environ[cc]; ++cc) { - env.push_back(environ[cc]); + env.emplace_back(environ[cc]); } return env; } @@ -1663,7 +1649,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, e += outFileName; e += "\": "; e += cmSystemTools::GetLastSystemError(); - cmSystemTools::Error(e.c_str()); + cmSystemTools::Error(e); return false; } cmArchiveWrite::Compress compress = cmArchiveWrite::CompressNone; @@ -1696,7 +1682,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, } } if (!a) { - cmSystemTools::Error(a.GetError().c_str()); + cmSystemTools::Error(a.GetError()); return false; } return true; @@ -1899,13 +1885,13 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract) if (verbose) { if (extract) { cmSystemTools::Stdout("x "); - cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str()); + cmSystemTools::Stdout(cm_archive_entry_pathname(entry)); } else { list_item_verbose(stdout, entry); } cmSystemTools::Stdout("\n"); } else if (!extract) { - cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str()); + cmSystemTools::Stdout(cm_archive_entry_pathname(entry)); cmSystemTools::Stdout("\n"); } if (extract) { @@ -3063,7 +3049,7 @@ std::vector<std::string> cmSystemTools::tokenize(const std::string& str, } while (tokend != std::string::npos); if (tokens.empty()) { - tokens.push_back(""); + tokens.emplace_back(); } return tokens; } @@ -3114,7 +3100,8 @@ std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes) } bool cmSystemTools::CreateSymlink(const std::string& origName, - const std::string& newName) + const std::string& newName, + std::string* errorMessage) { uv_fs_t req; int flags = 0; @@ -3128,7 +3115,32 @@ bool cmSystemTools::CreateSymlink(const std::string& origName, if (err) { std::string e = "failed to create symbolic link '" + newName + "': " + uv_strerror(err); - cmSystemTools::Error(e.c_str()); + if (errorMessage) { + *errorMessage = std::move(e); + } else { + cmSystemTools::Error(e); + } + return false; + } + + return true; +} + +bool cmSystemTools::CreateLink(const std::string& origName, + const std::string& newName, + std::string* errorMessage) +{ + uv_fs_t req; + int err = + uv_fs_link(nullptr, &req, origName.c_str(), newName.c_str(), nullptr); + if (err) { + std::string e = + "failed to create link '" + newName + "': " + uv_strerror(err); + if (errorMessage) { + *errorMessage = std::move(e); + } else { + cmSystemTools::Error(e); + } return false; } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index c0999e720d..990c932b0c 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -10,6 +10,7 @@ #include "cmProcessOutput.h" #include "cmsys/Process.h" #include "cmsys/SystemTools.hxx" // IWYU pragma: export +#include <functional> #include <stddef.h> #include <string> #include <vector> @@ -55,42 +56,42 @@ public: */ static std::string TrimWhitespace(const std::string& s); - typedef void (*MessageCallback)(const char*, const char*, bool&, void*); + using MessageCallback = std::function<void(const char*, const char*)>; /** * Set the function used by GUIs to display error messages * Function gets passed: message as a const char*, - * title as a const char*, and a reference to bool that when - * set to false, will disable further messages (cancel). + * title as a const char*. */ - static void SetMessageCallback(MessageCallback f, - void* clientData = nullptr); + static void SetMessageCallback(MessageCallback f); /** * Display an error message. */ static void Error(const char* m, const char* m2 = nullptr, const char* m3 = nullptr, const char* m4 = nullptr); + static void Error(const std::string& m); /** * Display a message. */ static void Message(const char* m, const char* title = nullptr); + static void Message(const std::string& m, const char* title = nullptr) + { + Message(m.c_str(), title); + } - typedef void (*OutputCallback)(const char*, size_t length, void*); + using OutputCallback = std::function<void(const char*, size_t)>; ///! Send a string to stdout - static void Stdout(const char* s); - static void Stdout(const char* s, size_t length); - static void SetStdoutCallback(OutputCallback, void* clientData = nullptr); + static void Stdout(const std::string& s); + static void SetStdoutCallback(OutputCallback f); ///! Send a string to stderr - static void Stderr(const char* s); - static void Stderr(const char* s, size_t length); - static void SetStderrCallback(OutputCallback, void* clientData = nullptr); + static void Stderr(const std::string& s); + static void SetStderrCallback(OutputCallback f); - typedef bool (*InterruptCallback)(void*); - static void SetInterruptCallback(InterruptCallback f, - void* clientData = nullptr); + using InterruptCallback = std::function<bool()>; + static void SetInterruptCallback(InterruptCallback f); static bool GetInterruptFlag(); ///! Return true if there was an error at any point. @@ -176,12 +177,13 @@ public: std::vector<std::string>& files, int type = 0); ///! Copy a file. - static bool cmCopyFile(const char* source, const char* destination); - static bool CopyFileIfDifferent(const char* source, const char* destination); + static bool cmCopyFile(const std::string& source, + const std::string& destination); /** Rename a file or directory within a single disk volume (atomic if possible). */ - static bool RenameFile(const char* oldname, const char* newname); + static bool RenameFile(const std::string& oldname, + const std::string& newname); ///! Compute the hash of a file static std::string ComputeFileHash(const std::string& source, @@ -528,7 +530,14 @@ public: /** Create a symbolic link if the platform supports it. Returns whether creation succeeded. */ static bool CreateSymlink(const std::string& origName, - const std::string& newName); + const std::string& newName, + std::string* errorMessage = nullptr); + + /** Create a hard link if the platform supports it. Returns whether + creation succeeded. */ + static bool CreateLink(const std::string& origName, + const std::string& newName, + std::string* errorMessage = nullptr); private: static bool s_ForceUnixPaths; @@ -537,14 +546,6 @@ private: static bool s_FatalErrorOccured; static bool s_DisableMessages; static bool s_DisableRunCommandOutput; - static MessageCallback s_MessageCallback; - static OutputCallback s_StdoutCallback; - static OutputCallback s_StderrCallback; - static InterruptCallback s_InterruptCallback; - static void* s_MessageCallbackClientData; - static void* s_StdoutCallbackClientData; - static void* s_StderrCallbackClientData; - static void* s_InterruptCallbackClientData; }; #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a94cf6ad93..93cdd46ce9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -19,7 +19,6 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmMessenger.h" -#include "cmOutputConverter.h" #include "cmProperty.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" @@ -662,7 +661,7 @@ public: } }; -cmSourceFile* cmTarget::AddSource(const std::string& src) +cmSourceFile* cmTarget::AddSource(const std::string& src, bool before) { cmSourceFileLocation sfl(this->Makefile, src, cmSourceFileLocationKind::Known); @@ -671,8 +670,14 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) TargetPropertyEntryFinder(sfl)) == this->Internal->SourceEntries.end()) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(src); - this->Internal->SourceBacktraces.push_back(lfbt); + this->Internal->SourceEntries.insert( + before ? this->Internal->SourceEntries.begin() + : this->Internal->SourceEntries.end(), + src); + this->Internal->SourceBacktraces.insert( + before ? this->Internal->SourceBacktraces.begin() + : this->Internal->SourceBacktraces.end(), + lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { return nullptr; @@ -731,7 +736,7 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature, } } if (this->TLLCommands.empty() || this->TLLCommands.back().second != lfc) { - this->TLLCommands.push_back(std::make_pair(signature, lfc)); + this->TLLCommands.emplace_back(signature, lfc); } return ret; } @@ -741,11 +746,12 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const const char* sigString = (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); s << "The uses of the " << sigString << " signature are here:\n"; - cmOutputConverter converter(this->GetMakefile()->GetStateSnapshot()); + cmStateDirectory cmDir = + this->GetMakefile()->GetStateSnapshot().GetDirectory(); for (auto const& cmd : this->TLLCommands) { if (cmd.first == sig) { cmListFileContext lfc = cmd.second; - lfc.FilePath = converter.ConvertToRelativePath( + lfc.FilePath = cmDir.ConvertToRelPathIfNotContained( this->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath); s << " * " << lfc << std::endl; } @@ -975,7 +981,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->IncludeDirectoriesEntries.clear(); this->Internal->IncludeDirectoriesBacktraces.clear(); if (value) { - this->Internal->IncludeDirectoriesEntries.push_back(value); + this->Internal->IncludeDirectoriesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } @@ -983,7 +989,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->CompileOptionsEntries.clear(); this->Internal->CompileOptionsBacktraces.clear(); if (value) { - this->Internal->CompileOptionsEntries.push_back(value); + this->Internal->CompileOptionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->CompileOptionsBacktraces.push_back(lfbt); } @@ -991,7 +997,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->CompileFeaturesEntries.clear(); this->Internal->CompileFeaturesBacktraces.clear(); if (value) { - this->Internal->CompileFeaturesEntries.push_back(value); + this->Internal->CompileFeaturesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } @@ -999,7 +1005,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->CompileDefinitionsEntries.clear(); this->Internal->CompileDefinitionsBacktraces.clear(); if (value) { - this->Internal->CompileDefinitionsEntries.push_back(value); + this->Internal->CompileDefinitionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } @@ -1007,7 +1013,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->LinkOptionsEntries.clear(); this->Internal->LinkOptionsBacktraces.clear(); if (value) { - this->Internal->LinkOptionsEntries.push_back(value); + this->Internal->LinkOptionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->LinkOptionsBacktraces.push_back(lfbt); } @@ -1015,7 +1021,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->LinkDirectoriesEntries.clear(); this->Internal->LinkDirectoriesBacktraces.clear(); if (value) { - this->Internal->LinkDirectoriesEntries.push_back(value); + this->Internal->LinkDirectoriesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->LinkDirectoriesBacktraces.push_back(lfbt); } @@ -1024,7 +1030,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->LinkImplementationPropertyBacktraces.clear(); if (value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkImplementationPropertyEntries.push_back(value); + this->Internal->LinkImplementationPropertyEntries.emplace_back(value); this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == propSOURCES) { @@ -1032,7 +1038,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->SourceBacktraces.clear(); if (value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(value); + this->Internal->SourceEntries.emplace_back(value); this->Internal->SourceBacktraces.push_back(lfbt); } } else if (prop == propIMPORTED_GLOBAL) { @@ -1102,49 +1108,49 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } if (prop == "INCLUDE_DIRECTORIES") { if (value && *value) { - this->Internal->IncludeDirectoriesEntries.push_back(value); + this->Internal->IncludeDirectoriesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_OPTIONS") { if (value && *value) { - this->Internal->CompileOptionsEntries.push_back(value); + this->Internal->CompileOptionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->CompileOptionsBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_FEATURES") { if (value && *value) { - this->Internal->CompileFeaturesEntries.push_back(value); + this->Internal->CompileFeaturesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_DEFINITIONS") { if (value && *value) { - this->Internal->CompileDefinitionsEntries.push_back(value); + this->Internal->CompileDefinitionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } } else if (prop == "LINK_OPTIONS") { if (value && *value) { - this->Internal->LinkOptionsEntries.push_back(value); + this->Internal->LinkOptionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->LinkOptionsBacktraces.push_back(lfbt); } } else if (prop == "LINK_DIRECTORIES") { if (value && *value) { - this->Internal->LinkDirectoriesEntries.push_back(value); + this->Internal->LinkDirectoriesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->LinkDirectoriesBacktraces.push_back(lfbt); } } else if (prop == "LINK_LIBRARIES") { if (value && *value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkImplementationPropertyEntries.push_back(value); + this->Internal->LinkImplementationPropertyEntries.emplace_back(value); this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == "SOURCES") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(value); + this->Internal->SourceEntries.emplace_back(value); this->Internal->SourceBacktraces.push_back(lfbt); } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME")) { this->Makefile->IssueMessage(MessageType::FATAL_ERROR, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 655cefd0f0..24b37423e3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -123,7 +123,7 @@ public: void AddSources(std::vector<std::string> const& srcs); void AddTracedSources(std::vector<std::string> const& srcs); cmSourceFile* AddSourceCMP0049(const std::string& src); - cmSourceFile* AddSource(const std::string& src); + cmSourceFile* AddSource(const std::string& src, bool before = false); //* how we identify a library, by name and type typedef std::pair<std::string, cmTargetLinkLibraryType> LibraryID; diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 4d0cbaafcc..7d45cf5e3f 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -14,9 +14,7 @@ cmTest::cmTest(cmMakefile* mf) this->OldStyle = true; } -cmTest::~cmTest() -{ -} +cmTest::~cmTest() = default; cmListFileBacktrace const& cmTest::GetBacktrace() const { diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 1e2ddc7b90..5102613eba 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -26,9 +26,7 @@ cmTestGenerator::cmTestGenerator( this->LG = nullptr; } -cmTestGenerator::~cmTestGenerator() -{ -} +cmTestGenerator::~cmTestGenerator() = default; void cmTestGenerator::Compute(cmLocalGenerator* lg) { @@ -90,7 +88,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Prepend with the emulator when cross compiling if required. const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); - if (emulator != nullptr) { + if (emulator != nullptr && *emulator) { std::vector<std::string> emulatorWithArgs; cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); std::string emulatorExe(emulatorWithArgs[0]); diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h index 2f75acba0d..d5fbdfd671 100644 --- a/Source/cmTimestamp.h +++ b/Source/cmTimestamp.h @@ -15,8 +15,6 @@ class cmTimestamp { public: - cmTimestamp() {} - std::string CurrentTime(const std::string& formatString, bool utcFlag); std::string FileModificationTime(const char* path, diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index e224a27e72..c57aabdc3b 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -101,11 +101,11 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, bool captureRunOutput = false; if (!this->OutputVariable.empty()) { captureRunOutput = true; - tryCompile.push_back("OUTPUT_VARIABLE"); + tryCompile.emplace_back("OUTPUT_VARIABLE"); tryCompile.push_back(this->OutputVariable); } if (!this->CompileOutputVariable.empty()) { - tryCompile.push_back("OUTPUT_VARIABLE"); + tryCompile.emplace_back("OUTPUT_VARIABLE"); tryCompile.push_back(this->CompileOutputVariable); } if (!this->RunOutputVariable.empty()) { @@ -121,7 +121,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, // now try running the command if it compiled if (!res) { if (this->OutputFile.empty()) { - cmSystemTools::Error(this->FindErrorMessage.c_str()); + cmSystemTools::Error(this->FindErrorMessage); } else { // "run" it and capture the output std::string runOutputContents; @@ -217,7 +217,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, // removed at the end of TRY_RUN and the user can run it manually // on the target platform. std::string copyDest = this->Makefile->GetHomeOutputDirectory(); - copyDest += cmake::GetCMakeFilesDirectory(); + copyDest += "/CMakeFiles"; copyDest += "/"; copyDest += cmSystemTools::GetFilenameWithoutExtension(this->OutputFile); copyDest += "-"; @@ -354,7 +354,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, errorMessage += " " + internalRunOutputName + " (advanced)\n"; } errorMessage += detailsString; - cmSystemTools::Error(errorMessage.c_str()); + cmSystemTools::Error(errorMessage); return; } diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h index 73ee334da8..d42969e66a 100644 --- a/Source/cmUVHandlePtr.h +++ b/Source/cmUVHandlePtr.h @@ -86,8 +86,8 @@ public: } // Dtor and ctor need to be inline defined like this for default ctors and - // dtors to work. - uv_handle_ptr_base_() {} + // dtors to work. Some compilers do not like '= default' here. + uv_handle_ptr_base_() {} // NOLINT(modernize-use-equals-default) uv_handle_ptr_base_(std::nullptr_t) {} ~uv_handle_ptr_base_() { reset(); } diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h index 7154881a4d..33d6bdc2c2 100644 --- a/Source/cmUnexpectedCommand.h +++ b/Source/cmUnexpectedCommand.h @@ -6,6 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <string> +#include <utility> #include <vector> #include "cmCommand.h" @@ -15,8 +16,8 @@ class cmExecutionStatus; class cmUnexpectedCommand : public cmCommand { public: - cmUnexpectedCommand(std::string const& name, const char* error) - : Name(name) + cmUnexpectedCommand(std::string name, const char* error) + : Name(std::move(name)) , Error(error) { } diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index 01ef5cbea4..9648b21d8f 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -100,6 +100,6 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source, // close the files before attempting to copy fin.close(); fout.close(); - cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), outFile.c_str()); + cmSystemTools::CopyFileIfDifferent(tempOutputFile, outFile); cmSystemTools::RemoveFile(tempOutputFile); } diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index f374626446..231bca41df 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -40,7 +40,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, msg += ". If your intention is to run this executable, you need to " "preload the cache with the full path to a version of that " "program, which runs on this build machine."; - cmSystemTools::Message(msg.c_str(), "Warning"); + cmSystemTools::Message(msg, "Warning"); } } else { cmState* state = this->Makefile->GetState(); diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 9187c29b9f..91a0e15124 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -188,8 +188,16 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo( // Check if a compiler is installed with this instance. { std::string const vcRoot = vsInstanceInfo.GetInstallLocation(); - std::string const vcToolsVersionFile = + std::string vcToolsVersionFile = vcRoot + "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt"; + if (!cmSystemTools::PathExists(vcToolsVersionFile)) { + // FIXME: VS 2019 Preview 2 installs the v142 toolset and does not + // provide the plain `Microsoft.VCToolsVersion.default.txt` that v141 + // does. This should be fixed in preview 3 and this workaround can + // be dropped. Otherwise, we may need to switch to globbing. + vcToolsVersionFile = vcRoot + + "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.v142.default.txt"; + } std::string vcToolsVersion; cmsys::ifstream fin(vcToolsVersionFile.c_str()); if (!fin || !cmSystemTools::GetLineFromStream(fin, vcToolsVersion)) { diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h index 4748a7aec5..1bda54a47b 100644 --- a/Source/cmVSSetupHelper.h +++ b/Source/cmVSSetupHelper.h @@ -112,8 +112,6 @@ struct VSInstanceInfo bool IsWin10SDKInstalled = false; bool IsWin81SDKInstalled = false; - VSInstanceInfo() = default; - std::string GetInstallLocation() const; }; diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index 06ca53c0af..c02157ad1e 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -57,7 +57,7 @@ bool cmVariableRequiresCommand::InitialPass( "One or more of the required variables is advanced." " To set the variable, you must turn on advanced mode in cmake."; } - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); } return true; diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx index bd5d19c396..3df1420991 100644 --- a/Source/cmVariableWatch.cxx +++ b/Source/cmVariableWatch.cxx @@ -19,13 +19,9 @@ const char* cmVariableWatch::GetAccessAsString(int access_type) return cmVariableWatchAccessStrings[access_type]; } -cmVariableWatch::cmVariableWatch() -{ -} +cmVariableWatch::cmVariableWatch() = default; -cmVariableWatch::~cmVariableWatch() -{ -} +cmVariableWatch::~cmVariableWatch() = default; bool cmVariableWatch::AddWatch(const std::string& variable, WatchMethod method, void* client_data /*=0*/, diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 2f444edf6b..5855fed292 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -66,7 +66,6 @@ protected: WatchMethod Method = nullptr; void* ClientData = nullptr; DeleteData DeleteDataCall = nullptr; - Pair() {} ~Pair() { if (this->DeleteDataCall && this->ClientData) { diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index 03e00594c6..5fe55bd535 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -60,7 +60,7 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable, error << "Error in cmake code at\nUnknown:0:\n" << "A command failed during the invocation of callback \"" << data->Command << "\"."; - cmSystemTools::Error(error.str().c_str()); + cmSystemTools::Error(error.str()); data->InCallback = false; return; } @@ -84,9 +84,7 @@ static void deleteVariableWatchCallbackData(void* client_data) delete data; } -cmVariableWatchCommand::cmVariableWatchCommand() -{ -} +cmVariableWatchCommand::cmVariableWatchCommand() = default; cmVariableWatchCommand::~cmVariableWatchCommand() { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ac4a4f526f..9d7dd07d8b 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3584,8 +3584,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions( this->LocalGenerator->GetCurrentBinaryDirectory(); for (cmComputeLinkInformation::Item const& l : libs) { if (l.IsPath && cmVS10IsTargetsFile(l.Value)) { - std::string path = - this->LocalGenerator->ConvertToRelativePath(currentBinDir, l.Value); + std::string path = this->LocalGenerator->MaybeConvertToRelativePath( + currentBinDir, l.Value); ConvertToWindowsSlash(path); this->AddTargetsFileAndConfigPair(path, config); } @@ -3668,8 +3668,8 @@ void cmVisualStudio10TargetGenerator::AddLibraries( } if (l.IsPath) { - std::string path = - this->LocalGenerator->ConvertToRelativePath(currentBinDir, l.Value); + std::string path = this->LocalGenerator->MaybeConvertToRelativePath( + currentBinDir, l.Value); ConvertToWindowsSlash(path); if (cmVS10IsTargetsFile(l.Value)) { vsTargetVec.push_back(path); diff --git a/Source/cmVisualStudio10ToolsetOptions.cxx b/Source/cmVisualStudio10ToolsetOptions.cxx index 39063ed917..a490e03df2 100644 --- a/Source/cmVisualStudio10ToolsetOptions.cxx +++ b/Source/cmVisualStudio10ToolsetOptions.cxx @@ -11,7 +11,9 @@ std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName( { std::string const useToolset = this->GetToolsetName(name, toolset); - if (toolset == "v141") { + if (toolset == "v142") { + return "v142"; + } else if (toolset == "v141") { return "v141"; } else if (useToolset == "v140") { return "v140"; @@ -31,7 +33,10 @@ std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName( { std::string const useToolset = this->GetToolsetName(name, toolset); - if ((useToolset == "v141")) { + if (useToolset == "v142") { + // FIXME: Add CSharp flag table for v142. + return "v141"; + } else if (useToolset == "v141") { return "v141"; } else if (useToolset == "v140") { return "v140"; @@ -51,7 +56,8 @@ std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName( { std::string const useToolset = this->GetToolsetName(name, toolset); - if ((useToolset == "v140") || (useToolset == "v141")) { + if ((useToolset == "v140") || (useToolset == "v141") || + (useToolset == "v142")) { return "v14"; } else if (useToolset == "v120") { return "v12"; @@ -69,7 +75,8 @@ std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName( { std::string const useToolset = this->GetToolsetName(name, toolset); - if ((useToolset == "v140") || (useToolset == "v141")) { + if ((useToolset == "v140") || (useToolset == "v141") || + (useToolset == "v142")) { return "v14"; } else if (useToolset == "v120") { return "v12"; @@ -87,7 +94,9 @@ std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName( { std::string const useToolset = this->GetToolsetName(name, toolset); - if (useToolset == "v141") { + if (useToolset == "v142") { + return "v142"; + } else if (useToolset == "v141") { return "v141"; } else if (useToolset == "v140") { return "v140"; @@ -107,7 +116,8 @@ std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName( { std::string const useToolset = this->GetToolsetName(name, toolset); - if ((useToolset == "v140") || (useToolset == "v141")) { + if ((useToolset == "v140") || (useToolset == "v141") || + (useToolset == "v142")) { return "v14"; } else if (useToolset == "v120") { return "v12"; diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index d301ad0d60..1b161987af 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -5,16 +5,17 @@ #include <iomanip> #include <iostream> #include <sstream> +#include <utility> #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmXMLSafe.h" -cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, const TestObjects& tests, +cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, TestObjects tests, const std::vector<std::string>& configList, unsigned int xcVersion) : Target(xcObj) - , Tests(tests) + , Tests(std::move(tests)) , TargetName(xcObj->GetTarget()->GetName()) , ConfigList(configList) , XcodeVersion(xcVersion) diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h index 96c76e6424..8c47123599 100644 --- a/Source/cmXCodeScheme.h +++ b/Source/cmXCodeScheme.h @@ -20,7 +20,7 @@ class cmXCodeScheme public: typedef std::vector<const cmXCodeObject*> TestObjects; - cmXCodeScheme(cmXCodeObject* xcObj, const TestObjects& tests, + cmXCodeScheme(cmXCodeObject* xcObj, TestObjects tests, const std::vector<std::string>& configList, unsigned int xcVersion); diff --git a/Source/cm_codecvt.cxx b/Source/cm_codecvt.cxx index 9519f9155a..821c112b3b 100644 --- a/Source/cm_codecvt.cxx +++ b/Source/cm_codecvt.cxx @@ -38,9 +38,7 @@ codecvt::codecvt(Encoding e) } } -codecvt::~codecvt() -{ -} +codecvt::~codecvt() = default; bool codecvt::do_always_noconv() const throw() { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9fcfbde93a..2b627ff83a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -115,8 +115,10 @@ typedef std::unordered_map<std::string, Json::Value> JsonValueMapType; } // namespace -static bool cmakeCheckStampFile(const char* stampName, bool verbose = true); -static bool cmakeCheckStampList(const char* stampList, bool verbose = true); +static bool cmakeCheckStampFile(const std::string& stampName, + bool verbose = true); +static bool cmakeCheckStampList(const std::string& stampList, + bool verbose = true); void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/, void* ctx, const char* /*unused*/, @@ -155,8 +157,6 @@ cmake::cmake(Role role, cmState::Mode mode) #endif this->GlobalGenerator = nullptr; - this->ProgressCallback = nullptr; - this->ProgressCallbackClientData = nullptr; this->CurrentWorkingMode = NORMAL_MODE; #ifdef CMAKE_BUILD_WITH_CMAKE @@ -179,31 +179,31 @@ cmake::cmake(Role role, cmState::Mode mode) // these are used to find files when the extension // is not given // The "c" extension MUST precede the "C" extension. - this->SourceFileExtensions.push_back("c"); - this->SourceFileExtensions.push_back("C"); - - this->SourceFileExtensions.push_back("c++"); - this->SourceFileExtensions.push_back("cc"); - this->SourceFileExtensions.push_back("cpp"); - this->SourceFileExtensions.push_back("cxx"); - this->SourceFileExtensions.push_back("cu"); - this->SourceFileExtensions.push_back("m"); - this->SourceFileExtensions.push_back("M"); - this->SourceFileExtensions.push_back("mm"); + this->SourceFileExtensions.emplace_back("c"); + this->SourceFileExtensions.emplace_back("C"); + + this->SourceFileExtensions.emplace_back("c++"); + this->SourceFileExtensions.emplace_back("cc"); + this->SourceFileExtensions.emplace_back("cpp"); + this->SourceFileExtensions.emplace_back("cxx"); + this->SourceFileExtensions.emplace_back("cu"); + this->SourceFileExtensions.emplace_back("m"); + this->SourceFileExtensions.emplace_back("M"); + this->SourceFileExtensions.emplace_back("mm"); std::copy(this->SourceFileExtensions.begin(), this->SourceFileExtensions.end(), std::inserter(this->SourceFileExtensionsSet, this->SourceFileExtensionsSet.end())); - this->HeaderFileExtensions.push_back("h"); - this->HeaderFileExtensions.push_back("hh"); - this->HeaderFileExtensions.push_back("h++"); - this->HeaderFileExtensions.push_back("hm"); - this->HeaderFileExtensions.push_back("hpp"); - this->HeaderFileExtensions.push_back("hxx"); - this->HeaderFileExtensions.push_back("in"); - this->HeaderFileExtensions.push_back("txx"); + this->HeaderFileExtensions.emplace_back("h"); + this->HeaderFileExtensions.emplace_back("hh"); + this->HeaderFileExtensions.emplace_back("h++"); + this->HeaderFileExtensions.emplace_back("hm"); + this->HeaderFileExtensions.emplace_back("hpp"); + this->HeaderFileExtensions.emplace_back("hxx"); + this->HeaderFileExtensions.emplace_back("in"); + this->HeaderFileExtensions.emplace_back("txx"); std::copy(this->HeaderFileExtensions.begin(), this->HeaderFileExtensions.end(), @@ -533,7 +533,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) mf->SetArgcArgv(args); std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake"); - mf->ReadListFile(systemFile.c_str()); + mf->ReadListFile(systemFile); std::string language = mf->GetSafeDefinition("LANGUAGE"); std::string mode = mf->GetSafeDefinition("MODE"); @@ -810,8 +810,11 @@ void cmake::SetArgs(const std::vector<std::string>& args) if (this->CurrentWorkingMode == cmake::NORMAL_MODE && !haveSourceDir && !haveBinaryDir) { - cmSystemTools::Error("No source or binary directory provided"); - return; + this->IssueMessage( + MessageType::WARNING, + "No source or binary directory provided. Both will be assumed to be " + "the same as the current working directory, but note that this " + "warning will become a fatal error in future CMake releases."); } if (!haveSourceDir) { @@ -959,17 +962,25 @@ void cmake::AddDefaultExtraGenerators() #endif } -void cmake::GetRegisteredGenerators( - std::vector<GeneratorInfo>& generators) const +void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators, + bool includeNamesWithPlatform) const { for (cmGlobalGeneratorFactory* gen : this->Generators) { - std::vector<std::string> names; - gen->GetGenerators(names); + std::vector<std::string> names = gen->GetGeneratorNames(); + + if (includeNamesWithPlatform) { + std::vector<std::string> namesWithPlatform = + gen->GetGeneratorNamesWithPlatform(); + names.insert(names.end(), namesWithPlatform.begin(), + namesWithPlatform.end()); + } for (std::string const& name : names) { GeneratorInfo info; info.supportsToolset = gen->SupportsToolset(); info.supportsPlatform = gen->SupportsPlatform(); + info.supportedPlatforms = gen->GetKnownPlatforms(); + info.defaultPlatform = gen->GetDefaultPlatformName(); info.name = name; info.baseName = name; info.isAlias = false; @@ -1161,7 +1172,7 @@ int cmake::DoPreConfigureChecks() } err << "Specify --help for usage, or press the help button on the CMake " "GUI."; - cmSystemTools::Error(err.str().c_str()); + cmSystemTools::Error(err.str()); return -2; } @@ -1179,7 +1190,7 @@ int cmake::DoPreConfigureChecks() message += cacheStart; message += "\" used to generate cache. "; message += "Re-run cmake with a different source directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } else { @@ -1239,7 +1250,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) for (SaveCacheEntry const& i : saved) { this->AddCacheEntry(i.key, i.value.c_str(), i.help.c_str(), i.type); } - cmSystemTools::Message(warning.str().c_str()); + cmSystemTools::Message(warning.str()); // avoid reconfigure if there were errors if (!cmSystemTools::GetErrorOccuredFlag()) { // re-run configure @@ -1389,7 +1400,7 @@ int cmake::ActualConfigure() message += *genName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } @@ -1413,7 +1424,7 @@ int cmake::ActualConfigure() message += *instance; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } else { @@ -1432,7 +1443,7 @@ int cmake::ActualConfigure() message += *platformName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } else { @@ -1450,7 +1461,7 @@ int cmake::ActualConfigure() message += *tsName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } else { @@ -1519,7 +1530,7 @@ int cmake::ActualConfigure() return 0; } -void cmake::CreateDefaultGlobalGenerator() +std::unique_ptr<cmGlobalGenerator> cmake::EvaluateDefaultGlobalGenerator() { #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) std::string found; @@ -1572,13 +1583,22 @@ void cmake::CreateDefaultGlobalGenerator() if (!gen) { gen = new cmGlobalNMakeMakefileGenerator(this); } - this->SetGlobalGenerator(gen); - std::cout << "-- Building for: " << gen->GetName() << "\n"; + return std::unique_ptr<cmGlobalGenerator>(gen); #else - this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this)); + return cm::make_unique<cmGlobalUnixMakefileGenerator3>(this); #endif } +void cmake::CreateDefaultGlobalGenerator() +{ + auto gen = this->EvaluateDefaultGlobalGenerator(); +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) + // This print could be unified for all platforms + std::cout << "-- Building for: " << gen->GetName() << "\n"; +#endif + this->SetGlobalGenerator(gen.release()); +} + void cmake::PreLoadCMakeFiles() { std::vector<std::string> args; @@ -1609,13 +1629,13 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) // If we are given a stamp list file check if it is really out of date. if (!this->CheckStampList.empty() && - cmakeCheckStampList(this->CheckStampList.c_str())) { + cmakeCheckStampList(this->CheckStampList)) { return 0; } // If we are given a stamp file check if it is really out of date. if (!this->CheckStampFile.empty() && - cmakeCheckStampFile(this->CheckStampFile.c_str())) { + cmakeCheckStampFile(this->CheckStampFile)) { return 0; } @@ -1900,17 +1920,15 @@ bool cmake::DeleteCache(const std::string& path) return this->State->DeleteCache(path); } -void cmake::SetProgressCallback(ProgressCallbackType f, void* cd) +void cmake::SetProgressCallback(ProgressCallbackType f) { - this->ProgressCallback = f; - this->ProgressCallbackClientData = cd; + this->ProgressCallback = std::move(f); } void cmake::UpdateProgress(const char* msg, float prog) { if (this->ProgressCallback && !this->State->GetIsInTryCompile()) { - (*this->ProgressCallback)(msg, prog, this->ProgressCallbackClientData); - return; + this->ProgressCallback(msg, prog); } } @@ -1924,13 +1942,28 @@ void cmake::SetIsInTryCompile(bool b) this->State->SetIsInTryCompile(b); } -void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) +void cmake::AppendGlobalGeneratorsDocumentation( + std::vector<cmDocumentationEntry>& v) { + const auto defaultGenerator = this->EvaluateDefaultGlobalGenerator(); + const std::string defaultName = defaultGenerator->GetName(); + bool foundDefaultOne = false; + for (cmGlobalGeneratorFactory* g : this->Generators) { cmDocumentationEntry e; g->GetDocumentation(e); + if (!foundDefaultOne && + cmSystemTools::StringStartsWith(e.Name, defaultName.c_str())) { + e.CustomNamePrefix = '*'; + foundDefaultOne = true; + } v.push_back(std::move(e)); } +} + +void cmake::AppendExtraGeneratorsDocumentation( + std::vector<cmDocumentationEntry>& v) +{ for (cmExternalMakefileProjectGeneratorFactory* eg : this->ExtraGenerators) { const std::string doc = eg->GetDocumentation(); const std::string name = eg->GetName(); @@ -1956,12 +1989,19 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) } } +std::vector<cmDocumentationEntry> cmake::GetGeneratorsDocumentation() +{ + std::vector<cmDocumentationEntry> v; + this->AppendGlobalGeneratorsDocumentation(v); + this->AppendExtraGeneratorsDocumentation(v); + return v; +} + void cmake::PrintGeneratorList() { #ifdef CMAKE_BUILD_WITH_CMAKE cmDocumentation doc; - std::vector<cmDocumentationEntry> generators; - this->GetGeneratorDocumentation(generators); + auto generators = this->GetGeneratorsDocumentation(); doc.AppendSection("Generators", generators); std::cerr << "\n"; doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr); @@ -2006,7 +2046,7 @@ int cmake::CheckBuildSystem() if (verbose) { std::ostringstream msg; msg << "Re-run cmake no build system arguments\n"; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } return 1; } @@ -2017,7 +2057,7 @@ int cmake::CheckBuildSystem() std::ostringstream msg; msg << "Re-run cmake missing file: " << this->CheckBuildSystemArgument << "\n"; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } return 1; } @@ -2031,13 +2071,13 @@ int cmake::CheckBuildSystem() cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); cmMakefile mf(&gg, cm.GetCurrentSnapshot()); - if (!mf.ReadListFile(this->CheckBuildSystemArgument.c_str()) || + if (!mf.ReadListFile(this->CheckBuildSystemArgument) || cmSystemTools::GetErrorOccuredFlag()) { if (verbose) { std::ostringstream msg; msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument << "\n"; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } // There was an error reading the file. Just rerun. return 1; @@ -2071,7 +2111,7 @@ int cmake::CheckBuildSystem() if (verbose) { std::ostringstream msg; msg << "Re-run cmake, missing byproduct: " << p << "\n"; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } return 1; } @@ -2092,7 +2132,7 @@ int cmake::CheckBuildSystem() std::ostringstream msg; msg << "Re-run cmake no CMAKE_MAKEFILE_DEPENDS " "or CMAKE_MAKEFILE_OUTPUTS :\n"; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } return 1; } @@ -2102,8 +2142,7 @@ int cmake::CheckBuildSystem() std::string dep_newest = *dep++; for (; dep != depends.end(); ++dep) { int result = 0; - if (this->FileComparison->FileTimeCompare(dep_newest.c_str(), dep->c_str(), - &result)) { + if (this->FileComparison->FileTimeCompare(dep_newest, *dep, &result)) { if (result < 0) { dep_newest = *dep; } @@ -2111,7 +2150,7 @@ int cmake::CheckBuildSystem() if (verbose) { std::ostringstream msg; msg << "Re-run cmake: build system dependency is missing\n"; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } return 1; } @@ -2122,8 +2161,7 @@ int cmake::CheckBuildSystem() std::string out_oldest = *out++; for (; out != outputs.end(); ++out) { int result = 0; - if (this->FileComparison->FileTimeCompare(out_oldest.c_str(), out->c_str(), - &result)) { + if (this->FileComparison->FileTimeCompare(out_oldest, *out, &result)) { if (result > 0) { out_oldest = *out; } @@ -2131,7 +2169,7 @@ int cmake::CheckBuildSystem() if (verbose) { std::ostringstream msg; msg << "Re-run cmake: build system output is missing\n"; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } return 1; } @@ -2140,14 +2178,14 @@ int cmake::CheckBuildSystem() // If any output is older than any dependency then rerun. { int result = 0; - if (!this->FileComparison->FileTimeCompare(out_oldest.c_str(), - dep_newest.c_str(), &result) || + if (!this->FileComparison->FileTimeCompare(out_oldest, dep_newest, + &result) || result < 0) { if (verbose) { std::ostringstream msg; msg << "Re-run cmake file: " << out_oldest << " older than: " << dep_newest << "\n"; - cmSystemTools::Stdout(msg.str().c_str()); + cmSystemTools::Stdout(msg.str()); } return 1; } @@ -2316,7 +2354,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) outFile += "/CMakeLists.txt"; // Copy file - if (!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) { + if (!cmSystemTools::cmCopyFile(inFile, outFile)) { std::cerr << "Error copying file \"" << inFile << "\" to \"" << outFile << "\".\n"; return 1; @@ -2374,7 +2412,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) return 0; } -static bool cmakeCheckStampFile(const char* stampName, bool verbose) +static bool cmakeCheckStampFile(const std::string& stampName, bool verbose) { // The stamp file does not exist. Use the stamp dependencies to // determine whether it is really out of date. This works in @@ -2402,8 +2440,7 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose) while (cmSystemTools::GetLineFromStream(fin, dep)) { int result; if (!dep.empty() && dep[0] != '#' && - (!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result) || - result < 0)) { + (!ftc.FileTimeCompare(stampDepends, dep, &result) || result < 0)) { // The stamp depends file is older than this dependency. The // build system is really out of date. std::cout << "CMake is re-running because " << stampName @@ -2419,12 +2456,11 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose) // by the VS IDE due to a "rebuild" request. Restore it atomically. std::ostringstream stampTempStream; stampTempStream << stampName << ".tmp" << cmSystemTools::RandomSeed(); - std::string stampTempString = stampTempStream.str(); - const char* stampTemp = stampTempString.c_str(); + std::string stampTemp = stampTempStream.str(); { // TODO: Teach cmGeneratedFileStream to use a random temp file (with // multiple tries in unlikely case of conflict) and use that here. - cmsys::ofstream stamp(stampTemp); + cmsys::ofstream stamp(stampTemp.c_str()); stamp << "# CMake generation timestamp file for this directory.\n"; } if (cmSystemTools::RenameFile(stampTemp, stampName)) { @@ -2438,11 +2474,11 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose) return true; } cmSystemTools::RemoveFile(stampTemp); - cmSystemTools::Error("Cannot restore timestamp ", stampName); + cmSystemTools::Error("Cannot restore timestamp ", stampName.c_str()); return false; } -static bool cmakeCheckStampList(const char* stampList, bool verbose) +static bool cmakeCheckStampList(const std::string& stampList, bool verbose) { // If the stamp list does not exist CMake must rerun to generate it. if (!cmSystemTools::FileExists(stampList)) { @@ -2450,7 +2486,7 @@ static bool cmakeCheckStampList(const char* stampList, bool verbose) << "is missing.\n"; return false; } - cmsys::ifstream fin(stampList); + cmsys::ifstream fin(stampList.c_str()); if (!fin) { std::cout << "CMake is re-running because generate.stamp.list " << "could not be read.\n"; @@ -2460,7 +2496,7 @@ static bool cmakeCheckStampList(const char* stampList, bool verbose) // Check each stamp. std::string stampName; while (cmSystemTools::GetLineFromStream(fin, stampName)) { - if (!cmakeCheckStampFile(stampName.c_str(), verbose)) { + if (!cmakeCheckStampFile(stampName, verbose)) { return false; } } @@ -2485,7 +2521,7 @@ std::vector<std::string> cmake::GetDebugConfigs() } // If no configurations were specified, use a default list. if (configs.empty()) { - configs.push_back("DEBUG"); + configs.emplace_back("DEBUG"); } return configs; } @@ -2497,7 +2533,8 @@ cmMessenger* cmake::GetMessenger() const int cmake::Build(int jobs, const std::string& dir, const std::string& target, const std::string& config, - const std::vector<std::string>& nativeOptions, bool clean) + const std::vector<std::string>& nativeOptions, bool clean, + bool verbose) { this->SetHomeDirectory(""); @@ -2550,11 +2587,11 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target, return 1; } projName = cachedProjectName; - bool verbose = false; + const char* cachedVerbose = this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE"); - if (cachedVerbose) { - verbose = cmSystemTools::IsOn(cachedVerbose); + if (cmSystemTools::IsOn(cachedVerbose)) { + verbose = true; } #ifdef CMAKE_HAVE_VS_GENERATORS @@ -2562,8 +2599,7 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target, // actually starting the build. If not done separately from the build // itself, there is the risk of building an out-of-date solution file due // to limitations of the underlying build system. - std::string const stampList = cachePath + "/" + - GetCMakeFilesDirectoryPostSlash() + + std::string const stampList = cachePath + "/" + "CMakeFiles/" + cmGlobalVisualStudio9Generator::GetGenerateStampList(); // Note that the stampList file only exists for VS generators. @@ -2573,15 +2609,15 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target, // the glob verification script before starting the build this->AddScriptingCommands(); if (this->GlobalGenerator->MatchesGeneratorName("Visual Studio 9 2008")) { - std::string const globVerifyScript = cachePath + "/" + - GetCMakeFilesDirectoryPostSlash() + "VerifyGlobs.cmake"; + std::string const globVerifyScript = + cachePath + "/" + "CMakeFiles/" + "VerifyGlobs.cmake"; if (cmSystemTools::FileExists(globVerifyScript)) { std::vector<std::string> args; this->ReadListFile(args, globVerifyScript.c_str()); } } - if (!cmakeCheckStampList(stampList.c_str(), false)) { + if (!cmakeCheckStampList(stampList, false)) { // Correctly initialize the home (=source) and home output (=binary) // directories, which is required for running the generation step. std::string homeOrig = this->GetHomeDirectory(); diff --git a/Source/cmake.h b/Source/cmake.h index cd8c622413..afd41175a9 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <functional> #include <map> #include <memory> // IWYU pragma: keep #include <set> @@ -104,6 +105,8 @@ public: std::string extraName; bool supportsToolset; bool supportsPlatform; + std::vector<std::string> supportedPlatforms; + std::string defaultPlatform; bool isAlias; }; @@ -123,12 +126,6 @@ public: #endif std::string ReportCapabilities(bool haveServerMode) const; - static const char* GetCMakeFilesDirectory() { return "/CMakeFiles"; } - static const char* GetCMakeFilesDirectoryPostSlash() - { - return "CMakeFiles/"; - } - //@{ /** * Set/Get the home directory (or output directory) in the project. The @@ -196,7 +193,8 @@ public: void SetGlobalGenerator(cmGlobalGenerator*); ///! Get the names of the current registered generators - void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators) const; + void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators, + bool includeNamesWithPlatform = true) const; ///! Set the name of the selected generator-specific instance. void SetGeneratorInstance(std::string const& instance) @@ -274,7 +272,7 @@ public: ///! Parse command line arguments that might set cache values bool SetCacheArgs(const std::vector<std::string>&); - typedef void (*ProgressCallbackType)(const char* msg, float progress, void*); + using ProgressCallbackType = std::function<void(const char*, float)>; /** * Set the function used by GUIs to receive progress updates * Function gets passed: message as a const char*, a progress @@ -282,7 +280,7 @@ public: * number provided may be negative in cases where a message is * to be displayed without any progress percentage. */ - void SetProgressCallback(ProgressCallbackType f, void* clientData = nullptr); + void SetProgressCallback(ProgressCallbackType f); ///! this is called by generators to update the progress void UpdateProgress(const char* msg, float prog); @@ -292,7 +290,7 @@ public: cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } #endif - void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&); + std::vector<cmDocumentationEntry> GetGeneratorsDocumentation(); ///! Set/Get a property of this target file void SetProperty(const std::string& prop, const char* value); @@ -427,7 +425,8 @@ public: ///! run the --build option int Build(int jobs, const std::string& dir, const std::string& target, const std::string& config, - const std::vector<std::string>& nativeOptions, bool clean); + const std::vector<std::string>& nativeOptions, bool clean, + bool verbose); ///! run the --open option bool Open(const std::string& dir, bool dryRun); @@ -487,7 +486,6 @@ protected: private: ProgressCallbackType ProgressCallback; - void* ProgressCallbackClientData; bool InTryCompile; WorkingMode CurrentWorkingMode; bool DebugOutput; @@ -531,8 +529,12 @@ private: // Print a list of valid generators to stderr. void PrintGeneratorList(); + std::unique_ptr<cmGlobalGenerator> EvaluateDefaultGlobalGenerator(); void CreateDefaultGlobalGenerator(); + void AppendGlobalGeneratorsDocumentation(std::vector<cmDocumentationEntry>&); + void AppendExtraGeneratorsDocumentation(std::vector<cmDocumentationEntry>&); + /** * Convert a message type between a warning and an error, based on the state * of the error output CMake variables, in the cache. diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 84d14146e4..890b74e0f2 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAlgorithms.h" -#include "cmDocumentationEntry.h" +#include "cmDocumentationEntry.h" // IWYU pragma: keep #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmState.h" @@ -68,6 +68,8 @@ static const char* cmDocumentationUsageNote[][2] = { " --clean-first = Build target 'clean' first, then build.\n" \ " (To clean only, use --target 'clean'.)\n" \ " --use-stderr = Ignored. Behavior is default in CMake >= 3.0.\n" \ + " -v --verbose = Enable verbose output - if supported - including\n" \ + " the build commands to be executed. \n" \ " -- = Pass remaining options to the native tool.\n" static const char* cmDocumentationOptions[][2] = { @@ -106,7 +108,7 @@ static int do_command(int ac, char const* const* av) { std::vector<std::string> args; args.reserve(ac - 1); - args.push_back(av[0]); + args.emplace_back(av[0]); args.insert(args.end(), av + 2, av + ac); return cmcmd::ExecuteCMakeCommand(args); } @@ -115,9 +117,8 @@ int do_cmake(int ac, char const* const* av); static int do_build(int ac, char const* const* av); static int do_open(int ac, char const* const* av); -static cmMakefile* cmakemainGetMakefile(void* clientdata) +static cmMakefile* cmakemainGetMakefile(cmake* cm) { - cmake* cm = static_cast<cmake*>(clientdata); if (cm && cm->GetDebugOutput()) { cmGlobalGenerator* gg = cm->GetGlobalGenerator(); if (gg) { @@ -127,10 +128,10 @@ static cmMakefile* cmakemainGetMakefile(void* clientdata) return nullptr; } -static std::string cmakemainGetStack(void* clientdata) +static std::string cmakemainGetStack(cmake* cm) { std::string msg; - cmMakefile* mf = cmakemainGetMakefile(clientdata); + cmMakefile* mf = cmakemainGetMakefile(cm); if (mf) { msg = mf->FormatListFileStack(); if (!msg.empty()) { @@ -142,15 +143,14 @@ static std::string cmakemainGetStack(void* clientdata) } static void cmakemainMessageCallback(const char* m, const char* /*unused*/, - bool& /*unused*/, void* clientdata) + cmake* cm) { - std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush; + std::cerr << m << cmakemainGetStack(cm) << std::endl << std::flush; } -static void cmakemainProgressCallback(const char* m, float prog, - void* clientdata) +static void cmakemainProgressCallback(const char* m, float prog, cmake* cm) { - cmMakefile* mf = cmakemainGetMakefile(clientdata); + cmMakefile* mf = cmakemainGetMakefile(cm); std::string dir; if ((mf) && (strstr(m, "Configuring") == m) && (prog < 0)) { dir = " "; @@ -161,8 +161,7 @@ static void cmakemainProgressCallback(const char* m, float prog, } if ((prog < 0) || (!dir.empty())) { - std::cout << "-- " << m << dir << cmakemainGetStack(clientdata) - << std::endl; + std::cout << "-- " << m << dir << cmakemainGetStack(cm) << std::endl; } std::cout.flush(); @@ -227,9 +226,7 @@ int do_cmake(int ac, char const* const* av) std::vector<std::string> args(av, av + ac); hcm.SetCacheArgs(args); - std::vector<cmDocumentationEntry> generators; - - hcm.GetGeneratorDocumentation(generators); + auto generators = hcm.GetGeneratorsDocumentation(); doc.SetName("cmake"); doc.SetSection("Name", cmDocumentationName); @@ -288,14 +285,14 @@ int do_cmake(int ac, char const* const* av) return 1; } workingMode = cmake::SCRIPT_MODE; - args.push_back(av[i]); + args.emplace_back(av[i]); i++; - args.push_back(av[i]); + args.emplace_back(av[i]); } else if (cmHasLiteralPrefix(av[i], "--find-package")) { workingMode = cmake::FIND_PACKAGE_MODE; - args.push_back(av[i]); + args.emplace_back(av[i]); } else { - args.push_back(av[i]); + args.emplace_back(av[i]); } } if (sysinfo) { @@ -322,8 +319,12 @@ int do_cmake(int ac, char const* const* av) cmake cm(role, mode); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); - cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); - cm.SetProgressCallback(cmakemainProgressCallback, &cm); + cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) { + cmakemainMessageCallback(msg, title, &cm); + }); + cm.SetProgressCallback([&cm](const char* msg, float prog) { + cmakemainProgressCallback(msg, prog, &cm); + }); cm.SetWorkingMode(workingMode); int res = cm.Run(args, view_only); @@ -360,6 +361,31 @@ int do_cmake(int ac, char const* const* av) return 0; } +namespace { +int extract_job_number(int& index, char const* current, char const* next, + int len_of_flag) +{ + std::string command(current); + std::string jobString = command.substr(len_of_flag); + if (jobString.empty() && next && isdigit(next[0])) { + ++index; // skip parsing the job number + jobString = std::string(next); + } + + int jobs = -1; + unsigned long numJobs = 0; + if (jobString.empty()) { + jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL; + } else if (cmSystemTools::StringToULong(jobString.c_str(), &numJobs)) { + jobs = int(numJobs); + } else { + std::cerr << "'" << command.substr(0, len_of_flag) << "' invalid number '" + << jobString << "' given.\n\n"; + } + return jobs; +} +} + static int do_build(int ac, char const* const* av) { #ifndef CMAKE_BUILD_WITH_CMAKE @@ -372,12 +398,12 @@ static int do_build(int ac, char const* const* av) std::string dir; std::vector<std::string> nativeOptions; bool clean = false; + bool verbose = cmSystemTools::HasEnv("VERBOSE"); bool hasTarget = false; enum Doing { DoingNone, - DoingJobs, DoingDir, DoingTarget, DoingConfig, @@ -386,13 +412,18 @@ static int do_build(int ac, char const* const* av) Doing doing = DoingDir; for (int i = 2; i < ac; ++i) { if (doing == DoingNative) { - nativeOptions.push_back(av[i]); - } else if ((strcmp(av[i], "-j") == 0) || - (strcmp(av[i], "--parallel") == 0)) { - jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL; - /* does the next argument start with a number? */ - if ((i + 1 < ac) && (isdigit(*av[i + 1]))) { - doing = DoingJobs; + nativeOptions.emplace_back(av[i]); + } else if (cmHasLiteralPrefix(av[i], "-j")) { + const char* nextArg = ((i + 1 < ac) ? av[i + 1] : nullptr); + jobs = extract_job_number(i, av[i], nextArg, sizeof("-j") - 1); + if (jobs < 0) { + dir.clear(); + } + } else if (cmHasLiteralPrefix(av[i], "--parallel")) { + const char* nextArg = ((i + 1 < ac) ? av[i + 1] : nullptr); + jobs = extract_job_number(i, av[i], nextArg, sizeof("--parallel") - 1); + if (jobs < 0) { + dir.clear(); } } else if (strcmp(av[i], "--target") == 0) { if (!hasTarget) { @@ -408,24 +439,16 @@ static int do_build(int ac, char const* const* av) } else if (strcmp(av[i], "--clean-first") == 0) { clean = true; doing = DoingNone; + } else if ((strcmp(av[i], "--verbose") == 0) || + (strcmp(av[i], "-v") == 0)) { + verbose = true; + doing = DoingNone; } else if (strcmp(av[i], "--use-stderr") == 0) { /* tolerate legacy option */ } else if (strcmp(av[i], "--") == 0) { doing = DoingNative; } else { switch (doing) { - case DoingJobs: { - unsigned long numJobs = 0; - if (cmSystemTools::StringToULong(av[i], &numJobs)) { - jobs = int(numJobs); - doing = DoingNone; - } else { - std::cerr << "'" << av[i - 1] << "' invalid number '" << av[i] - << "' given.\n\n"; - dir.clear(); - break; - } - } break; case DoingDir: dir = cmSystemTools::CollapseFullPath(av[i]); doing = DoingNone; @@ -476,9 +499,13 @@ static int do_build(int ac, char const* const* av) } cmake cm(cmake::RoleInternal, cmState::Unknown); - cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); - cm.SetProgressCallback(cmakemainProgressCallback, &cm); - return cm.Build(jobs, dir, target, config, nativeOptions, clean); + cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) { + cmakemainMessageCallback(msg, title, &cm); + }); + cm.SetProgressCallback([&cm](const char* msg, float prog) { + cmakemainProgressCallback(msg, prog, &cm); + }); + return cm.Build(jobs, dir, target, config, nativeOptions, clean, verbose); #endif } @@ -514,8 +541,12 @@ static int do_open(int ac, char const* const* av) } cmake cm(cmake::RoleInternal, cmState::Unknown); - cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); - cm.SetProgressCallback(cmakemainProgressCallback, &cm); + cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) { + cmakemainMessageCallback(msg, title, &cm); + }); + cm.SetProgressCallback([&cm](const char* msg, float prog) { + cmakemainProgressCallback(msg, prog, &cm); + }); return cm.Open(dir, false) ? 0 : 1; #endif } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index ee8df356f2..d20c5d23a3 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -78,7 +78,8 @@ void CMakeCommandUsage(const char* program) << " capabilities - Report capabilities built into cmake " "in JSON format\n" << " chdir dir cmd [args...] - run command in a given directory\n" - << " compare_files file1 file2 - check if file1 is same as file2\n" + << " compare_files [--ignore-eol] file1 file2\n" + << " - check if file1 is same as file2\n" << " copy <file>... destination - copy files to destination " "(either file or directory)\n" << " copy_directory <dir>... destination - copy content of <dir>... " @@ -123,7 +124,7 @@ void CMakeCommandUsage(const char* program) ; /* clang-format on */ - cmSystemTools::Error(errorStream.str().c_str()); + cmSystemTools::Error(errorStream.str()); } static bool cmTarFilesFrom(std::string const& file, @@ -132,14 +133,14 @@ static bool cmTarFilesFrom(std::string const& file, if (cmSystemTools::FileIsDirectory(file)) { std::ostringstream e; e << "-E tar --files-from= file '" << file << "' is a directory"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } cmsys::ifstream fin(file.c_str()); if (!fin) { std::ostringstream e; e << "-E tar --files-from= file '" << file << "' not found"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } std::string line; @@ -153,7 +154,7 @@ static bool cmTarFilesFrom(std::string const& file, std::ostringstream e; e << "-E tar --files-from='" << file << "' file invalid line:\n" << line << "\n"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } else { files.push_back(line); @@ -201,7 +202,7 @@ static int HandleTidy(const std::string& runCmd, const std::string& sourceFile, std::vector<std::string> tidy_cmd; cmSystemTools::ExpandListArgument(runCmd, tidy_cmd, true); tidy_cmd.push_back(sourceFile); - tidy_cmd.push_back("--"); + tidy_cmd.emplace_back("--"); tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end()); // Run the tidy command line. Capture its stdout and hide its stderr. @@ -228,9 +229,9 @@ static int HandleLWYU(const std::string& runCmd, // Construct the ldd -r -u (link what you use lwyu) command line // ldd -u -r lwuy target std::vector<std::string> lwyu_cmd; - lwyu_cmd.push_back("ldd"); - lwyu_cmd.push_back("-u"); - lwyu_cmd.push_back("-r"); + lwyu_cmd.emplace_back("ldd"); + lwyu_cmd.emplace_back("-u"); + lwyu_cmd.emplace_back("-r"); lwyu_cmd.push_back(runCmd); // Run the ldd -u -r command line. @@ -481,8 +482,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // If error occurs we want to continue copying next files. bool return_value = false; for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { - if (!cmSystemTools::cmCopyFile(args[cc].c_str(), - args.back().c_str())) { + if (!cmSystemTools::cmCopyFile(args[cc], args.back())) { std::cerr << "Error copying file \"" << args[cc] << "\" to \"" << args.back() << "\".\n"; return_value = true; @@ -504,8 +504,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // If error occurs we want to continue copying next files. bool return_value = false; for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { - if (!cmSystemTools::CopyFileIfDifferent(args[cc].c_str(), - args.back().c_str())) { + if (!cmSystemTools::CopyFileIfDifferent(args[cc], args.back())) { std::cerr << "Error copying file (if different) from \"" << args[cc] << "\" to \"" << args.back() << "\".\n"; return_value = true; @@ -530,7 +529,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Rename a file or directory if (args[1] == "rename" && args.size() == 4) { - if (!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str())) { + if (!cmSystemTools::RenameFile(args[2], args[3])) { std::string e = cmSystemTools::GetLastSystemError(); std::cerr << "Error renaming from \"" << args[2] << "\" to \"" << args[3] << "\": " << e << "\n"; @@ -540,10 +539,20 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Compare files - if (args[1] == "compare_files" && args.size() == 4) { - if (cmSystemTools::FilesDiffer(args[2], args[3])) { - std::cerr << "Files \"" << args[2] << "\" to \"" << args[3] - << "\" are different.\n"; + if (args[1] == "compare_files" && (args.size() == 4 || args.size() == 5)) { + bool filesDiffer; + if (args.size() == 4) { + filesDiffer = cmSystemTools::FilesDiffer(args[2], args[3]); + } else if (args[2] == "--ignore-eol") { + filesDiffer = cmsys::SystemTools::TextFilesDiffer(args[3], args[4]); + } else { + ::CMakeCommandUsage(args[0].c_str()); + return 1; + } + + if (filesDiffer) { + std::cerr << "Files \"" << args[args.size() - 2] << "\" to \"" + << args[args.size() - 1] << "\" are different.\n"; return 1; } return 0; @@ -964,8 +973,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mf)); // Actually scan dependencies. - return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0 - : 2; + return lgd->UpdateDependencies(depInfo, verbose, color) ? 0 : 2; } return 1; } @@ -1173,7 +1181,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if (server.Serve(&errorMessage)) { return 0; } - cmSystemTools::Error(errorMessage.c_str()); + cmSystemTools::Error(errorMessage); #else static_cast<void>(supportExperimental); static_cast<void>(isDebug); @@ -1294,7 +1302,7 @@ bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link) cmSystemTools::RemoveFile(link); } #if defined(_WIN32) && !defined(__CYGWIN__) - return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str()); + return cmSystemTools::CopyFileAlways(file, link); #else std::string linktext = cmSystemTools::GetFilenameName(file); return cmSystemTools::CreateSymlink(linktext, link); @@ -1351,8 +1359,8 @@ static void cmcmdProgressReport(std::string const& dir, std::string const& num) int cmcmd::ExecuteEchoColor(std::vector<std::string>& args) { // The arguments are - // argv[0] == <cmake-executable> - // argv[1] == cmake_echo_color + // args[0] == <cmake-executable> + // args[1] == cmake_echo_color bool enabled = true; int color = cmsysTerminal_Color_Normal; @@ -1409,10 +1417,10 @@ int cmcmd::ExecuteEchoColor(std::vector<std::string>& args) int cmcmd::ExecuteLinkScript(std::vector<std::string>& args) { // The arguments are - // argv[0] == <cmake-executable> - // argv[1] == cmake_link_script - // argv[2] == <link-script-name> - // argv[3] == --verbose=? + // args[0] == <cmake-executable> + // args[1] == cmake_link_script + // args[2] == <link-script-name> + // args[3] == --verbose=? bool verbose = false; if (args.size() >= 4) { if (args[3].find("--verbose=") == 0) { @@ -1733,7 +1741,7 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg, } if (this->LinkGeneratesManifest) { - this->LinkCommand.push_back("/MANIFEST"); + this->LinkCommand.emplace_back("/MANIFEST"); this->LinkCommand.push_back("/MANIFESTFILE:" + this->LinkerManifestFile); } @@ -1881,8 +1889,8 @@ int cmVSLink::RunMT(std::string const& out, bool notify) { std::vector<std::string> mtCommand; mtCommand.push_back(this->MtPath.empty() ? "mt" : this->MtPath); - mtCommand.push_back("/nologo"); - mtCommand.push_back("/manifest"); + mtCommand.emplace_back("/nologo"); + mtCommand.emplace_back("/manifest"); if (this->LinkGeneratesManifest) { mtCommand.push_back(this->LinkerManifestFile); } @@ -1892,7 +1900,7 @@ int cmVSLink::RunMT(std::string const& out, bool notify) if (notify) { // Add an undocumented option that enables a special return // code to notify us when the manifest is modified. - mtCommand.push_back("/notify_update"); + mtCommand.emplace_back("/notify_update"); } int mtRet = 0; if (!RunCommand("MT", mtCommand, this->Verbose, FORMAT_HEX, &mtRet, diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 8ba126fbe3..4a2531a4e6 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -208,7 +208,7 @@ int main(int argc, char const* const* argv) std::vector<std::string> args; args.reserve(argc); for (int i = 0; i < argc; ++i) { - args.push_back(argv[i]); + args.emplace_back(argv[i]); } // run ctest std::string output; diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index a2fcc16abf..b33aa80291 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -454,6 +454,10 @@ ELSE() SET(KWSYS_LIBRARY_TYPE STATIC) ENDIF() +if(NOT DEFINED KWSYS_BUILD_PIC) + set(KWSYS_BUILD_PIC 0) +endif() + #----------------------------------------------------------------------------- # Configure some implementation details. @@ -870,7 +874,7 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) SET(KWSYS_LINK_DEPENDENCY INTERFACE) ADD_LIBRARY(${KWSYS_TARGET_OBJECT} OBJECT ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) - IF(KWSYS_BUILD_SHARED) + IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC) SET_PROPERTY(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY POSITION_INDEPENDENT_CODE TRUE) ENDIF() @@ -965,7 +969,7 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) ${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK}) SET(KWSYS_LINK_DEPENDENCY INTERFACE) ADD_LIBRARY(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS}) - IF(KWSYS_BUILD_SHARED) + IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC) SET_PROPERTY(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY POSITION_INDEPENDENT_CODE TRUE) ENDIF() diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index d368fa29f3..6c12355de7 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -3871,7 +3871,8 @@ SystemInformation::LongLong SystemInformationImplementation::GetProcessId() { #if defined(_WIN32) return GetCurrentProcessId(); -#elif defined(__linux) || defined(__APPLE__) +#elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || \ + defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) return getpid(); #else return -1; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index c5160a993a..cbdfe11759 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2161,6 +2161,32 @@ bool SystemTools::FilesDiffer(const std::string& source, return false; } +bool SystemTools::TextFilesDiffer(const std::string& path1, + const std::string& path2) +{ + kwsys::ifstream if1(path1.c_str()); + kwsys::ifstream if2(path2.c_str()); + if (!if1 || !if2) { + return true; + } + + for (;;) { + std::string line1, line2; + bool hasData1 = GetLineFromStream(if1, line1); + bool hasData2 = GetLineFromStream(if2, line2); + if (hasData1 != hasData2) { + return true; + } + if (!hasData1) { + break; + } + if (line1 != line2) { + return true; + } + } + return false; +} + /** * Blockwise copy source to destination file */ @@ -2979,10 +3005,36 @@ bool SystemTools::FileIsDirectory(const std::string& inName) bool SystemTools::FileIsSymlink(const std::string& name) { #if defined(_WIN32) - DWORD attr = - GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str()); + std::wstring path = Encoding::ToWindowsExtendedPath(name); + DWORD attr = GetFileAttributesW(path.c_str()); if (attr != INVALID_FILE_ATTRIBUTES) { - return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0; + if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + // FILE_ATTRIBUTE_REPARSE_POINT means: + // * a file or directory that has an associated reparse point, or + // * a file that is a symbolic link. + HANDLE hFile = CreateFileW( + path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + return false; + } + byte buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; + DWORD bytesReturned = 0; + if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer, + MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned, + NULL)) { + CloseHandle(hFile); + // Since FILE_ATTRIBUTE_REPARSE_POINT is set this file must be + // a symbolic link if it is not a reparse point. + return GetLastError() == ERROR_NOT_A_REPARSE_POINT; + } + CloseHandle(hFile); + ULONG reparseTag = + reinterpret_cast<PREPARSE_GUID_DATA_BUFFER>(&buffer[0])->ReparseTag; + return (reparseTag == IO_REPARSE_TAG_SYMLINK) || + (reparseTag == IO_REPARSE_TAG_MOUNT_POINT); + } + return false; } else { return false; } diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 8d1f78cf73..1967860ab4 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -579,6 +579,13 @@ public: const std::string& destination); /** + * Compare the contents of two files, ignoring line ending differences. + * Return true if different + */ + static bool TextFilesDiffer(const std::string& path1, + const std::string& path2); + + /** * Return true if the two files are the same file */ static bool SameFile(const std::string& file1, const std::string& file2); diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 0477d5937a..9a40b53302 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -984,6 +984,50 @@ static bool CheckGetLineFromStreamLongLine() return true; } +static bool writeFile(const char* fileName, const char* data) +{ + kwsys::ofstream out(fileName, std::ios::binary); + out << data; + if (!out) { + std::cerr << "Failed to write file: " << fileName << std::endl; + return false; + } + return true; +} + +static bool CheckTextFilesDiffer() +{ + struct + { + const char* a; + const char* b; + bool differ; + } test_cases[] = { { "one", "one", false }, + { "one", "two", true }, + { "", "", false }, + { "\n", "\r\n", false }, + { "one\n", "one\n", false }, + { "one\r\n", "one\n", false }, + { "one\n", "one", false }, + { "one\ntwo", "one\ntwo", false }, + { "one\ntwo", "one\r\ntwo", false } }; + const int num_test_cases = sizeof(test_cases) / sizeof(test_cases[0]); + for (int i = 0; i < num_test_cases; ++i) { + if (!writeFile("file_a", test_cases[i].a) || + !writeFile("file_b", test_cases[i].b)) { + return false; + } + if (kwsys::SystemTools::TextFilesDiffer("file_a", "file_b") != + test_cases[i].differ) { + std::cerr << "Incorrect TextFilesDiffer result for test case " << i + 1 + << "." << std::endl; + return false; + } + } + + return true; +} + int testSystemTools(int, char* []) { bool res = true; @@ -1027,5 +1071,7 @@ int testSystemTools(int, char* []) res &= CheckGetFilenameName(); + res &= CheckTextFilesDiffer(); + return res ? 0 : 1; } diff --git a/Templates/MSBuild/FlagTables/v142_CL.json b/Templates/MSBuild/FlagTables/v142_CL.json new file mode 100644 index 0000000000..95b9d14f61 --- /dev/null +++ b/Templates/MSBuild/FlagTables/v142_CL.json @@ -0,0 +1,1212 @@ +[ + { + "name": "DebugInformationFormat", + "switch": "", + "comment": "None", + "value": "None", + "flags": [] + }, + { + "name": "DebugInformationFormat", + "switch": "Z7", + "comment": "C7 compatible", + "value": "OldStyle", + "flags": [] + }, + { + "name": "DebugInformationFormat", + "switch": "Zi", + "comment": "Program Database", + "value": "ProgramDatabase", + "flags": [] + }, + { + "name": "DebugInformationFormat", + "switch": "ZI", + "comment": "Program Database for Edit And Continue", + "value": "EditAndContinue", + "flags": [] + }, + { + "name": "CompileAsManaged", + "switch": "", + "comment": "No Common Language RunTime Support", + "value": "false", + "flags": [] + }, + { + "name": "CompileAsManaged", + "switch": "clr", + "comment": "Common Language RunTime Support", + "value": "true", + "flags": [] + }, + { + "name": "CompileAsManaged", + "switch": "clr:pure", + "comment": "Pure MSIL Common Language RunTime Support", + "value": "Pure", + "flags": [] + }, + { + "name": "CompileAsManaged", + "switch": "clr:safe", + "comment": "Safe MSIL Common Language RunTime Support", + "value": "Safe", + "flags": [] + }, + { + "name": "WarningLevel", + "switch": "W0", + "comment": "Turn Off All Warnings", + "value": "TurnOffAllWarnings", + "flags": [] + }, + { + "name": "WarningLevel", + "switch": "W1", + "comment": "Level1", + "value": "Level1", + "flags": [] + }, + { + "name": "WarningLevel", + "switch": "W2", + "comment": "Level2", + "value": "Level2", + "flags": [] + }, + { + "name": "WarningLevel", + "switch": "W3", + "comment": "Level3", + "value": "Level3", + "flags": [] + }, + { + "name": "WarningLevel", + "switch": "W4", + "comment": "Level4", + "value": "Level4", + "flags": [] + }, + { + "name": "WarningLevel", + "switch": "Wall", + "comment": "EnableAllWarnings", + "value": "EnableAllWarnings", + "flags": [] + }, + { + "name": "DiagnosticsFormat", + "switch": "diagnostics:caret", + "comment": "Caret", + "value": "Caret", + "flags": [] + }, + { + "name": "DiagnosticsFormat", + "switch": "diagnostics:column", + "comment": "Column Info", + "value": "Column", + "flags": [] + }, + { + "name": "DiagnosticsFormat", + "switch": "diagnostics:classic", + "comment": "Classic", + "value": "Classic", + "flags": [] + }, + { + "name": "Optimization", + "switch": "", + "comment": "Custom", + "value": "Custom", + "flags": [] + }, + { + "name": "Optimization", + "switch": "Od", + "comment": "Disabled", + "value": "Disabled", + "flags": [] + }, + { + "name": "Optimization", + "switch": "O1", + "comment": "Maximum Optimization (Favor Size)", + "value": "MinSpace", + "flags": [] + }, + { + "name": "Optimization", + "switch": "O2", + "comment": "Maximum Optimization (Favor Speed)", + "value": "MaxSpeed", + "flags": [] + }, + { + "name": "Optimization", + "switch": "Ox", + "comment": "Optimizations (Favor Speed)", + "value": "Full", + "flags": [] + }, + { + "name": "InlineFunctionExpansion", + "switch": "", + "comment": "Default", + "value": "Default", + "flags": [] + }, + { + "name": "InlineFunctionExpansion", + "switch": "Ob0", + "comment": "Disabled", + "value": "Disabled", + "flags": [] + }, + { + "name": "InlineFunctionExpansion", + "switch": "Ob1", + "comment": "Only __inline", + "value": "OnlyExplicitInline", + "flags": [] + }, + { + "name": "InlineFunctionExpansion", + "switch": "Ob2", + "comment": "Any Suitable", + "value": "AnySuitable", + "flags": [] + }, + { + "name": "FavorSizeOrSpeed", + "switch": "Os", + "comment": "Favor small code", + "value": "Size", + "flags": [] + }, + { + "name": "FavorSizeOrSpeed", + "switch": "Ot", + "comment": "Favor fast code", + "value": "Speed", + "flags": [] + }, + { + "name": "FavorSizeOrSpeed", + "switch": "", + "comment": "Neither", + "value": "Neither", + "flags": [] + }, + { + "name": "ExceptionHandling", + "switch": "EHa", + "comment": "Yes with SEH Exceptions", + "value": "Async", + "flags": [] + }, + { + "name": "ExceptionHandling", + "switch": "EHsc", + "comment": "Yes", + "value": "Sync", + "flags": [] + }, + { + "name": "ExceptionHandling", + "switch": "EHs", + "comment": "Yes with Extern C functions", + "value": "SyncCThrow", + "flags": [] + }, + { + "name": "ExceptionHandling", + "switch": "", + "comment": "No", + "value": "false", + "flags": [] + }, + { + "name": "BasicRuntimeChecks", + "switch": "RTCs", + "comment": "Stack Frames", + "value": "StackFrameRuntimeCheck", + "flags": [] + }, + { + "name": "BasicRuntimeChecks", + "switch": "RTCu", + "comment": "Uninitialized variables", + "value": "UninitializedLocalUsageCheck", + "flags": [] + }, + { + "name": "BasicRuntimeChecks", + "switch": "RTC1", + "comment": "Both (/RTC1, equiv. to /RTCsu)", + "value": "EnableFastChecks", + "flags": [] + }, + { + "name": "BasicRuntimeChecks", + "switch": "", + "comment": "Default", + "value": "Default", + "flags": [] + }, + { + "name": "RuntimeLibrary", + "switch": "MT", + "comment": "Multi-threaded", + "value": "MultiThreaded", + "flags": [] + }, + { + "name": "RuntimeLibrary", + "switch": "MTd", + "comment": "Multi-threaded Debug", + "value": "MultiThreadedDebug", + "flags": [] + }, + { + "name": "RuntimeLibrary", + "switch": "MD", + "comment": "Multi-threaded DLL", + "value": "MultiThreadedDLL", + "flags": [] + }, + { + "name": "RuntimeLibrary", + "switch": "MDd", + "comment": "Multi-threaded Debug DLL", + "value": "MultiThreadedDebugDLL", + "flags": [] + }, + { + "name": "StructMemberAlignment", + "switch": "Zp1", + "comment": "1 Byte", + "value": "1Byte", + "flags": [] + }, + { + "name": "StructMemberAlignment", + "switch": "Zp2", + "comment": "2 Bytes", + "value": "2Bytes", + "flags": [] + }, + { + "name": "StructMemberAlignment", + "switch": "Zp4", + "comment": "4 Byte", + "value": "4Bytes", + "flags": [] + }, + { + "name": "StructMemberAlignment", + "switch": "Zp8", + "comment": "8 Bytes", + "value": "8Bytes", + "flags": [] + }, + { + "name": "StructMemberAlignment", + "switch": "Zp16", + "comment": "16 Bytes", + "value": "16Bytes", + "flags": [] + }, + { + "name": "StructMemberAlignment", + "switch": "", + "comment": "Default", + "value": "Default", + "flags": [] + }, + { + "name": "BufferSecurityCheck", + "switch": "GS-", + "comment": "Disable Security Check", + "value": "false", + "flags": [] + }, + { + "name": "BufferSecurityCheck", + "switch": "GS", + "comment": "Enable Security Check", + "value": "true", + "flags": [] + }, + { + "name": "ControlFlowGuard", + "switch": "guard:cf", + "comment": "Yes", + "value": "Guard", + "flags": [] + }, + { + "name": "ControlFlowGuard", + "switch": "", + "comment": "No", + "value": "false", + "flags": [] + }, + { + "name": "EnableEnhancedInstructionSet", + "switch": "arch:SSE", + "comment": "Streaming SIMD Extensions", + "value": "StreamingSIMDExtensions", + "flags": [] + }, + { + "name": "EnableEnhancedInstructionSet", + "switch": "arch:SSE2", + "comment": "Streaming SIMD Extensions 2", + "value": "StreamingSIMDExtensions2", + "flags": [] + }, + { + "name": "EnableEnhancedInstructionSet", + "switch": "arch:AVX", + "comment": "Advanced Vector Extensions", + "value": "AdvancedVectorExtensions", + "flags": [] + }, + { + "name": "EnableEnhancedInstructionSet", + "switch": "arch:AVX2", + "comment": "Advanced Vector Extensions 2", + "value": "AdvancedVectorExtensions2", + "flags": [] + }, + { + "name": "EnableEnhancedInstructionSet", + "switch": "arch:IA32", + "comment": "No Enhanced Instructions", + "value": "NoExtensions", + "flags": [] + }, + { + "name": "EnableEnhancedInstructionSet", + "switch": "", + "comment": "Not Set", + "value": "NotSet", + "flags": [] + }, + { + "name": "FloatingPointModel", + "switch": "fp:precise", + "comment": "Precise", + "value": "Precise", + "flags": [] + }, + { + "name": "FloatingPointModel", + "switch": "fp:strict", + "comment": "Strict", + "value": "Strict", + "flags": [] + }, + { + "name": "FloatingPointModel", + "switch": "fp:fast", + "comment": "Fast", + "value": "Fast", + "flags": [] + }, + { + "name": "SpectreMitigation", + "switch": "Qspectre-", + "comment": "Spectre mitigations disabled", + "value": "false", + "flags": [] + }, + { + "name": "SpectreMitigation", + "switch": "Qspectre", + "comment": "Spectre mitigations enabled", + "value": "Spectre", + "flags": [] + }, + { + "name": "LanguageStandard", + "switch": "std:c++14", + "comment": "ISO C++14 Standard", + "value": "stdcpp14", + "flags": [] + }, + { + "name": "LanguageStandard", + "switch": "std:c++17", + "comment": "ISO C++17 Standard", + "value": "stdcpp17", + "flags": [] + }, + { + "name": "LanguageStandard", + "switch": "std:c++latest", + "comment": "Preview - Features from the Latest C++ Working Draft", + "value": "stdcpplatest", + "flags": [] + }, + { + "name": "PrecompiledHeader", + "switch": "Yc", + "comment": "Create", + "value": "Create", + "flags": [ + "UserValue", + "UserIgnored", + "Continue" + ] + }, + { + "name": "PrecompiledHeader", + "switch": "Yu", + "comment": "Use", + "value": "Use", + "flags": [ + "UserValue", + "UserIgnored", + "Continue" + ] + }, + { + "name": "PrecompiledHeader", + "switch": "Y-", + "comment": "Not Using Precompiled Headers", + "value": "NotUsing", + "flags": [] + }, + { + "name": "AssemblerOutput", + "switch": "", + "comment": "No Listing", + "value": "NoListing", + "flags": [] + }, + { + "name": "AssemblerOutput", + "switch": "FA", + "comment": "Assembly-Only Listing", + "value": "AssemblyCode", + "flags": [] + }, + { + "name": "AssemblerOutput", + "switch": "FAc", + "comment": "Assembly With Machine Code", + "value": "AssemblyAndMachineCode", + "flags": [] + }, + { + "name": "AssemblerOutput", + "switch": "FAs", + "comment": "Assembly With Source Code", + "value": "AssemblyAndSourceCode", + "flags": [] + }, + { + "name": "AssemblerOutput", + "switch": "FAcs", + "comment": "Assembly, Machine Code and Source", + "value": "All", + "flags": [] + }, + { + "name": "CallingConvention", + "switch": "Gd", + "comment": "__cdecl", + "value": "Cdecl", + "flags": [] + }, + { + "name": "CallingConvention", + "switch": "Gr", + "comment": "__fastcall", + "value": "FastCall", + "flags": [] + }, + { + "name": "CallingConvention", + "switch": "Gz", + "comment": "__stdcall", + "value": "StdCall", + "flags": [] + }, + { + "name": "CallingConvention", + "switch": "Gv", + "comment": "__vectorcall", + "value": "VectorCall", + "flags": [] + }, + { + "name": "CompileAs", + "switch": "", + "comment": "Default", + "value": "Default", + "flags": [] + }, + { + "name": "CompileAs", + "switch": "TC", + "comment": "Compile as C Code", + "value": "CompileAsC", + "flags": [] + }, + { + "name": "CompileAs", + "switch": "TP", + "comment": "Compile as C++ Code", + "value": "CompileAsCpp", + "flags": [] + }, + { + "name": "ErrorReporting", + "switch": "errorReport:none", + "comment": "Do Not Send Report", + "value": "None", + "flags": [] + }, + { + "name": "ErrorReporting", + "switch": "errorReport:prompt", + "comment": "Prompt Immediately", + "value": "Prompt", + "flags": [] + }, + { + "name": "ErrorReporting", + "switch": "errorReport:queue", + "comment": "Queue For Next Login", + "value": "Queue", + "flags": [] + }, + { + "name": "ErrorReporting", + "switch": "errorReport:send", + "comment": "Send Automatically", + "value": "Send", + "flags": [] + }, + { + "name": "SupportJustMyCode", + "switch": "JMC-", + "comment": "Support Just My Code Debugging", + "value": "false", + "flags": [] + }, + { + "name": "SupportJustMyCode", + "switch": "JMC", + "comment": "Support Just My Code Debugging", + "value": "true", + "flags": [] + }, + { + "name": "CompileAsWinRT", + "switch": "ZW", + "comment": "Consume Windows Runtime Extension", + "value": "true", + "flags": [] + }, + { + "name": "WinRTNoStdLib", + "switch": "ZW:nostdlib", + "comment": "No Standard WinRT Libraries", + "value": "true", + "flags": [] + }, + { + "name": "SuppressStartupBanner", + "switch": "nologo", + "comment": "Suppress Startup Banner", + "value": "true", + "flags": [] + }, + { + "name": "TreatWarningAsError", + "switch": "WX-", + "comment": "Treat Warnings As Errors", + "value": "false", + "flags": [] + }, + { + "name": "TreatWarningAsError", + "switch": "WX", + "comment": "Treat Warnings As Errors", + "value": "true", + "flags": [] + }, + { + "name": "SDLCheck", + "switch": "sdl-", + "comment": "SDL checks", + "value": "false", + "flags": [] + }, + { + "name": "SDLCheck", + "switch": "sdl", + "comment": "SDL checks", + "value": "true", + "flags": [] + }, + { + "name": "MultiProcessorCompilation", + "switch": "MP", + "comment": "Multi-processor Compilation", + "value": "true", + "flags": [ + "UserValue", + "UserIgnored", + "Continue" + ] + }, + { + "name": "IntrinsicFunctions", + "switch": "Oi", + "comment": "Enable Intrinsic Functions", + "value": "true", + "flags": [] + }, + { + "name": "OmitFramePointers", + "switch": "Oy-", + "comment": "Omit Frame Pointers", + "value": "false", + "flags": [] + }, + { + "name": "OmitFramePointers", + "switch": "Oy", + "comment": "Omit Frame Pointers", + "value": "true", + "flags": [] + }, + { + "name": "EnableFiberSafeOptimizations", + "switch": "GT", + "comment": "Enable Fiber-Safe Optimizations", + "value": "true", + "flags": [] + }, + { + "name": "WholeProgramOptimization", + "switch": "GL", + "comment": "Whole Program Optimization", + "value": "true", + "flags": [] + }, + { + "name": "UndefineAllPreprocessorDefinitions", + "switch": "u", + "comment": "Undefine All Preprocessor Definitions", + "value": "true", + "flags": [] + }, + { + "name": "IgnoreStandardIncludePath", + "switch": "X", + "comment": "Ignore Standard Include Paths", + "value": "true", + "flags": [] + }, + { + "name": "PreprocessToFile", + "switch": "P", + "comment": "Preprocess to a File", + "value": "true", + "flags": [] + }, + { + "name": "PreprocessSuppressLineNumbers", + "switch": "EP", + "comment": "Preprocess Suppress Line Numbers", + "value": "true", + "flags": [] + }, + { + "name": "PreprocessKeepComments", + "switch": "C", + "comment": "Keep Comments", + "value": "true", + "flags": [] + }, + { + "name": "StringPooling", + "switch": "GF-", + "comment": "Enable String Pooling", + "value": "false", + "flags": [] + }, + { + "name": "StringPooling", + "switch": "GF", + "comment": "Enable String Pooling", + "value": "true", + "flags": [] + }, + { + "name": "MinimalRebuild", + "switch": "Gm-", + "comment": "Enable Minimal Rebuild", + "value": "false", + "flags": [] + }, + { + "name": "MinimalRebuild", + "switch": "Gm", + "comment": "Enable Minimal Rebuild", + "value": "true", + "flags": [] + }, + { + "name": "SmallerTypeCheck", + "switch": "RTCc", + "comment": "Smaller Type Check", + "value": "true", + "flags": [] + }, + { + "name": "FunctionLevelLinking", + "switch": "Gy-", + "comment": "Enable Function-Level Linking", + "value": "false", + "flags": [] + }, + { + "name": "FunctionLevelLinking", + "switch": "Gy", + "comment": "Enable Function-Level Linking", + "value": "true", + "flags": [] + }, + { + "name": "EnableParallelCodeGeneration", + "switch": "Qpar-", + "comment": "Enable Parallel Code Generation", + "value": "false", + "flags": [] + }, + { + "name": "EnableParallelCodeGeneration", + "switch": "Qpar", + "comment": "Enable Parallel Code Generation", + "value": "true", + "flags": [] + }, + { + "name": "FloatingPointExceptions", + "switch": "fp:except-", + "comment": "Enable Floating Point Exceptions", + "value": "false", + "flags": [] + }, + { + "name": "FloatingPointExceptions", + "switch": "fp:except", + "comment": "Enable Floating Point Exceptions", + "value": "true", + "flags": [] + }, + { + "name": "CreateHotpatchableImage", + "switch": "hotpatch", + "comment": "Create Hotpatchable Image", + "value": "true", + "flags": [] + }, + { + "name": "DisableLanguageExtensions", + "switch": "Za", + "comment": "Disable Language Extensions", + "value": "true", + "flags": [] + }, + { + "name": "ConformanceMode", + "switch": "permissive-", + "comment": "Conformance mode enabled", + "value": "true", + "flags": [] + }, + { + "name": "ConformanceMode", + "switch": "permissive", + "comment": "Conformance mode disabled", + "value": "false", + "flags": [] + }, + { + "name": "TreatWChar_tAsBuiltInType", + "switch": "Zc:wchar_t-", + "comment": "Treat WChar_t As Built in Type", + "value": "false", + "flags": [] + }, + { + "name": "TreatWChar_tAsBuiltInType", + "switch": "Zc:wchar_t", + "comment": "Treat WChar_t As Built in Type", + "value": "true", + "flags": [] + }, + { + "name": "ForceConformanceInForLoopScope", + "switch": "Zc:forScope-", + "comment": "Force Conformance in For Loop Scope", + "value": "false", + "flags": [] + }, + { + "name": "ForceConformanceInForLoopScope", + "switch": "Zc:forScope", + "comment": "Force Conformance in For Loop Scope", + "value": "true", + "flags": [] + }, + { + "name": "RemoveUnreferencedCodeData", + "switch": "Zc:inline-", + "comment": "Remove unreferenced code and data", + "value": "false", + "flags": [] + }, + { + "name": "RemoveUnreferencedCodeData", + "switch": "Zc:inline", + "comment": "Remove unreferenced code and data", + "value": "true", + "flags": [] + }, + { + "name": "EnforceTypeConversionRules", + "switch": "Zc:rvalueCast-", + "comment": "Enforce type conversion rules", + "value": "false", + "flags": [] + }, + { + "name": "EnforceTypeConversionRules", + "switch": "Zc:rvalueCast", + "comment": "Enforce type conversion rules", + "value": "true", + "flags": [] + }, + { + "name": "RuntimeTypeInfo", + "switch": "GR-", + "comment": "Enable Run-Time Type Information", + "value": "false", + "flags": [] + }, + { + "name": "RuntimeTypeInfo", + "switch": "GR", + "comment": "Enable Run-Time Type Information", + "value": "true", + "flags": [] + }, + { + "name": "OpenMPSupport", + "switch": "openmp-", + "comment": "Open MP Support", + "value": "false", + "flags": [] + }, + { + "name": "OpenMPSupport", + "switch": "openmp", + "comment": "Open MP Support", + "value": "true", + "flags": [] + }, + { + "name": "EnableModules", + "switch": "experimental:module", + "comment": "Enable C++ Modules (experimental)", + "value": "true", + "flags": [] + }, + { + "name": "ExpandAttributedSource", + "switch": "Fx", + "comment": "Expand Attributed Source", + "value": "true", + "flags": [] + }, + { + "name": "UseUnicodeForAssemblerListing", + "switch": "FAu", + "comment": "Use Unicode For Assembler Listing", + "value": "true", + "flags": [] + }, + { + "name": "GenerateXMLDocumentationFiles", + "switch": "doc", + "comment": "Generate XML Documentation Files", + "value": "true", + "flags": [ + "UserValue", + "UserIgnored", + "Continue" + ] + }, + { + "name": "BrowseInformation", + "switch": "FR", + "comment": "Enable Browse Information", + "value": "true", + "flags": [ + "UserValue", + "UserIgnored", + "Continue" + ] + }, + { + "name": "ShowIncludes", + "switch": "showIncludes", + "comment": "Show Includes", + "value": "true", + "flags": [] + }, + { + "name": "EnablePREfast", + "switch": "analyze-", + "comment": "Enable Code Analysis", + "value": "false", + "flags": [] + }, + { + "name": "EnablePREfast", + "switch": "analyze", + "comment": "Enable Code Analysis", + "value": "true", + "flags": [] + }, + { + "name": "UseFullPaths", + "switch": "FC", + "comment": "Use Full Paths", + "value": "true", + "flags": [] + }, + { + "name": "OmitDefaultLibName", + "switch": "Zl", + "comment": "Omit Default Library Name", + "value": "true", + "flags": [] + }, + { + "name": "AdditionalIncludeDirectories", + "switch": "I", + "comment": "Additional Include Directories", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "AdditionalUsingDirectories", + "switch": "AI", + "comment": "Additional #using Directories", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "PreprocessorDefinitions", + "switch": "D", + "comment": "Preprocessor Definitions", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "UndefinePreprocessorDefinitions", + "switch": "U", + "comment": "Undefine Preprocessor Definitions", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "DisableSpecificWarnings", + "switch": "wd", + "comment": "Disable Specific Warnings", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "ForcedIncludeFiles", + "switch": "FI", + "comment": "Forced Include File", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "ForcedUsingFiles", + "switch": "FU", + "comment": "Forced #using File", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "PREfastLog", + "switch": "analyze:log", + "comment": "Code Analysis Log", + "value": "", + "flags": [ + "UserFollowing" + ] + }, + { + "name": "PREfastAdditionalPlugins", + "switch": "analyze:plugin", + "comment": "Additional Code Analysis Native plugins", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "TreatSpecificWarningsAsErrors", + "switch": "we", + "comment": "Treat Specific Warnings As Errors", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "WarningVersion", + "switch": "Wv:", + "comment": "Warning Version", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "PreprocessOutputPath", + "switch": "Fi", + "comment": "Preprocess Output Path", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "PrecompiledHeaderFile", + "switch": "Yu", + "comment": "Precompiled Header File", + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] + }, + { + "name": "PrecompiledHeaderFile", + "switch": "Yc", + "comment": "Precompiled Header File", + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] + }, + { + "name": "PrecompiledHeaderOutputFile", + "switch": "Fp", + "comment": "Precompiled Header Output File", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "AssemblerListingLocation", + "switch": "Fa", + "comment": "ASM List Location", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "ObjectFileName", + "switch": "Fo", + "comment": "Object File Name", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "ProgramDataBaseFileName", + "switch": "Fd", + "comment": "Program Database File Name", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "XMLDocumentationFileName", + "switch": "doc", + "comment": "XML Documentation File Name", + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] + }, + { + "name": "BrowseInformationFile", + "switch": "FR", + "comment": "Browse Information File", + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] + }, + { + "name": "ProcessorNumber", + "switch": "MP", + "comment": "Number of processors", + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] + } +] diff --git a/Templates/MSBuild/FlagTables/v142_Link.json b/Templates/MSBuild/FlagTables/v142_Link.json new file mode 100644 index 0000000000..66ee76fcb4 --- /dev/null +++ b/Templates/MSBuild/FlagTables/v142_Link.json @@ -0,0 +1,1323 @@ +[ + { + "name": "ShowProgress", + "switch": "", + "comment": "Not Set", + "value": "NotSet", + "flags": [] + }, + { + "name": "ShowProgress", + "switch": "VERBOSE", + "comment": "Display all progress messages", + "value": "LinkVerbose", + "flags": [] + }, + { + "name": "ShowProgress", + "switch": "VERBOSE:Lib", + "comment": "For Libraries Searched", + "value": "LinkVerboseLib", + "flags": [] + }, + { + "name": "ShowProgress", + "switch": "VERBOSE:ICF", + "comment": "About COMDAT folding during optimized linking", + "value": "LinkVerboseICF", + "flags": [] + }, + { + "name": "ShowProgress", + "switch": "VERBOSE:REF", + "comment": "About data removed during optimized linking", + "value": "LinkVerboseREF", + "flags": [] + }, + { + "name": "ShowProgress", + "switch": "VERBOSE:SAFESEH", + "comment": "About Modules incompatible with SEH", + "value": "LinkVerboseSAFESEH", + "flags": [] + }, + { + "name": "ShowProgress", + "switch": "VERBOSE:CLR", + "comment": "About linker activity related to managed code", + "value": "LinkVerboseCLR", + "flags": [] + }, + { + "name": "ForceFileOutput", + "switch": "FORCE", + "comment": "Enabled", + "value": "Enabled", + "flags": [] + }, + { + "name": "ForceFileOutput", + "switch": "FORCE:MULTIPLE", + "comment": "Multiply Defined Symbol Only", + "value": "MultiplyDefinedSymbolOnly", + "flags": [] + }, + { + "name": "ForceFileOutput", + "switch": "FORCE:UNRESOLVED", + "comment": "Undefined Symbol Only", + "value": "UndefinedSymbolOnly", + "flags": [] + }, + { + "name": "CreateHotPatchableImage", + "switch": "FUNCTIONPADMIN", + "comment": "Enabled", + "value": "Enabled", + "flags": [] + }, + { + "name": "CreateHotPatchableImage", + "switch": "FUNCTIONPADMIN:5", + "comment": "X86 Image Only", + "value": "X86Image", + "flags": [] + }, + { + "name": "CreateHotPatchableImage", + "switch": "FUNCTIONPADMIN:6", + "comment": "X64 Image Only", + "value": "X64Image", + "flags": [] + }, + { + "name": "CreateHotPatchableImage", + "switch": "FUNCTIONPADMIN:16", + "comment": "Itanium Image Only", + "value": "ItaniumImage", + "flags": [] + }, + { + "name": "UACExecutionLevel", + "switch": "level='asInvoker'", + "comment": "asInvoker", + "value": "AsInvoker", + "flags": [] + }, + { + "name": "UACExecutionLevel", + "switch": "level='highestAvailable'", + "comment": "highestAvailable", + "value": "HighestAvailable", + "flags": [] + }, + { + "name": "UACExecutionLevel", + "switch": "level='requireAdministrator'", + "comment": "requireAdministrator", + "value": "RequireAdministrator", + "flags": [] + }, + { + "name": "GenerateDebugInformation", + "switch": "DEBUG", + "comment": "Generate Debug Information", + "value": "true", + "flags": [ + "CaseInsensitive" + ] + }, + { + "name": "GenerateDebugInformation", + "switch": "DEBUG:FASTLINK", + "comment": "Generate Debug Information optimized for faster links", + "value": "DebugFastLink", + "flags": [ + "CaseInsensitive" + ] + }, + { + "name": "GenerateDebugInformation", + "switch": "DEBUG:FULL", + "comment": "Generate Debug Information optimized for sharing and publishing", + "value": "DebugFull", + "flags": [ + "CaseInsensitive" + ] + }, + { + "name": "GenerateDebugInformation", + "switch": "DEBUG:NONE", + "comment": "Produces no debugging information", + "value": "false", + "flags": [ + "CaseInsensitive" + ] + }, + { + "name": "SubSystem", + "switch": "", + "comment": "Not Set", + "value": "NotSet", + "flags": [] + }, + { + "name": "SubSystem", + "switch": "SUBSYSTEM:CONSOLE", + "comment": "Console", + "value": "Console", + "flags": [] + }, + { + "name": "SubSystem", + "switch": "SUBSYSTEM:WINDOWS", + "comment": "Windows", + "value": "Windows", + "flags": [] + }, + { + "name": "SubSystem", + "switch": "SUBSYSTEM:NATIVE", + "comment": "Native", + "value": "Native", + "flags": [] + }, + { + "name": "SubSystem", + "switch": "SUBSYSTEM:EFI_APPLICATION", + "comment": "EFI Application", + "value": "EFI Application", + "flags": [] + }, + { + "name": "SubSystem", + "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER", + "comment": "EFI Boot Service Driver", + "value": "EFI Boot Service Driver", + "flags": [] + }, + { + "name": "SubSystem", + "switch": "SUBSYSTEM:EFI_ROM", + "comment": "EFI ROM", + "value": "EFI ROM", + "flags": [] + }, + { + "name": "SubSystem", + "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER", + "comment": "EFI Runtime", + "value": "EFI Runtime", + "flags": [] + }, + { + "name": "SubSystem", + "switch": "SUBSYSTEM:POSIX", + "comment": "POSIX", + "value": "POSIX", + "flags": [] + }, + { + "name": "Driver", + "switch": "", + "comment": "Not Set", + "value": "NotSet", + "flags": [] + }, + { + "name": "Driver", + "switch": "Driver", + "comment": "Driver", + "value": "Driver", + "flags": [] + }, + { + "name": "Driver", + "switch": "DRIVER:UPONLY", + "comment": "UP Only", + "value": "UpOnly", + "flags": [] + }, + { + "name": "Driver", + "switch": "DRIVER:WDM", + "comment": "WDM", + "value": "WDM", + "flags": [] + }, + { + "name": "LinkTimeCodeGeneration", + "switch": "", + "comment": "Default", + "value": "Default", + "flags": [] + }, + { + "name": "LinkTimeCodeGeneration", + "switch": "LTCG:incremental", + "comment": "Use Fast Link Time Code Generation", + "value": "UseFastLinkTimeCodeGeneration", + "flags": [] + }, + { + "name": "LinkTimeCodeGeneration", + "switch": "LTCG", + "comment": "Use Link Time Code Generation", + "value": "UseLinkTimeCodeGeneration", + "flags": [] + }, + { + "name": "LinkTimeCodeGeneration", + "switch": "LTCG:PGInstrument", + "comment": "Profile Guided Optimization - Instrument", + "value": "PGInstrument", + "flags": [] + }, + { + "name": "LinkTimeCodeGeneration", + "switch": "LTCG:PGOptimize", + "comment": "Profile Guided Optimization - Optimization", + "value": "PGOptimization", + "flags": [] + }, + { + "name": "LinkTimeCodeGeneration", + "switch": "LTCG:PGUpdate", + "comment": "Profile Guided Optimization - Update", + "value": "PGUpdate", + "flags": [] + }, + { + "name": "GenerateWindowsMetadata", + "switch": "WINMD", + "comment": "Yes", + "value": "true", + "flags": [] + }, + { + "name": "GenerateWindowsMetadata", + "switch": "WINMD:NO", + "comment": "No", + "value": "false", + "flags": [] + }, + { + "name": "WindowsMetadataSignHash", + "switch": "WINMDSIGNHASH:SHA1", + "comment": "SHA1", + "value": "SHA1", + "flags": [] + }, + { + "name": "WindowsMetadataSignHash", + "switch": "WINMDSIGNHASH:SHA256", + "comment": "SHA256", + "value": "SHA256", + "flags": [] + }, + { + "name": "WindowsMetadataSignHash", + "switch": "WINMDSIGNHASH:SHA384", + "comment": "SHA384", + "value": "SHA384", + "flags": [] + }, + { + "name": "WindowsMetadataSignHash", + "switch": "WINMDSIGNHASH:SHA512", + "comment": "SHA512", + "value": "SHA512", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "", + "comment": "Not Set", + "value": "NotSet", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:ARM", + "comment": "MachineARM", + "value": "MachineARM", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:ARM64", + "comment": "MachineARM64", + "value": "MachineARM64", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:EBC", + "comment": "MachineEBC", + "value": "MachineEBC", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:IA64", + "comment": "MachineIA64", + "value": "MachineIA64", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:MIPS", + "comment": "MachineMIPS", + "value": "MachineMIPS", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:MIPS16", + "comment": "MachineMIPS16", + "value": "MachineMIPS16", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:MIPSFPU", + "comment": "MachineMIPSFPU", + "value": "MachineMIPSFPU", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:MIPSFPU16", + "comment": "MachineMIPSFPU16", + "value": "MachineMIPSFPU16", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:SH4", + "comment": "MachineSH4", + "value": "MachineSH4", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:THUMB", + "comment": "MachineTHUMB", + "value": "MachineTHUMB", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:X64", + "comment": "MachineX64", + "value": "MachineX64", + "flags": [] + }, + { + "name": "TargetMachine", + "switch": "MACHINE:X86", + "comment": "MachineX86", + "value": "MachineX86", + "flags": [] + }, + { + "name": "CLRThreadAttribute", + "switch": "CLRTHREADATTRIBUTE:MTA", + "comment": "MTA threading attribute", + "value": "MTAThreadingAttribute", + "flags": [] + }, + { + "name": "CLRThreadAttribute", + "switch": "CLRTHREADATTRIBUTE:STA", + "comment": "STA threading attribute", + "value": "STAThreadingAttribute", + "flags": [] + }, + { + "name": "CLRThreadAttribute", + "switch": "CLRTHREADATTRIBUTE:NONE", + "comment": "Default threading attribute", + "value": "DefaultThreadingAttribute", + "flags": [] + }, + { + "name": "CLRImageType", + "switch": "CLRIMAGETYPE:IJW", + "comment": "Force IJW image", + "value": "ForceIJWImage", + "flags": [] + }, + { + "name": "CLRImageType", + "switch": "CLRIMAGETYPE:PURE", + "comment": "Force Pure IL Image", + "value": "ForcePureILImage", + "flags": [] + }, + { + "name": "CLRImageType", + "switch": "CLRIMAGETYPE:SAFE", + "comment": "Force Safe IL Image", + "value": "ForceSafeILImage", + "flags": [] + }, + { + "name": "CLRImageType", + "switch": "", + "comment": "Default image type", + "value": "Default", + "flags": [] + }, + { + "name": "SignHash", + "switch": "CLRSIGNHASH:SHA1", + "comment": "SHA1", + "value": "SHA1", + "flags": [] + }, + { + "name": "SignHash", + "switch": "CLRSIGNHASH:SHA256", + "comment": "SHA256", + "value": "SHA256", + "flags": [] + }, + { + "name": "SignHash", + "switch": "CLRSIGNHASH:SHA384", + "comment": "SHA384", + "value": "SHA384", + "flags": [] + }, + { + "name": "SignHash", + "switch": "CLRSIGNHASH:SHA512", + "comment": "SHA512", + "value": "SHA512", + "flags": [] + }, + { + "name": "LinkErrorReporting", + "switch": "ERRORREPORT:PROMPT", + "comment": "PromptImmediately", + "value": "PromptImmediately", + "flags": [] + }, + { + "name": "LinkErrorReporting", + "switch": "ERRORREPORT:QUEUE", + "comment": "Queue For Next Login", + "value": "QueueForNextLogin", + "flags": [] + }, + { + "name": "LinkErrorReporting", + "switch": "ERRORREPORT:SEND", + "comment": "Send Error Report", + "value": "SendErrorReport", + "flags": [] + }, + { + "name": "LinkErrorReporting", + "switch": "ERRORREPORT:NONE", + "comment": "No Error Report", + "value": "NoErrorReport", + "flags": [] + }, + { + "name": "CLRSupportLastError", + "switch": "CLRSupportLastError", + "comment": "Enabled", + "value": "Enabled", + "flags": [] + }, + { + "name": "CLRSupportLastError", + "switch": "CLRSupportLastError:NO", + "comment": "Disabled", + "value": "Disabled", + "flags": [] + }, + { + "name": "CLRSupportLastError", + "switch": "CLRSupportLastError:SYSTEMDLL", + "comment": "System Dlls Only", + "value": "SystemDlls", + "flags": [] + }, + { + "name": "LinkIncremental", + "switch": "INCREMENTAL:NO", + "comment": "Enable Incremental Linking", + "value": "false", + "flags": [] + }, + { + "name": "LinkIncremental", + "switch": "INCREMENTAL", + "comment": "Enable Incremental Linking", + "value": "true", + "flags": [] + }, + { + "name": "SuppressStartupBanner", + "switch": "NOLOGO", + "comment": "Suppress Startup Banner", + "value": "true", + "flags": [] + }, + { + "name": "LinkStatus", + "switch": "LTCG:NOSTATUS", + "comment": "Link Status", + "value": "false", + "flags": [] + }, + { + "name": "LinkStatus", + "switch": "LTCG:STATUS", + "comment": "Link Status", + "value": "true", + "flags": [] + }, + { + "name": "PreventDllBinding", + "switch": "ALLOWBIND:NO", + "comment": "Prevent Dll Binding", + "value": "false", + "flags": [] + }, + { + "name": "PreventDllBinding", + "switch": "ALLOWBIND", + "comment": "Prevent Dll Binding", + "value": "true", + "flags": [] + }, + { + "name": "TreatLinkerWarningAsErrors", + "switch": "WX:NO", + "comment": "Treat Linker Warning As Errors", + "value": "false", + "flags": [] + }, + { + "name": "TreatLinkerWarningAsErrors", + "switch": "WX", + "comment": "Treat Linker Warning As Errors", + "value": "true", + "flags": [] + }, + { + "name": "IgnoreAllDefaultLibraries", + "switch": "NODEFAULTLIB", + "comment": "Ignore All Default Libraries", + "value": "true", + "flags": [] + }, + { + "name": "GenerateManifest", + "switch": "MANIFEST:NO", + "comment": "Generate Manifest", + "value": "false", + "flags": [] + }, + { + "name": "GenerateManifest", + "switch": "MANIFEST", + "comment": "Generate Manifest", + "value": "true", + "flags": [] + }, + { + "name": "AllowIsolation", + "switch": "ALLOWISOLATION:NO", + "comment": "Allow Isolation", + "value": "false", + "flags": [] + }, + { + "name": "AllowIsolation", + "switch": "", + "comment": "Allow Isolation", + "value": "true", + "flags": [] + }, + { + "name": "EnableUAC", + "switch": "MANIFESTUAC:", + "comment": "", + "value": "", + "flags": [ + "UserValue", + "UserRequired", + "SpaceAppendable" + ] + }, + { + "name": "UACUIAccess", + "switch": "uiAccess='false'", + "comment": "UAC Bypass UI Protection", + "value": "false", + "flags": [ + "UserValue", + "UserRequired" + ] + }, + { + "name": "UACUIAccess", + "switch": "uiAccess='false'", + "comment": "UAC Bypass UI Protection", + "value": "false", + "flags": [] + }, + { + "name": "UACUIAccess", + "switch": "uiAccess='true'", + "comment": "UAC Bypass UI Protection", + "value": "true", + "flags": [] + }, + { + "name": "ManifestEmbed", + "switch": "manifest:embed", + "comment": "Embed Manifest", + "value": "true", + "flags": [] + }, + { + "name": "GenerateMapFile", + "switch": "MAP", + "comment": "Generate Map File", + "value": "true", + "flags": [ + "UserValue", + "UserIgnored", + "Continue" + ] + }, + { + "name": "MapExports", + "switch": "MAPINFO:EXPORTS", + "comment": "Map Exports", + "value": "true", + "flags": [] + }, + { + "name": "AssemblyDebug", + "switch": "ASSEMBLYDEBUG:DISABLE", + "comment": "Debuggable Assembly", + "value": "false", + "flags": [] + }, + { + "name": "AssemblyDebug", + "switch": "ASSEMBLYDEBUG", + "comment": "Debuggable Assembly", + "value": "true", + "flags": [] + }, + { + "name": "LargeAddressAware", + "switch": "LARGEADDRESSAWARE:NO", + "comment": "Enable Large Addresses", + "value": "false", + "flags": [] + }, + { + "name": "LargeAddressAware", + "switch": "LARGEADDRESSAWARE", + "comment": "Enable Large Addresses", + "value": "true", + "flags": [] + }, + { + "name": "TerminalServerAware", + "switch": "TSAWARE:NO", + "comment": "Terminal Server", + "value": "false", + "flags": [] + }, + { + "name": "TerminalServerAware", + "switch": "TSAWARE", + "comment": "Terminal Server", + "value": "true", + "flags": [] + }, + { + "name": "SwapRunFromCD", + "switch": "SWAPRUN:CD", + "comment": "Swap Run From CD", + "value": "true", + "flags": [] + }, + { + "name": "SwapRunFromNET", + "switch": "SWAPRUN:NET", + "comment": "Swap Run From Network", + "value": "true", + "flags": [] + }, + { + "name": "OptimizeReferences", + "switch": "OPT:NOREF", + "comment": "References", + "value": "false", + "flags": [] + }, + { + "name": "OptimizeReferences", + "switch": "OPT:REF", + "comment": "References", + "value": "true", + "flags": [] + }, + { + "name": "EnableCOMDATFolding", + "switch": "OPT:NOICF", + "comment": "Enable COMDAT Folding", + "value": "false", + "flags": [] + }, + { + "name": "EnableCOMDATFolding", + "switch": "OPT:ICF", + "comment": "Enable COMDAT Folding", + "value": "true", + "flags": [] + }, + { + "name": "IgnoreEmbeddedIDL", + "switch": "IGNOREIDL", + "comment": "Ignore Embedded IDL", + "value": "true", + "flags": [] + }, + { + "name": "AppContainer", + "switch": "APPCONTAINER", + "comment": "", + "value": "true", + "flags": [] + }, + { + "name": "WindowsMetadataLinkDelaySign", + "switch": "WINMDDELAYSIGN:NO", + "comment": "Windows Metadata Delay Sign", + "value": "false", + "flags": [] + }, + { + "name": "WindowsMetadataLinkDelaySign", + "switch": "WINMDDELAYSIGN", + "comment": "Windows Metadata Delay Sign", + "value": "true", + "flags": [] + }, + { + "name": "NoEntryPoint", + "switch": "NOENTRY", + "comment": "No Entry Point", + "value": "true", + "flags": [] + }, + { + "name": "SetChecksum", + "switch": "RELEASE", + "comment": "Set Checksum", + "value": "true", + "flags": [] + }, + { + "name": "RandomizedBaseAddress", + "switch": "DYNAMICBASE:NO", + "comment": "Randomized Base Address", + "value": "false", + "flags": [] + }, + { + "name": "RandomizedBaseAddress", + "switch": "DYNAMICBASE", + "comment": "Randomized Base Address", + "value": "true", + "flags": [] + }, + { + "name": "FixedBaseAddress", + "switch": "FIXED:NO", + "comment": "Fixed Base Address", + "value": "false", + "flags": [] + }, + { + "name": "FixedBaseAddress", + "switch": "FIXED", + "comment": "Fixed Base Address", + "value": "true", + "flags": [] + }, + { + "name": "DataExecutionPrevention", + "switch": "NXCOMPAT:NO", + "comment": "Data Execution Prevention (DEP)", + "value": "false", + "flags": [] + }, + { + "name": "DataExecutionPrevention", + "switch": "NXCOMPAT", + "comment": "Data Execution Prevention (DEP)", + "value": "true", + "flags": [] + }, + { + "name": "TurnOffAssemblyGeneration", + "switch": "NOASSEMBLY", + "comment": "Turn Off Assembly Generation", + "value": "true", + "flags": [] + }, + { + "name": "SupportUnloadOfDelayLoadedDLL", + "switch": "DELAY:UNLOAD", + "comment": "Unload delay loaded DLL", + "value": "true", + "flags": [] + }, + { + "name": "SupportNobindOfDelayLoadedDLL", + "switch": "DELAY:NOBIND", + "comment": "Nobind delay loaded DLL", + "value": "true", + "flags": [] + }, + { + "name": "Profile", + "switch": "PROFILE", + "comment": "Profile", + "value": "true", + "flags": [] + }, + { + "name": "LinkDelaySign", + "switch": "DELAYSIGN:NO", + "comment": "Delay Sign", + "value": "false", + "flags": [] + }, + { + "name": "LinkDelaySign", + "switch": "DELAYSIGN", + "comment": "Delay Sign", + "value": "true", + "flags": [] + }, + { + "name": "CLRUnmanagedCodeCheck", + "switch": "CLRUNMANAGEDCODECHECK:NO", + "comment": "CLR Unmanaged Code Check", + "value": "false", + "flags": [] + }, + { + "name": "CLRUnmanagedCodeCheck", + "switch": "CLRUNMANAGEDCODECHECK", + "comment": "CLR Unmanaged Code Check", + "value": "true", + "flags": [] + }, + { + "name": "DetectOneDefinitionRule", + "switch": "ODR", + "comment": "Detect One Definition Rule violations", + "value": "true", + "flags": [] + }, + { + "name": "ImageHasSafeExceptionHandlers", + "switch": "SAFESEH:NO", + "comment": "Image Has Safe Exception Handlers", + "value": "false", + "flags": [] + }, + { + "name": "ImageHasSafeExceptionHandlers", + "switch": "SAFESEH", + "comment": "Image Has Safe Exception Handlers", + "value": "true", + "flags": [] + }, + { + "name": "LinkDLL", + "switch": "DLL", + "comment": "", + "value": "true", + "flags": [] + }, + { + "name": "AdditionalLibraryDirectories", + "switch": "LIBPATH:", + "comment": "Additional Library Directories", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "Natvis", + "switch": "NATVIS:", + "comment": "Natvis files", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "IgnoreSpecificDefaultLibraries", + "switch": "NODEFAULTLIB:", + "comment": "Ignore Specific Default Libraries", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "AddModuleNamesToAssembly", + "switch": "ASSEMBLYMODULE:", + "comment": "Add Module to Assembly", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "EmbedManagedResourceFile", + "switch": "ASSEMBLYRESOURCE:", + "comment": "Embed Managed Resource File", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "ForceSymbolReferences", + "switch": "INCLUDE:", + "comment": "Force Symbol References", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "DelayLoadDLLs", + "switch": "DELAYLOAD:", + "comment": "Delay Loaded Dlls", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "AssemblyLinkResource", + "switch": "ASSEMBLYLINKRESOURCE:", + "comment": "Assembly Link Resource", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "AdditionalManifestDependencies", + "switch": "MANIFESTDEPENDENCY:", + "comment": "Additional Manifest Dependencies", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "ManifestInput", + "switch": "manifestinput:", + "comment": "Manifest Input", + "value": "", + "flags": [ + "UserValue", + "SemicolonAppendable" + ] + }, + { + "name": "OutputFile", + "switch": "OUT:", + "comment": "Output File", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "Version", + "switch": "VERSION:", + "comment": "Version", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "SpecifySectionAttributes", + "switch": "SECTION:", + "comment": "Specify Section Attributes", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "MSDOSStubFileName", + "switch": "STUB:", + "comment": "MS-DOS Stub File Name", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "ModuleDefinitionFile", + "switch": "DEF:", + "comment": "Module Definition File", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "ManifestFile", + "switch": "ManifestFile:", + "comment": "Manifest File", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "ProgramDatabaseFile", + "switch": "PDB:", + "comment": "Generate Program Database File", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "StripPrivateSymbols", + "switch": "PDBSTRIPPED:", + "comment": "Strip Private Symbols", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "MapFileName", + "switch": "MAP:", + "comment": "Map File Name", + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] + }, + { + "name": "HeapReserveSize", + "switch": "HEAP:", + "comment": "Heap Reserve Size", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "HeapCommitSize", + "switch": "HEAP", + "comment": "Heap Commit Size", + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] + }, + { + "name": "StackReserveSize", + "switch": "STACK:", + "comment": "Stack Reserve Size", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "StackCommitSize", + "switch": "STACK", + "comment": "Stack Commit Size", + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] + }, + { + "name": "FunctionOrder", + "switch": "ORDER:@", + "comment": "Function Order", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "ProfileGuidedDatabase", + "switch": "PGD:", + "comment": "Profile Guided Database", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "MidlCommandFile", + "switch": "MIDL:@", + "comment": "MIDL Commands", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "MergedIDLBaseFileName", + "switch": "IDLOUT:", + "comment": "Merged IDL Base File Name", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "TypeLibraryFile", + "switch": "TLBOUT:", + "comment": "Type Library", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "WindowsMetadataFile", + "switch": "WINMDFILE:", + "comment": "Windows Metadata File", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "WindowsMetadataLinkKeyFile", + "switch": "WINMDKEYFILE:", + "comment": "Windows Metadata Key File", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "WindowsMetadataKeyContainer", + "switch": "WINMDKEYCONTAINER:", + "comment": "Windows Metadata Key Container", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "EntryPointSymbol", + "switch": "ENTRY:", + "comment": "Entry Point", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "BaseAddress", + "switch": "BASE:", + "comment": "Base Address", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "ImportLibrary", + "switch": "IMPLIB:", + "comment": "Import Library", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "MergeSections", + "switch": "MERGE:", + "comment": "Merge Sections", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "LinkKeyFile", + "switch": "KEYFILE:", + "comment": "Key File", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "KeyContainer", + "switch": "KEYCONTAINER:", + "comment": "Key Container", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "TypeLibraryResourceID", + "switch": "TLBID:", + "comment": "TypeLib Resource ID", + "value": "", + "flags": [ + "UserValue" + ] + }, + { + "name": "SectionAlignment", + "switch": "ALIGN:", + "comment": "SectionAlignment", + "value": "", + "flags": [ + "UserValue" + ] + } +] diff --git a/Templates/Windows/ApplicationIcon.png b/Templates/Windows/ApplicationIcon.png Binary files differindex 7d95d4e081..c715e1bc73 100644 --- a/Templates/Windows/ApplicationIcon.png +++ b/Templates/Windows/ApplicationIcon.png diff --git a/Templates/Windows/Logo.png b/Templates/Windows/Logo.png Binary files differindex e26771cb33..65f91ac0f9 100644 --- a/Templates/Windows/Logo.png +++ b/Templates/Windows/Logo.png diff --git a/Templates/Windows/SmallLogo.png b/Templates/Windows/SmallLogo.png Binary files differindex 1eb0d9d528..460c0222d4 100644 --- a/Templates/Windows/SmallLogo.png +++ b/Templates/Windows/SmallLogo.png diff --git a/Templates/Windows/SmallLogo44x44.png b/Templates/Windows/SmallLogo44x44.png Binary files differindex 28810b7c0e..c2374581a8 100644 --- a/Templates/Windows/SmallLogo44x44.png +++ b/Templates/Windows/SmallLogo44x44.png diff --git a/Templates/Windows/SplashScreen.png b/Templates/Windows/SplashScreen.png Binary files differindex c951e031bd..8342565809 100644 --- a/Templates/Windows/SplashScreen.png +++ b/Templates/Windows/SplashScreen.png diff --git a/Templates/Windows/StoreLogo.png b/Templates/Windows/StoreLogo.png Binary files differindex dcb672712c..508c8a809a 100644 --- a/Templates/Windows/StoreLogo.png +++ b/Templates/Windows/StoreLogo.png diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6b166d64b8..ed98d974b0 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -436,6 +436,9 @@ if(BUILD_TESTING) ADD_TEST_MACRO(PolicyScope PolicyScope) ADD_TEST_MACRO(EmptyLibrary EmptyLibrary) ADD_TEST_MACRO(CompileDefinitions CompileDefinitions) + if(CMAKE_Fortran_COMPILER) + set(CompileOptions_BUILD_OPTIONS -DTEST_FORTRAN=1) + endif() ADD_TEST_MACRO(CompileOptions CompileOptions) ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) ADD_TEST_MACRO(AliasTarget AliasTarget) @@ -1362,18 +1365,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets") if(Qt5Widgets_FOUND AND NOT Qt5Widgets_VERSION VERSION_LESS 5.1.0) - add_test(Qt4And5Automoc ${CMAKE_CTEST_COMMAND} + add_test(Qt4And5AutomocForward ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc" - "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc" + "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward" ${build_generator_args} --build-project Qt4And5Automoc - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward" --force-new-ctest-process --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward") add_test(Qt4And5AutomocReverse ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc" @@ -1434,6 +1437,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindGIF) endif() + if(CMake_TEST_FindGit) + add_subdirectory(FindGit) + endif() + if(CMake_TEST_FindGSL) add_subdirectory(FindGSL) endif() @@ -1551,7 +1558,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindXercesC) endif() - if(CMake_TEST_FindPython) + if(CMake_TEST_FindPython OR CMake_TEST_FindPython_NumPy) add_subdirectory(FindPython) endif() @@ -1635,6 +1642,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir") + add_test(NAME ExternalProjectSourceSubdirNotCMake + COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/ExternalProjectSourceSubdirNotCMake" + "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdirNotCMake" + ${build_generator_args} + --build-project ExternalProjectSourceSubdirNotCMake + --force-new-ctest-process + --build-options ${build_options} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdirNotCMake") + add_test(ExternalProjectLocal ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/ExternalProjectLocal" @@ -1685,18 +1704,37 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release DEPENDS ExternalProjectUpdateSetup ) # do each of the tutorial steps - foreach(STP RANGE 1 7) - add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND} + function(add_tutorial_test step_name use_mymath) + set(tutorial_test_name Tutorial${step_name}) + set(tutorial_build_dir "${CMake_BINARY_DIR}/Tests/Tutorial/${step_name}") + if (use_mymath) + set(tutorial_build_options "") + else() + set(tutorial_test_name ${tutorial_test_name}_MYMATH) + set(tutorial_build_dir "${tutorial_build_dir}_MYMATH") + set(tutorial_build_options -DUSE_MYMATH:BOOL=OFF) + endif() + add_test(${tutorial_test_name} ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}" - "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}" - --build-two-config + "${CMake_SOURCE_DIR}/Tests/Tutorial/${step_name}" + ${tutorial_build_dir}_Build ${build_generator_args} --build-project Tutorial - --build-options ${build_options} + --build-options ${build_options} ${tutorial_build_options} --test-command Tutorial 25.0) - endforeach() - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/${tutorial_build_dir}_Build") + endfunction() + + if(NOT CMake_TEST_EXTERNAL_CMAKE) + foreach(STP RANGE 1 11) + add_tutorial_test(Step${STP} TRUE) + endforeach() + add_tutorial_test(Complete TRUE) + foreach(STP RANGE 3 11) + add_tutorial_test(Step${STP} FALSE) + endforeach() + add_tutorial_test(Complete FALSE) + endif() add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test @@ -2260,32 +2298,104 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() if (CMake_TEST_GreenHillsMULTI) - macro(add_test_GhsMulti name primaryTarget bspName) - add_test(NAME GhsMulti.${name} COMMAND ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/GhsMulti" - "${CMake_BINARY_DIR}/Tests/GhsMulti/${name}" - --build-generator "Green Hills MULTI" - --build-project ReturnNum - --build-config $<CONFIGURATION> - --build-options -DGHS_PRIMARY_TARGET=${primaryTarget} - -DGHS_BSP_NAME=${bspName} - ) - endmacro () - add_test_GhsMulti("arm_integrity_simarm" "arm_integrity.tgt" "simarm") - add_test_GhsMulti("arm64_integrity_simarm" "arm64_integrity.tgt" "simarm") - add_test(NAME GhsMulti.duplicate_source_filenames + macro(add_test_GhsMulti test_name test_dir bin_sub_dir build_opts) + separate_arguments(_ghs_build_opts UNIX_COMMAND ${build_opts}) + separate_arguments(_ghs_toolset_extra UNIX_COMMAND ${ghs_toolset_extra}) + if(${ARGC} GREATER 4) + set(_ghs_test_command --test-command ${ARGN}) + endif() + if(ghs_config_name STREQUAL "__default__") + set(_ghs_test_name "${test_name}") + else() + set(_ghs_test_name "${ghs_config_name}.${test_name}") + endif() + add_test(NAME GhsMulti.${_ghs_test_name} COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/GhsMultiDuplicateSourceFilenames" - "${CMake_BINARY_DIR}/Tests/GhsMultiDuplicateSourceFilenames" + "${CMake_SOURCE_DIR}/Tests/GhsMulti/${test_dir}" + "${CMake_BINARY_DIR}/Tests/GhsMulti/${ghs_config_name}/${test_dir}/${bin_sub_dir}" --build-generator "Green Hills MULTI" - --build-project ReturnNum + --build-project test --build-config $<CONFIGURATION> - --build-options -DGHS_PRIMARY_TARGET=arm_integrity.tgt - -DGHS_BSP_NAME="simarm" + --build-options ${ghs_target_arch} ${ghs_toolset_name} ${ghs_toolset_root} ${ghs_target_platform} + ${ghs_os_root} ${ghs_os_dir} ${ghs_bsp_name} ${_ghs_build_opts} ${_ghs_toolset_extra} + ${_ghs_test_command} ) - endif () + unset(_ghs_build_opts) + unset(_ghs_toolset_extra) + unset(_ghs_test_command) + unset(_ghs_test_name) + endmacro() + macro(add_test_GhsMulti_rename_install test_name) + add_test_GhsMulti( ${test_name} GhsMultiRenameInstall ${test_name} + "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} -P ./cmake_install.cmake) + endmacro() + #unset ghs config variables + unset(ghs_config_name) + unset(ghs_target_arch) + unset(ghs_toolset_root) + unset(ghs_toolset_name) + unset(ghs_os_root) + unset(ghs_os_dir) + unset(ghs_target_platform) + unset(ghs_bsp_name) + unset(ghs_toolset_extra) + if(NOT CMake_TEST_GreenHillsMULTI_config) + #if list of config settings not defined then just run once as default + set(CMake_TEST_GreenHillsMULTI_config "__default__") + endif() + foreach(ghs_file IN LISTS CMake_TEST_GreenHillsMULTI_config) + # source GHS tools config file + if(NOT ghs_file STREQUAL "__default__") + if(IS_ABSOLUTE ${ghs_file}) + include(${ghs_file}) + else() + include(${CMAKE_BINARY_DIR}/${ghs_file}) + endif() + endif() + if(NOT ghs_config_name) + set(ghs_config_name "__default__") + endif() + # test integrity build + if (NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity")) + add_test_GhsMulti(integrityDDInt GhsMultiIntegrity/GhsMultiIntegrityDDInt "" "") + add_test_GhsMulti(integrityMonolith GhsMultiIntegrity/GhsMultiIntegrityMonolith "" "") + add_test_GhsMulti(integrityDD GhsMultiIntegrity/GhsMultiIntegrityDD "" "") + endif() + add_test_GhsMulti(duplicate_source_filenames GhsMultiDuplicateSourceFilenames "" "") + add_test_GhsMulti_rename_install(SINGLE_EXEC) + add_test_GhsMulti_rename_install(SINGLE_EXEC_RENAMED) + add_test_GhsMulti_rename_install(EXEC_AND_LIB) + add_test_GhsMulti(multiple_source_groups GhsMultiSrcGroups Default "") + add_test_GhsMulti(multiple_source_groups_folders GhsMultiSrcGroups PropFolders "-DTEST_PROP=ON") + add_test_GhsMulti(multiple_source_groups_all_folders GhsMultiSrcGroups AllFolders "-DGHS_NO_SOURCE_GROUP_FILE=ON") + add_test_GhsMulti(unsupported_targets GhsMultiUnsupportedTargets "" "") + add_test_GhsMulti(object_library GhsMultiObjectLibrary "" "") + add_test_GhsMulti(exclude GhsMultiExclude "" "" + ${CMAKE_CMAKE_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/GhsMulti/GhsMultiExclude/verify.cmake) + add_test_GhsMulti(interface GhsMultiInterface "" "") + add_test_GhsMulti(transitive_link_test GhsMultiLinkTest TransitiveLink "-DRUN_TEST=NO_FLAGS") + add_test_GhsMulti(flags_link_test GhsMultiLinkTest FlagsCheck "-DRUN_TEST=CHECK_FLAGS") + add_test_GhsMulti(sub_link_test GhsMultiLinkTestSub "" "") + add_test_GhsMulti(multiple_projects GhsMultiMultipleProjects "" "" + ${CMAKE_CMAKE_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake) + add_test_GhsMulti(compiler_options_none GhsMultiCompilerOptions None "-DRUN_TEST=RELEASE_FLAGS -DRUN_TEST_BUILD_TYPE=\"\"") + add_test_GhsMulti(compiler_options_kernel GhsMultiCompilerOptions Kernel "-DRUN_TEST=KERNEL_FLAGS -DRUN_TEST_BUILD_TYPE=DEBUG") + add_test_GhsMulti(try_compile_copy GhsMultiCopyFile "" "") + add_test_GhsMulti(ghs_platform GhsMultiPlatform "" "") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GhsMulti/${ghs_config_name}") + #unset ghs config variables + unset(ghs_config_name) + unset(ghs_target_arch) + unset(ghs_toolset_root) + unset(ghs_toolset_name) + unset(ghs_os_root) + unset(ghs_os_dir) + unset(ghs_target_platform) + unset(ghs_bsp_name) + unset(ghs_toolset_extra) + endforeach() + endif() if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ") macro(add_test_VSNsightTegra name generator) diff --git a/Tests/CMakeTests/FileDownloadInput.png b/Tests/CMakeTests/FileDownloadInput.png Binary files differindex 7bbcee413c..9ab565a1b4 100644 --- a/Tests/CMakeTests/FileDownloadInput.png +++ b/Tests/CMakeTests/FileDownloadInput.png diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index f6d9ad99b9..39354490be 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -32,7 +32,7 @@ file(DOWNLOAD ${url} ${dir}/file3.png TIMEOUT 2 - EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 + EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 ) message(STATUS "FileDownload:4") @@ -41,7 +41,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA1=50c614fc28b39c1281d0517bb6d5858b4359c9b7 + EXPECTED_HASH SHA1=67eee17f79d9ac557284fc0b8ad19f25723fb578 ) message(STATUS "FileDownload:5") @@ -50,7 +50,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA224=73cd5f442b04e8320e4f907f8e1b21d4befff98b5bd77bc32526ea68 + EXPECTED_HASH SHA224=ba283726bbb602776818b463943189afd91836cb7ee5dd6e2c7b5ae4 ) message(STATUS "FileDownload:6") @@ -59,7 +59,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA256=2e067f6c09cbc7cd619c8fbcc44eb64cd6b45a95e4cddb3a585eee1f731c4da9 + EXPECTED_HASH SHA256=cf3334b1275071e1da6e8c396ccb72cf1b2388d8c937526f3af26230affb9423 ) message(STATUS "FileDownload:7") @@ -68,7 +68,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA384=398bf41902a7251c30e522b307e3e41e3fb617c765b3feaa99b2f7d063894708ad399267ccc25d877437a10e5e890d35 + EXPECTED_HASH SHA384=43a5d13978d97c660db44481aee0604cb4ff6ca0775cd5c2cd68cd8000e107e507c4caf6c228941231041e282ffb8950 ) message(STATUS "FileDownload:8") @@ -77,7 +77,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA512=c51854d21052713968b849c2b4263cf54be03bc3a7e9847a6c71c6c8d1d13cd805fe1b9fa95f9ba1d0a5631513974f6fae21e34ab5b171d94bad48df5f073e48 + EXPECTED_HASH SHA512=6984e0909a1018030ccaa418e3be1654223cdccff0fe6adc745f9aea7e377f178be53b9fc7d54a6f81c2b62ef9ddcd38ba1978fedf4c5e7139baaf355eefad5b ) message(STATUS "FileDownload:9") file(DOWNLOAD @@ -85,7 +85,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH MD5=d16778650db435bda3a8c3435c3ff5d1 + EXPECTED_HASH MD5=dbd330d52f4dbd60115d4191904ded92 ) message(STATUS "FileDownload:10") @@ -94,7 +94,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 + EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 ) message(STATUS "${status}") diff --git a/Tests/CMakeTests/FileUploadTest.cmake.in b/Tests/CMakeTests/FileUploadTest.cmake.in index 9e2290988c..0e6f080483 100644 --- a/Tests/CMakeTests/FileUploadTest.cmake.in +++ b/Tests/CMakeTests/FileUploadTest.cmake.in @@ -35,7 +35,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png" OUTPUT_VARIABLE sum1 OUTPUT_STRIP_TRAILING_WHITESPACE) -if(NOT sum1 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file1.png$") +if(NOT sum1 MATCHES "^dbd330d52f4dbd60115d4191904ded92 .*/uploads/file1.png$") message(FATAL_ERROR "file1.png did not upload correctly (sum1='${sum1}')") endif() @@ -43,7 +43,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png" OUTPUT_VARIABLE sum2 OUTPUT_STRIP_TRAILING_WHITESPACE) -if(NOT sum2 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file2.png$") +if(NOT sum2 MATCHES "^dbd330d52f4dbd60115d4191904ded92 .*/uploads/file2.png$") message(FATAL_ERROR "file2.png did not upload correctly (sum2='${sum2}')") endif() diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index c9f171076c..15a993c688 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -4,6 +4,10 @@ project(CompileOptions) add_library(testlib other.cpp) +if(TEST_FORTRAN) + enable_language(Fortran) +endif() + add_executable(CompileOptions main.cpp) macro(get_compiler_test_genex lst lang) @@ -13,6 +17,9 @@ endmacro() get_compiler_test_genex(c_tests C) get_compiler_test_genex(cxx_tests CXX) +if(TEST_FORTRAN) + get_compiler_test_genex(fortran_tests Fortran) +endif() set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "-DTEST_DEFINE" @@ -21,6 +28,7 @@ set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "SHELL:" # produces no options ${c_tests} ${cxx_tests} + ${fortran_tests} ) if(BORLAND OR WATCOM) # these compilers do not support separate -D flags @@ -54,3 +62,12 @@ target_compile_definitions(CompileOptions "EXPECTED_C_COMPILER_VERSION=\"${CMAKE_C_COMPILER_VERSION}\"" "EXPECTED_CXX_COMPILER_VERSION=\"${CMAKE_CXX_COMPILER_VERSION}\"" ) + +if(TEST_FORTRAN) + # Definitions for the C++ code to test the values + target_compile_definitions(CompileOptions + PRIVATE + "TEST_FORTRAN" + "EXPECTED_Fortran_COMPILER_VERSION=\"${CMAKE_Fortran_COMPILER_VERSION}\"" + ) +endif() diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp index 1379940c73..d94a169c73 100644 --- a/Tests/CompileOptions/main.cpp +++ b/Tests/CompileOptions/main.cpp @@ -47,10 +47,17 @@ int main() #endif && strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0 && - strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == - 0 && - TEST_C_COMPILER_VERSION_EQUALITY == 1 && - TEST_CXX_COMPILER_VERSION_EQUALITY == 1) + strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == 0 +#ifdef TEST_FORTRAN + && strcmp(EXPECTED_Fortran_COMPILER_VERSION, + TEST_Fortran_COMPILER_VERSION) == 0 +#endif + && TEST_C_COMPILER_VERSION_EQUALITY == 1 && + TEST_CXX_COMPILER_VERSION_EQUALITY == 1 +#ifdef TEST_FORTRAN + && TEST_Fortran_COMPILER_VERSION_EQUALITY == 1 +#endif + ) ? 0 : 1; } diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt index 55fd713300..1075a9d079 100644 --- a/Tests/ExternalProjectLocal/CMakeLists.txt +++ b/Tests/ExternalProjectLocal/CMakeLists.txt @@ -20,71 +20,55 @@ set(binary_base "${base}/Build") set_property(DIRECTORY PROPERTY EP_BASE ${base}) set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) -if(NOT DEFINED can_build_tutorial_step5) - set(can_build_tutorial_step5 1) - - # The ExternalProject builds of Tutorial Step5 cannot be built - # correctly 2nd and later times in an in-source build... - # (because the CMakeCache.txt from the real in-source build of - # the Tests/Tutorial/Step5 directory gets copied when we do - # the "source directory copy" step... but it still refers to - # its original path which yields a configure error.) So: - # - if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - set(can_build_tutorial_step5 0) - endif() -endif() # Local DIR: # -if(can_build_tutorial_step5) - set(proj TutorialStep5-Local) - ExternalProject_Add(${proj} - URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" - CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> - CMAKE_ARGS -G ${CMAKE_GENERATOR} <SOURCE_DIR> - TEST_BEFORE_INSTALL 1 - LOG_INSTALL 1 - ) - set_property(TARGET ${proj} PROPERTY FOLDER "Local") - ExternalProject_Get_Property(${proj} install_dir) - set(TutorialStep5_install_dir ${install_dir}) - - set(proj TutorialStep5-Local-TestAfterInstall) - ExternalProject_Add(${proj} - URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> - CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF - TEST_AFTER_INSTALL 1 - LOG_TEST 1 - ) - set_property(TARGET ${proj} PROPERTY FOLDER "Local") - - set(proj TutorialStep5-Local-TestExcludeFromMainBefore) - ExternalProject_Add(${proj} - URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> - CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF - TEST_BEFORE_INSTALL 1 - TEST_EXCLUDE_FROM_MAIN 1 - STEP_TARGETS test - LOG_TEST 1 - ) - set_property(TARGET ${proj} PROPERTY FOLDER "Local") - - set(proj TutorialStep5-Local-TestExcludeFromMainAfter) - ExternalProject_Add(${proj} - URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> - CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF - TEST_AFTER_INSTALL 1 - TEST_EXCLUDE_FROM_MAIN 1 - STEP_TARGETS test - LOG_TEST 1 - ) - set_property(TARGET ${proj} PROPERTY FOLDER "Local") +set(proj TutorialStep5-Local) +ExternalProject_Add(${proj} +URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5" +CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> +CMAKE_ARGS -G ${CMAKE_GENERATOR} <SOURCE_DIR> +TEST_BEFORE_INSTALL 1 +LOG_INSTALL 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local") +ExternalProject_Get_Property(${proj} install_dir) +set(TutorialStep5_install_dir ${install_dir}) + +set(proj TutorialStep5-Local-TestAfterInstall) +ExternalProject_Add(${proj} +URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5" +CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> +CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF +TEST_AFTER_INSTALL 1 +LOG_TEST 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local") + +set(proj TutorialStep5-Local-TestExcludeFromMainBefore) +ExternalProject_Add(${proj} +URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5" +CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> +CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF +TEST_BEFORE_INSTALL 1 +TEST_EXCLUDE_FROM_MAIN 1 +STEP_TARGETS test +LOG_TEST 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local") + +set(proj TutorialStep5-Local-TestExcludeFromMainAfter) +ExternalProject_Add(${proj} +URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5" +CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> +CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF +TEST_AFTER_INSTALL 1 +TEST_EXCLUDE_FROM_MAIN 1 +STEP_TARGETS test +LOG_TEST 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local") -endif() # Local TAR: @@ -209,12 +193,10 @@ enable_testing() # # BuildTree tests: # -if(can_build_tutorial_step5) - add_test(TutorialStep5-Local-BuildTreeTest - "${binary_base}/TutorialStep5-Local/Tutorial" 42) - set_property(TEST TutorialStep5-Local-BuildTreeTest - APPEND PROPERTY LABELS Step5 BuildTree) -endif() +add_test(TutorialStep5-Local-BuildTreeTest +"${binary_base}/TutorialStep5-Local/Tutorial" 42) +set_property(TEST TutorialStep5-Local-BuildTreeTest +APPEND PROPERTY LABELS Step5 BuildTree) add_test(TutorialStep1-LocalTAR-BuildTreeTest "${binary_base}/TutorialStep1-LocalTAR/EP-Tutorial" 36) @@ -234,12 +216,7 @@ add_test(TutorialStep1-LocalNoDirTGZ-BuildTreeTest # InstallTree tests: # -if(can_build_tutorial_step5) - add_test(TutorialStep5-InstallTreeTest - "${TutorialStep5_install_dir}/bin/Tutorial" 49) - set_property(TEST TutorialStep5-InstallTreeTest - APPEND PROPERTY LABELS Step5 InstallTree) -endif() - - -message(STATUS "can_build_tutorial_step5='${can_build_tutorial_step5}'") +add_test(TutorialStep5-InstallTreeTest +"${TutorialStep5_install_dir}/bin/Tutorial" 49) +set_property(TEST TutorialStep5-InstallTreeTest +APPEND PROPERTY LABELS Step5 InstallTree) diff --git a/Tests/ExternalProjectLocal/Step5/CMakeLists.txt b/Tests/ExternalProjectLocal/Step5/CMakeLists.txt new file mode 100644 index 0000000000..93b3880f06 --- /dev/null +++ b/Tests/ExternalProjectLocal/Step5/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) + +# The version number. +set (Tutorial_VERSION_MAJOR 1) +set (Tutorial_VERSION_MINOR 0) + +# does this system provide the log and exp functions? +include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) +check_function_exists (log HAVE_LOG) +check_function_exists (exp HAVE_EXP) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +include_directories ("${PROJECT_BINARY_DIR}") + +# add the MathFunctions library? +if (USE_MYMATH) + include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") + add_subdirectory (MathFunctions) + set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) +endif () + +# add the executable +add_executable (Tutorial tutorial.cxx) +target_link_libraries (Tutorial ${EXTRA_LIBS}) + +# add the install targets +install (TARGETS Tutorial DESTINATION bin) +install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include) + +# enable testing +enable_testing () + +# does the application run +add_test (TutorialRuns Tutorial 25) + +# does the usage message work? +add_test (TutorialUsage Tutorial) +set_tests_properties (TutorialUsage + PROPERTIES + PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +#define a macro to simplify adding tests +macro (do_test arg result) + add_test (TutorialComp${arg} Tutorial ${arg}) + set_tests_properties (TutorialComp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endmacro () + +# do a bunch of result based tests +do_test (4 "4 is 2") +do_test (9 "9 is 3") +do_test (5 "5 is 2.236") +do_test (7 "7 is 2.645") +do_test (25 "25 is 5") +do_test (-25 "-25 is 0") +do_test (0.0001 "0.0001 is 0.01") diff --git a/Tests/ExternalProjectLocal/Step5/MathFunctions/CMakeLists.txt b/Tests/ExternalProjectLocal/Step5/MathFunctions/CMakeLists.txt new file mode 100644 index 0000000000..453a46332e --- /dev/null +++ b/Tests/ExternalProjectLocal/Step5/MathFunctions/CMakeLists.txt @@ -0,0 +1,17 @@ +# first we add the executable that generates the table +# add the binary tree directory to the search path for include files +include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) + +add_executable(MakeTable MakeTable.cxx ) +# add the command to generate the source code +add_custom_command ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + +# add the main library +add_library(MathFunctions mysqrt.cxx ${CMAKE_CURRENT_BINARY_DIR}/Table.h ) + +install (TARGETS MathFunctions DESTINATION bin) +install (FILES MathFunctions.h DESTINATION include) diff --git a/Tests/ExternalProjectLocal/Step5/MathFunctions/MakeTable.cxx b/Tests/ExternalProjectLocal/Step5/MathFunctions/MakeTable.cxx new file mode 100644 index 0000000000..cebd50fcc1 --- /dev/null +++ b/Tests/ExternalProjectLocal/Step5/MathFunctions/MakeTable.cxx @@ -0,0 +1,32 @@ +// A simple program that builds a sqrt table +#include <math.h> +#include <stdio.h> + +int main(int argc, char* argv[]) +{ + int i; + double result; + + // make sure we have enough arguments + if (argc < 2) { + return 1; + } + + // open the output file + FILE* fout = fopen(argv[1], "w"); + if (!fout) { + return 1; + } + + // create a source file with a table of square roots + fprintf(fout, "double sqrtTable[] = {\n"); + for (i = 0; i < 10; ++i) { + result = sqrt(static_cast<double>(i)); + fprintf(fout, "%g,\n", result); + } + + // close the table with a zero + fprintf(fout, "0};\n"); + fclose(fout); + return 0; +} diff --git a/Tests/ExternalProjectLocal/Step5/MathFunctions/MathFunctions.h b/Tests/ExternalProjectLocal/Step5/MathFunctions/MathFunctions.h new file mode 100644 index 0000000000..cd36bccffd --- /dev/null +++ b/Tests/ExternalProjectLocal/Step5/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/ExternalProjectLocal/Step5/MathFunctions/mysqrt.cxx b/Tests/ExternalProjectLocal/Step5/MathFunctions/mysqrt.cxx new file mode 100644 index 0000000000..458ed63a15 --- /dev/null +++ b/Tests/ExternalProjectLocal/Step5/MathFunctions/mysqrt.cxx @@ -0,0 +1,40 @@ +#include "MathFunctions.h" +#include "TutorialConfig.h" +#include <stdio.h> + +// include the generated table +#include "Table.h" + +#include <math.h> + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) { + return 0; + } + + double result; + + // if we have both log and exp then use them + double delta; + + // use the table to help find an initial value + result = x; + if (x >= 1 && x < 10) { + result = sqrtTable[static_cast<int>(x)]; + } + + // do ten iterations + int i; + for (i = 0; i < 10; ++i) { + if (result <= 0) { + result = 0.1; + } + delta = x - (result * result); + result = result + 0.5 * delta / result; + fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + } + + return result; +} diff --git a/Tests/ExternalProjectLocal/Step5/TutorialConfig.h.in b/Tests/ExternalProjectLocal/Step5/TutorialConfig.h.in new file mode 100644 index 0000000000..e97ce24ea9 --- /dev/null +++ b/Tests/ExternalProjectLocal/Step5/TutorialConfig.h.in @@ -0,0 +1,8 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH + +// does the platform provide exp and log functions? +#cmakedefine HAVE_LOG +#cmakedefine HAVE_EXP diff --git a/Tests/ExternalProjectLocal/Step5/tutorial.cxx b/Tests/ExternalProjectLocal/Step5/tutorial.cxx new file mode 100644 index 0000000000..37f6ac4567 --- /dev/null +++ b/Tests/ExternalProjectLocal/Step5/tutorial.cxx @@ -0,0 +1,33 @@ +// A simple program that computes the square root of a number +#include "TutorialConfig.h" +#include <math.h> +#include <stdio.h> +#include <stdlib.h> + +#ifdef USE_MYMATH +# include "MathFunctions.h" +#endif + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, + Tutorial_VERSION_MINOR); + fprintf(stdout, "Usage: %s number\n", argv[0]); + return 1; + } + + double inputValue = atof(argv[1]); + double outputValue = 0; + + if (inputValue >= 0) { +#ifdef USE_MYMATH + outputValue = mysqrt(inputValue); +#else + outputValue = sqrt(inputValue); +#endif + } + + fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + return 0; +} diff --git a/Tests/ExternalProjectSourceSubdirNotCMake/CMakeLists.txt b/Tests/ExternalProjectSourceSubdirNotCMake/CMakeLists.txt new file mode 100644 index 0000000000..f64df1a77f --- /dev/null +++ b/Tests/ExternalProjectSourceSubdirNotCMake/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.6) +project(ExternalProjectSourceSubdirNotCMake NONE) +include(ExternalProject) + +find_program(MAKE_EXECUTABLE + NAMES gmake make) + +if (NOT MAKE_EXECUTABLE) + message("No `make` executable found; skipping") + return () +endif () + +ExternalProject_Add(Example + SOURCE_SUBDIR subdir + BUILD_IN_SOURCE 1 + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Example + CONFIGURE_COMMAND "" + BUILD_COMMAND "${MAKE_EXECUTABLE}" + INSTALL_COMMAND "" + ) diff --git a/Tests/ExternalProjectSourceSubdirNotCMake/Example/subdir/Makefile b/Tests/ExternalProjectSourceSubdirNotCMake/Example/subdir/Makefile new file mode 100644 index 0000000000..cab3b8f4b1 --- /dev/null +++ b/Tests/ExternalProjectSourceSubdirNotCMake/Example/subdir/Makefile @@ -0,0 +1,2 @@ +all: + echo "complete" diff --git a/Tests/FindGit/CMakeLists.txt b/Tests/FindGit/CMakeLists.txt new file mode 100644 index 0000000000..5d061f4696 --- /dev/null +++ b/Tests/FindGit/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindGit.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindGit/Test" + "${CMake_BINARY_DIR}/Tests/FindGit/Test" + ${build_generator_args} + --build-project TestFindGit + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindGit/Test/CMakeLists.txt b/Tests/FindGit/Test/CMakeLists.txt new file mode 100644 index 0000000000..26fb372e6a --- /dev/null +++ b/Tests/FindGit/Test/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.12) +project(TestFindGit NONE) +include(CTest) + +find_package(Git REQUIRED) + +add_test(NAME test_git + COMMAND ${CMAKE_COMMAND} + "-DGIT_EXECUTABLE=${GIT_EXECUTABLE}" + "-DGIT_EXECUTABLE_TARGET=$<TARGET_FILE:Git::Git>" + "-DGIT_VERSION_STRING=${GIT_VERSION_STRING}" + -P "${CMAKE_CURRENT_LIST_DIR}/RunGit.cmake" + ) diff --git a/Tests/FindGit/Test/RunGit.cmake b/Tests/FindGit/Test/RunGit.cmake new file mode 100644 index 0000000000..f798cd355a --- /dev/null +++ b/Tests/FindGit/Test/RunGit.cmake @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.12) + +function(run_git exe exe_display) + execute_process(COMMAND ${exe} --version + OUTPUT_VARIABLE output + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE result + ) + + if(NOT result EQUAL 0) + message(SEND_ERROR "Result of ${exe_display} --version is ${result}, should be 0") + endif() + + if(NOT output STREQUAL "git version ${GIT_VERSION_STRING}") + message(SEND_ERROR "Output of ${exe_display} --version is \"${output}\", should be \"git version ${GIT_VERSION_STRING}\"") + endif() +endfunction() + +run_git("${GIT_EXECUTABLE}" "\${GIT_EXECUTABLE}") +run_git("${GIT_EXECUTABLE_TARGET}" "Git::Git") diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 6a80df5f45..f8b36c555a 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -188,6 +188,37 @@ find_package(ArchC 3.1 EXACT NAMES zot) find_package(ArchD 4.0 EXACT NAMES zot) unset(CMAKE_LIBRARY_ARCHITECTURE) +# Test find_package() with CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS enabled +if(UNIX) + # Create ./symlink pointing back here. + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + . "${CMAKE_CURRENT_SOURCE_DIR}/symlink") + # Make find_package search through the symlink + set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/symlink") + + # First, test the default behavior where symlinks are preserved. + set(SetFoundResolved_DIR "") + find_package(SetFoundResolved) + # The result must preserve the /symlink/ path. + set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/symlink/cmake") + if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}") + message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") + endif() + + # Resolve symlinks when finding the package. + set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE) + set(SetFoundResolved_DIR "") + find_package(SetFoundResolved) + # ./symlink points back here so it should be gone when resolved. + set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}") + message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") + endif() + # Cleanup. + unset(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS) + file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/symlink") +endif() + # Test <PackageName>_DIR environment variable. # We erase the main prefix path to ensure the env var is used. set(CMAKE_PREFIX_PATH) diff --git a/Tests/FindPackageTest/cmake/SetFoundResolvedConfig.cmake b/Tests/FindPackageTest/cmake/SetFoundResolvedConfig.cmake new file mode 100644 index 0000000000..b2cf87ce62 --- /dev/null +++ b/Tests/FindPackageTest/cmake/SetFoundResolvedConfig.cmake @@ -0,0 +1 @@ +set(SetFoundResolved_DIR "${CMAKE_CURRENT_LIST_DIR}") diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index 639d29c65f..38211a4bb5 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -1,69 +1,94 @@ -add_test(NAME FindPython.Python2 COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2" - ${build_generator_args} - --build-project TestPython2 - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) +if(CMake_TEST_FindPython) + add_test(NAME FindPython.Python2 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2" + ${build_generator_args} + --build-project TestPython2 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) -add_test(NAME FindPython.Python2Fail COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Fail" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2Fail" - ${build_generator_args} - --build-project TestPython2Fail - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) -set_tests_properties(FindPython.Python2Fail PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") + add_test(NAME FindPython.Python2Fail COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Fail" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2Fail" + ${build_generator_args} + --build-project TestPython2Fail + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + set_tests_properties(FindPython.Python2Fail PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") -add_test(NAME FindPython.Python3 COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3" - ${build_generator_args} - --build-project TestPython3 - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) + add_test(NAME FindPython.Python3 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3" + ${build_generator_args} + --build-project TestPython3 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) -add_test(NAME FindPython.Python3Fail COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Fail" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3Fail" - ${build_generator_args} - --build-project TestPython3Fail - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) -set_tests_properties(FindPython.Python3Fail PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)") + add_test(NAME FindPython.Python3Fail COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Fail" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3Fail" + ${build_generator_args} + --build-project TestPython3Fail + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + set_tests_properties(FindPython.Python3Fail PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)") -add_test(NAME FindPython.Python COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) + add_test(NAME FindPython.Python COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + add_test(NAME FindPython.MultiplePackages COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages" + "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages" + ${build_generator_args} + --build-project TestMultiplePackages + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +endif() -add_test(NAME FindPython.MultiplePackages COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages" - "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages" - ${build_generator_args} - --build-project TestMultiplePackages - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> +if(CMake_TEST_FindPython_NumPy) + add_test(NAME FindPython.NumPy COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/NumPy" + "${CMake_BINARY_DIR}/Tests/FindPython/NumPy" + ${build_generator_args} + --build-project TestNumPy + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.NumPyOnly COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/NumPyOnly" + "${CMake_BINARY_DIR}/Tests/FindPython/NumPyOnly" + ${build_generator_args} + --build-project TestNumPyOnly + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + endif() diff --git a/Tests/FindPython/FindPythonScript.cmake b/Tests/FindPython/FindPythonScript.cmake new file mode 100644 index 0000000000..94500920eb --- /dev/null +++ b/Tests/FindPython/FindPythonScript.cmake @@ -0,0 +1 @@ +find_package(${PYTHON_PACKAGE_NAME} REQUIRED QUIET) diff --git a/Tests/FindPython/NumPy/CMakeLists.txt b/Tests/FindPython/NumPy/CMakeLists.txt new file mode 100644 index 0000000000..f55702666d --- /dev/null +++ b/Tests/FindPython/NumPy/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestNumPy C) + +find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy) +find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy) + +Python2_add_library (arraytest2 MODULE arraytest.c) +target_compile_definitions (arraytest2 PRIVATE PYTHON2) +target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + +Python3_add_library (arraytest3 MODULE arraytest.c) +target_compile_definitions (arraytest3 PRIVATE PYTHON3) +target_link_libraries (arraytest3 PRIVATE Python3::NumPy) + +add_test (NAME python2_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest2>" + "${Python2_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));") + +add_test (NAME python3_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>" + "${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));") diff --git a/Tests/FindPython/NumPy/arraytest.c b/Tests/FindPython/NumPy/arraytest.c new file mode 100644 index 0000000000..135877ddf9 --- /dev/null +++ b/Tests/FindPython/NumPy/arraytest.c @@ -0,0 +1,58 @@ +#include "Python.h" + +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include "arrayobject.h" + +#include <math.h> + +static PyObject* vecsq(PyObject* self, PyObject* args); + +static PyMethodDef arraytestMethods[] = { { "vecsq", vecsq, METH_VARARGS }, + { NULL, NULL } }; + +static PyObject* vecsq(PyObject* self, PyObject* args) +{ + PyArrayObject *vecin, *vecout; + npy_intp dims[2]; + double *cin, *cout; + int i, j, n, m; + + if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &vecin)) + return NULL; + + n = dims[0] = PyArray_NDIM(vecin); + vecout = (PyArrayObject*)PyArray_SimpleNew(1, dims, NPY_DOUBLE); + + cin = (double*)PyArray_DATA(vecin); + cout = (double*)PyArray_DATA(vecout); + + for (i = 0; i < n; i++) { + cout[i] = cin[i] * cin[i]; + } + return PyArray_Return(vecout); +} + +#if defined(PYTHON2) +PyMODINIT_FUNC init_C_arraytest(void) +{ + (void)Py_InitModule("arraytest2", arraytestMethods); + import_array(); +} +#endif + +#if defined(PYTHON3) +static struct PyModuleDef arraytestmodule = { + PyModuleDef_HEAD_INIT, "arraytest3", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + arraytestMethods +}; + +PyMODINIT_FUNC PyInit_C_arraytest(void) +{ + PyObject* po = PyModule_Create(&arraytestmodule); + import_array(); + return po; +} +#endif diff --git a/Tests/FindPython/NumPyOnly/CMakeLists.txt b/Tests/FindPython/NumPyOnly/CMakeLists.txt new file mode 100644 index 0000000000..a5db6037c4 --- /dev/null +++ b/Tests/FindPython/NumPyOnly/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestNumPyOnly C) + +find_package(Python2 REQUIRED COMPONENTS NumPy) +find_package(Python3 REQUIRED COMPONENTS NumPy) + +Python2_add_library (arraytest2 MODULE ../NumPy/arraytest.c) +target_compile_definitions (arraytest2 PRIVATE PYTHON2) +target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + +Python3_add_library (arraytest3 MODULE ../NumPy/arraytest.c) +target_compile_definitions (arraytest3 PRIVATE PYTHON3) +target_link_libraries (arraytest3 PRIVATE Python3::NumPy) diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt index bebd23fc82..f7fc24368f 100644 --- a/Tests/FindPython/Python/CMakeLists.txt +++ b/Tests/FindPython/Python/CMakeLists.txt @@ -9,9 +9,21 @@ if (NOT Python_FOUND) message (FATAL_ERROR "Fail to found Python 3") endif() +if(NOT TARGET Python::Interpreter) + message(SEND_ERROR "Python::Interpreter not found") +endif() + +if(NOT TARGET Python::Python) + message(SEND_ERROR "Python::Python not found") +endif() + Python_add_library (spam3 MODULE ../spam.c) target_compile_definitions (spam3 PRIVATE PYTHON3) add_test (NAME python_spam3 COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" "${Python_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") + +add_test(NAME findpython_script + COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python + -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt index 9622b6fa64..a0753f611a 100644 --- a/Tests/FindPython/Python2/CMakeLists.txt +++ b/Tests/FindPython/Python2/CMakeLists.txt @@ -14,9 +14,21 @@ if (NOT Python2_FOUND) message (FATAL_ERROR "Fail to found Python 2") endif() +if(NOT TARGET Python2::Interpreter) + message(SEND_ERROR "Python2::Interpreter not found") +endif() + +if(NOT TARGET Python2::Python) + message(SEND_ERROR "Python2::Python not found") +endif() + Python2_add_library (spam2 MODULE ../spam.c) target_compile_definitions (spam2 PRIVATE PYTHON2) add_test (NAME python2_spam2 COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>" "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")") + +add_test(NAME findpython2_script + COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python2 + -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt index cb86eae68d..65eea4c271 100644 --- a/Tests/FindPython/Python3/CMakeLists.txt +++ b/Tests/FindPython/Python3/CMakeLists.txt @@ -14,9 +14,21 @@ if (NOT Python3_FOUND) message (FATAL_ERROR "Fail to found Python 3") endif() +if(NOT TARGET Python3::Interpreter) + message(SEND_ERROR "Python2::Interpreter not found") +endif() + +if(NOT TARGET Python3::Python) + message(SEND_ERROR "Python2::Python not found") +endif() + Python3_add_library (spam3 MODULE ../spam.c) target_compile_definitions (spam3 PRIVATE PYTHON3) add_test (NAME python3_spam3 COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") + +add_test(NAME findpython3_script + COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3 + -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") diff --git a/Tests/GhsMulti/CMakeLists.txt b/Tests/GhsMulti/CMakeLists.txt deleted file mode 100644 index 6e15ba9a7f..0000000000 --- a/Tests/GhsMulti/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(ReturnNum) - -add_subdirectory(ReturnNum) diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt new file mode 100644 index 0000000000..4a3f5c2381 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt @@ -0,0 +1,92 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +message("Copy project") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/src/CMakeLists.txt COPYONLY) + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.c + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src +) + +message("Building project") +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +try_compile(RESULT + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/src + test + CMAKE_FLAGS + -DRUN_TEST=${RUN_TEST} + -DCMAKE_BUILD_TYPE=${RUN_TEST_BUILD_TYPE} + OUTPUT_VARIABLE OUTPUT) + +message("Output from build:\n${OUTPUT}") +if (RUN_TEST STREQUAL "RELEASE_FLAGS") + find_file (fileName test_none.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/test_none + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-unexpected_release_option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( NOT opt_found EQUAL -1 ) + message(SEND_ERROR "Release option found: ${opt}") + endif() +else() + unset(fileName CACHE) + find_file (fileName K1.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/K1 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-required-debug-option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Missing debug option: ${opt}") + endif() + + unset(fileName CACHE) + find_file (fileName K2.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/K2 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-required-debug-option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Missing debug option: ${opt}") + endif() + + unset(fileName CACHE) + find_file (fileName K3.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/K3 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-required-debug-option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Missing debug option: ${opt}") + endif() + + unset(fileName CACHE) + find_file (fileName K4.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/K4 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-required-debug-option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Missing debug option: ${opt}") + endif() +endif() diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in new file mode 100644 index 0000000000..fc24d907b7 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in @@ -0,0 +1,32 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + +if(RUN_TEST STREQUAL "RELEASE_FLAGS") + #RELEASE flags used when CMAKE_BUILD_TYPE is undefined + string(APPEND CMAKE_C_FLAGS_RELEASE " -unexpected_release_option") + add_executable(test_none test.c) +endif() + +if(RUN_TEST STREQUAL "KERNEL_FLAGS") + #DEBUG flag missing when -kernel is added as a compile option + string(APPEND CMAKE_C_FLAGS_DEBUG " -required-debug-option") + + add_executable(K1 test.c) + + add_executable(K2 test.c) + target_compile_options(K2 PRIVATE -kernel) + + add_executable(K3 test.c) + target_compile_options(K3 PRIVATE -kernel=fast) + + add_executable(K4 test.c) + target_link_options(K4 PRIVATE -kernel) +endif() diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/test.c b/Tests/GhsMulti/GhsMultiCompilerOptions/test.c new file mode 100644 index 0000000000..95f2e8ec1e --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/test.c @@ -0,0 +1,4 @@ +int main(void) +{ + return -1; +} diff --git a/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt new file mode 100644 index 0000000000..d6d007d9c5 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt @@ -0,0 +1,30 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +try_compile(RESULT + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_SOURCE_DIR}/test.c + OUTPUT_VARIABLE OUTPUT + COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/test_library" +) + +message(STATUS "Output from build:\n${OUTPUT}") + +if(NOT RESULT) + message(SEND_ERROR "try_compile() failed") +endif() + +if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/test_library") + if (IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_library") + message(SEND_ERROR "library is folder !") + else() + message(STATUS "library seems okay") + endif() +else() + message(SEND_ERROR "library is not found !") +endif() diff --git a/Tests/GhsMulti/GhsMultiCopyFile/test.c b/Tests/GhsMulti/GhsMultiCopyFile/test.c new file mode 100644 index 0000000000..5c657b5613 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCopyFile/test.c @@ -0,0 +1,4 @@ +int lib(int x) +{ + return -x; +} diff --git a/Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt index 82a014bb7f..a1f152f295 100644 --- a/Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt @@ -1,15 +1,17 @@ cmake_minimum_required(VERSION 3.5) -project(demo C) +project(test C) add_library(libdemo test.c + testCase.c subfolder_test.c subfolder_test_0.c "subfolder/test.c" + subfolder/testcase.c ) add_executable(demo main.c) target_link_libraries(demo libdemo) -if(GHSMULTI) - target_compile_options(demo PUBLIC "-non_shared") +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + target_link_options(demo PRIVATE "-non_shared") endif() diff --git a/Tests/GhsMultiDuplicateSourceFilenames/main.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/main.c index d5b7914094..d4ef7bb0f0 100644 --- a/Tests/GhsMultiDuplicateSourceFilenames/main.c +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/main.c @@ -2,6 +2,8 @@ int test_a(void); int test_b(void); int test_c(void); int test_d(void); +int test_e(void); +int test_f(void); int main(int argc, char* argv[]) { @@ -9,5 +11,7 @@ int main(int argc, char* argv[]) test_b(); test_c(); test_d(); + test_e(); + test_f(); return 0; } diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/test.c index e1e1759216..5d857dde67 100644 --- a/Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/test.c @@ -1,4 +1,3 @@ - int test_b() { return 2; diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/testcase.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/testcase.c new file mode 100644 index 0000000000..66ee6f3806 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/testcase.c @@ -0,0 +1,4 @@ +int test_f() +{ + return 1; +} diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test.c index c552e6a13e..83589ba196 100644 --- a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test.c @@ -1,4 +1,3 @@ - int test_c() { return 1; diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c index 170b33d2c8..82f9a52b7b 100644 --- a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c @@ -1,4 +1,3 @@ - int test_d() { return 1; diff --git a/Tests/GhsMultiDuplicateSourceFilenames/test.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/test.c index 5ffcbdf720..feba80efc7 100644 --- a/Tests/GhsMultiDuplicateSourceFilenames/test.c +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/test.c @@ -1,4 +1,3 @@ - int test_a() { return 1; diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/testCase.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/testCase.c new file mode 100644 index 0000000000..943c19de6d --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/testCase.c @@ -0,0 +1,4 @@ +int test_e() +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt new file mode 100644 index 0000000000..0448cf2d67 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + +add_library(lib1 lib1.c) +set_target_properties( lib1 PROPERTIES EXCLUDE_FROM_ALL yes ) + +add_library(lib2 EXCLUDE_FROM_ALL lib1.c) + +add_executable(exe1 exe1.c) diff --git a/Tests/GhsMulti/GhsMultiExclude/exe1.c b/Tests/GhsMulti/GhsMultiExclude/exe1.c new file mode 100644 index 0000000000..8488f4e58f --- /dev/null +++ b/Tests/GhsMulti/GhsMultiExclude/exe1.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/GhsMulti/GhsMultiExclude/lib1.c b/Tests/GhsMulti/GhsMultiExclude/lib1.c new file mode 100644 index 0000000000..b35e9cc5ec --- /dev/null +++ b/Tests/GhsMulti/GhsMultiExclude/lib1.c @@ -0,0 +1,4 @@ +int func(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiExclude/verify.cmake b/Tests/GhsMulti/GhsMultiExclude/verify.cmake new file mode 100644 index 0000000000..0467b5a0d2 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiExclude/verify.cmake @@ -0,0 +1,54 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#test project was generated +unset(fileName CACHE) +find_file (fileName lib1.gpj + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/lib1 + ) + +if (fileName) + message("Found target lib1: ${fileName}") +else() + message(SEND_ERROR "Could not find target lib1: ${fileName}") +endif() + +#test project was built +unset(fileName CACHE) +find_file (fileName lib1.a + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/lib1 + ) + +if (fileName) + message(SEND_ERROR "Found target lib1: ${fileName}") +else() + message("Could not find target lib1: ${fileName}") +endif() + +#test project was generated +unset(fileName CACHE) +find_file (fileName lib2.gpj + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/lib2 + ) + +if (fileName) + message("Found target lib2 ${fileName}") +else() + message(SEND_ERROR "Could not find target lib2: ${fileName}") +endif() + +#test project was built +unset(fileName CACHE) +find_file (fileName lib2.a + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/lib2 + ) + +if (fileName) + message(SEND_ERROR "Found target lib2: ${fileName}") +else() + message("Could not find target lib2: ${fileName}") +endif() diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt new file mode 100644 index 0000000000..d4cbf04768 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt @@ -0,0 +1,19 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +add_link_options("-non_shared") + +# create virtual AS +add_executable(vas exe.c) +target_link_libraries(vas lib) +add_library(lib func.c) + +# create dynamic download INTEGRITY application +add_executable(dynamic) +set_target_properties(dynamic PROPERTIES ghs_integrity_app ON) +target_compile_options(dynamic PRIVATE -dynamic) +add_dependencies(dynamic vas) diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/exe.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/exe.c new file mode 100644 index 0000000000..29ad70a3b5 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/exe.c @@ -0,0 +1,5 @@ +extern int func(void); +int main(void) +{ + return func(); +} diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/func.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/func.c new file mode 100644 index 0000000000..b35e9cc5ec --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/func.c @@ -0,0 +1,4 @@ +int func(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/ReturnNum/App/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt index 2adbd4e3d0..e431217aaf 100644 --- a/Tests/GhsMulti/ReturnNum/App/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../Lib) add_executable(App Main.c) +target_include_directories(App PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../Lib) target_link_libraries(App Lib) target_compile_options(App PUBLIC "-non_shared") diff --git a/Tests/GhsMulti/ReturnNum/App/Main.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/Main.c index db8d6587d3..db8d6587d3 100644 --- a/Tests/GhsMulti/ReturnNum/App/Main.c +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/Main.c diff --git a/Tests/GhsMulti/ReturnNum/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/CMakeLists.txt index 7bcc5f96a5..92254e673e 100644 --- a/Tests/GhsMulti/ReturnNum/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/CMakeLists.txt @@ -1,3 +1,6 @@ +cmake_minimum_required(VERSION 3.1) +project(test) + add_subdirectory(App) add_subdirectory(Int) add_subdirectory(Lib) diff --git a/Tests/GhsMulti/ReturnNum/Int/AppDD.int b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/AppDD.int index 9e22b5e258..5035d581a3 100644 --- a/Tests/GhsMulti/ReturnNum/Int/AppDD.int +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/AppDD.int @@ -7,6 +7,6 @@ Kernel EndKernel AddressSpace App - Filename "App/App.as" + Filename "App/App" Language C EndAddressSpace diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/CMakeLists.txt new file mode 100644 index 0000000000..d173c0151c --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(AppDD AppDD.int) diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt new file mode 100644 index 0000000000..00e0f59b8f --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt @@ -0,0 +1 @@ +add_library(Lib HelperFun.c HelperFun.h) diff --git a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.c index 61922bb755..61922bb755 100644 --- a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.c +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.c diff --git a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.h b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.h index 00971b04f2..00971b04f2 100644 --- a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.h +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.h diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt new file mode 100644 index 0000000000..c5db1551a4 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt @@ -0,0 +1,20 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +add_link_options("-non_shared") + +project(test C) + +# create virtual AS +add_executable(vas exe.c) +target_link_libraries(vas lib) +add_library(lib func.c) + +# create kernel +add_executable(kernel kernel.c) +target_link_options(kernel PRIVATE -kernel) + +# create monolith INTEGRITY application +add_executable(monolith test.int) diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/exe.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/exe.c new file mode 100644 index 0000000000..29ad70a3b5 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/exe.c @@ -0,0 +1,5 @@ +extern int func(void); +int main(void) +{ + return func(); +} diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/func.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/func.c new file mode 100644 index 0000000000..c302418f95 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/func.c @@ -0,0 +1,5 @@ + +int func(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/kernel.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/kernel.c new file mode 100644 index 0000000000..d1bce33c9a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/kernel.c @@ -0,0 +1,15 @@ +#include "INTEGRITY.h" +#include "boottable.h" + +void main() +{ + Exit(0); +} + +/* This global table will be filled in during the Integrate phase with */ +/* information about the AddressSpaces, Tasks, and Objects that are to be */ +/* created. If you do not plan to use Integrate, you may omit this file from + */ +/* the kernel, and the boot table code will then not be included. */ + +GlobalTable TheGlobalTable = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/test.int b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/test.int new file mode 100644 index 0000000000..361793a861 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/test.int @@ -0,0 +1,8 @@ +Kernel + Filename kernel +EndKernel + +AddressSpace App + Filename vas + Language C +EndAddressSpace diff --git a/Tests/GhsMulti/GhsMultiInterface/CMakeLists.txt b/Tests/GhsMulti/GhsMultiInterface/CMakeLists.txt new file mode 100644 index 0000000000..fa0dce0273 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiInterface/CMakeLists.txt @@ -0,0 +1,8 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +add_library(iface INTERFACE) diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt new file mode 100644 index 0000000000..da80b510f6 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt @@ -0,0 +1,92 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +message("Copy project") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/link_src/CMakeLists.txt COPYONLY) + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/exe1.c + ${CMAKE_CURRENT_SOURCE_DIR}/exe1.h + ${CMAKE_CURRENT_SOURCE_DIR}/func2.c + ${CMAKE_CURRENT_SOURCE_DIR}/func3.c + ${CMAKE_CURRENT_SOURCE_DIR}/func4.c + ${CMAKE_CURRENT_SOURCE_DIR}/func5.c + ${CMAKE_CURRENT_SOURCE_DIR}/func6.c + ${CMAKE_CURRENT_SOURCE_DIR}/func7.c + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/link_src +) + +message("Building project") +try_compile(RESULT + ${CMAKE_CURRENT_BINARY_DIR}/link_build + ${CMAKE_CURRENT_BINARY_DIR}/link_src + test + CMAKE_FLAGS + -DRUN_TEST=${RUN_TEST} + -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} + OUTPUT_VARIABLE OUTPUT) + +message("Output from build:\n${OUTPUT}") +if (RUN_TEST STREQUAL "NO_FLAGS") + if(NOT RESULT) + message(SEND_ERROR "Could not build test project (1)!") + endif() +else() + unset(fileName CACHE) + find_file(fileName exe1.gpj + ${CMAKE_CURRENT_BINARY_DIR}/link_build + ${CMAKE_CURRENT_BINARY_DIR}/link_build/exe1 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(expected_flags + -add-link-options1 -add-link-options2 + link_directories_used1 link_directories_used2 "c:/absolute" + link_libraries_used1 link_libraries_used2 + -lcsl1 csl2 + -clinkexe1 -clinkexe2 + -special-lib2-public-link) + foreach(opt IN LISTS expected_flags) + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Could not find: ${opt}") + endif() + endforeach() + + unset(fileName CACHE) + find_file (fileName lib1.gpj + ${CMAKE_CURRENT_BINARY_DIR}/link_build + ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib1 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(expected_flags + -clinkexeA1 -clinkexeA2 + -static-lib-flags1 -static-lib-flags2) + foreach(opt IN LISTS expected_flags) + string(FIND "${fileText}" "${opt}" opt_found) + if (opt_found EQUAL -1) + message(SEND_ERROR "Could not find: ${opt}") + endif() + endforeach() + + unset(fileName CACHE) + find_file (fileName lib2.gpj + ${CMAKE_CURRENT_BINARY_DIR}/link_build + ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib2 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(expected_flags + -clinkexeA1 -clinkexeA2) + foreach(opt IN LISTS expected_flags) + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Could not find: ${opt}") + endif() + endforeach() +endif() diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in new file mode 100644 index 0000000000..58c2115243 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in @@ -0,0 +1,43 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + add_link_options(-add-link-options1 -add-link-options2) + link_directories(link_directories_used1 link_directories_used2 "c:/absolute") + link_libraries(link_libraries_used1 link_libraries_used2 ) + set( CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lcsl1 csl2" ) + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -clinkexe1 -clinkexe2") +endif() + +add_executable(exe1 exe1.c) +target_link_libraries(exe1 lib1) + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + set_property(TARGET exe1 APPEND_STRING PROPERTY LINK_FLAGS "--link-flag-prop1 --link-flag-prop2") + set_property(TARGET exe1 APPEND PROPERTY LINK_OPTIONS --link-opt-prop1 --link-opt-prop2) +endif() + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + set(CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS} "-clinkexeA1 -clinkexeA2") +endif() + +add_library(lib1 STATIC func2.c func3.c func4.c) +target_link_libraries(lib1 lib2) + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + set_property(TARGET lib1 APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS "-static-lib-flags1 -static-lib-flags2") +endif() + +add_library(lib2 STATIC func5.c func6.c func7.c) + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + target_link_options(lib2 PUBLIC -special-lib2-public-link) +endif() diff --git a/Tests/GhsMulti/GhsMultiLinkTest/exe1.c b/Tests/GhsMulti/GhsMultiLinkTest/exe1.c new file mode 100644 index 0000000000..f21c12645e --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/exe1.c @@ -0,0 +1,6 @@ +#include "exe1.h" + +int main(void) +{ + return func2a() + func3a() + func4a() + func5a() + func6a() + func7a(); +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/exe1.h b/Tests/GhsMulti/GhsMultiLinkTest/exe1.h new file mode 100644 index 0000000000..e2b172570a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/exe1.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func2.c b/Tests/GhsMulti/GhsMultiLinkTest/func2.c new file mode 100644 index 0000000000..8f66fba252 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func2.c @@ -0,0 +1,4 @@ +int func2a(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func3.c b/Tests/GhsMulti/GhsMultiLinkTest/func3.c new file mode 100644 index 0000000000..57c7a6ffb0 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func3.c @@ -0,0 +1,4 @@ +int func3a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func4.c b/Tests/GhsMulti/GhsMultiLinkTest/func4.c new file mode 100644 index 0000000000..109fd7b4ae --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func4.c @@ -0,0 +1,4 @@ +int func4a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func5.c b/Tests/GhsMulti/GhsMultiLinkTest/func5.c new file mode 100644 index 0000000000..f28a705d46 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func5.c @@ -0,0 +1,4 @@ +int func5a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func6.c b/Tests/GhsMulti/GhsMultiLinkTest/func6.c new file mode 100644 index 0000000000..bf77406589 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func6.c @@ -0,0 +1,4 @@ +int func6a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func7.c b/Tests/GhsMulti/GhsMultiLinkTest/func7.c new file mode 100644 index 0000000000..6a4a9a1f0a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func7.c @@ -0,0 +1,4 @@ +int func7a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTestSub/CMakeLists.txt new file mode 100644 index 0000000000..145dac0eb0 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/CMakeLists.txt @@ -0,0 +1,9 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +add_subdirectory(sub_exe) +add_subdirectory(sub_lib) diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt new file mode 100644 index 0000000000..f49e33d6cc --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt @@ -0,0 +1,12 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +add_executable(exe1 exe1.c) +target_link_libraries(exe1 lib1) +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + target_link_options(exe1 PRIVATE "-non_shared") +endif() diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.c new file mode 100644 index 0000000000..f21c12645e --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.c @@ -0,0 +1,6 @@ +#include "exe1.h" + +int main(void) +{ + return func2a() + func3a() + func4a() + func5a() + func6a() + func7a(); +} diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.h b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.h new file mode 100644 index 0000000000..e2b172570a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/CMakeLists.txt new file mode 100644 index 0000000000..90397304f6 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/CMakeLists.txt @@ -0,0 +1,7 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +add_library(lib1 STATIC func2.c func3.c func4.c) +target_link_libraries(lib1 lib2) + +add_library(lib2 STATIC func5.c func6.c func7.c) diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func2.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func2.c new file mode 100644 index 0000000000..8f66fba252 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func2.c @@ -0,0 +1,4 @@ +int func2a(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func3.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func3.c new file mode 100644 index 0000000000..57c7a6ffb0 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func3.c @@ -0,0 +1,4 @@ +int func3a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func4.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func4.c new file mode 100644 index 0000000000..109fd7b4ae --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func4.c @@ -0,0 +1,4 @@ +int func4a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func5.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func5.c new file mode 100644 index 0000000000..f28a705d46 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func5.c @@ -0,0 +1,4 @@ +int func5a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func6.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func6.c new file mode 100644 index 0000000000..bf77406589 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func6.c @@ -0,0 +1,4 @@ +int func6a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func7.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func7.c new file mode 100644 index 0000000000..6a4a9a1f0a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func7.c @@ -0,0 +1,4 @@ +int func7a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt b/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt new file mode 100644 index 0000000000..9e077a9a46 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + +add_library(lib1 lib1.c) +add_executable(exe1 exe1.c) +target_link_libraries(exe1 lib1) + +add_subdirectory(sub) +add_subdirectory(sub2 examples EXCLUDE_FROM_ALL) diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/exe1.c b/Tests/GhsMulti/GhsMultiMultipleProjects/exe1.c new file mode 100644 index 0000000000..b9cdd61e72 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/exe1.c @@ -0,0 +1,5 @@ +extern int lib1_func(void); +int main(void) +{ + return lib1_func(); +} diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/lib1.c b/Tests/GhsMulti/GhsMultiMultipleProjects/lib1.c new file mode 100644 index 0000000000..5100945892 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/lib1.c @@ -0,0 +1,4 @@ +int lib1_func(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub/CMakeLists.txt b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/CMakeLists.txt new file mode 100644 index 0000000000..0d83bc310b --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/CMakeLists.txt @@ -0,0 +1,10 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test2 C) + +add_library(lib2 lib2.c) +add_executable(exe2 exe2.c) +target_link_libraries(exe2 lib1 lib2) diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub/exe2.c b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/exe2.c new file mode 100644 index 0000000000..9238cf369a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/exe2.c @@ -0,0 +1,6 @@ +extern int func(void); +extern int lib1_func(void); +int main(void) +{ + return func() + lib1_func(); +} diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub/lib2.c b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/lib2.c new file mode 100644 index 0000000000..b35e9cc5ec --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/lib2.c @@ -0,0 +1,4 @@ +int func(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/CMakeLists.txt b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/CMakeLists.txt new file mode 100644 index 0000000000..e42e7fb2c6 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/CMakeLists.txt @@ -0,0 +1,10 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test3 C) + +add_library(lib3 lib3.c) +add_executable(exe3 exe3.c) +target_link_libraries(exe3 lib1 lib3) diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/exe3.c b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/exe3.c new file mode 100644 index 0000000000..9238cf369a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/exe3.c @@ -0,0 +1,6 @@ +extern int func(void); +extern int lib1_func(void); +int main(void) +{ + return func() + lib1_func(); +} diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/lib3.c b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/lib3.c new file mode 100644 index 0000000000..b35e9cc5ec --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/lib3.c @@ -0,0 +1,4 @@ +int func(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake new file mode 100644 index 0000000000..3855215afb --- /dev/null +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake @@ -0,0 +1,58 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#test project was generated +unset(fileName CACHE) +find_file(fileName lib3.gpj + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/lib3 + ${CMAKE_CURRENT_BINARY_DIR}/examples + ) + +if (fileName) + message("Found target lib3: ${fileName}") +else() + message(SEND_ERROR "Could not find target lib3: ${fileName}") +endif() + +#test project was generated +unset(fileName CACHE) +find_file (fileName exe3.gpj + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/exe3 + ${CMAKE_CURRENT_BINARY_DIR}/examples + ) + +if (fileName) + message("Found target exe3: ${fileName}") +else() + message(SEND_ERROR "Could not find target exe3: ${fileName}") +endif() + +#test project was not built +unset(fileName CACHE) +find_file (fileName lib3.a + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/lib3 + ${CMAKE_CURRENT_BINARY_DIR}/examples + ) + +if (fileName) + message(SEND_ERROR "Found target lib3: ${fileName}") +else() + message("Could not find target lib3: ${fileName}") +endif() + +unset(fileName CACHE) +find_file (fileName NAMES exe3.as exe3 + HINTS + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/exe3 + ${CMAKE_CURRENT_BINARY_DIR}/examples + ) + +if (fileName) + message(SEND_ERROR "Found target exe3: ${fileName}") +else() + message("Could not find target exe3: ${fileName}") +endif() diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt b/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt new file mode 100644 index 0000000000..a025814eda --- /dev/null +++ b/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt @@ -0,0 +1,13 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +add_library(obj1 OBJECT testObj.c testObj.h sub/testObj.c testObj2.c) + +add_executable(exe1 exe.c $<TARGET_OBJECTS:obj1>) +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + target_link_options(exe1 PRIVATE "-non_shared") +endif() diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/exe.c b/Tests/GhsMulti/GhsMultiObjectLibrary/exe.c new file mode 100644 index 0000000000..c2c5a19455 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiObjectLibrary/exe.c @@ -0,0 +1,8 @@ +extern int funcOBJ(void); +extern int funcOBJ2(void); +extern int funcOBJs(void); + +int main(void) +{ + return funcOBJ() + funcOBJ2() + funcOBJs(); +} diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/sub/testOBJ.c b/Tests/GhsMulti/GhsMultiObjectLibrary/sub/testOBJ.c new file mode 100644 index 0000000000..5228ef2644 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiObjectLibrary/sub/testOBJ.c @@ -0,0 +1,4 @@ +int funcOBJs(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.c b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.c new file mode 100644 index 0000000000..ec6f2c3312 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.c @@ -0,0 +1,4 @@ +int funcOBJ(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.h b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.h new file mode 100644 index 0000000000..9aef4315c2 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.h @@ -0,0 +1 @@ +extern int funcOBJ(void); diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ2.c b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ2.c new file mode 100644 index 0000000000..b6a9b93f25 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ2.c @@ -0,0 +1,4 @@ +int funcOBJ2(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt b/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt new file mode 100644 index 0000000000..b177887c91 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt @@ -0,0 +1,34 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test) + +message("PLATFORM_ID = ${PLATFORM_ID}") + +message("CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}") +message("CMAKE_C_COMPILER_ID = ${CMAKE_C_COMPILER_ID}") +message("CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION}") +message("CMAKE_C_COMPILER_VERSION_INTERNAL = ${CMAKE_C_COMPILER_VERSION_INTERNAL}") +message("CMAKE_C_PLATFORM_ID = ${CMAKE_C_PLATFORM_ID}") +message("CMAKE_C_COMPILER_ARCHITECTURE_ID = ${CMAKE_C_COMPILER_ARCHITECTURE_ID}") +message("CMAKE_C_COMPILER_ABI = ${CMAKE_C_COMPILER_ABI}") +message("CMAKE_C_STANDARD_COMPUTED_DEFAULT = ${CMAKE_C_STANDARD_COMPUTED_DEFAULT}") + +message("CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}") +message("CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}") +message("CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}") +message("CMAKE_CXX_COMPILER_VERSION_INTERNAL = ${CMAKE_CXX_COMPILER_VERSION_INTERNAL}") +message("CMAKE_CXX_PLATFORM_ID = ${CMAKE_CXX_PLATFORM_ID}") +message("CMAKE_CXX_COMPILER_ARCHITECTURE_ID = ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") +message("CMAKE_CXX_COMPILER_ABI = ${CMAKE_CXX_COMPILER_ABI}") +message("CMAKE_CXX_STANDARD_COMPUTED_DEFAULT = ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}") + +if(CMAKE_C_COMPILER AND NOT CMAKE_C_COMPILER_ID STREQUAL "GHS") + message(FATAL_ERROR "CMAKE_C_COMPILER_ID != GHS") +endif() + +if(CMAKE_CXX_COMPILER AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "GHS") + message(FATAL_ERROR "CMAKE_CXX_COMPILER_ID != GHS") +endif() diff --git a/Tests/GhsMulti/GhsMultiPlatform/file1.c b/Tests/GhsMulti/GhsMultiPlatform/file1.c new file mode 100644 index 0000000000..4132aa406d --- /dev/null +++ b/Tests/GhsMulti/GhsMultiPlatform/file1.c @@ -0,0 +1,4 @@ +int main(void) +{ + return -42; +} diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt b/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt new file mode 100644 index 0000000000..f5792b4054 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt @@ -0,0 +1,42 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +set(targets_to_install "") + +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + +if(RUN_TEST STREQUAL "SINGLE_EXEC") + add_executable(exe1 exe.c) + set(targets_to_install ${targets_to_install} exe1) +endif() + +if(RUN_TEST STREQUAL "SINGLE_EXEC_RENAMED") + set(name new_name) + add_executable(exe1 exe.c) + set_property(TARGET exe1 PROPERTY RUNTIME_OUTPUT_DIRECTORY ${name}_bin_$<CONFIG>) + set_property(TARGET exe1 PROPERTY OUTPUT_NAME ${name}_$<CONFIG>) + set_property(TARGET exe1 PROPERTY SUFFIX .bin) + set(targets_to_install ${targets_to_install} exe1) +endif() + +if(RUN_TEST STREQUAL "EXEC_AND_LIB") + add_library(lib1 lib1.c) + set_property(TARGET lib1 PROPERTY ARCHIVE_OUTPUT_DIRECTORY forced-$<CONFIG>) + set_property(TARGET lib1 PROPERTY SUFFIX .LL) + set_property(TARGET lib1 PROPERTY OUTPUT_NAME lib1_$<CONFIG>) + + add_executable(exe1 exe1.c) + target_link_libraries(exe1 lib1) + set(targets_to_install ${targets_to_install} exe1 lib1) +endif() + +install(TARGETS ${targets_to_install} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/exe.c b/Tests/GhsMulti/GhsMultiRenameInstall/exe.c new file mode 100644 index 0000000000..8488f4e58f --- /dev/null +++ b/Tests/GhsMulti/GhsMultiRenameInstall/exe.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/exe1.c b/Tests/GhsMulti/GhsMultiRenameInstall/exe1.c new file mode 100644 index 0000000000..29ad70a3b5 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiRenameInstall/exe1.c @@ -0,0 +1,5 @@ +extern int func(void); +int main(void) +{ + return func(); +} diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/lib1.c b/Tests/GhsMulti/GhsMultiRenameInstall/lib1.c new file mode 100644 index 0000000000..b35e9cc5ec --- /dev/null +++ b/Tests/GhsMulti/GhsMultiRenameInstall/lib1.c @@ -0,0 +1,4 @@ +int func(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/Atest3.c b/Tests/GhsMulti/GhsMultiSrcGroups/Atest3.c new file mode 100644 index 0000000000..9c9c1d91bf --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/Atest3.c @@ -0,0 +1,4 @@ +int funcA3a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt b/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt new file mode 100644 index 0000000000..93a1afcb60 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt @@ -0,0 +1,45 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +#set(CMAKE_FOLDER ON) +add_executable(groups + test1.c + test1.h + test2a.c + test4.c + test5.c + test6.c + test7.c + standard.h + testOBJ.c + testOBJ.h + sub/testOBJ.c + sub/testOBJ.h + textfile.txt + textfile2.txt + test3.c + Atest3.c +# object.o + resource.pdf + cmake.rule + s5.h + s2.h + s4.h + standard.h + ) + +if(TEST_PROP) + set_target_properties(groups PROPERTIES GHS_NO_SOURCE_GROUP_FILE ON) +endif() +if(CMAKE_C_COMPILER_ID MATCHES "GHS") + target_link_options(groups PRIVATE "-non_shared") +endif() +source_group( gC FILES sub/testOBJ.h testOBJ.c testOBJ.h sub/testOBJ.c ) +source_group( gA FILES test1.c test1.h) +source_group( gB test[65].c ) +source_group( gC\\gD FILES test7.c ) +source_group( docs FILES textfile.txt ) diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule b/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule new file mode 100644 index 0000000000..c6cac69265 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule @@ -0,0 +1 @@ +empty diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/object.o b/Tests/GhsMulti/GhsMultiSrcGroups/object.o new file mode 100644 index 0000000000..c6cac69265 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/object.o @@ -0,0 +1 @@ +empty diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf b/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/s2.h b/Tests/GhsMulti/GhsMultiSrcGroups/s2.h new file mode 100644 index 0000000000..e2b172570a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/s2.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/s4.h b/Tests/GhsMulti/GhsMultiSrcGroups/s4.h new file mode 100644 index 0000000000..e2b172570a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/s4.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/s5.h b/Tests/GhsMulti/GhsMultiSrcGroups/s5.h new file mode 100644 index 0000000000..e2b172570a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/s5.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/standard.h b/Tests/GhsMulti/GhsMultiSrcGroups/standard.h new file mode 100644 index 0000000000..2773a55111 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/standard.h @@ -0,0 +1 @@ +#define somthing diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.c b/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.c new file mode 100644 index 0000000000..90ea9b991c --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.c @@ -0,0 +1,6 @@ +#include "testOBJ.h" + +int funcOBJsub(void) +{ + return func2a() + func3a() + func4a() + func5a() + func6a() + func7a(); +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.h b/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.h new file mode 100644 index 0000000000..e2b172570a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test1.c b/Tests/GhsMulti/GhsMultiSrcGroups/test1.c new file mode 100644 index 0000000000..94f818a0ef --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test1.c @@ -0,0 +1,6 @@ +#include "test1.h" + +int main(void) +{ + return func2a() + func3a() + func4a() + func5a() + func6a() + func7a(); +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test1.h b/Tests/GhsMulti/GhsMultiSrcGroups/test1.h new file mode 100644 index 0000000000..e2b172570a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test1.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test2a.c b/Tests/GhsMulti/GhsMultiSrcGroups/test2a.c new file mode 100644 index 0000000000..8f66fba252 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test2a.c @@ -0,0 +1,4 @@ +int func2a(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test3.c b/Tests/GhsMulti/GhsMultiSrcGroups/test3.c new file mode 100644 index 0000000000..57c7a6ffb0 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test3.c @@ -0,0 +1,4 @@ +int func3a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test3.h b/Tests/GhsMulti/GhsMultiSrcGroups/test3.h new file mode 100644 index 0000000000..2773a55111 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test3.h @@ -0,0 +1 @@ +#define somthing diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test4.c b/Tests/GhsMulti/GhsMultiSrcGroups/test4.c new file mode 100644 index 0000000000..109fd7b4ae --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test4.c @@ -0,0 +1,4 @@ +int func4a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test5.c b/Tests/GhsMulti/GhsMultiSrcGroups/test5.c new file mode 100644 index 0000000000..f28a705d46 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test5.c @@ -0,0 +1,4 @@ +int func5a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test6.c b/Tests/GhsMulti/GhsMultiSrcGroups/test6.c new file mode 100644 index 0000000000..bf77406589 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test6.c @@ -0,0 +1,4 @@ +int func6a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test7.c b/Tests/GhsMulti/GhsMultiSrcGroups/test7.c new file mode 100644 index 0000000000..6a4a9a1f0a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test7.c @@ -0,0 +1,4 @@ +int func7a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.c b/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.c new file mode 100644 index 0000000000..e86e2a4519 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.c @@ -0,0 +1,11 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); + +int funcOBJ(void) +{ + return func2a() + func3a() + func4a() + func5a() + func6a() + func7a(); +} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.h b/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.h new file mode 100644 index 0000000000..e2b172570a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/textfile.txt b/Tests/GhsMulti/GhsMultiSrcGroups/textfile.txt new file mode 100644 index 0000000000..48cdce8528 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/textfile.txt @@ -0,0 +1 @@ +placeholder diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/textfile2.txt b/Tests/GhsMulti/GhsMultiSrcGroups/textfile2.txt new file mode 100644 index 0000000000..48cdce8528 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiSrcGroups/textfile2.txt @@ -0,0 +1 @@ +placeholder diff --git a/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt b/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt new file mode 100644 index 0000000000..ed3094b025 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt @@ -0,0 +1,12 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +add_custom_target(testTarget ALL echo this is a test) + +add_library(sharedLib SHARED file.c) + +add_library(moduleLib MODULE file.c) diff --git a/Tests/GhsMulti/GhsMultiUnsupportedTargets/file.c b/Tests/GhsMulti/GhsMultiUnsupportedTargets/file.c new file mode 100644 index 0000000000..6a4a9a1f0a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiUnsupportedTargets/file.c @@ -0,0 +1,4 @@ +int func7a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/ReturnNum/Int/CMakeLists.txt b/Tests/GhsMulti/ReturnNum/Int/CMakeLists.txt deleted file mode 100644 index 44c5de1c51..0000000000 --- a/Tests/GhsMulti/ReturnNum/Int/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_executable(AppDD AppDD.int Default.bsp) diff --git a/Tests/GhsMulti/ReturnNum/Int/Default.bsp b/Tests/GhsMulti/ReturnNum/Int/Default.bsp deleted file mode 100644 index 224ec29063..0000000000 --- a/Tests/GhsMulti/ReturnNum/Int/Default.bsp +++ /dev/null @@ -1,35 +0,0 @@ -# Target description File for the Integrate utility for use with the -# INTEGRITY real-time operating system by Green Hills Software. -# Before editing this file, refer to your Integrate documentation. -# default.bsp is appropriate for INTEGRITY applications which are -# fully linked with the kernel (for RAM or ROM) or dynamically downloaded. -# -# MinimumAddress must match the value of .ramend in the linker directives -# file used for the KernelSpace program - see default.ld for more info. -# The MaximumAddress used here allows memory mappings to be specified -# for up to the 16 MB mark in RAM. Intex will not permit programs -# that require more memory for its mappings. If the board has less -# memory, this number can be reduced by the user. - -Target - MinimumAddress .ramend - MaximumAddress .ramlimit - Clock StandardTick - EndClock - Clock HighResTimer - EndClock - IODevice "SerialDev0" - InitialKernelObjects 200 - DefaultStartIt false - DefaultMaxPriority 255 - DefaultPriority 127 - DefaultWeight 1 - DefaultMaxWeight 255 - DefaultHeapSize 0x10000 - LastVirtualAddress 0x3fffffff - PageSize 0x1000 - ArchitectedPageSize 0x1000 - ArchitectedPageSize 0x10000 - ArchitectedPageSize 0x100000 - DefaultMemoryRegionSize 0x20000 -EndTarget diff --git a/Tests/GhsMulti/ReturnNum/Lib/CMakeLists.txt b/Tests/GhsMulti/ReturnNum/Lib/CMakeLists.txt deleted file mode 100644 index 9c822da565..0000000000 --- a/Tests/GhsMulti/ReturnNum/Lib/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library(Lib HelperFun.c HelperFun.h)
\ No newline at end of file diff --git a/Tests/QtAutogen/MocOsMacros/TestClass.cpp b/Tests/QtAutogen/MocOsMacros/TestClass.cpp index 340d130b14..13f8fd93aa 100644 --- a/Tests/QtAutogen/MocOsMacros/TestClass.cpp +++ b/Tests/QtAutogen/MocOsMacros/TestClass.cpp @@ -1,6 +1,11 @@ #include "TestClass.hpp" #include <iostream> +void TestClass::open() +{ + std::cout << "open\n"; +} + // -- Mac #ifndef Q_OS_MAC void TestClass::MacNotDef() diff --git a/Tests/QtAutogen/MocOsMacros/TestClass.hpp b/Tests/QtAutogen/MocOsMacros/TestClass.hpp index 53000aa79c..87fd494789 100644 --- a/Tests/QtAutogen/MocOsMacros/TestClass.hpp +++ b/Tests/QtAutogen/MocOsMacros/TestClass.hpp @@ -3,12 +3,17 @@ #include <QObject> #include <QtGlobal> +// include qplatformdefs.h for #18669 +#include <qplatformdefs.h> class TestClass : public QObject { Q_OBJECT public Q_SLOTS: + // Method named "open" to test if #18669 is fixed + void open(); + // -- Mac #ifndef Q_OS_MAC void MacNotDef(); diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index c53fb4f1d8..096d5e3bd5 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -39,8 +39,7 @@ endif() # Qt5 only tests if(QT_TEST_VERSION GREATER 4) ADD_AUTOGEN_TEST(MocMacroName mocMacroName) - # Disabled for issue #18669 - #ADD_AUTOGEN_TEST(MocOsMacros) + ADD_AUTOGEN_TEST(MocOsMacros) ADD_AUTOGEN_TEST(RerunMocPlugin) if(APPLE) ADD_AUTOGEN_TEST(MacOsFW) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c8653b45e1..2de90e743e 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -123,7 +123,7 @@ if(NOT CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") add_RunCMake_test(CMP0065) endif() if(CMAKE_GENERATOR MATCHES "Make") - add_RunCMake_test(Make) + add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU}) endif() if(CMAKE_GENERATOR STREQUAL "Ninja") set(Ninja_ARGS @@ -186,6 +186,7 @@ add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) add_RunCMake_test(ObjectLibrary) +add_RunCMake_test(ParseImplicitIncludeInfo) if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") add_RunCMake_test(RuntimePath) endif() @@ -214,6 +215,7 @@ endif() add_RunCMake_test(CompatibleInterface) add_RunCMake_test(Syntax) add_RunCMake_test(WorkingDirectory) +add_RunCMake_test(MaxRecursionDepth) add_RunCMake_test(add_custom_command) add_RunCMake_test(add_custom_target) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt b/Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt new file mode 100644 index 0000000000..332b0230d2 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.12) +project(CMakeRoleGlobalPropertyBuildAndTest NONE) +include(CTest) + +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "PROJECT") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"PROJECT\"") +endif() + +add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in index 913239c295..bb8f9c1408 100644 --- a/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) -project(CTestStart@CASE_NAME@ NONE) +cmake_minimum_required(VERSION 3.12) +project(CMakeRoleGlobalProperty@CASE_NAME@ NONE) include(CTest) add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake index b840317c8f..3cbd51d6e3 100644 --- a/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake @@ -5,3 +5,10 @@ run_cmake(Project) run_cmake_command(Script "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/Script.cmake") run_cmake_command(FindPackage "${CMAKE_COMMAND}" --find-package -DNAME=DummyPackage -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}") run_ctest(CTest) +run_cmake_command(BuildAndTest "${CMAKE_CTEST_COMMAND}" + --build-and-test + "${RunCMake_SOURCE_DIR}/BuildAndTest" + "${RunCMake_BINARY_DIR}/BuildAndTest-build" + --build-project CMakeRoleGlobalPropertyBuildAndTest + --build-generator "${RunCMake_GENERATOR}" + ) diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index cae14b1202..d524f41842 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -174,12 +174,15 @@ function(run_TestStdin) endfunction() run_TestStdin() -function(ShowAsJson_check_python v) +function(show_only_json_check_python v) + if(RunCMake_TEST_FAILED OR NOT PYTHON_EXECUTABLE) + return() + endif() set(json_file "${RunCMake_TEST_BINARY_DIR}/ctest.json") file(WRITE "${json_file}" "${actual_stdout}") set(actual_stdout "" PARENT_SCOPE) execute_process( - COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/ShowAsJson${v}-check.py" "${json_file}" + COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/show-only_json-v${v}_check.py" "${json_file}" RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE output @@ -190,15 +193,18 @@ function(ShowAsJson_check_python v) endif() endfunction() -function(run_ShowAsJson) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ShowAsJson) +function(run_ShowOnly) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ShowOnly) set(RunCMake_TEST_NO_CLEAN 1) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " - add_test(ShowAsJson \"${CMAKE_COMMAND}\" -E echo) - set_tests_properties(ShowAsJson PROPERTIES WILL_FAIL true _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\") + add_test(ShowOnly \"${CMAKE_COMMAND}\" -E echo) + set_tests_properties(ShowOnly PROPERTIES WILL_FAIL true _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\") + add_test(ShowOnlyNotAvailable NOT_AVAILABLE) ") - run_cmake_command(ShowAsJsonVersionOne ${CMAKE_CTEST_COMMAND} --show-only=json-v1) + run_cmake_command(show-only_human ${CMAKE_CTEST_COMMAND} --show-only=human) + run_cmake_command(show-only_bad ${CMAKE_CTEST_COMMAND} --show-only=bad) + run_cmake_command(show-only_json-v1 ${CMAKE_CTEST_COMMAND} --show-only=json-v1) endfunction() -run_ShowAsJson() +run_ShowOnly() diff --git a/Tests/RunCMake/CommandLine/no-S-B-result.txt b/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt index d00491fd7e..d00491fd7e 100644 --- a/Tests/RunCMake/CommandLine/no-S-B-result.txt +++ b/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt diff --git a/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt b/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt new file mode 100644 index 0000000000..cc55ab390e --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt @@ -0,0 +1 @@ +^CMake Error: '--show-only=' given unknown value 'bad'$ diff --git a/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt b/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt new file mode 100644 index 0000000000..13321496ca --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt @@ -0,0 +1 @@ +Test #1: ShowOnly diff --git a/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake b/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake new file mode 100644 index 0000000000..f9234f8d9b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake @@ -0,0 +1 @@ +show_only_json_check_python(1) diff --git a/Tests/RunCMake/CTestCommandLine/ShowAsJson1-check.py b/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py index d794e7dfd2..4dff90cd0c 100644 --- a/Tests/RunCMake/CTestCommandLine/ShowAsJson1-check.py +++ b/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py @@ -1,4 +1,4 @@ -from ShowAsJson_check import * +from show_only_json_check import * def check_kind(k): assert is_string(k) @@ -77,7 +77,7 @@ def check_workingdir_property(p): assert is_string(p["name"]) assert is_string(p["value"]) assert p["name"] == "WORKING_DIRECTORY" - assert p["value"].endswith("Tests/RunCMake/CTestCommandLine/ShowAsJson") + assert p["value"].endswith("Tests/RunCMake/CTestCommandLine/ShowOnly") def check_properties(p): assert is_list(p) @@ -95,7 +95,7 @@ def check_tests(t): assert test["backtrace"] == 1 check_command(test["command"]) assert is_string(test["name"]) - assert test["name"] == "ShowAsJson" + assert test["name"] == "ShowOnly" check_properties(test["properties"]) assert is_dict(ctest_json) diff --git a/Tests/RunCMake/CTestCommandLine/ShowAsJson_check.py b/Tests/RunCMake/CTestCommandLine/show_only_json_check.py index 493c9e579d..493c9e579d 100644 --- a/Tests/RunCMake/CTestCommandLine/ShowAsJson_check.py +++ b/Tests/RunCMake/CTestCommandLine/show_only_json_check.py diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-stderr.txt new file mode 100644 index 0000000000..e73d76020b --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-stderr.txt @@ -0,0 +1,3 @@ +^'--parallel' invalid number '12ab' given\. ++ +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-stderr.txt index 3c2c808e97..3c2c808e97 100644 --- a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing-stderr.txt +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-stderr.txt diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-trailing--target-stderr.txt index 3c2c808e97..3c2c808e97 100644 --- a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing-stderr.txt +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-trailing--target-stderr.txt diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-stderr.txt new file mode 100644 index 0000000000..c810087861 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-stderr.txt @@ -0,0 +1,3 @@ +^'-j' invalid number '12ab' given\. ++ +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-stderr.txt index 3c2c808e97..3c2c808e97 100644 --- a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing-stderr.txt +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-stderr.txt diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-trailing--target-stderr.txt index 3c2c808e97..3c2c808e97 100644 --- a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing-stderr.txt +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-trailing--target-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt new file mode 100644 index 0000000000..4729ccb8fa --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt @@ -0,0 +1 @@ +^Files ".*/compare_files/lf" to ".*/compare_files/crlf" are different.$ diff --git a/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt new file mode 100644 index 0000000000..8a9ca81f88 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt @@ -0,0 +1 @@ +^Files "nonexistent_a" to "nonexistent_b" are different.$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 0e04ad1ad8..23fb9ef46d 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -18,6 +18,10 @@ run_cmake_command(Uno-src ${CMAKE_COMMAND} -B DummyBuildDir -UVAR) run_cmake_command(E-no-arg ${CMAKE_COMMAND} -E) run_cmake_command(E_capabilities ${CMAKE_COMMAND} -E capabilities) run_cmake_command(E_capabilities-arg ${CMAKE_COMMAND} -E capabilities --extra-arg) +run_cmake_command(E_compare_files-different-eol ${CMAKE_COMMAND} -E compare_files ${RunCMake_SOURCE_DIR}/compare_files/lf ${RunCMake_SOURCE_DIR}/compare_files/crlf) +run_cmake_command(E_compare_files-ignore-eol-same ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/lf ${RunCMake_SOURCE_DIR}/compare_files/crlf) +run_cmake_command(E_compare_files-ignore-eol-empty ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/empty1 ${RunCMake_SOURCE_DIR}/compare_files/empty2) +run_cmake_command(E_compare_files-ignore-eol-nonexistent ${CMAKE_COMMAND} -E compare_files --ignore-eol nonexistent_a nonexistent_b) run_cmake_command(E_echo_append ${CMAKE_COMMAND} -E echo_append) run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename) run_cmake_command(E_server-arg ${CMAKE_COMMAND} -E server --extra-arg) @@ -56,12 +60,22 @@ run_cmake_command(cache-empty-entry ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-empty-entry/) function(run_ExplicitDirs) + set(source_dir ${RunCMake_BINARY_DIR}/ExplicitDirsMissing) + + file(REMOVE_RECURSE "${source_dir}") + file(MAKE_DIRECTORY "${source_dir}") + file(WRITE ${source_dir}/CMakeLists.txt [=[ +cmake_minimum_required(VERSION 3.13) +project(ExplicitDirsMissing LANGUAGES NONE) +]=]) + run_cmake_command(no-S-B ${CMAKE_COMMAND} -E chdir ${source_dir} + ${CMAKE_COMMAND} -DFOO=BAR) + set(source_dir ${RunCMake_SOURCE_DIR}/ExplicitDirs) set(binary_dir ${RunCMake_BINARY_DIR}/ExplicitDirs-build) file(REMOVE_RECURSE "${binary_dir}") file(MAKE_DIRECTORY "${binary_dir}") - run_cmake_command(no-S-B ${CMAKE_COMMAND} -DFOO=BAR) run_cmake_command(S-arg ${CMAKE_COMMAND} -S ${source_dir} ${binary_dir}) run_cmake_command(S-arg-reverse-order ${CMAKE_COMMAND} ${binary_dir} -S${source_dir} ) run_cmake_command(S-no-arg ${CMAKE_COMMAND} -S ) @@ -105,6 +119,19 @@ function(run_BuildDir) ${CMAKE_COMMAND} --build BuildDir-build --parallel 2) run_cmake_command(BuildDir--build--parallel-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --parallel 2 --target CustomTarget) + run_cmake_command(BuildDir--build-jobs-no-space-bad-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j12ab) + run_cmake_command(BuildDir--build-jobs-no-space-good-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j2) + run_cmake_command(BuildDir--build-jobs-no-space-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j2 --target CustomTarget) + run_cmake_command(BuildDir--build--parallel-no-space-bad-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel12ab) + run_cmake_command(BuildDir--build--parallel-no-space-good-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel2) + run_cmake_command(BuildDir--build--parallel-no-space-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel2 --target CustomTarget) + # No default jobs for Xcode and FreeBSD build command if(NOT RunCMake_GENERATOR MATCHES "Xcode" AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") run_cmake_command(BuildDir--build-jobs-no-number ${CMAKE_COMMAND} -E chdir .. diff --git a/Tests/RunCMake/CommandLine/compare_files/.gitattributes b/Tests/RunCMake/CommandLine/compare_files/.gitattributes new file mode 100644 index 0000000000..91d5c104c9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/compare_files/.gitattributes @@ -0,0 +1,2 @@ +crlf eol=crlf +lf eol=lf diff --git a/Tests/RunCMake/CommandLine/compare_files/crlf b/Tests/RunCMake/CommandLine/compare_files/crlf new file mode 100644 index 0000000000..a29bdeb434 --- /dev/null +++ b/Tests/RunCMake/CommandLine/compare_files/crlf @@ -0,0 +1 @@ +line1 diff --git a/Tests/RunCMake/CommandLine/compare_files/empty1 b/Tests/RunCMake/CommandLine/compare_files/empty1 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/CommandLine/compare_files/empty1 diff --git a/Tests/RunCMake/CommandLine/compare_files/empty2 b/Tests/RunCMake/CommandLine/compare_files/empty2 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/CommandLine/compare_files/empty2 diff --git a/Tests/RunCMake/CommandLine/compare_files/lf b/Tests/RunCMake/CommandLine/compare_files/lf new file mode 100644 index 0000000000..a29bdeb434 --- /dev/null +++ b/Tests/RunCMake/CommandLine/compare_files/lf @@ -0,0 +1 @@ +line1 diff --git a/Tests/RunCMake/CommandLine/no-S-B-stderr.txt b/Tests/RunCMake/CommandLine/no-S-B-stderr.txt index 7a943077b5..c166dcf561 100644 --- a/Tests/RunCMake/CommandLine/no-S-B-stderr.txt +++ b/Tests/RunCMake/CommandLine/no-S-B-stderr.txt @@ -1 +1,4 @@ -CMake Error: No source or binary directory provided +CMake Warning: + No source or binary directory provided. Both will be assumed to be the + same as the current working directory, but note that this warning will + become a fatal error in future CMake releases. diff --git a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake index 1aeb510f0c..2fdefc4ce7 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake @@ -26,3 +26,9 @@ get_property(emulator TARGET target_without_emulator if(NOT "${emulator}" STREQUAL "") message(SEND_ERROR "Default CROSSCOMPILING_EMULATOR property not set to null") endif() + +add_executable(target_with_empty_emulator simple_src_exiterror.cxx) +set_property(TARGET target_with_empty_emulator PROPERTY CROSSCOMPILING_EMULATOR "") + +enable_testing() +add_test(NAME test_target_with_empty_emulator COMMAND target_with_empty_emulator) diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-stderr.txt new file mode 100644 index 0000000000..fc1324807e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at NonValidTarget-Fortran_COMPILER_ID.cmake:1 \(add_custom_command\): + Error evaluating generator expression: + + \$<Fortran_COMPILER_ID> + + \$<Fortran_COMPILER_ID> may only be used with binary targets. It may not be + used with add_custom_command or add_custom_target. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID.cmake new file mode 100644 index 0000000000..88a0bfb993 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID.cmake @@ -0,0 +1,4 @@ +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<Fortran_COMPILER_ID>.c" +) +add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c") diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-stderr.txt new file mode 100644 index 0000000000..f8a41205c4 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at NonValidTarget-Fortran_COMPILER_VERSION.cmake:1 \(add_custom_command\): + Error evaluating generator expression: + + \$<Fortran_COMPILER_VERSION> + + \$<Fortran_COMPILER_VERSION> may only be used with binary targets. It may + not be used with add_custom_command or add_custom_target. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION.cmake new file mode 100644 index 0000000000..34a4884d40 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION.cmake @@ -0,0 +1,4 @@ +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<Fortran_COMPILER_VERSION>.c" +) +add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c") diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 013117e87e..8a5604c7a2 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -15,8 +15,10 @@ run_cmake(BadSHELL_PATH) run_cmake(CMP0044-WARN) run_cmake(NonValidTarget-C_COMPILER_ID) run_cmake(NonValidTarget-CXX_COMPILER_ID) +run_cmake(NonValidTarget-Fortran_COMPILER_ID) run_cmake(NonValidTarget-C_COMPILER_VERSION) run_cmake(NonValidTarget-CXX_COMPILER_VERSION) +run_cmake(NonValidTarget-Fortran_COMPILER_VERSION) run_cmake(NonValidTarget-TARGET_BUNDLE_DIR) run_cmake(NonValidTarget-TARGET_BUNDLE_CONTENT_DIR) run_cmake(NonValidTarget-TARGET_PROPERTY) diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt index 164d3aa79d..7067423f45 100644 --- a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt @@ -5,6 +5,6 @@ CMake Error at CMakeLists.txt:[0-9]+ \(project\): given toolset specification - Test Toolset,host=x64,host=x64 + Test Toolset,host=x64,host=x86 that contains duplicate field key 'host'\.$ diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index ccf58b4d99..ef8fd25404 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -16,14 +16,16 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") run_cmake(TestToolsetHostArchBoth) set(RunCMake_GENERATOR_TOOLSET ",host=x64") - run_cmake(TestToolsetHostArchOnly) + run_cmake(TestToolsetHostArchOnly_x64) set(RunCMake_GENERATOR_TOOLSET "host=x64") - run_cmake(TestToolsetHostArchOnly) + run_cmake(TestToolsetHostArchOnly_x64) + set(RunCMake_GENERATOR_TOOLSET "host=x86") + run_cmake(TestToolsetHostArchOnly_x86) set(RunCMake_GENERATOR_TOOLSET "Test Toolset") run_cmake(TestToolsetHostArchNone) set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x65") run_cmake(BadToolsetHostArch) - set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64,host=x64") + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64,host=x86") run_cmake(BadToolsetHostArchTwice) if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[56]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Test Toolset Version") diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt index 576b40cc0c..e5e6c8da9b 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt @@ -1,2 +1,2 @@ -- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset' --- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='.*' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake index 26926f9dbd..085bb6b173 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake @@ -1,2 +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}'") + +if(CMAKE_GENERATOR MATCHES "Visual Studio 1[6]") + 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") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'x64' as expected.") + endif() + endif() +else() + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not empty as expected.") + endif() +endif() diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64-stdout.txt index 8271bd4876..8271bd4876 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64-stdout.txt diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64.cmake index 26926f9dbd..26926f9dbd 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64.cmake diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86-stdout.txt new file mode 100644 index 0000000000..c7293dc42a --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='x86' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86.cmake new file mode 100644 index 0000000000..26926f9dbd --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake index 3b2b8f5932..82db6b7425 100644 --- a/Tests/RunCMake/Make/RunCMakeTest.cmake +++ b/Tests/RunCMake/Make/RunCMakeTest.cmake @@ -16,5 +16,22 @@ run_TargetMessages(OFF) run_TargetMessages(VAR-ON -DCMAKE_TARGET_MESSAGES=ON) run_TargetMessages(VAR-OFF -DCMAKE_TARGET_MESSAGES=OFF) +function(run_VerboseBuild) + run_cmake(VerboseBuild) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VerboseBuild-build) + if(RunCMake_GENERATOR STREQUAL "Watcom WMake") + # wmake does not actually show the verbose output. + set(RunCMake-stdout-file VerboseBuild-build-watcom-stdout.txt) + endif() + run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first) + unset(RunCMake-stdout-file) + if(MAKE_IS_GNU) + set(RunCMake-stdout-file VerboseBuild-nowork-gnu-stdout.txt) + endif() + run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose) +endfunction() +run_VerboseBuild() + run_cmake(CustomCommandDepfile-ERROR) run_cmake(IncludeRegexSubdir) diff --git a/Tests/RunCMake/Make/VerboseBuild-build-stdout.txt b/Tests/RunCMake/Make/VerboseBuild-build-stdout.txt new file mode 100644 index 0000000000..884bf953e5 --- /dev/null +++ b/Tests/RunCMake/Make/VerboseBuild-build-stdout.txt @@ -0,0 +1 @@ +.*DEFINE_FOR_VERBOSE_DETECTION.*hello.dir.* diff --git a/Tests/RunCMake/Make/VerboseBuild-build-watcom-stdout.txt b/Tests/RunCMake/Make/VerboseBuild-build-watcom-stdout.txt new file mode 100644 index 0000000000..9c558e357c --- /dev/null +++ b/Tests/RunCMake/Make/VerboseBuild-build-watcom-stdout.txt @@ -0,0 +1 @@ +. diff --git a/Tests/RunCMake/Make/VerboseBuild-nowork-gnu-stdout.txt b/Tests/RunCMake/Make/VerboseBuild-nowork-gnu-stdout.txt new file mode 100644 index 0000000000..3e65cd95fd --- /dev/null +++ b/Tests/RunCMake/Make/VerboseBuild-nowork-gnu-stdout.txt @@ -0,0 +1 @@ +.*Nothing to be done for.*hello.* diff --git a/Tests/RunCMake/Make/VerboseBuild.cmake b/Tests/RunCMake/Make/VerboseBuild.cmake new file mode 100644 index 0000000000..70a971d13f --- /dev/null +++ b/Tests/RunCMake/Make/VerboseBuild.cmake @@ -0,0 +1,8 @@ +enable_language(C) + +# Make sure compile command is not hidden in a temp file. +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") + +add_executable(hello hello.c) +target_compile_definitions(hello PRIVATE "DEFINE_FOR_VERBOSE_DETECTION") diff --git a/Tests/RunCMake/Make/hello.c b/Tests/RunCMake/Make/hello.c new file mode 100644 index 0000000000..aac8b4e0f3 --- /dev/null +++ b/Tests/RunCMake/Make/hello.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(void) +{ + printf("Hello world!\n"); + return 0; +} diff --git a/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt new file mode 100644 index 0000000000..d2cd86d13c --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13) +if(DEFINED CMAKE_GENERATOR) + project(${RunCMake_TEST} NONE) +endif() +include("${CMAKE_CURRENT_LIST_DIR}/${TEST_NAME}.cmake") diff --git a/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in new file mode 100644 index 0000000000..fee3eda2f2 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.12) +project(MaxRecursionDepth NONE) diff --git a/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake b/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake new file mode 100644 index 0000000000..354bc7a4ef --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake @@ -0,0 +1,3 @@ +message("${x}") +math(EXPR x "${x} + 1") +ctest_read_custom_files("${CMAKE_CURRENT_LIST_DIR}") diff --git a/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake b/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake new file mode 100644 index 0000000000..3cbb99e872 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake @@ -0,0 +1,3 @@ +message("${x}") +math(EXPR x "${x} + 1") +find_package(RecursivePackage) diff --git a/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake b/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake new file mode 100644 index 0000000000..c5a859d877 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake @@ -0,0 +1,49 @@ +include(RunCMake) +include(RunCTest) + +function(run_cmake_recursive name) + set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name}) + run_cmake(${name}-default) + unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) + run_cmake(${name}-var) + unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a) + run_cmake(${name}-invalid-var) + unset(RunCMake_TEST_OPTIONS) + + run_cmake_command(${name}-default-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt") + run_cmake_command(${name}-var-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10 -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt") + run_cmake_command(${name}-invalid-var-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt") +endfunction() + +function(run_ctest_recursive name) + run_ctest(${name}-default "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name}) + run_ctest(${name}-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) + run_ctest(${name}-invalid-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a) +endfunction() + +run_cmake_recursive(function) +run_cmake_recursive(macro) +run_cmake_recursive(include) +run_cmake_recursive(find_package) +run_cmake_recursive(variable_watch) + +# We run these tests separately and only with a small limit because they are +# taxing and slow. The "implicit" and "invalid" cases are already thoroughly +# covered by the other tests above. +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=add_subdirectory -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) +run_cmake(add_subdirectory-var) +unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=try_compile -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) +run_cmake(try_compile-var) +unset(RunCMake_TEST_OPTIONS) + +run_ctest_recursive(ctest_read_custom_files) + +# We run the ctest_run_script() test separately and only with an explicit limit +# because ctest_run_script() is taxing and slow, and because the implicit +# recursion limit is hit by CTestScriptMode.cmake before we can test it +# properly. The "implicit" and "invalid" cases are already thoroughly covered +# by the other tests above. +run_ctest(ctest_run_script-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=ctest_run_script -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt new file mode 100644 index 0000000000..23fb5c65ba --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt @@ -0,0 +1,10 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at add_subdirectory/CMakeLists\.txt:1 \(message\): + Maximum recursion depth of 10 exceeded$ diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake new file mode 100644 index 0000000000..36c21f30a7 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake @@ -0,0 +1,2 @@ +set(x 3) +add_subdirectory(add_subdirectory) diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt new file mode 100644 index 0000000000..a8244affec --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt @@ -0,0 +1,3 @@ +message("${x}") +math(EXPR x "${x} + 1") +add_subdirectory(. dir) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt new file mode 100644 index 0000000000..b57e2deb77 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt new file mode 100644 index 0000000000..7dbbb3e72d --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt new file mode 100644 index 0000000000..b57e2deb77 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt new file mode 100644 index 0000000000..7dbbb3e72d --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt new file mode 100644 index 0000000000..b57e2deb77 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt new file mode 100644 index 0000000000..bc89703a07 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt @@ -0,0 +1,34 @@ +^2 +3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var/test\.cmake:10 \(ctest_read_custom_files\) + + +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake$ diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt new file mode 100644 index 0000000000..b57e2deb77 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt new file mode 100644 index 0000000000..b10b26d32c --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt @@ -0,0 +1,51 @@ +^2 +3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_11\.cmake:1 \(cmake_minimum_required\): + Maximum recursion depth of 10 exceeded + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_10\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_9\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_8\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_7\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_6\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_5\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_4\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_3\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_2\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var/test\.cmake:19 \(message\): + Nested script failed$ diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in new file mode 100644 index 0000000000..d4f28c4562 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.12) +set(CTEST_RUN_CURRENT_SCRIPT 0) + +message("@LEVEL_CURRENT@") + +set(CTEST_SOURCE_DIRECTORY "@CTEST_SOURCE_DIRECTORY@") +set(CTEST_BINARY_DIRECTORY "@CTEST_BINARY_DIRECTORY@") +set(CTEST_COMMAND "@CTEST_COMMAND@") + +ctest_run_script("${CMAKE_CURRENT_LIST_DIR}/ctest_run_script_@LEVEL_NEXT@.cmake" RETURN_VALUE val) + +if(NOT val EQUAL 0) + message(FATAL_ERROR "Nested script failed") +endif() diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt new file mode 100644 index 0000000000..b8557ab645 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/FindRecursivePackage\.cmake:3 \(find_package\) diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt new file mode 100644 index 0000000000..5d31e295b0 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + FindRecursivePackage\.cmake:3 \(find_package\) diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt new file mode 100644 index 0000000000..b8557ab645 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/FindRecursivePackage\.cmake:3 \(find_package\) diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt new file mode 100644 index 0000000000..5d31e295b0 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + FindRecursivePackage\.cmake:3 \(find_package\) diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt new file mode 100644 index 0000000000..53145515a5 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/find_package\.cmake:2 \(find_package\) + .*/CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt new file mode 100644 index 0000000000..b47a13a175 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + find_package\.cmake:2 \(find_package\) + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package.cmake b/Tests/RunCMake/MaxRecursionDepth/find_package.cmake new file mode 100644 index 0000000000..a235f7d418 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package.cmake @@ -0,0 +1,2 @@ +set(x 3) +find_package(RecursivePackage) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt new file mode 100644 index 0000000000..92de1fb3c7 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/function\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/function\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt new file mode 100644 index 0000000000..5c25c4b129 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at function\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + function\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt new file mode 100644 index 0000000000..92de1fb3c7 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/function\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/function\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt new file mode 100644 index 0000000000..5c25c4b129 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at function\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + function\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt new file mode 100644 index 0000000000..61304b13f7 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/function\.cmake:2 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:7 \(recursive\) + .*/CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt new file mode 100644 index 0000000000..54e72aff4b --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at function\.cmake:2 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:7 \(recursive\) + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/function.cmake b/Tests/RunCMake/MaxRecursionDepth/function.cmake new file mode 100644 index 0000000000..581cb89175 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function.cmake @@ -0,0 +1,7 @@ +function(recursive x) + message("${x}") + math(EXPR y "${x} + 1") + recursive(${y}) +endfunction() + +recursive(3) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt new file mode 100644 index 0000000000..0510e7c373 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/include_recursive\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/include_recursive\.cmake:3 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt new file mode 100644 index 0000000000..b1494a8e11 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at include_recursive\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + include_recursive\.cmake:3 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt new file mode 100644 index 0000000000..0510e7c373 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/include_recursive\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/include_recursive\.cmake:3 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt new file mode 100644 index 0000000000..b1494a8e11 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at include_recursive\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + include_recursive\.cmake:3 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt new file mode 100644 index 0000000000..f55f50536f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/include_recursive\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include\.cmake:2 \(include\) + .*/CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt new file mode 100644 index 0000000000..ff33985045 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at include_recursive\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include\.cmake:2 \(include\) + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/include.cmake b/Tests/RunCMake/MaxRecursionDepth/include.cmake new file mode 100644 index 0000000000..5e86a40cbe --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include.cmake @@ -0,0 +1,2 @@ +set(x 3) +include("${CMAKE_CURRENT_LIST_DIR}/include_recursive.cmake") diff --git a/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake b/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake new file mode 100644 index 0000000000..b3f744e380 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake @@ -0,0 +1,3 @@ +message("${x}") +math(EXPR x "${x} + 1") +include("${CMAKE_CURRENT_LIST_FILE}") diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt new file mode 100644 index 0000000000..c67be57d28 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/macro\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/macro\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt new file mode 100644 index 0000000000..0b271627da --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at macro\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + macro\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt new file mode 100644 index 0000000000..c67be57d28 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/macro\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/macro\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt new file mode 100644 index 0000000000..0b271627da --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at macro\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + macro\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt new file mode 100644 index 0000000000..142e068a08 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/macro\.cmake:2 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:7 \(recursive\) + .*/CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt new file mode 100644 index 0000000000..71de55376f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at macro\.cmake:2 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:7 \(recursive\) + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/macro.cmake b/Tests/RunCMake/MaxRecursionDepth/macro.cmake new file mode 100644 index 0000000000..a7cbfc2add --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro.cmake @@ -0,0 +1,7 @@ +macro(recursive x) + message("${x}") + math(EXPR y "${x} + 1") + recursive(${y}) +endmacro() + +recursive(3) diff --git a/Tests/RunCMake/MaxRecursionDepth/test.cmake.in b/Tests/RunCMake/MaxRecursionDepth/test.cmake.in new file mode 100644 index 0000000000..fd1fc10a5d --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/test.cmake.in @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.12) +set(CTEST_RUN_CURRENT_SCRIPT 0) + +set(CTEST_SOURCE_DIRECTORY "@RunCMake_SOURCE_DIR@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@") +set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}") + +if(TEST_NAME STREQUAL "ctest_read_custom_files") + set(x 2) + ctest_read_custom_files("@RunCMake_SOURCE_DIR@") +elseif(TEST_NAME STREQUAL "ctest_run_script") + foreach(LEVEL_CURRENT RANGE 2 15) + math(EXPR LEVEL_NEXT "${LEVEL_CURRENT} + 1") + configure_file("@RunCMake_SOURCE_DIR@/ctest_run_script.cmake.in" "@RunCMake_BINARY_DIR@/ctest_run_script_${LEVEL_CURRENT}.cmake" @ONLY) + endforeach() + + ctest_run_script("@RunCMake_BINARY_DIR@/ctest_run_script_2.cmake" RETURN_VALUE val) + if(NOT val EQUAL 0) + message(FATAL_ERROR "Nested script failed") + endif() +endif() diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt new file mode 100644 index 0000000000..130db346bd --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt @@ -0,0 +1,48 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:1 \(cmake_minimum_required\): + Maximum recursion depth of 10 exceeded + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at try_compile\.cmake:1 \(try_compile\): + Failed to configure test project build system\. +Call Stack \(most recent call first\): + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake b/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake new file mode 100644 index 0000000000..c40fb0612b --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake @@ -0,0 +1,6 @@ +try_compile(result + "${CMAKE_CURRENT_BINARY_DIR}/try_compile" + "${CMAKE_CURRENT_SOURCE_DIR}/try_compile" + try_compile + CMAKE_FLAGS -Dx:STRING=3 + ) diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt new file mode 100644 index 0000000000..2271090617 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.12) + +message("${x}") +math(EXPR x "${x} + 1") +try_compile(result + "${CMAKE_CURRENT_BINARY_DIR}/try_compile" + "${CMAKE_CURRENT_SOURCE_DIR}" + try_compile + CMAKE_FLAGS -Dx:STRING=${x} + ) + +# We put this last to avoid prematurely triggering the recursion limit +project(try_compile NONE) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt new file mode 100644 index 0000000000..4dddc96c8c --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt @@ -0,0 +1,6 @@ +[0-9]+ +CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt new file mode 100644 index 0000000000..a8b4756da1 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt @@ -0,0 +1,6 @@ +[0-9]+ +CMake Error at variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt new file mode 100644 index 0000000000..4dddc96c8c --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt @@ -0,0 +1,6 @@ +[0-9]+ +CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt new file mode 100644 index 0000000000..a8b4756da1 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt @@ -0,0 +1,6 @@ +[0-9]+ +CMake Error at variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt new file mode 100644 index 0000000000..00b2b3c111 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt @@ -0,0 +1,22 @@ +^4 +6 +8 +10 +CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:9 \(set\) + .*/CMakeLists\.txt:5 \(include\) + + +CMake Error: Error in cmake code at +Unknown:0: +A command failed during the invocation of callback "update_x"\.$ diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt new file mode 100644 index 0000000000..8f27bf1c29 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt @@ -0,0 +1,22 @@ +^4 +6 +8 +10 +CMake Error at variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:9 \(set\) + CMakeLists\.txt:5 \(include\) + + +CMake Error: Error in cmake code at +Unknown:0: +A command failed during the invocation of callback "update_x"\.$ diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake b/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake new file mode 100644 index 0000000000..b3c7b8dfed --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake @@ -0,0 +1,9 @@ +function(update_x) + message("${x}") + math(EXPR y "${x} + 2") + variable_watch(x update_x) + set(x "${y}") +endfunction() + +variable_watch(x update_x) +set(x 4) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 9e1e9a5fd5..8fa650a61d 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -30,6 +30,15 @@ function(run_NoWorkToDo) endfunction() run_NoWorkToDo() +function(run_VerboseBuild) + run_cmake(VerboseBuild) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VerboseBuild-build) + run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first) + run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose) +endfunction() +run_VerboseBuild() + function(run_CMP0058 case) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0058-${case}-build) diff --git a/Tests/RunCMake/Ninja/VerboseBuild-build-stdout.txt b/Tests/RunCMake/Ninja/VerboseBuild-build-stdout.txt new file mode 100644 index 0000000000..884bf953e5 --- /dev/null +++ b/Tests/RunCMake/Ninja/VerboseBuild-build-stdout.txt @@ -0,0 +1 @@ +.*DEFINE_FOR_VERBOSE_DETECTION.*hello.dir.* diff --git a/Tests/RunCMake/Ninja/VerboseBuild-nowork-stdout.txt b/Tests/RunCMake/Ninja/VerboseBuild-nowork-stdout.txt new file mode 100644 index 0000000000..60a9228b0d --- /dev/null +++ b/Tests/RunCMake/Ninja/VerboseBuild-nowork-stdout.txt @@ -0,0 +1 @@ +^ninja: no work to do diff --git a/Tests/RunCMake/Ninja/VerboseBuild.cmake b/Tests/RunCMake/Ninja/VerboseBuild.cmake new file mode 100644 index 0000000000..424e54eece --- /dev/null +++ b/Tests/RunCMake/Ninja/VerboseBuild.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(hello hello.c) +target_compile_definitions(hello PRIVATE "DEFINE_FOR_VERBOSE_DETECTION") diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/CMakeLists.txt b/Tests/RunCMake/ParseImplicitIncludeInfo/CMakeLists.txt new file mode 100644 index 0000000000..2897109554 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake new file mode 100644 index 0000000000..a9029dc54c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake @@ -0,0 +1,103 @@ +cmake_minimum_required(VERSION 3.0) +project(Minimal NONE) + +# +# list of targets to test. to add a target: put its files in the data +# subdirectory and add it to this list... we run each target's +# data/*.input file through the parser and check to see if it matches +# the corresponding data/*.output file. note that the empty-* case +# has special handling (it should not parse). +# +set(targets + aix-C-XL-13.1.3 aix-CXX-XL-13.1.3 + craype-C-Cray-8.7 craype-CXX-Cray-8.7 craype-Fortran-Cray-8.7 + craype-C-GNU-7.3.0 craype-CXX-GNU-7.3.0 craype-Fortran-GNU-7.3.0 + craype-C-Intel-18.0.2.20180210 craype-CXX-Intel-18.0.2.20180210 + craype-Fortran-Intel-18.0.2.20180210 + darwin-C-AppleClang-8.0.0.8000042 darwin-CXX-AppleClang-8.0.0.8000042 + darwin_nostdinc-C-AppleClang-8.0.0.8000042 + darwin_nostdinc-CXX-AppleClang-8.0.0.8000042 + empty-C empty-CXX + freebsd-C-Clang-3.3.0 freebsd-CXX-Clang-3.3.0 freebsd-Fortran-GNU-4.6.4 + linux-C-GNU-7.3.0 linux-CXX-GNU-7.3.0 linux-Fortran-GNU-7.3.0 + linux-C-Intel-18.0.0.20170811 linux-CXX-Intel-18.0.0.20170811 + linux-C-XL-12.1.0 linux-CXX-XL-12.1.0 linux-Fortran-XL-14.1.0 + linux_nostdinc-C-XL-12.1.0 linux_nostdinc-CXX-XL-12.1.0 + linux_nostdinc_i-C-XL-12.1.0 linux_nostdinc-CXX-XL-12.1.0 + linux-C-XL-16.1.0.0 linux-CXX-XL-16.1.0.0 + linux-CUDA-NVIDIA-9.2.148 + mingw.org-C-GNU-4.9.3 mingw.org-CXX-GNU-4.9.3 + netbsd-C-GNU-4.8.5 netbsd-CXX-GNU-4.8.5 + netbsd_nostdinc-C-GNU-4.8.5 netbsd_nostdinc-CXX-GNU-4.8.5 + openbsd-C-Clang-5.0.1 openbsd-CXX-Clang-5.0.1 + sunos-C-SunPro-5.13.0 sunos-CXX-SunPro-5.13.0 + ) + +include(${CMAKE_ROOT}/Modules/CMakeParseImplicitIncludeInfo.cmake) + +# +# load_compiler_info: read infile, parsing out cmake compiler info +# variables as we go. returns language, a list of variables we set +# (so we can clear them later), and the remaining verbose output +# from the compiler. +# +function(load_compiler_info infile lang_var outcmvars_var outstr_var) + unset(lang) + unset(outcmvars) + unset(outstr) + file(READ "${infile}" in) + string(REGEX REPLACE "\r?\n" ";" in_lines "${in}") + foreach(line IN LISTS in_lines) + # check for special CMAKE variable lines and parse them if found + if("${line}" MATCHES "^CMAKE_([_A-Za-z0-9]+)=(.*)$") + if("${CMAKE_MATCH_1}" STREQUAL "LANG") # handle CMAKE_LANG here + set(lang "${CMAKE_MATCH_2}") + else() + set(CMAKE_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" PARENT_SCOPE) + list(APPEND outcmvars "CMAKE_${CMAKE_MATCH_1}") + endif() + else() + string(APPEND outstr "${line}\n") + endif() + endforeach() + if(NOT lang) + message("load_compiler_info: ${infile} no LANG info; default to C") + set(lang C) + endif() + set(${lang_var} "${lang}" PARENT_SCOPE) + set(${outcmvars_var} "${outcmvars}" PARENT_SCOPE) + set(${outstr_var} "${outstr}" PARENT_SCOPE) +endfunction() + +# +# unload_compiler_info: clear out any CMAKE_* vars load previously set +# +function(unload_compiler_info cmvars) + foreach(var IN LISTS cmvars) + unset("${var}" PARENT_SCOPE) + endforeach() +endfunction() + +# +# main test loop +# +foreach(t ${targets}) + set(infile "${CMAKE_SOURCE_DIR}/data/${t}.input") + set(outfile "${CMAKE_SOURCE_DIR}/data/${t}.output") + if (NOT EXISTS ${infile} OR NOT EXISTS ${outfile}) + message("missing files for target ${t} in ${CMAKE_SOURCE_DIR}/data") + continue() + endif() + load_compiler_info(${infile} lang cmvars input) + file(READ ${outfile} output) + string(STRIP "${output}" output) + cmake_parse_implicit_include_info("${input}" "${lang}" idirs log state) + if(t MATCHES "^empty-") # empty isn't supposed to parse + if("${state}" STREQUAL "done") + message("empty parse failed: ${idirs}, log=${log}") + endif() + elseif(NOT "${state}" STREQUAL "done" OR NOT "${output}" STREQUAL "${idirs}") + message("parse failed: state=${state}, ${output} != ${idirs}, log=${log}") + endif() + unload_compiler_info("${cmvars}") +endforeach(t) diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/RunCMakeTest.cmake b/Tests/RunCMake/ParseImplicitIncludeInfo/RunCMakeTest.cmake new file mode 100644 index 0000000000..6266b500d0 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(ParseImplicitIncludeInfo) diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt b/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt new file mode 100644 index 0000000000..b854e2ea2c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt @@ -0,0 +1,87 @@ +# +# helper CMakeLists.txt file that can be used to generate input files +# for the Tests/RunCMake/ParseImplicitIncludeInfo test. +# +# usage: +# [create a temporary build directory and chdir to it] +# cmake [-D options] $CMAKE_SRC/Tests/RunCMake/ParseImplicitIncludeInfo/data +# +# where useful -D options include: +# -DLANGUAGES="C;CXX" -- list of languages to generate inputs for +# -DUNAME="Darwin" -- operating system name (def: CMAKE_SYSTEM_NAME) +# + +cmake_minimum_required(VERSION 3.3) + +set(lngs C CXX) +set(LANGUAGES "${lngs}" CACHE STRING "List of languages to generate inputs for") + +project(gen_implicit_include_data ${LANGUAGES}) + +set(UNAME "${CMAKE_SYSTEM_NAME}" CACHE STRING "System uname") +string(TOLOWER "${UNAME}" UNAME) +message("Generate input for system type: ${UNAME}") + +# CMAKE_<LANG>_COMPILER_* variables we save in the resultfile +set(compvars ABI AR ARCHITECTURE_ID EXTERNAL_TOOLCHAIN ID LAUNCHER LOADED + RANLIB TARGET VERSION VERSION_INTERAL) + +foreach(lang IN ITEMS ${LANGUAGES}) + + if("${lang}" STREQUAL "C") + set(file ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c) + elseif("${lang}" STREQUAL "CXX") + set(file ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) + elseif("${lang}" STREQUAL "CUDA") + set(file ${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu) + elseif("${lang}" STREQUAL "Fortran") + set(file ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) + else() + message(FATAL_ERROR "unknown language ${lang}") + endif() + + set(resultfile "${CMAKE_BINARY_DIR}/") + string(APPEND resultfile ${UNAME}-${lang}-${CMAKE_${lang}_COMPILER_ID}) + string(APPEND resultfile -${CMAKE_${lang}_COMPILER_VERSION}) + string(APPEND resultfile .input) + message("Generate input for language ${lang}") + message("Input file: ${file}") + message("Result file: ${resultfile}") + + # replicate logic from CMakeDetermineCompilerABI + set(outfile "${CMAKE_PLATFORM_INFO_DIR}/test${lang}.out") + set(CMAKE_FLAGS ) + set(COMPILE_DEFINITIONS ) + if(DEFINED CMAKE_${lang}_VERBOSE_FLAG) + set(CMAKE_FLAGS "-DEXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}") + set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_FLAG}") + endif() + if(DEFINED CMAKE_${lang}_VERBOSE_COMPILE_FLAG) + set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_COMPILE_FLAG}") + endif() + if(NOT "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC") + # Avoid adding our own platform standard libraries for compilers + # from which we might detect implicit link libraries. + list(APPEND CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD_LIBRARIES=") + endif() + + try_compile(rv ${CMAKE_BINARY_DIR} ${file} + CMAKE_FLAGS ${CMAKE_FLAGS} + COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} + CMAKE_FLAGS ${CMAKE_FLAGS} + OUTPUT_VARIABLE output + COPY_FILE "${outfile}" + COPY_FILE_ERROR copy_error) + + if(NOT rv) + message(FATAL_ERROR "${lang} compile failed!!") + endif() + + set(result "CMAKE_LANG=${lang}\n") + foreach(var IN ITEMS ${compvars}) + list(APPEND result + "CMAKE_${lang}_COMPILER_${var}=${CMAKE_${lang}_COMPILER_${var}}\n") + endforeach() + + file(WRITE ${resultfile} ${result} ${output}) +endforeach() diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/README b/Tests/RunCMake/ParseImplicitIncludeInfo/data/README new file mode 100644 index 0000000000..4f19b3c234 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/README @@ -0,0 +1,25 @@ +This directory contains sample input files for the implicit include +directories parser for testing. For each configuration there is one +".input" file and one ".output" file. + +To generate ".input" files for a system, create a temporary build +directory and chdir to it. Then run cmake pointing to this directory. +The CMakeLists.txt file here will generate ".input" files in your +build directory. The default set of languages is C and CXX. This +can be changed with -DLANGUAGES=language_list. For example: +-DLANGUAGES=Fortran will generate Fortran parser input. + +The ".output" files should be generated by hand from the input files. +The test will compare the parser output to the manually generated +".output" file. The two should match. + +For compilers that support "-nostdinc"-like flags, you can generate +a test for this with a command like: +cmake -DUNAME=netbsd_nostdinc \ + -DCMAKE_C_FLAGS=-nostdinc -DCMAKE_CXX_FLAGS=-nostdinc . + +Here is an example for testing the XL compiler with both -I and nostdinc: + +env CC=xlc CXX=xlC cmake -DUNAME=linux_nostdinc_i \ + -DCMAKE_C_FLAGS='-qnostdinc -I/tmp/ii/test_c' \ + -DCMAKE_CXX_FLAGS='-qnostdinc -I/tmp/ii/test_c -I/tmp/ii/test_cxx' . diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XL-13.1.3.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XL-13.1.3.input new file mode 100644 index 0000000000..14517c5cb4 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XL-13.1.3.input @@ -0,0 +1,40 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI= +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=XL +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=13.1.3 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_424d1/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_424d1.dir/build.make CMakeFiles/cmTC_424d1.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o +/opt/IBM/xlc/13.1.3/bin/xlc -qthreaded -qhalt=e -V -o CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c +export XL_CONFIG=/opt/IBM/xlc/13.1.3/etc/xlc.cfg.72:xlc +export XL_ASMOBJFILES=/tmp/xlcASvf7aid +export "XL_DIS=/opt/IBM/xlc/13.1.3/exe/dis -o "CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o"" +/opt/IBM/xlc/13.1.3/exe/xlcentry -qosvar=aix.7.2 -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -qthreaded -qhalt=e -qasm_as=/bin/as -qc_stdinc=/opt/IBM/xlc/13.1.3/include:/opt/IBM/xlmass/8.1.3/include:/usr/include -qvac_include_path=/opt/IBM/xlc/13.1.3/include -oCMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o /tmp/CMake/Modules/CMakeCCompilerABI.c /tmp/xlcW0uR7aia /tmp/xlcW1uV7aib /dev/null /tmp/xlcLvj7aieF.lst /dev/null /tmp/xlcW2vb7aic +export XL_BACKEND=/opt/IBM/xlc/13.1.3/exe/xlCcode +export XL_LINKER=/bin/ld +/opt/IBM/xlc/13.1.3/exe/xlCcode -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qthreaded -qhalt=e /tmp/xlcW0uR7aia /tmp/xlcW1uV7aib CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o /tmp/xlcLvj7aieB.lst /tmp/xlcW2vb7aic +rm /tmp/xlcASvf7aid +rm /tmp/xlcLvj7aie +rm /tmp/xlcW0uR7aia +rm /tmp/xlcW1uV7aib +rm /tmp/xlcW2vb7aic +Linking C executable cmTC_424d1 +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_424d1.dir/link.txt --verbose=1 +/opt/IBM/xlc/13.1.3/bin/xlc -qthreaded -qhalt=e -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o -o cmTC_424d1 -Wl,-blibpath:/usr/lib:/lib +export XL_CONFIG=/opt/IBM/xlc/13.1.3/etc/xlc.cfg.72:xlc +/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o -o cmTC_424d1 -blibpath:/usr/lib:/lib -L/opt/IBM/xlmass/8.1.3/lib/aix61 -L/opt/IBM/xlc/13.1.3/lib -lxlopt -lxlipa -lxl -lc +rm /tmp/xlcW0wn7aia +rm /tmp/xlcW1wr7aib +rm /tmp/xlcW2wz7aic +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XL-13.1.3.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XL-13.1.3.output new file mode 100644 index 0000000000..91b35ad15d --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XL-13.1.3.output @@ -0,0 +1 @@ +/opt/IBM/xlc/13.1.3/include;/opt/IBM/xlmass/8.1.3/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XL-13.1.3.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XL-13.1.3.input new file mode 100644 index 0000000000..5aec849e14 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XL-13.1.3.input @@ -0,0 +1,44 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI= +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=XL +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=13.1.3 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_e8f3a/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_e8f3a.dir/build.make CMakeFiles/cmTC_e8f3a.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o +/opt/IBM/xlC/13.1.3/bin/xlC -+ -qthreaded -qhalt=s -V -o CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp +export XL_CONFIG=/opt/IBM/xlc/13.1.3/etc/xlc.cfg.72:xlC +export XL_XLCMP_PATH=/opt/IBM/xlc/13.1.3:/opt/IBM/xlC/13.1.3 +export XL_COMPILER=xlc++ +export XL_ASMOBJFILES=/tmp/xlcAS3F7aid +export "XL_DIS=/opt/IBM/xlc/13.1.3/exe/dis -o "CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o"" +/opt/IBM/xlC/13.1.3/exe/xlCentry -qosvar=aix.7.2 -qalias=ansi -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -qthreaded -qhalt=s -qasm_as=/bin/as -qcpp_stdinc=/opt/IBM/xlC/13.1.3/include:/opt/IBM/xlmass/8.1.3/include:/usr/include -qc_stdinc=/opt/IBM/xlc/13.1.3/include:/opt/IBM/xlmass/8.1.3/include:/usr/include -oCMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW03r7aia /tmp/xlcW1347aib /dev/null /tmp/xlcL3J7aieF.lst /dev/null /tmp/xlcW2387aic +export XL_BACKEND=/opt/IBM/xlc/13.1.3/exe/xlCcode +export XL_LINKER=/bin/ld +/opt/IBM/xlc/13.1.3/exe/xlCcode -qalias=ansi -qthreaded -qhalt=s /tmp/xlcW03r7aia /tmp/xlcW1347aib CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcL3J7aieB.lst /tmp/xlcW2387aic +rm /tmp/xlcAS3F7aid +rm /tmp/xlcL3J7aie +rm /tmp/xlcW03r7aia +rm /tmp/xlcW1347aib +rm /tmp/xlcW2387aic +Linking CXX executable cmTC_e8f3a +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e8f3a.dir/link.txt --verbose=1 +/opt/IBM/xlC/13.1.3/bin/xlC -qthreaded -qhalt=s -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_e8f3a -Wl,-blibpath:/usr/lib:/lib +export XL_CONFIG=/opt/IBM/xlc/13.1.3/etc/xlc.cfg.72:xlC +/bin/ld -b32 /lib/crt0.o /lib/crti.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_e8f3a -blibpath:/usr/lib:/lib -bcdtors:all:0:s -btmplrename -L/opt/IBM/xlmass/8.1.3/lib/aix61 -L/opt/IBM/xlc/13.1.3/lib -lxlopt -lxlipa -lxl -L/opt/IBM/xlC/13.1.3/lib -lC -lm -lc | +/opt/IBM/xlC/13.1.3/bin/c++filt -S | +/bin/sed '/317.*::virtual-fn-table-ptr$/ s/^\(.*: \)*{*\([^}]*\)\(}*.*\)::virtual-fn-table-ptr$/\1Virtual table for class "\2": Some possible causes are: first non-inline virtual function in "\2" is not defined or the class is a template instantiation and an explicit instantiation definition of the class is missing./' +rm /tmp/xlcW04Jtaea +rm /tmp/xlcW14Vtaeb +rm /tmp/xlcW24Vtaec +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XL-13.1.3.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XL-13.1.3.output new file mode 100644 index 0000000000..264e4fe3b9 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XL-13.1.3.output @@ -0,0 +1 @@ +/opt/IBM/xlC/13.1.3/include;/opt/IBM/xlmass/8.1.3/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Cray-8.7.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Cray-8.7.input new file mode 100644 index 0000000000..b3218a2f5b --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Cray-8.7.input @@ -0,0 +1,53 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=Cray +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=8.7 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_cb7b8/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_cb7b8.dir/build.make CMakeFiles/cmTC_cb7b8.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o +/opt/cray/pe/craype/2.5.15/bin/cc -v -o CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake/Modules/CMakeCCompilerABI.c +rm /tmp/pe_15430/CMakeCCompilerABI_1.s + +/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/ccfe -hc -hcpu=haswell -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -hnetwork=aries -nostdinc -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/basic -isystem /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include -isystem /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include-fixed -isystem /opt/gcc/6.1.0/snos/include -isystem /usr/include -I /opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D__PEDRVR_GCC_BASE_ACTIVE__ -hpl=/tmp/pe_15430//pldir -rx8503 -ru87000 -CZ /tmp/pe_15430/CMakeCCompilerABI.T -Cx -CX /tmp/pe_15430/CMakeCCompilerABI.xml -hdecompile=/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI. -S /tmp/pe_15430/CMakeCCompilerABI_1.s -hipa3 -ufile_id=1 /usr/share/cmake/Modules/CMakeCCompilerABI.c + +/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/optcg /tmp/pe_15430//pldir 1 + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o --64 /tmp/pe_15430/CMakeCCompilerABI_1.s +rm /tmp/pe_15430/CMakeCCompilerABI_1.s +rm /tmp/pe_15430//CMakeCCompilerABI_1.cif.Ttmp +rm /tmp/pe_15430//CMakeCCompilerABI.Tfe +rm /tmp/pe_15430//CMakeCCompilerABI.T +rm /tmp/pe_15430//CMakeCCompilerABI_1.xml.Ttmp +rm /tmp/pe_15430//pldir/PL_path +rm /tmp/pe_15430//pldir/iline_1 +rm /tmp/pe_15430//pldir/PL_module_list +rm /tmp/pe_15430//pldir/CMakeCCompilerABI_1.inl +rm /tmp/pe_15430//pldir/gline_1 +rm /tmp/pe_15430//pldir/PL_global_data +rmdir /tmp/pe_15430//pldir +rm /tmp/pe_15430//CMakeCCompilerABI.xml +rmdir /tmp/pe_15430/ +Linking C executable cmTC_cb7b8 +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cb7b8.dir/link.txt --verbose=1 +/opt/cray/pe/craype/2.5.15/bin/cc -v CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o -o cmTC_cb7b8 + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtbeginT.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtfastmath.o /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o -Bstatic -rpath=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib -L /opt/gcc/6.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L /opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L /opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64 -L /opt/cray/pe/pmi/5.0.14/lib64 -L /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L /opt/cray/pe/atp/2.1.3/libApp -L /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/pkgconfig/../ -L /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L /usr/lib64 -L /lib64 -rpath=/usr/lib64 -rpath=/lib64 -lpthread -lsci_cray_mpi_mp -lm -lf -lsci_cray_mp -lcraymp -lm -lpthread -lf -lhugetlbfs -lmpich_cray -lrt -lpthread -lugni -lpmi -lpgas-dmapp -lfi -lu -lrt --undefined=dmapp_get_flag_nbi -ldmapp -lugni -ludreg -lpthread -lm -lcray-c++-rts -lstdc++ -lxpmem -ldmapp -lpthread -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lugni -lpthread -lalpsutil -lpthread -lrca -ludreg -lquadmath -lm -lomp -lrt -lcraymp -lpthread -lrt -ldl -lcray-c++-rts -lstdc++ -lm -lmodules -lm -lrt -lfi -lm -lquadmath -lrt -lcraymath -lm -lgfortran -lquadmath -lrt -lf -lm -lpthread -lrt -lu -lrt -ldl -lcray-c++-rts -lstdc++ -lm -lcsup -lrt --as-needed -latomic --no-as-needed -lstdc++ -lpthread --start-group -lc -lcsup -lgcc_eh -lm -lgcc --end-group -T/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/2.23.1.cce.ld -L /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0 -L /opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_cb7b8 --undefined=__pthread_initialize_minimal /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtend.o /usr/lib64//crtn.o + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_cb7b8 +rm /tmp/pe_15450//pldir/PL_path +rm /tmp/pe_15450//pldir/PL_module_list +rm /tmp/pe_15450//pldir/PL_global_data +rmdir /tmp/pe_15450//pldir +rmdir /tmp/pe_15450/ +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Cray-8.7.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Cray-8.7.output new file mode 100644 index 0000000000..cbd2132789 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Cray-8.7.output @@ -0,0 +1 @@ +/opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs;/opt/cray/pe/cce/8.7.4/cce/x86_64/include/basic;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include-fixed;/opt/gcc/6.1.0/snos/include;/usr/include;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-GNU-7.3.0.input new file mode 100644 index 0000000000..2dc60aff2e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-GNU-7.3.0.input @@ -0,0 +1,79 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=GNU +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=7.3.0 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_61245/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_61245.dir/build.make CMakeFiles/cmTC_61245.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o +/opt/cray/pe/craype/2.5.15/bin/cc -v -o CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake/Modules/CMakeCCompilerABI.c +Using built-in specs. +COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/gcc +Target: x86_64-suse-linux +Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib +Thread model: posix +gcc version 7.3.0 20180125 (Cray Inc.) (GCC) +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' + /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/cc1 -quiet -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -D __TARGET_LINUX__ /usr/share/cmake/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -march=core-avx2 -auxbase-strip CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o -version -o /tmp/ccNvdQ8R.s +GNU C11 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux) + compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring nonexistent directory "/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../x86_64-suse-linux/include" +#include "..." search starts here: +#include <...> search starts here: + /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include + /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include + /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include + /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include + /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include + /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include + /opt/cray/pe/pmi/5.0.14/include + /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include + /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include + /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include + /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include + /opt/cray-hss-devel/8.0.0/include + /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include + /usr/local/include + /opt/gcc/7.3.0/snos/include + /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed + /usr/include +End of search list. +GNU C11 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux) + compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +Compiler executable checksum: 4ecdcb30ed2f7ac4fb078d81fd42f086 +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' + as -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include --64 -o CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o /tmp/ccNvdQ8R.s +GNU assembler version 2.31.1 (x86_64-suse-linux) using BFD version (GNU Binutils SUSE Linux Enterprise 12) 2.31.1.20180828-9.26 +COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/ +LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' +Linking C executable cmTC_61245 +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_61245.dir/link.txt --verbose=1 +/opt/cray/pe/craype/2.5.15/bin/cc -v CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o -o cmTC_61245 +Using built-in specs. +COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/gcc +COLLECT_LTO_WRAPPER=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper +Target: x86_64-suse-linux +Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib +Thread model: posix +gcc version 7.3.0 20180125 (Cray Inc.) (GCC) +COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/ +LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_61245' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64' '-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64' '-L/opt/cray/pe/pmi/5.0.14/lib64' '-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64' '-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64' + /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/collect2 -plugin /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/liblto_plugin.so -plugin-opt=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccG3uxpY.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc -m elf_x86_64 -static -o cmTC_61245 -u pthread_mutex_destroy /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtbeginT.o -L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L/opt/cray/pe/pmi/5.0.14/lib64 -L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../.. CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o -rpath=/opt/cray/pe/gcc-libs --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -lpthread -lsci_gnu_71_mpi -lsci_gnu_71 -lpthread -lhugetlbfs -lmpich_gnu_71 -lrt -lugni -lpthread -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lalpsutil -lpthread -lrca -lxpmem -lugni -lpthread -ludreg --as-needed -lgfortran -lquadmath --no-as-needed --as-needed -lmvec --no-as-needed --as-needed -lm --no-as-needed --as-needed -lpthread --no-as-needed --start-group -lgcc -lgcc_eh -lc --end-group /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtend.o /usr/lib/../lib64/crtn.o +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_61245' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64' '-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64' '-L/opt/cray/pe/pmi/5.0.14/lib64' '-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64' '-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64' +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-GNU-7.3.0.output new file mode 100644 index 0000000000..64f127ef26 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-GNU-7.3.0.output @@ -0,0 +1 @@ +/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include;/usr/local/include;/opt/gcc/7.3.0/snos/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Intel-18.0.2.20180210.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Intel-18.0.2.20180210.input new file mode 100644 index 0000000000..8c68e5bf55 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Intel-18.0.2.20180210.input @@ -0,0 +1,40 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=Intel +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=18.0.2.20180210 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_96fde/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_96fde.dir/build.make CMakeFiles/cmTC_96fde.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o +/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/bin/intel64/icc -v -o CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake/Modules/CMakeCCompilerABI.c +icc version 18.0.2 (gcc version 6.3.0 compatibility) +/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/mcpcom --target_efi2 --lang=c -_g -mP3OPT_inline_alloca -D__ICC=1800 -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=2 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUC__=6 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 -D__LP64__ -D_LP64 -D__GXX_ABI_VERSION=1010 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B -Dunix -Dlinux "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__INTEL_COMPILER_BUILD_DATE=20180210 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -_k -_8 -_l --has_new_stdarg_support -_a -_b --gnu_version=60300 -_W5 --gcc-extern-inline --multibyte_chars -mGLOB_diag_suppress_sys --system_preinclude /usr/include/stdc-predef.h --array_section --simd --simd_func --offload_mode=1 --offload_target_names=gfx,GFX,mic,MIC --offload_unique_string=icc1641499230JViDRp -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-v -o CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -c" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icc6TGEr2as_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d92 -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x8 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icc1641499230JViDRp -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -mIPOPT_whole_archive_fixup_file_name=/tmp/iccwarchM4gS0h -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/icctempfileMGADNU -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C -mP1OPT_source_file_name=/usr/share/cmake/Modules/CMakeCCompilerABI.c -mP1OPT_full_source_file_name=/usr/share/cmake/Modules/CMakeCCompilerABI.c /usr/share/cmake/Modules/CMakeCCompilerABI.c +#include "..." search starts here: +#include <...> search starts here: + /opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64 + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include + /usr/local/include + /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include + /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed + /opt/gcc/6.3.0/snos/include/ + /usr/include +End of search list. +Linking C executable cmTC_96fde +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_96fde.dir/link.txt --verbose=1 +/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/bin/intel64/icc -v CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -o cmTC_96fde -rdynamic +icc version 18.0.2 (gcc version 6.3.0 compatibility) +/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/mcpcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-v -o cmTC_96fde -rdynamic" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/iccRJ58KYas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d92 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icc0762718770pMrhfB -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/iccslisYmrmw5 -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/iccscript8Dy5AI "-mIPOPT_cmdline_link="/usr/lib/../lib64/crt1.o" "/usr/lib/../lib64/crti.o" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbegin.o" "-export-dynamic" "--eh-frame-hdr" "--build-id" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-m" "elf_x86_64" "-o" "cmTC_96fde" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o" "-Bdynamic" "-Bstatic" "-limf" "-lsvml" "-lirng" "-Bdynamic" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "--as-needed" "-Bdynamic" "-lcilkrts" "-lstdc++" "--no-as-needed" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-lsvml" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o" "/usr/lib/../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_icclnz13i.o -mIPOPT_whole_archive_fixup_file_name=/tmp/iccwarch0d1B2R -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/icctempfilelBn98u -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_icclnz13i.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.c CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/iccalisA2xsdz -mIPOPT_generated_tempfiles=/tmp/iccelisbUgbic -mIPOPT_embedded_object_base_name=/tmp/icceobjEt9TmP -mIPOPT_cmdline_link_new_name=/tmp/iccllisYEcDrs +ld /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbegin.o -export-dynamic --eh-frame-hdr --build-id -dynamic-linker /lib64/ld-linux-x86-64.so.2 -m elf_x86_64 -o cmTC_96fde -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64 -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64 -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -Bdynamic -Bstatic -limf -lsvml -lirng -Bdynamic -lm -Bstatic -lipgo -ldecimal --as-needed -Bdynamic -lcilkrts -lstdc++ --no-as-needed -lgcc -lgcc_s -Bstatic -lirc -lsvml -Bdynamic -lc -lgcc -lgcc_s -Bstatic -lirc_s -Bdynamic -ldl -lc /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o /usr/lib/../lib64/crtn.o +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Intel-18.0.2.20180210.output new file mode 100644 index 0000000000..f0989ca2bb --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-C-Intel-18.0.2.20180210.output @@ -0,0 +1 @@ +/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include;/usr/local/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed;/opt/gcc/6.3.0/snos/include/;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Cray-8.7.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Cray-8.7.input new file mode 100644 index 0000000000..73c9c8a7f8 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Cray-8.7.input @@ -0,0 +1,53 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=Cray +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=8.7 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_f3b1f/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_f3b1f.dir/build.make CMakeFiles/cmTC_f3b1f.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o +/opt/cray/pe/craype/2.5.15/bin/CC -v -o CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp +rm /tmp/pe_15530/CMakeCXXCompilerABI_1.s + +/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/ccfe -hcpu=haswell -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -hnetwork=aries -nostdinc -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs -isystem /opt/gcc/6.1.0/snos/include/g++ -isystem /opt/gcc/6.1.0/snos/include/g++/x86_64-suse-linux -isystem /opt/gcc/6.1.0/snos/include/g++/backward -isystem /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include -isystem /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include-fixed -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/c++ -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/basic -isystem /opt/gcc/6.1.0/snos/include -isystem /usr/include -I /opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D__PEDRVR_GCC_BASE_ACTIVE__ -hpl=/tmp/pe_15530//pldir -rx8503 -ru87000 -hipafrom=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/libcray-c++-rts.a -CZ /tmp/pe_15530/CMakeCXXCompilerABI.T -Cx -CX /tmp/pe_15530/CMakeCXXCompilerABI.xml -hdecompile=/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI. -S /tmp/pe_15530/CMakeCXXCompilerABI_1.s -hipa4 -ufile_id=1 /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp + +/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/optcg /tmp/pe_15530//pldir 1 + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o --64 /tmp/pe_15530/CMakeCXXCompilerABI_1.s +rm /tmp/pe_15530/CMakeCXXCompilerABI_1.s +rm /tmp/pe_15530//CMakeCXXCompilerABI.xml +rm /tmp/pe_15530//CMakeCXXCompilerABI_1.cif.Ttmp +rm /tmp/pe_15530//CMakeCXXCompilerABI.T +rm /tmp/pe_15530//pldir/PL_path +rm /tmp/pe_15530//pldir/CMakeCXXCompilerABI_1.inl +rm /tmp/pe_15530//pldir/iline_1 +rm /tmp/pe_15530//pldir/PL_module_list +rm /tmp/pe_15530//pldir/gline_1 +rm /tmp/pe_15530//pldir/PL_global_data +rmdir /tmp/pe_15530//pldir +rm /tmp/pe_15530//CMakeCXXCompilerABI.Tfe +rm /tmp/pe_15530//CMakeCXXCompilerABI_1.xml.Ttmp +rmdir /tmp/pe_15530/ +Linking CXX executable cmTC_f3b1f +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f3b1f.dir/link.txt --verbose=1 +/opt/cray/pe/craype/2.5.15/bin/CC -v CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_f3b1f + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtbeginT.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtfastmath.o /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o -Bstatic -rpath=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib -L /opt/gcc/6.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L /opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L /opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64 -L /opt/cray/pe/pmi/5.0.14/lib64 -L /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L /opt/cray/pe/atp/2.1.3/libApp -L /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/pkgconfig/../ -L /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L /usr/lib64 -L /lib64 -rpath=/usr/lib64 -rpath=/lib64 -lpthread -lsci_cray_mpi_mp -lm -lf -lsci_cray_mp -lcraymp -lm -lpthread -lf -lhugetlbfs -lmpichcxx_cray -lrt -lpthread -lugni -lpmi -lmpich_cray -lrt -lpthread -lugni -lpmi -lpgas-dmapp -lfi -lu -lrt --undefined=dmapp_get_flag_nbi -ldmapp -lugni -ludreg -lpthread -lm -lcray-c++-rts -lstdc++ -lxpmem -ldmapp -lpthread -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lugni -lpthread -lalpsutil -lpthread -lrca -ludreg -lquadmath -lm -lomp -lrt -lcraymp -lpthread -lrt -ldl -lcray-c++-rts -lstdc++ -lm -lmodules -lm -lrt -lfi -lm -lquadmath -lrt -lcraymath -lm -lgfortran -lquadmath -lrt -lf -lm -lpthread -lrt -lu -lrt -ldl -lcray-c++-rts -lstdc++ -lm -lcsup -lrt --as-needed -latomic --no-as-needed -lcray-c++-rts -lstdc++ -lsupc++ -lstdc++ -lpthread --start-group -lc -lcsup -lgcc_eh -lm -lgcc --end-group -T/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/2.23.1.cce.ld -L /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0 -L /opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_f3b1f --undefined=__pthread_initialize_minimal /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtend.o /usr/lib64//crtn.o + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_f3b1f +rm /tmp/pe_15566//pldir/PL_path +rm /tmp/pe_15566//pldir/PL_module_list +rm /tmp/pe_15566//pldir/PL_global_data +rmdir /tmp/pe_15566//pldir +rmdir /tmp/pe_15566/ +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Cray-8.7.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Cray-8.7.output new file mode 100644 index 0000000000..259c42af41 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Cray-8.7.output @@ -0,0 +1 @@ +/opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs;/opt/gcc/6.1.0/snos/include/g++;/opt/gcc/6.1.0/snos/include/g++/x86_64-suse-linux;/opt/gcc/6.1.0/snos/include/g++/backward;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include-fixed;/opt/cray/pe/cce/8.7.4/cce/x86_64/include/c++;/opt/cray/pe/cce/8.7.4/cce/x86_64/include/basic;/opt/gcc/6.1.0/snos/include;/usr/include;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-GNU-7.3.0.input new file mode 100644 index 0000000000..50f2859c79 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-GNU-7.3.0.input @@ -0,0 +1,82 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=GNU +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=7.3.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_66e70/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_66e70.dir/build.make CMakeFiles/cmTC_66e70.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o +/opt/cray/pe/craype/2.5.15/bin/CC -v -o CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp +Using built-in specs. +COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/g++ +Target: x86_64-suse-linux +Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib +Thread model: posix +gcc version 7.3.0 20180125 (Cray Inc.) (GCC) +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' + /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/cc1plus -quiet -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D_GNU_SOURCE -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -D __TARGET_LINUX__ /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -march=core-avx2 -auxbase-strip CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o -version -o /tmp/ccH9m9Qh.s +GNU C++14 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux) + compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring nonexistent directory "/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../x86_64-suse-linux/include" +#include "..." search starts here: +#include <...> search starts here: + /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include + /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include + /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include + /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include + /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include + /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include + /opt/cray/pe/pmi/5.0.14/include + /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include + /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include + /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include + /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include + /opt/cray-hss-devel/8.0.0/include + /opt/gcc/7.3.0/snos/include/g++ + /opt/gcc/7.3.0/snos/include/g++/x86_64-suse-linux + /opt/gcc/7.3.0/snos/include/g++/backward + /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include + /usr/local/include + /opt/gcc/7.3.0/snos/include + /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed + /usr/include +End of search list. +GNU C++14 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux) + compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +Compiler executable checksum: f544672a0be6a74646c0fce634253d7e +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' + as -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include --64 -o CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o /tmp/ccH9m9Qh.s +GNU assembler version 2.31.1 (x86_64-suse-linux) using BFD version (GNU Binutils SUSE Linux Enterprise 12) 2.31.1.20180828-9.26 +COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/ +LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' +Linking CXX executable cmTC_66e70 +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_66e70.dir/link.txt --verbose=1 +/opt/cray/pe/craype/2.5.15/bin/CC -v CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_66e70 +Using built-in specs. +COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/g++ +COLLECT_LTO_WRAPPER=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper +Target: x86_64-suse-linux +Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib +Thread model: posix +gcc version 7.3.0 20180125 (Cray Inc.) (GCC) +COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/ +LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_66e70' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64' '-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64' '-L/opt/cray/pe/pmi/5.0.14/lib64' '-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64' '-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64' + /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/collect2 -plugin /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/liblto_plugin.so -plugin-opt=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccPBC8Um.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc -m elf_x86_64 -static -o cmTC_66e70 -u pthread_mutex_destroy /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtbeginT.o -L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L/opt/cray/pe/pmi/5.0.14/lib64 -L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../.. CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o -rpath=/opt/cray/pe/gcc-libs --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -lpthread -lsci_gnu_71_mpi -lsci_gnu_71 -lpthread -lhugetlbfs -lmpichcxx_gnu_71 -lrt -lugni -lpthread -lpmi -lmpich_gnu_71 -lrt -lugni -lpthread -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lalpsutil -lpthread -lrca -lugni -lpthread -lxpmem -ludreg --as-needed -lgfortran -lquadmath --no-as-needed --as-needed -lmvec --no-as-needed --as-needed -lm --no-as-needed --as-needed -lpthread --no-as-needed -lstdc++ -lm --start-group -lgcc -lgcc_eh -lc --end-group /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtend.o /usr/lib/../lib64/crtn.o +COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_66e70' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64' '-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64' '-L/opt/cray/pe/pmi/5.0.14/lib64' '-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64' '-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64' +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-GNU-7.3.0.output new file mode 100644 index 0000000000..d9095f7c61 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-GNU-7.3.0.output @@ -0,0 +1 @@ +/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include;/opt/gcc/7.3.0/snos/include/g++;/opt/gcc/7.3.0/snos/include/g++/x86_64-suse-linux;/opt/gcc/7.3.0/snos/include/g++/backward;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include;/usr/local/include;/opt/gcc/7.3.0/snos/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Intel-18.0.2.20180210.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Intel-18.0.2.20180210.input new file mode 100644 index 0000000000..e25f7cf9d9 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Intel-18.0.2.20180210.input @@ -0,0 +1,43 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=Intel +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=18.0.2.20180210 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_7f9a2/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_7f9a2.dir/build.make CMakeFiles/cmTC_7f9a2.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o +/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/bin/intel64/icpc -v -o CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp +icpc version 18.0.2 (gcc version 6.3.0 compatibility) +/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/mcpcom --target_efi2 --lang=c++ -_g -mP3OPT_inline_alloca -D__ICC=1800 -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=2 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__GLIBCXX_TYPE_INT_N_0=__int128 -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUG__=6 -D__GNUC__=6 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 -D__LP64__ -D_LP64 -D_GNU_SOURCE=1 -D__DEPRECATED=1 -D__GXX_WEAK__=1 -D__GXX_ABI_VERSION=1010 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__EXCEPTIONS=1 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B -Dunix -Dlinux "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__INTEL_COMPILER_BUILD_DATE=20180210 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -_k -_8 -_l --has_new_stdarg_support -_a -_b --gnu_version=60300 -_W5 --gcc-extern-inline -p --bool -tused -x --multibyte_chars -mGLOB_diag_suppress_sys --system_preinclude /usr/include/stdc-predef.h --array_section --simd --simd_func --offload_mode=1 --offload_target_names=gfx,GFX,mic,MIC --offload_unique_string=icpc0677339003u7vp5M --bool -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-v -o CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -c" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icpc9QgBnwas_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d8f -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x8 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icpc0677339003u7vp5M -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -mIPOPT_whole_archive_fixup_file_name=/tmp/icpcwarchdKZxrN -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/icpctempfilejCzFYq -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C_PLUS_PLUS -mP1OPT_source_file_name=/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp -mP1OPT_full_source_file_name=/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp -mGLOB_eh_linux /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp +#include "..." search starts here: +#include <...> search starts here: + /opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64 + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include + /opt/gcc/6.3.0/snos/include/g++ + /opt/gcc/6.3.0/snos/include/g++/x86_64-suse-linux + /opt/gcc/6.3.0/snos/include/g++/backward + /usr/local/include + /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include + /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed + /opt/gcc/6.3.0/snos/include/ + /usr/include +End of search list. +Linking CXX executable cmTC_7f9a2 +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7f9a2.dir/link.txt --verbose=1 +/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/bin/intel64/icpc -v CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_7f9a2 -rdynamic +icpc version 18.0.2 (gcc version 6.3.0 compatibility) +/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/mcpcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-v -o cmTC_7f9a2 -rdynamic" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icpczXhKsFas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d8f -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icpc0782944392Xjn3gY -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/icpcslis0WLMWJ -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/icpcscriptx5xyMn "-mIPOPT_cmdline_link="/usr/lib/../lib64/crt1.o" "/usr/lib/../lib64/crti.o" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbegin.o" "-export-dynamic" "--eh-frame-hdr" "--build-id" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-m" "elf_x86_64" "-o" "cmTC_7f9a2" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o" "-Bdynamic" "-Bstatic" "-limf" "-lsvml" "-lirng" "-Bdynamic" "-lstdc++" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "--as-needed" "-Bdynamic" "-lcilkrts" "--no-as-needed" "-lstdc++" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-lsvml" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o" "/usr/lib/../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_icpcP4kcWS.o -mIPOPT_whole_archive_fixup_file_name=/tmp/icpcwarchR2OJ1A -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/icpctempfileWiVxTe -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_icpcP4kcWS.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.c CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/icpcalis76IIBa -mIPOPT_generated_tempfiles=/tmp/icpcelisj58trO -mIPOPT_embedded_object_base_name=/tmp/icpceobjgmHfhs -mIPOPT_cmdline_link_new_name=/tmp/icpcllis3p9065 +ld /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbegin.o -export-dynamic --eh-frame-hdr --build-id -dynamic-linker /lib64/ld-linux-x86-64.so.2 -m elf_x86_64 -o cmTC_7f9a2 -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64 -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64 -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -Bdynamic -Bstatic -limf -lsvml -lirng -Bdynamic -lstdc++ -lm -Bstatic -lipgo -ldecimal --as-needed -Bdynamic -lcilkrts --no-as-needed -lstdc++ -lgcc -lgcc_s -Bstatic -lirc -lsvml -Bdynamic -lc -lgcc -lgcc_s -Bstatic -lirc_s -Bdynamic -ldl -lc /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o /usr/lib/../lib64/crtn.o +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Intel-18.0.2.20180210.output new file mode 100644 index 0000000000..73d779b9b1 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-CXX-Intel-18.0.2.20180210.output @@ -0,0 +1 @@ +/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include;/opt/gcc/6.3.0/snos/include/g++;/opt/gcc/6.3.0/snos/include/g++/x86_64-suse-linux;/opt/gcc/6.3.0/snos/include/g++/backward;/usr/local/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed;/opt/gcc/6.3.0/snos/include/;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Cray-8.7.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Cray-8.7.input new file mode 100644 index 0000000000..4c4e2f4834 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Cray-8.7.input @@ -0,0 +1,52 @@ +CMAKE_LANG=Fortran +CMAKE_Fortran_COMPILER_ABI=ELF +CMAKE_Fortran_COMPILER_AR= +CMAKE_Fortran_COMPILER_ARCHITECTURE_ID= +CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_Fortran_COMPILER_ID=Cray +CMAKE_Fortran_COMPILER_LAUNCHER= +CMAKE_Fortran_COMPILER_LOADED=1 +CMAKE_Fortran_COMPILER_RANLIB= +CMAKE_Fortran_COMPILER_TARGET= +CMAKE_Fortran_COMPILER_VERSION=8.7 +CMAKE_Fortran_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_9c3ab/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_9c3ab.dir/build.make CMakeFiles/cmTC_9c3ab.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building Fortran object CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o +/opt/cray/pe/craype/2.5.15/bin/ftn -em -J. -v -c /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o + +/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/ftnfe -h cpu=haswell -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -h network=aries -em -J. -I/opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs -I/usr/include -I/usr/include -I/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -hpl=/tmp/pe_32428//pldir -usystem_mod=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/libmodules.a -usystem_mod=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/libomp.a -usystem_mod=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/omp_lib.a -usystem_mod=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/libopenacc.a -usystem_mod=/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include -usystem_mod=/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include -usystem_mod=/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -usystem_mod=/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -usystem_mod=/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -usystem_mod=/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -usystem_mod=/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include -usystem_mod=/opt/cray/pe/pmi/5.0.14/include -usystem_mod=/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -usystem_mod=/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -usystem_mod=/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -usystem_mod=/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -usystem_mod=/opt/cray-hss-devel/8.0.0/include -ux=x8503 -udv=87000 -ffixed -CZ/tmp/pe_32428/CMakeFortranCompilerABI.T -Cx -CX/tmp/pe_32428/CMakeFortranCompilerABI.xml -hdecompile=/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI. -S /tmp/pe_32428/CMakeFortranCompilerABI_1.s -Oipa3 -uo=/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o -ufile_id=1 /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F + +/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/optcg /tmp/pe_32428//pldir 1 + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o --64 /tmp/pe_32428/CMakeFortranCompilerABI_1.s +rm /tmp/pe_32428/CMakeFortranCompilerABI_1.s +rm /tmp/pe_32428//pldir/PL_path +rm /tmp/pe_32428//pldir/iline_1 +rm /tmp/pe_32428//pldir/gline_1 +rm /tmp/pe_32428//pldir/PL_global_data +rm /tmp/pe_32428//pldir/PL_module_list +rm /tmp/pe_32428//pldir/CMakeFortranCompilerABI_1.inl +rmdir /tmp/pe_32428//pldir +rm /tmp/pe_32428//CMakeFortranCompilerABI_1.xml.Ttmp +rm /tmp/pe_32428//CMakeFortranCompilerABI.T +rm /tmp/pe_32428//CMakeFortranCompilerABI_1.cif.Ttmp +rm /tmp/pe_32428//CMakeFortranCompilerABI.Tfe +rm /tmp/pe_32428//CMakeFortranCompilerABI.xml +rmdir /tmp/pe_32428/ +Linking Fortran executable cmTC_9c3ab +/usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9c3ab.dir/link.txt --verbose=1 +/opt/cray/pe/craype/2.5.15/bin/ftn -v -dynamic CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o -o cmTC_9c3ab + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_x86_64 --enable-new-dtags --dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtbegin.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtfastmath.o /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o -Bdynamic -rpath=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib -L/opt/gcc/6.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/pkgconfig/../ --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L/usr/lib64 -L/lib64 -rpath=/usr/lib64 -rpath=/lib64 -lrca --as-needed -lsci_cray_mpi_mp --no-as-needed --as-needed -lsci_cray_mp --no-as-needed --as-needed -lmpich_cray --no-as-needed --as-needed -lmpichf90_cray --no-as-needed --as-needed -lpgas-dmapp --no-as-needed -lquadmath -lomp -lcraymp -lmodules -lfi -lcraymath -lf -lu -lcsup --as-needed -latomic --no-as-needed --as-needed -lgfortran --no-as-needed --whole-archive -ltcmalloc_minimal --no-whole-archive -lstdc++ -lpthread --start-group -lc -lcsup -lgcc_eh -lm -lgcc --end-group -L /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0 -L /opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_9c3ab /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtend.o /usr/lib64//crtn.o + +/opt/cray/pe/cce/8.7.4/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_9c3ab +rm /tmp/pe_32450//pldir/PL_path +rm /tmp/pe_32450//pldir/PL_global_data +rm /tmp/pe_32450//pldir/PL_module_list +rmdir /tmp/pe_32450//pldir +rmdir /tmp/pe_32450/ +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Cray-8.7.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Cray-8.7.output new file mode 100644 index 0000000000..d57439c66e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Cray-8.7.output @@ -0,0 +1 @@ +/opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs;/usr/include;/usr/include;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-GNU-7.3.0.input new file mode 100644 index 0000000000..bee298c378 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-GNU-7.3.0.input @@ -0,0 +1,83 @@ +CMAKE_LANG=Fortran +CMAKE_Fortran_COMPILER_ABI= +CMAKE_Fortran_COMPILER_AR=/usr/bin/gcc-ar +CMAKE_Fortran_COMPILER_ARCHITECTURE_ID= +CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_Fortran_COMPILER_ID=GNU +CMAKE_Fortran_COMPILER_LAUNCHER= +CMAKE_Fortran_COMPILER_LOADED=1 +CMAKE_Fortran_COMPILER_RANLIB=/usr/bin/gcc-ranlib +CMAKE_Fortran_COMPILER_TARGET= +CMAKE_Fortran_COMPILER_VERSION=7.3.0 +CMAKE_Fortran_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_390ef/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_390ef.dir/build.make CMakeFiles/cmTC_390ef.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building Fortran object CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o +/opt/cray/pe/craype/2.5.15/bin/ftn -v -c /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o +Using built-in specs. +COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/gfortran +Target: x86_64-suse-linux +Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib +Thread model: posix +gcc version 7.3.0 20180125 (Cray Inc.) (GCC) +COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-c' '-o' 'CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' + /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/f951 /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -ffixed-form -cpp=/tmp/ccxLli6i.f90 -quiet -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -D __TARGET_LINUX__ /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -quiet -dumpbase CMakeFortranCompilerABI.F -march=core-avx2 -auxbase-strip CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o -version -fintrinsic-modules-path /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/finclude -o /tmp/ccqY0cGk.s +GNU Fortran (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux) + compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring nonexistent directory "/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../x86_64-suse-linux/include" +#include "..." search starts here: +#include <...> search starts here: + /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include + /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include + /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include + /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include + /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include + /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include + /opt/cray/pe/pmi/5.0.14/include + /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include + /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include + /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include + /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include + /opt/cray-hss-devel/8.0.0/include + /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/finclude + /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include + /usr/local/include + /opt/gcc/7.3.0/snos/include + /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed + /usr/include +End of search list. +GNU Fortran2008 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux) + compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-c' '-o' 'CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' + as -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include --64 -o CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o /tmp/ccqY0cGk.s +GNU assembler version 2.31.1 (x86_64-suse-linux) using BFD version (GNU Binutils SUSE Linux Enterprise 12) 2.31.1.20180828-9.26 +COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/ +LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-c' '-o' 'CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' +Linking Fortran executable cmTC_390ef +/usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_390ef.dir/link.txt --verbose=1 +/opt/cray/pe/craype/2.5.15/bin/ftn -v -dynamic CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o -o cmTC_390ef +Driving: /opt/gcc/7.3.0/bin/../snos/bin/gfortran -march=core-avx2 -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -D__TARGET_LINUX__ -v CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o -o cmTC_390ef -Wl,-rpath=/opt/cray/pe/gcc-libs -Wl,-Bdynamic -I/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -Wl,--no-as-needed,-lAtpSigHandler,-lAtpSigHCommData -Wl,--undefined=_ATP_Data_Globals -Wl,--undefined=__atpHandlerInstall -lrca -Wl,--as-needed,-lsci_gnu_71_mpi,--no-as-needed -Wl,--as-needed,-lsci_gnu_71,--no-as-needed -Wl,--as-needed,-lmpich_gnu_71,--no-as-needed -Wl,--as-needed,-lmpichf90_gnu_71,--no-as-needed -Wl,--as-needed,-lgfortran,-lquadmath,--no-as-needed -Wl,--as-needed,-lpthread,--no-as-needed -l gfortran -l m -shared-libgcc +Using built-in specs. +COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/gfortran +COLLECT_LTO_WRAPPER=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper +Target: x86_64-suse-linux +Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib +Thread model: posix +gcc version 7.3.0 20180125 (Cray Inc.) (GCC) +Reading specs from /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/libgfortran.spec +rename spec lib to liborig +COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_390ef' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-shared-libgcc' +COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/ +LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_390ef' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-shared-libgcc' + /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/collect2 -plugin /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/liblto_plugin.so -plugin-opt=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cc1AyzSl.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_390ef /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtbegin.o -L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../.. CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o -rpath=/opt/cray/pe/gcc-libs -Bdynamic --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -lrca --as-needed -lsci_gnu_71_mpi --no-as-needed --as-needed -lsci_gnu_71 --no-as-needed --as-needed -lmpich_gnu_71 --no-as-needed --as-needed -lmpichf90_gnu_71 --no-as-needed --as-needed -lgfortran -lquadmath --no-as-needed --as-needed -lpthread --no-as-needed -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtend.o /usr/lib/../lib64/crtn.o +COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_390ef' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-shared-libgcc' +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-GNU-7.3.0.output new file mode 100644 index 0000000000..5b96c9d083 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-GNU-7.3.0.output @@ -0,0 +1 @@ +/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/finclude;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include;/usr/local/include;/opt/gcc/7.3.0/snos/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Intel-18.0.2.20180210.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Intel-18.0.2.20180210.input new file mode 100644 index 0000000000..4cdff74ec0 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Intel-18.0.2.20180210.input @@ -0,0 +1,80 @@ +CMAKE_LANG=Fortran +CMAKE_Fortran_COMPILER_ABI=ELF +CMAKE_Fortran_COMPILER_AR= +CMAKE_Fortran_COMPILER_ARCHITECTURE_ID= +CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_Fortran_COMPILER_ID=Intel +CMAKE_Fortran_COMPILER_LAUNCHER= +CMAKE_Fortran_COMPILER_LOADED=1 +CMAKE_Fortran_COMPILER_RANLIB= +CMAKE_Fortran_COMPILER_TARGET= +CMAKE_Fortran_COMPILER_VERSION=18.0.2.20180210 +CMAKE_Fortran_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_7523d/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_7523d.dir/build.make CMakeFiles/cmTC_7523d.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building Fortran object CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o +/opt/cray/pe/craype/2.5.15/bin/ftn -v -c /usr/share/cmake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o +ifort version 18.0.2 +/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/fpp -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=2 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -Dunix -Dlinux -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ -D__INTEL_COMPILER_BUILD_DATE=20180210 -D__INTEL_OFFLOAD -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -D__AVX__ -D__AVX_I__ -D__AVX2__ -D__FMA__ -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -I. -I/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -I/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64 -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include -I/usr/local/include -I/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include -I/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed -I/opt/gcc/6.3.0/snos/include/ -I/usr/include -fixed -4Ycpp -4Ncvf -f_com=yes -MX /usr/share/cmake/Modules/CMakeFortranCompilerABI.F /tmp/ifortjocHCJ.i +#include "..." search starts here: +#include <...> search starts here: + . + /opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include + /opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include + /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include + /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include + /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include + /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include + /opt/cray/pe/pmi/5.0.14/include + /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include + /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include + /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include + /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include + /opt/cray-hss-devel/8.0.0/include + /opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64 + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include + /usr/local/include + /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include + /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed + /opt/gcc/6.3.0/snos/include/ + /usr/include +End of search list. +/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/fortcom -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=2 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -Dunix -Dlinux -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ -D__INTEL_COMPILER_BUILD_DATE=20180210 -D__INTEL_OFFLOAD -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -D__AVX__ -D__AVX_I__ -D__AVX2__ -D__FMA__ -mGLOB_pack_sort_init_list -I/usr/share/cmake/Modules -I. -I/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -I/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64 -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include -I/usr/local/include -I/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include -I/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed -I/opt/gcc/6.3.0/snos/include/ -I/usr/include -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -O2 "-reentrancy none" -simd -offload_host -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mGLOB_source_language=GLOB_SOURCE_LANGUAGE_F90 -mP2OPT_static_promotion -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-I/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -xCORE-AVX2 -static -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -v -c -o CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/ifortYH2Bi3as_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d90 -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x4000 -mGLOB_advanced_optim=TRUE -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=ifort0690104118gDFZUy -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -mIPOPT_whole_archive_fixup_file_name=/tmp/ifortwarch8cLx6A -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/iforttempfiledtmF0m -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_FORTRAN -mP1OPT_source_file_name=/usr/share/cmake/Modules/CMakeFortranCompilerABI.F -mP1OPT_full_source_file_name=/usr/share/cmake/Modules/CMakeFortranCompilerABI.F -mP2OPT_symtab_type_copy=true /tmp/ifortjocHCJ.i +#include "..." search starts here: +#include <...> search starts here: + /usr/share/cmake/Modules + . + /opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include + /opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include + /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include + /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include + /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include + /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include + /opt/cray/pe/pmi/5.0.14/include + /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include + /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include + /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include + /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include + /opt/cray-hss-devel/8.0.0/include + /opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64 + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc + /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include + /usr/local/include + /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include + /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed + /opt/gcc/6.3.0/snos/include/ + /usr/include +End of search list. +Linking Fortran executable cmTC_7523d +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7523d.dir/link.txt --verbose=1 +/opt/cray/pe/craype/2.5.15/bin/ftn -v CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -o cmTC_7523d +ifort version 18.0.2 +/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/fortcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mGLOB_source_language=GLOB_SOURCE_LANGUAGE_F90 -mP2OPT_static_promotion -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-I/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -xCORE-AVX2 -static -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -v -o cmTC_7523d -L/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L/opt/cray/pe/pmi/5.0.14/lib64 -L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 -Wl,-Ttext-segment=0x20000000,-zmax-page-size=0x20000000 -Wl,--whole-archive,-lhugetlbfs,--no-whole-archive -Wl,--no-as-needed,-lAtpSigHandler,-lAtpSigHCommData -Wl,--undefined=_ATP_Data_Globals -Wl,--undefined=__atpHandlerInstall -lpthread -lmpichf90_intel -lrt -lugni -lpmi -lm -lpthread -ldl -lsci_intel_mpi -lsci_intel -lm -ldl -lmpich_intel -lrt -lugni -lpthread -lpmi -lm -ldl -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lalpsutil -lpthread -lrca -lxpmem -lugni -lpthread -ludreg -lsci_intel -lm -lpthread -ldl -lhugetlbfs -Wl,--as-needed,-limf,--no-as-needed -Wl,--as-needed,-lm,--no-as-needed -Wl,--as-needed,-lpthread,--no-as-needed" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/ifort3JZMSVas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d90 -mGLOB_extended_instructions=0x4000 -mGLOB_advanced_optim=TRUE -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=ifort0690373519HAIHNw -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/ifortslis6v0DlA -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/ifortscriptsKB8Qm "-mIPOPT_cmdline_link="/usr/lib/../lib64/crt1.o" "/usr/lib/../lib64/crti.o" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbeginT.o" "--build-id" "-static" "-m" "elf_x86_64" "-L/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/lib" "-L/opt/cray/dmapp/default/lib64" "-L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib" "-L/opt/cray/dmapp/default/lib64" "-L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib" "-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64" "-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64" "-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64" "-L/opt/cray/pe/pmi/5.0.14/lib64" "-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64" "-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64" "-L/opt/cray/pe/atp/2.1.3/libApp" "-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64" "-o" "cmTC_7523d" "/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin/for_main.o" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o" "-Ttext-segment=0x20000000" "-zmax-page-size=0x20000000" "--whole-archive" "-lhugetlbfs" "--no-whole-archive" "--no-as-needed" "-lAtpSigHandler" "-lAtpSigHCommData" "--undefined=_ATP_Data_Globals" "--undefined=__atpHandlerInstall" "-lpthread" "-lmpichf90_intel" "-lrt" "-lugni" "-lpmi" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-limf" "-lm" "-lpthread" "-ldl" "-lsci_intel_mpi" "-lsci_intel" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-limf" "-lm" "-ldl" "-lmpich_intel" "-lrt" "-lugni" "-lpthread" "-lpmi" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-limf" "-lm" "-ldl" "-lpmi" "-lpthread" "-lalpslli" "-lpthread" "-lwlm_detect" "-lalpsutil" "-lpthread" "-lrca" "-lxpmem" "-lugni" "-lpthread" "-ludreg" "-lsci_intel" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-limf" "-lm" "-lpthread" "-ldl" "-lhugetlbfs" "--as-needed" "-limf" "--no-as-needed" "--as-needed" "-lm" "--no-as-needed" "--as-needed" "-lpthread" "--no-as-needed" "-lifport" "-lifcore" "-limf" "-lsvml" "-lm" "-lipgo" "-lirc" "-lsvml" "-lc" "-lgcc" "-lgcc_eh" "-lirc_s" "-ldl" "-lc" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o" "/usr/lib/../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_ifort5KgIiT.o -mIPOPT_whole_archive_fixup_file_name=/tmp/ifortwarchltBXsh -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/iforttempfilesugt03 -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_ifort5KgIiT.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.f -mP2OPT_symtab_type_copy=true CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/ifortalisCY2Fjs -mIPOPT_generated_tempfiles=/tmp/ifortelisXEqaPe -mIPOPT_embedded_object_base_name=/tmp/iforteobjRoVEk1 -mIPOPT_cmdline_link_new_name=/tmp/ifortllisJHg9PN +ld /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbeginT.o --build-id -static -m elf_x86_64 -L/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L/opt/cray/pe/pmi/5.0.14/lib64 -L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 -o cmTC_7523d /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin/for_main.o -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64 -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64 -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -Ttext-segment=0x20000000 -zmax-page-size=0x20000000 --whole-archive -lhugetlbfs --no-whole-archive --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -lpthread -lmpichf90_intel -lrt -lugni -lpmi -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -limf -lm -lpthread -ldl -lsci_intel_mpi -lsci_intel -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -limf -lm -ldl -lmpich_intel -lrt -lugni -lpthread -lpmi -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -limf -lm -ldl -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lalpsutil -lpthread -lrca -lxpmem -lugni -lpthread -ludreg -lsci_intel -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -limf -lm -lpthread -ldl -lhugetlbfs --as-needed -limf --no-as-needed --as-needed -lm --no-as-needed --as-needed -lpthread --no-as-needed -lifport -lifcore -limf -lsvml -lm -lipgo -lirc -lsvml -lc -lgcc -lgcc_eh -lirc_s -ldl -lc /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o /usr/lib/../lib64/crtn.o +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Intel-18.0.2.20180210.output new file mode 100644 index 0000000000..c3915b6735 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/craype-Fortran-Intel-18.0.2.20180210.output @@ -0,0 +1 @@ +.;/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include;/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include;/usr/local/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed;/opt/gcc/6.3.0/snos/include/;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-C-AppleClang-8.0.0.8000042.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-C-AppleClang-8.0.0.8000042.input new file mode 100644 index 0000000000..4bc26bcbae --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-C-AppleClang-8.0.0.8000042.input @@ -0,0 +1,50 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI= +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=AppleClang +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=8.0.0.8000042 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_0c33e/fast" +/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_0c33e.dir/build.make CMakeFiles/cmTC_0c33e.dir/build +Building C object CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -v -Wl,-v -o CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCCompilerABI.c +Apple LLVM version 8.0.0 (clang-800.0.42.1) +Target: x86_64-apple-darwin15.6.0 +Thread model: posix +InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin +clang: warning: -Wl,-v: 'linker' input unused + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file /private/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -fdebug-compilation-dir /private/tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -o CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -x c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCCompilerABI.c +clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0 +ignoring nonexistent directory "/usr/local/include" +#include "..." search starts here: +#include <...> search starts here: + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include + /usr/include + /System/Library/Frameworks (framework directory) + /Library/Frameworks (framework directory) +End of search list. +Linking C executable cmTC_0c33e +/usr/local/pkg.1804/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0c33e.dir/link.txt --verbose=1 +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -o cmTC_0c33e +Apple LLVM version 8.0.0 (clang-800.0.42.1) +Target: x86_64-apple-darwin15.6.0 +Thread model: posix +InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_0c33e -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a +@(#)PROGRAM:ld PROJECT:ld64-274.2 +configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) +Library search paths: + /usr/lib + /usr/local/lib +Framework search paths: + /Library/Frameworks/ + /System/Library/Frameworks/ diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-C-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-C-AppleClang-8.0.0.8000042.output new file mode 100644 index 0000000000..c857928abe --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-C-AppleClang-8.0.0.8000042.output @@ -0,0 +1 @@ +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-CXX-AppleClang-8.0.0.8000042.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-CXX-AppleClang-8.0.0.8000042.input new file mode 100644 index 0000000000..907a92e248 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-CXX-AppleClang-8.0.0.8000042.input @@ -0,0 +1,52 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI= +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=AppleClang +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=8.0.0.8000042 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_b7e96/fast" +/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_b7e96.dir/build.make CMakeFiles/cmTC_b7e96.dir/build +Building CXX object CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -v -Wl,-v -o CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp +Apple LLVM version 8.0.0 (clang-800.0.42.1) +Target: x86_64-apple-darwin15.6.0 +Thread model: posix +InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin +clang: warning: -Wl,-v: 'linker' input unused + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file /private/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /private/tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -x c++ /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp +clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0 +ignoring nonexistent directory "/usr/include/c++/v1" +ignoring nonexistent directory "/usr/local/include" +#include "..." search starts here: +#include <...> search starts here: + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include + /usr/include + /System/Library/Frameworks (framework directory) + /Library/Frameworks (framework directory) +End of search list. +Linking CXX executable cmTC_b7e96 +/usr/local/pkg.1804/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b7e96.dir/link.txt --verbose=1 +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_b7e96 +Apple LLVM version 8.0.0 (clang-800.0.42.1) +Target: x86_64-apple-darwin15.6.0 +Thread model: posix +InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_b7e96 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a +@(#)PROGRAM:ld PROJECT:ld64-274.2 +configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) +Library search paths: + /usr/lib + /usr/local/lib +Framework search paths: + /Library/Frameworks/ + /System/Library/Frameworks/ diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-CXX-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-CXX-AppleClang-8.0.0.8000042.output new file mode 100644 index 0000000000..6df208c634 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin-CXX-AppleClang-8.0.0.8000042.output @@ -0,0 +1 @@ +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-C-AppleClang-8.0.0.8000042.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-C-AppleClang-8.0.0.8000042.input new file mode 100644 index 0000000000..effaedf552 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-C-AppleClang-8.0.0.8000042.input @@ -0,0 +1,44 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI= +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=AppleClang +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=8.0.0.8000042 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_ba7aa/fast" +/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_ba7aa.dir/build.make CMakeFiles/cmTC_ba7aa.dir/build +Building C object CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -nostdinc -v -Wl,-v -o CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCCompilerABI.c +Apple LLVM version 8.0.0 (clang-800.0.42.1) +Target: x86_64-apple-darwin15.6.0 +Thread model: posix +InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin +clang: warning: -Wl,-v: 'linker' input unused + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file /private/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -nostdsysteminc -nobuiltininc -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -fdebug-compilation-dir /private/tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -o CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -x c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCCompilerABI.c +clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0 +#include "..." search starts here: +End of search list. +Linking C executable cmTC_ba7aa +/usr/local/pkg.1804/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ba7aa.dir/link.txt --verbose=1 +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -nostdinc -v -Wl,-v -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -o cmTC_ba7aa +Apple LLVM version 8.0.0 (clang-800.0.42.1) +Target: x86_64-apple-darwin15.6.0 +Thread model: posix +InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin +clang: warning: argument unused during compilation: '-nostdinc' + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_ba7aa -v -search_paths_first -headerpad_max_install_names CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a +@(#)PROGRAM:ld PROJECT:ld64-274.2 +configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) +Library search paths: + /usr/lib + /usr/local/lib +Framework search paths: + /Library/Frameworks/ + /System/Library/Frameworks/ diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.input new file mode 100644 index 0000000000..5504e9472d --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.input @@ -0,0 +1,44 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI= +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=AppleClang +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=8.0.0.8000042 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_638bd/fast" +/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_638bd.dir/build.make CMakeFiles/cmTC_638bd.dir/build +Building CXX object CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -nostdinc -v -Wl,-v -o CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp +Apple LLVM version 8.0.0 (clang-800.0.42.1) +Target: x86_64-apple-darwin15.6.0 +Thread model: posix +InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin +clang: warning: -Wl,-v: 'linker' input unused + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file /private/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -nostdsysteminc -nobuiltininc -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /private/tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -x c++ /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp +clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0 +#include "..." search starts here: +End of search list. +Linking CXX executable cmTC_638bd +/usr/local/pkg.1804/bin/cmake -E cmake_link_script CMakeFiles/cmTC_638bd.dir/link.txt --verbose=1 +/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -nostdinc -v -Wl,-v -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_638bd +Apple LLVM version 8.0.0 (clang-800.0.42.1) +Target: x86_64-apple-darwin15.6.0 +Thread model: posix +InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin +clang: warning: argument unused during compilation: '-nostdinc' + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_638bd -v -search_paths_first -headerpad_max_install_names CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a +@(#)PROGRAM:ld PROJECT:ld64-274.2 +configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) +Library search paths: + /usr/lib + /usr/local/lib +Framework search paths: + /Library/Frameworks/ + /System/Library/Frameworks/ diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-C.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-C.input new file mode 100644 index 0000000000..b27eb027d5 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-C.input @@ -0,0 +1,14 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR=/usr/bin/gcc-ar-7 +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=GNU +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7 +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=7.3.0 +CMAKE_C_COMPILER_VERSION_INTERAL= + +This is a test and there is nothing here to parse. diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-C.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-C.output new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-C.output diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-CXX.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-CXX.input new file mode 100644 index 0000000000..b983d6b630 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-CXX.input @@ -0,0 +1,14 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-7 +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=GNU +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7 +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=7.3.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= + +This is a test and there is nothing here to parse. diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-CXX.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-CXX.output new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/empty-CXX.output diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-C-Clang-3.3.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-C-Clang-3.3.0.input new file mode 100644 index 0000000000..81626f932e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-C-Clang-3.3.0.input @@ -0,0 +1,38 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=Clang +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=3.3.0 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/local/bin/gmake" "cmTC_0c44b/fast" +/usr/local/bin/gmake -f CMakeFiles/cmTC_0c44b.dir/build.make CMakeFiles/cmTC_0c44b.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o +/usr/bin/cc -v -o CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -c /usr/local/share/cmake-3.7/Modules/CMakeCCompilerABI.c +FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610 +Target: x86_64-unknown-freebsd10.0 +Thread model: posix + "/usr/bin/cc" -cc1 -triple x86_64-unknown-freebsd10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name CMakeCCompilerABI.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -coverage-file /tmp/ii/CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -resource-dir /usr/bin/../lib/clang/3.3 -fdebug-compilation-dir /tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gnustep -fobjc-default-synthesize-properties -fdiagnostics-show-option -backend-option -vectorize-loops -o CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -x c /usr/local/share/cmake-3.7/Modules/CMakeCCompilerABI.c +clang -cc1 version 3.3 based upon LLVM 3.3 default target x86_64-unknown-freebsd10.0 +ignoring nonexistent directory "/usr/bin/../lib/clang/3.3/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/include/clang/3.3 + /usr/include +End of search list. +Linking C executable cmTC_0c44b +/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0c44b.dir/link.txt --verbose=1 +/usr/bin/cc -v CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -o cmTC_0c44b +FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610 +Target: x86_64-unknown-freebsd10.0 +Thread model: posix + "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o cmTC_0c44b /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-C-Clang-3.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-C-Clang-3.3.0.output new file mode 100644 index 0000000000..893ec49724 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-C-Clang-3.3.0.output @@ -0,0 +1 @@ +/usr/include/clang/3.3;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-CXX-Clang-3.3.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-CXX-Clang-3.3.0.input new file mode 100644 index 0000000000..1f7758b17b --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-CXX-Clang-3.3.0.input @@ -0,0 +1,45 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=Clang +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=3.3.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/local/bin/gmake" "cmTC_c3442/fast" +/usr/local/bin/gmake -f CMakeFiles/cmTC_c3442.dir/build.make CMakeFiles/cmTC_c3442.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o +/usr/bin/CC -v -o CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/share/cmake-3.7/Modules/CMakeCXXCompilerABI.cpp +FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610 +Target: x86_64-unknown-freebsd10.0 +Thread model: posix + "/usr/bin/CC" -cc1 -triple x86_64-unknown-freebsd10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -coverage-file /tmp/ii/CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -resource-dir /usr/bin/../lib/clang/3.3 -internal-isystem /usr/include/c++/v1 -fdeprecated-macro -fdebug-compilation-dir /tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gnustep -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -backend-option -vectorize-loops -o CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -x c++ /usr/local/share/cmake-3.7/Modules/CMakeCXXCompilerABI.cpp +clang -cc1 version 3.3 based upon LLVM 3.3 default target x86_64-unknown-freebsd10.0 +ignoring nonexistent directory "/usr/include/c++/4.2/backward/backward" +ignoring nonexistent directory "/usr/bin/../lib/clang/3.3/include" +ignoring duplicate directory "/usr/include/c++/4.2" +ignoring duplicate directory "/usr/include/c++/4.2/backward" +ignoring duplicate directory "/usr/include/c++/4.2/backward" +#include "..." search starts here: +#include <...> search starts here: + /usr/include/c++/v1 + /usr/include/c++/4.2 + /usr/include/c++/4.2/backward + /usr/include/clang/3.3 + /usr/include +End of search list. +Linking CXX executable cmTC_c3442 +/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c3442.dir/link.txt --verbose=1 +/usr/bin/CC -v CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_c3442 +FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610 +Target: x86_64-unknown-freebsd10.0 +Thread model: posix + "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o cmTC_c3442 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-CXX-Clang-3.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-CXX-Clang-3.3.0.output new file mode 100644 index 0000000000..cd64264f81 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-CXX-Clang-3.3.0.output @@ -0,0 +1 @@ +/usr/include/c++/v1;/usr/include/c++/4.2;/usr/include/c++/4.2/backward;/usr/include/clang/3.3;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-Fortran-GNU-4.6.4.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-Fortran-GNU-4.6.4.input new file mode 100644 index 0000000000..8a5d7411a1 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-Fortran-GNU-4.6.4.input @@ -0,0 +1,78 @@ +CMAKE_LANG=Fortran +CMAKE_Fortran_COMPILER_ABI= +CMAKE_Fortran_COMPILER_AR= +CMAKE_Fortran_COMPILER_ARCHITECTURE_ID= +CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_Fortran_COMPILER_ID=GNU +CMAKE_Fortran_COMPILER_LAUNCHER= +CMAKE_Fortran_COMPILER_LOADED=1 +CMAKE_Fortran_COMPILER_RANLIB= +CMAKE_Fortran_COMPILER_TARGET= +CMAKE_Fortran_COMPILER_VERSION=4.6.4 +CMAKE_Fortran_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/local/bin/gmake" "cmTC_9ec75/fast" +/usr/local/bin/gmake -f CMakeFiles/cmTC_9ec75.dir/build.make CMakeFiles/cmTC_9ec75.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building Fortran object CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o +/usr/local/bin/gfortran46 -v -c /usr/local/share/cmake-3.7/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o +Using built-in specs. +COLLECT_GCC=/usr/local/bin/gfortran46 +COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/lto-wrapper +Target: x86_64-portbld-freebsd10.0 +Configured with: ./../gcc-4.6.4/configure --disable-bootstrap --disable-nls --libdir=/usr/local/lib/gcc46 --libexecdir=/usr/local/libexec/gcc46 --program-suffix=46 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc46/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --disable-libgcj --enable-languages=c,c++,objc,fortran --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc46 --build=x86_64-portbld-freebsd10.0 +Thread model: posix +gcc version 4.6.4 (FreeBSD Ports Collection) +COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64' + /usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/f951 /usr/local/share/cmake-3.7/Modules/CMakeFortranCompilerABI.F -ffixed-form -cpp=/tmp//ccp5PsLd.f90 -quiet -v /usr/local/share/cmake-3.7/Modules/CMakeFortranCompilerABI.F -quiet -dumpbase CMakeFortranCompilerABI.F -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o -version -fintrinsic-modules-path /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/finclude -o /tmp//ccGWxrQ5.s +GNU Fortran (FreeBSD Ports Collection) version 4.6.4 (x86_64-portbld-freebsd10.0) + compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.3 (tags/RELEASE_33/final 183502), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring nonexistent directory "/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/finclude + /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/include + /usr/local/include + /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/include-fixed + /usr/include +End of search list. +GNU Fortran (FreeBSD Ports Collection) version 4.6.4 (x86_64-portbld-freebsd10.0) + compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.3 (tags/RELEASE_33/final 183502), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64' + /usr/local/bin/as -v -o CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o /tmp//ccGWxrQ5.s +GNU assembler version 2.23.2 (x86_64-portbld-freebsd10.0) using BFD version (GNU Binutils) 2.23.2 +COMPILER_PATH=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/bin/ +LIBRARY_PATH=/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/lib/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64' +Linking Fortran executable cmTC_9ec75 +/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9ec75.dir/link.txt --verbose=1 +/usr/local/bin/gfortran46 -v CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o -o cmTC_9ec75 +Driving: /usr/local/bin/gfortran46 -v CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o -o cmTC_9ec75 -l gfortran -l m -shared-libgcc +Using built-in specs. +COLLECT_GCC=/usr/local/bin/gfortran46 +COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/lto-wrapper +Target: x86_64-portbld-freebsd10.0 +Configured with: ./../gcc-4.6.4/configure --disable-bootstrap --disable-nls --libdir=/usr/local/lib/gcc46 --libexecdir=/usr/local/libexec/gcc46 --program-suffix=46 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc46/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --disable-libgcj --enable-languages=c,c++,objc,fortran --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc46 --build=x86_64-portbld-freebsd10.0 +Thread model: posix +gcc version 4.6.4 (FreeBSD Ports Collection) +Reading specs from /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../libgfortran.spec +rename spec lib to liborig +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_9ec75' '-shared-libgcc' '-mtune=generic' '-march=x86-64' +COMPILER_PATH=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/bin/ +LIBRARY_PATH=/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/lib/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_9ec75' '-shared-libgcc' '-mtune=generic' '-march=x86-64' + /usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/collect2 --eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 -o cmTC_9ec75 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/crtbegin.o -L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4 -L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/lib -L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../.. CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/crtend.o /usr/lib/crtn.o +GNU ld (GNU Binutils) 2.23.2 + Supported emulations: + elf_x86_64_fbsd + elf_i386_fbsd + elf_x86_64 + elf_i386 + elf_l1om + elf_l1om_fbsd + elf_k1om + elf_k1om_fbsd +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-Fortran-GNU-4.6.4.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-Fortran-GNU-4.6.4.output new file mode 100644 index 0000000000..c0aee11188 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/freebsd-Fortran-GNU-4.6.4.output @@ -0,0 +1 @@ +/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/finclude;/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/include;/usr/local/include;/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/include-fixed;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-GNU-7.3.0.input new file mode 100644 index 0000000000..ee296a7a10 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-GNU-7.3.0.input @@ -0,0 +1,72 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR=/usr/bin/gcc-ar-7 +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=GNU +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7 +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=7.3.0 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_1f304/fast" +/usr/bin/make -f CMakeFiles/cmTC_1f304.dir/build.make CMakeFiles/cmTC_1f304.dir/build +make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o +/usr/bin/cc -v -o CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c +Using built-in specs. +COLLECT_GCC=/usr/bin/cc +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/7/cc1 -quiet -v -imultiarch x86_64-linux-gnu /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/cc3JNm0a.s +GNU C11 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu) + compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" +ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/lib/gcc/x86_64-linux-gnu/7/include + /usr/local/include + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed + /usr/include/x86_64-linux-gnu + /usr/include +End of search list. +GNU C11 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu) + compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +Compiler executable checksum: c8081a99abb72bbfd9129549110a350c +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64' + as -v --64 -o CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o /tmp/cc3JNm0a.s +GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30 +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64' +Linking C executable cmTC_1f304 +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1f304.dir/link.txt --verbose=1 +/usr/bin/cc -v -rdynamic CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o -o cmTC_1f304 +Using built-in specs. +COLLECT_GCC=/usr/bin/cc +COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_1f304' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper -plugin-opt=-fresolution=/tmp/ccg3L1R6.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_1f304 /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o +COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_1f304' '-mtune=generic' '-march=x86-64' +make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-GNU-7.3.0.output new file mode 100644 index 0000000000..dcd6565d74 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-GNU-7.3.0.output @@ -0,0 +1 @@ +/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-Intel-18.0.0.20170811.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-Intel-18.0.0.20170811.input new file mode 100644 index 0000000000..1e6544b90e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-Intel-18.0.0.20170811.input @@ -0,0 +1,43 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=Intel +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=18.0.0.20170811 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_a5f0a/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_a5f0a.dir/build.make CMakeFiles/cmTC_a5f0a.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o +/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icc -v -o CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c +icc version 18.0.0 (gcc version 4.8.5 compatibility) +/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/mcpcom --target_efi2 --lang=c -_g -mP3OPT_inline_alloca -D__ICC=1800 -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=0 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUC__=4 -D__GNUC_MINOR__=8 -D__GNUC_PATCHLEVEL__=5 -D__LP64__ -D_LP64 -D__GXX_ABI_VERSION=1002 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B -Dunix -Dlinux "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__INTEL_COMPILER_BUILD_DATE=20170811 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -_k -_8 -_l --has_new_stdarg_support -_a -_b --gnu_version=40805 -_W5 --gcc-extern-inline --multibyte_chars -mGLOB_diag_suppress_sys --system_preinclude /usr/include/stdc-predef.h --array_section --simd --simd_func --offload_mode=1 --offload_target_names=gfx,GFX,mic,MIC --offload_unique_string=icc1018727407m03RCD -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=485 "-mGLOB_options_string=-v -o CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -c" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/iccMjPSufas_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d92 -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x8 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icc1018727407m03RCD -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -mIPOPT_whole_archive_fixup_file_name=/tmp/iccwarchDkkYqW -mGLOB_linker_version=2.27 -mGLOB_driver_tempfile_name=/tmp/icctempfileg2vfUM -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C -mP1OPT_source_file_name=/tmp/CMake/Modules/CMakeCCompilerABI.c -mP1OPT_full_source_file_name=/tmp/CMake/Modules/CMakeCCompilerABI.c /tmp/CMake/Modules/CMakeCCompilerABI.c +#include "..." search starts here: +#include <...> search starts here: + /opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/pstl/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/intel64 + /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/icc + /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include + /usr/local/include + /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include + /usr/include/ + /usr/include +End of search list. +Linking C executable cmTC_a5f0a +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a5f0a.dir/link.txt --verbose=1 +/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icc -v -rdynamic CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -o cmTC_a5f0a +icc version 18.0.0 (gcc version 4.8.5 compatibility) +/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/mcpcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=485 "-mGLOB_options_string=-v -rdynamic -o cmTC_a5f0a" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/iccSNrbyQas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d92 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icc0131594309ugIRtJ -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/iccslis4FFYii -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/iccscriptV37728 "-mIPOPT_cmdline_link="/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o" "-export-dynamic" "--eh-frame-hdr" "--build-id" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-m" "elf_x86_64" "-o" "cmTC_a5f0a" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o" "-Bdynamic" "-Bstatic" "-limf" "-lsvml" "-lirng" "-Bdynamic" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "--as-needed" "-Bdynamic" "-lcilkrts" "-lstdc++" "--no-as-needed" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-lsvml" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_iccYpsdQb.o -mIPOPT_whole_archive_fixup_file_name=/tmp/iccwarchgEXmQo -mGLOB_linker_version=2.27 -mGLOB_driver_tempfile_name=/tmp/icctempfilemNLlCf -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_iccYpsdQb.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.c CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/iccalisRmwrkT -mIPOPT_generated_tempfiles=/tmp/iccelisUgbz4J -mIPOPT_embedded_object_base_name=/tmp/icceobj0agHOA -mIPOPT_cmdline_link_new_name=/tmp/iccllis0qIPyr +ld /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o -export-dynamic --eh-frame-hdr --build-id -dynamic-linker /lib64/ld-linux-x86-64.so.2 -m elf_x86_64 -o cmTC_a5f0a -L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/ -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/ -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -Bdynamic -Bstatic -limf -lsvml -lirng -Bdynamic -lm -Bstatic -lipgo -ldecimal --as-needed -Bdynamic -lcilkrts -lstdc++ --no-as-needed -lgcc -lgcc_s -Bstatic -lirc -lsvml -Bdynamic -lc -lgcc -lgcc_s -Bstatic -lirc_s -Bdynamic -ldl -lc /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-Intel-18.0.0.20170811.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-Intel-18.0.0.20170811.output new file mode 100644 index 0000000000..ba0269bf4b --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-Intel-18.0.0.20170811.output @@ -0,0 +1 @@ +/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/pstl/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/intel64;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/icc;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include;/usr/local/include;/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include;/usr/include/;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-12.1.0.input new file mode 100644 index 0000000000..a6d9e5a48e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-12.1.0.input @@ -0,0 +1,42 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=XL +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=12.1.0 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_79cdf/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_79cdf.dir/build.make CMakeFiles/cmTC_79cdf.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qthreaded -qhalt=e -V -o CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +export XL_ASMOBJFILES=/tmp/xlcASgBamaX +export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o"" +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlcentry -qosvar=rhel.6.9 -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qthreaded -qhalt=e -qasm_as=/usr/bin/as -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qvac_include_path=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -oCMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c /tmp/xlcW06RQxFR /tmp/xlcW1Og9D2y /dev/null /tmp/xlcLUravVDF.lst /dev/null /tmp/xlcW2kTjRpg +export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode +export XL_LINKER=/usr/bin/ld +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -qtls -qthreaded -qhalt=e /tmp/xlcW06RQxFR /tmp/xlcW1Og9D2y CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o /tmp/xlcLUravVDB.lst /tmp/xlcW2kTjRpg +rm /tmp/xlcASgBamaX +rm /tmp/xlcLUravVD +rm /tmp/xlcW06RQxFR +rm /tmp/xlcW1Og9D2y +rm /tmp/xlcW2kTjRpg +Linking C executable cmTC_79cdf +/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_79cdf.dir/link.txt --verbose=1 +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qthreaded -qhalt=e -V CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o -o cmTC_79cdf -Wl,-export-dynamic +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o -o cmTC_79cdf -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o +rm /tmp/xlcW0JVPZO4 +rm /tmp/xlcW1cwDxtZ +rm /tmp/xlcW2j5Va8T +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-12.1.0.output new file mode 100644 index 0000000000..eceacf954e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-12.1.0.output @@ -0,0 +1 @@ +/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include;/usr/local/include;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-16.1.0.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-16.1.0.0.input new file mode 100644 index 0000000000..97fa28be9c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-16.1.0.0.input @@ -0,0 +1,40 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=XL +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=16.1.0.0 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_56ad1/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_56ad1.dir/build.make CMakeFiles/cmTC_56ad1.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o +/opt/ibm/xlC/16.1.0/bin/xlc -qthreaded -V -o CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o -c "/tmp/CMake/Modules/CMakeCCompilerABI.c" +export XL_CONFIG=/opt/ibm/xlC/16.1.0/etc/xlc.cfg.centos.7.gcc.4.8.5:xlc +export XL_ASMOBJFILES=/tmp/xlcASSb1cI4 +export "XL_DIS=/opt/ibm/xlC/16.1.0/exe/dis -o "CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o"" +/opt/ibm/xlC/16.1.0/exe/xlCentry -qosvar=centos.7.0 -qlanglvl=extc99 -qalias=ansi -qthreaded -D_REENTRANT -D__VACPP_MULTI__ -qtls -q64 -D_CALL_SYSV -D__NO_MATH_INLINES -D_CALL_ELF=2 -Wno-parentheses -Wno-unused-value -maltivec -qtls -q64 -qgnu_version=4.8.5 -qthreaded -qasm_as=/usr/bin/as -qc_stdinc=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include -qgcc_c_stdinc=/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -qcomplexgccincl=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include:/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -qvac_include_path=/opt/ibm/xlC/16.1.0/include -oCMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o "/tmp/CMake/Modules/CMakeCCompilerABI.c" /tmp/xlcW0T1FYwj /tmp/xlcW1fu4lVT /dev/null /tmp/xlcLWBpG6EF.lst /dev/null /tmp/xlcW2TKQJju +export XL_BACKEND=/opt/ibm/xlC/16.1.0/exe/xlCcode +export XL_LINKER=/usr/bin/ld +/opt/ibm/xlC/16.1.0/exe/xlCcode -qlanglvl=extc99 -qalias=ansi -qthreaded -qtls -maltivec -qtls -qthreaded /tmp/xlcW0T1FYwj /tmp/xlcW1fu4lVT CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o /tmp/xlcLWBpG6EB.lst /tmp/xlcW2TKQJju +rm /tmp/xlcASSb1cI4 +rm /tmp/xlcLWBpG6E +rm /tmp/xlcW0T1FYwj +rm /tmp/xlcW1fu4lVT +rm /tmp/xlcW2TKQJju +Linking C executable cmTC_56ad1 +"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_56ad1.dir/link.txt --verbose=1 +/opt/ibm/xlC/16.1.0/bin/xlc -qthreaded -V -Wl,-export-dynamic CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o -o cmTC_56ad1 +export XL_CONFIG=/opt/ibm/xlC/16.1.0/etc/xlc.cfg.centos.7.gcc.4.8.5:xlc +/usr/bin/ld --eh-frame-hdr -Qy -melf64lppc -dynamic-linker /lib64/ld64.so.2 --enable-new-dtags /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtbegin.o -L/opt/ibm/xlsmp/5.1.0/lib -L/opt/ibm/xlmass/9.1.0/lib -L/opt/ibm/xlC/16.1.0/lib -R/opt/ibm/lib -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../.. -export-dynamic CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o -o cmTC_56ad1 -lxlopt -lxl --as-needed -ldl --no-as-needed -lgcc_s --as-needed -lpthread --no-as-needed -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crtn.o +rm /tmp/xlcW0S2fv6n +rm /tmp/xlcW11wDdxY +rm /tmp/xlcW2JqnWXy +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-16.1.0.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-16.1.0.0.output new file mode 100644 index 0000000000..2a89b17bc2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-C-XL-16.1.0.0.output @@ -0,0 +1 @@ +/opt/ibm/xlsmp/5.1.0/include;/opt/ibm/xlsmp/5.1.0/include;/opt/ibm/xlmass/9.1.0/include;/opt/ibm/xlC/16.1.0/include;/opt/ibm/xlC/16.1.0/include;/usr/local/include;/opt/ibm/xlC/16.1.0/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CUDA-NVIDIA-9.2.148.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CUDA-NVIDIA-9.2.148.input new file mode 100644 index 0000000000..5dd36508eb --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CUDA-NVIDIA-9.2.148.input @@ -0,0 +1,124 @@ +CMAKE_LANG=CUDA +CMAKE_CUDA_COMPILER_ABI=ELF +CMAKE_CUDA_COMPILER_AR= +CMAKE_CUDA_COMPILER_ARCHITECTURE_ID= +CMAKE_CUDA_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CUDA_COMPILER_ID=NVIDIA +CMAKE_CUDA_COMPILER_LAUNCHER= +CMAKE_CUDA_COMPILER_LOADED=1 +CMAKE_CUDA_COMPILER_RANLIB= +CMAKE_CUDA_COMPILER_TARGET= +CMAKE_CUDA_COMPILER_VERSION=9.2.148 +CMAKE_CUDA_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_5996d/fast" +/usr/bin/make -f CMakeFiles/cmTC_5996d.dir/build.make CMakeFiles/cmTC_5996d.dir/build +make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CUDA object CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o +/usr/bin/nvcc -Xcompiler=-v -x cu -c "/tmp/CMake/Modules/CMakeCUDACompilerABI.cu" -o CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o +Using built-in specs. +COLLECT_GCC=gcc-5 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Debian 5.5.0-12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 5.5.0 20171010 (Debian 5.5.0-12) +COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-E' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-D' '__CUDACC__' '-D' '__NVCC__' '-v' '-D' '__CUDACC_VER_BUILD__=148' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_MAJOR__=9' '-include' 'cuda_runtime.h' '-m64' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D __CUDA_ARCH__=300 -D CUDA_DOUBLE_MATH_FUNCTIONS -D __CUDACC__ -D __NVCC__ -D __CUDACC_VER_BUILD__=148 -D __CUDACC_VER_MINOR__=2 -D __CUDACC_VER_MAJOR__=9 -include cuda_runtime.h /tmp/CMake/Modules/CMakeCUDACompilerABI.cu -m64 -mtune=generic -march=x86-64 -std=c++14 +ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5" +ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" +ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/include/c++/5 + /usr/include/x86_64-linux-gnu/c++/5 + /usr/include/c++/5/backward + /usr/lib/gcc/x86_64-linux-gnu/5/include + /usr/local/include + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed + /usr/include/x86_64-linux-gnu + /usr/include +End of search list. +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-E' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-D' '__CUDACC__' '-D' '__NVCC__' '-v' '-D' '__CUDACC_VER_BUILD__=148' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_MAJOR__=9' '-include' 'cuda_runtime.h' '-m64' '-mtune=generic' '-march=x86-64' +Using built-in specs. +COLLECT_GCC=gcc-5 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Debian 5.5.0-12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 5.5.0 20171010 (Debian 5.5.0-12) +COLLECT_GCC_OPTIONS='-std=c++14' '-E' '-D' '__CUDACC__' '-D' '__NVCC__' '-v' '-D' '__CUDACC_VER_BUILD__=148' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_MAJOR__=9' '-include' 'cuda_runtime.h' '-m64' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D __CUDACC__ -D __NVCC__ -D __CUDACC_VER_BUILD__=148 -D __CUDACC_VER_MINOR__=2 -D __CUDACC_VER_MAJOR__=9 -include cuda_runtime.h /tmp/CMake/Modules/CMakeCUDACompilerABI.cu -m64 -mtune=generic -march=x86-64 -std=c++14 +ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5" +ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" +ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/include/c++/5 + /usr/include/x86_64-linux-gnu/c++/5 + /usr/include/c++/5/backward + /usr/lib/gcc/x86_64-linux-gnu/5/include + /usr/local/include + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed + /usr/include/x86_64-linux-gnu + /usr/include +End of search list. +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-std=c++14' '-E' '-D' '__CUDACC__' '-D' '__NVCC__' '-v' '-D' '__CUDACC_VER_BUILD__=148' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_MAJOR__=9' '-include' 'cuda_runtime.h' '-m64' '-mtune=generic' '-march=x86-64' +Using built-in specs. +COLLECT_GCC=gcc-5 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Debian 5.5.0-12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 5.5.0 20171010 (Debian 5.5.0-12) +COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-c' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-v' '-m64' '-o' 'CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D __CUDA_ARCH__=300 -D CUDA_DOUBLE_MATH_FUNCTIONS /tmp/tmpxft_00002df4_00000000-5_CMakeCUDACompilerABI.cudafe1.cpp -quiet -dumpbase tmpxft_00002df4_00000000-5_CMakeCUDACompilerABI.cudafe1.cpp -m64 -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o -std=c++14 -version -o /tmp/ccSDI00n.s +GNU C++14 (Debian 5.5.0-12) version 5.5.0 20171010 (x86_64-linux-gnu) + compiled by GNU C version 5.5.0 20171010, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0 +warning: MPFR header version 4.0.1 differs from library version 4.0.2-rc1. +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5" +ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" +ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/include/c++/5 + /usr/include/x86_64-linux-gnu/c++/5 + /usr/include/c++/5/backward + /usr/lib/gcc/x86_64-linux-gnu/5/include + /usr/local/include + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed + /usr/include/x86_64-linux-gnu + /usr/include +End of search list. +GNU C++14 (Debian 5.5.0-12) version 5.5.0 20171010 (x86_64-linux-gnu) + compiled by GNU C version 5.5.0 20171010, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0 +warning: MPFR header version 4.0.1 differs from library version 4.0.2-rc1. +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +Compiler executable checksum: 3caa6244fa07ed8a2b405a77ac6cb692 +COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-c' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-v' '-m64' '-o' 'CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o' '-mtune=generic' '-march=x86-64' + as -v --64 -o CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o /tmp/ccSDI00n.s +GNU assembler version 2.31.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.31.1 +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-c' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-v' '-m64' '-o' 'CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o' '-mtune=generic' '-march=x86-64' +Linking CUDA device code CMakeFiles/cmTC_5996d.dir/cmake_device_link.o +"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_5996d.dir/dlink.txt --verbose=1 +/usr/bin/nvcc -Xcompiler=-fPIC -Wno-deprecated-gpu-targets -shared -dlink CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o -o CMakeFiles/cmTC_5996d.dir/cmake_device_link.o -L"/usr/lib/x86_64-linux-gnu" +Linking CUDA executable cmTC_5996d +"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_5996d.dir/link.txt --verbose=1 +/usr/lib/nvidia-cuda-toolkit/bin/g++ -v CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o CMakeFiles/cmTC_5996d.dir/cmake_device_link.o -o cmTC_5996d -L"/usr/lib/x86_64-linux-gnu/stubs" -lcudadevrt -lcudart_static -lrt -lpthread -ldl +Using built-in specs. +COLLECT_GCC=g++-5 +COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Debian 5.5.0-12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 5.5.0 20171010 (Debian 5.5.0-12) +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_5996d' '-L/usr/lib/x86_64-linux-gnu/stubs' '-shared-libgcc' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/cc85GscA.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_5996d /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/x86_64-linux-gnu/stubs -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o CMakeFiles/cmTC_5996d.dir/cmake_device_link.o -lcudadevrt -lcudart_static -lrt -lpthread -ldl -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o +make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CUDA-NVIDIA-9.2.148.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CUDA-NVIDIA-9.2.148.output new file mode 100644 index 0000000000..4f49cd1e91 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CUDA-NVIDIA-9.2.148.output @@ -0,0 +1 @@ +/usr/include/c++/5;/usr/include/x86_64-linux-gnu/c++/5;/usr/include/c++/5/backward;/usr/lib/gcc/x86_64-linux-gnu/5/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-GNU-7.3.0.input new file mode 100644 index 0000000000..633a0efa7b --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-GNU-7.3.0.input @@ -0,0 +1,76 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-7 +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=GNU +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7 +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=7.3.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_63146/fast" +/usr/bin/make -f CMakeFiles/cmTC_63146.dir/build.make CMakeFiles/cmTC_63146.dir/build +make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o +/usr/bin/c++ -v -o CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp +Using built-in specs. +COLLECT_GCC=/usr/bin/c++ +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/7/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccXqnn3f.s +GNU C++14 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu) + compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/7" +ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" +ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/include/c++/7 + /usr/include/x86_64-linux-gnu/c++/7 + /usr/include/c++/7/backward + /usr/lib/gcc/x86_64-linux-gnu/7/include + /usr/local/include + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed + /usr/include/x86_64-linux-gnu + /usr/include +End of search list. +GNU C++14 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu) + compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +Compiler executable checksum: 1bfae38ae5df64de6196cbd8c3b07d86 +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' + as -v --64 -o CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o /tmp/ccXqnn3f.s +GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30 +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' +Linking CXX executable cmTC_63146 +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_63146.dir/link.txt --verbose=1 +/usr/bin/c++ -v -rdynamic CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_63146 +Using built-in specs. +COLLECT_GCC=/usr/bin/c++ +COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_63146' '-shared-libgcc' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper -plugin-opt=-fresolution=/tmp/cca3NVun.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_63146 /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o +COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_63146' '-shared-libgcc' '-mtune=generic' '-march=x86-64' +make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-GNU-7.3.0.output new file mode 100644 index 0000000000..6f5d071945 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-GNU-7.3.0.output @@ -0,0 +1 @@ +/usr/include/c++/7;/usr/include/x86_64-linux-gnu/c++/7;/usr/include/c++/7/backward;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-Intel-18.0.0.20170811.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-Intel-18.0.0.20170811.input new file mode 100644 index 0000000000..22d8715984 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-Intel-18.0.0.20170811.input @@ -0,0 +1,46 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=Intel +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=18.0.0.20170811 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_d768a/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_d768a.dir/build.make CMakeFiles/cmTC_d768a.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o +/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icpc -v -o CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp +icpc version 18.0.0 (gcc version 4.8.5 compatibility) +/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/mcpcom --target_efi2 --lang=c++ -_g -mP3OPT_inline_alloca -D__ICC=1800 -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=0 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUG__=4 -D__GNUC__=4 -D__GNUC_MINOR__=8 -D__GNUC_PATCHLEVEL__=5 -D__LP64__ -D_LP64 -D_GNU_SOURCE=1 -D__DEPRECATED=1 -D__GXX_WEAK__=1 -D__GXX_ABI_VERSION=1002 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__EXCEPTIONS=1 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B -Dunix -Dlinux "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__INTEL_COMPILER_BUILD_DATE=20170811 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -_k -_8 -_l --has_new_stdarg_support -_a -_b --gnu_version=40805 -_W5 --gcc-extern-inline -p --bool -tused -x --multibyte_chars -mGLOB_diag_suppress_sys --system_preinclude /usr/include/stdc-predef.h --array_section --simd --simd_func --offload_mode=1 --offload_target_names=gfx,GFX,mic,MIC --offload_unique_string=icpc1792177319iuY4UR --bool -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=485 "-mGLOB_options_string=-v -o CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -c" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icpcv8rR8Aas_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d8f -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x8 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icpc1792177319iuY4UR -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -mIPOPT_whole_archive_fixup_file_name=/tmp/icpcwarchqQRwIj -mGLOB_linker_version=2.27 -mGLOB_driver_tempfile_name=/tmp/icpctempfilekXiB0a -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C_PLUS_PLUS -mP1OPT_source_file_name=/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp -mP1OPT_full_source_file_name=/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp -mGLOB_eh_linux /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp +#include "..." search starts here: +#include <...> search starts here: + /opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/pstl/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include + /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/intel64 + /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/icc + /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include + /usr/include/c++/4.8.5 + /usr/include/c++/4.8.5/x86_64-redhat-linux + /usr/include/c++/4.8.5/backward + /usr/local/include + /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include + /usr/include/ + /usr/include +End of search list. +Linking CXX executable cmTC_d768a +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d768a.dir/link.txt --verbose=1 +/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icpc -v -rdynamic CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_d768a +icpc version 18.0.0 (gcc version 4.8.5 compatibility) +/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/mcpcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=485 "-mGLOB_options_string=-v -rdynamic -o cmTC_d768a" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icpczjpPCuas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d8f -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icpc1401760296yQqGc2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/icpcslis4PdBUT -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/icpcscript0uzJtL "-mIPOPT_cmdline_link="/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o" "-export-dynamic" "--eh-frame-hdr" "--build-id" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-m" "elf_x86_64" "-o" "cmTC_d768a" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o" "-Bdynamic" "-Bstatic" "-limf" "-lsvml" "-lirng" "-Bdynamic" "-lstdc++" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "--as-needed" "-Bdynamic" "-lcilkrts" "--no-as-needed" "-lstdc++" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-lsvml" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_icpcGEmWvI.o -mIPOPT_whole_archive_fixup_file_name=/tmp/icpcwarchvs7jo5 -mGLOB_linker_version=2.27 -mGLOB_driver_tempfile_name=/tmp/icpctempfileQPMrZW -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_icpcGEmWvI.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.c CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/icpcalisfym8Dr -mIPOPT_generated_tempfiles=/tmp/icpcelisfz0edj -mIPOPT_embedded_object_base_name=/tmp/icpceobjS73lMa -mIPOPT_cmdline_link_new_name=/tmp/icpcllisTgrtl2 +ld /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o -export-dynamic --eh-frame-hdr --build-id -dynamic-linker /lib64/ld-linux-x86-64.so.2 -m elf_x86_64 -o cmTC_d768a -L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/ -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/ -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -Bdynamic -Bstatic -limf -lsvml -lirng -Bdynamic -lstdc++ -lm -Bstatic -lipgo -ldecimal --as-needed -Bdynamic -lcilkrts --no-as-needed -lstdc++ -lgcc -lgcc_s -Bstatic -lirc -lsvml -Bdynamic -lc -lgcc -lgcc_s -Bstatic -lirc_s -Bdynamic -ldl -lc /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-Intel-18.0.0.20170811.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-Intel-18.0.0.20170811.output new file mode 100644 index 0000000000..56d2b9ff7f --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-Intel-18.0.0.20170811.output @@ -0,0 +1 @@ +/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/pstl/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/intel64;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/icc;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include;/usr/include/c++/4.8.5;/usr/include/c++/4.8.5/x86_64-redhat-linux;/usr/include/c++/4.8.5/backward;/usr/local/include;/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include;/usr/include/;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-12.1.0.input new file mode 100644 index 0000000000..494b45c143 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-12.1.0.input @@ -0,0 +1,42 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=XL +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=12.1.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_a9a18/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_a9a18.dir/build.make CMakeFiles/cmTC_a9a18.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlc++ -+ -qthreaded -qhalt=e -V -o CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc++ +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +export XL_ASMOBJFILES=/tmp/xlcAS0adOWz +export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o"" +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/exe/xlCentry -qosvar=rhel.6.9 -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qthreaded -qhalt=e -qasm_as=/usr/bin/as -qcpp_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/include -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_cpp_stdinc=/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ppc64-redhat-linux:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -oCMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW0C4fVNg /tmp/xlcW1gn9wsn /dev/null /tmp/xlcLo7QvMFF.lst /dev/null /tmp/xlcW2svId7t +export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode +export XL_LINKER=/usr/bin/ld +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qalias=ansi -qtls -qtls -qthreaded -qhalt=e /tmp/xlcW0C4fVNg /tmp/xlcW1gn9wsn CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcLo7QvMFB.lst /tmp/xlcW2svId7t +rm /tmp/xlcAS0adOWz +rm /tmp/xlcLo7QvMF +rm /tmp/xlcW0C4fVNg +rm /tmp/xlcW1gn9wsn +rm /tmp/xlcW2svId7t +Linking CXX executable cmTC_a9a18 +/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a9a18.dir/link.txt --verbose=1 +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlc++ -qthreaded -qhalt=e -V CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_a9a18 -Wl,-export-dynamic +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc++ +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_a9a18 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -libmc++ -lxlopt -lxl -lstdc++ -lm -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o +rm /tmp/xlcW0zyCKVs +rm /tmp/xlcW1UOt3GL +rm /tmp/xlcW2lKGvs4 +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-12.1.0.output new file mode 100644 index 0000000000..1c545e074c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-12.1.0.output @@ -0,0 +1 @@ +/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/include;/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7;/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ppc64-redhat-linux;/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward;/usr/local/include;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-16.1.0.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-16.1.0.0.input new file mode 100644 index 0000000000..37aa450fbc --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-16.1.0.0.input @@ -0,0 +1,40 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=XL +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=16.1.0.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_f0c9c/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_f0c9c.dir/build.make CMakeFiles/cmTC_f0c9c.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o +/opt/ibm/xlC/16.1.0/bin/xlc++ -+ -qthreaded -V -o CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o -c "/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp" +export XL_CONFIG=/opt/ibm/xlC/16.1.0/etc/xlc.cfg.centos.7.gcc.4.8.5:xlc++ +export XL_ASMOBJFILES=/tmp/xlcASfU5Npd +export "XL_DIS=/opt/ibm/xlC/16.1.0/exe/dis -o "CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o"" +/opt/ibm/xlC/16.1.0/exe/xlCentry -qosvar=centos.7.0 -qalias=ansi -qthreaded -D_REENTRANT -D__VACPP_MULTI__ -qtls -q64 -D_CALL_SYSV -D__NO_MATH_INLINES -D_CALL_ELF=2 -Wno-parentheses -Wno-unused-value -maltivec -qtls -q64 -qgnu_version=4.8.5 -qthreaded -xc++ -qasm_as=/usr/bin/as -qcpp_stdinc=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include -qc_stdinc=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include -qgcc_cpp_stdinc=/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5:/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ppc64le-redhat-linux:/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward:/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -qgcc_c_stdinc=/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -qcomplexgccincl=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include:/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -oCMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o "/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp" /tmp/xlcW02F8mZr /tmp/xlcW1xG0Ns2 /dev/null /tmp/xlcLI57mTNF.lst /dev/null /tmp/xlcW2qVifWC +export XL_BACKEND=/opt/ibm/xlC/16.1.0/exe/xlCcode +export XL_LINKER=/usr/bin/ld +/opt/ibm/xlC/16.1.0/exe/xlCcode -qalias=ansi -qthreaded -qtls -maltivec -qtls -qthreaded /tmp/xlcW02F8mZr /tmp/xlcW1xG0Ns2 CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcLI57mTNB.lst /tmp/xlcW2qVifWC +rm /tmp/xlcASfU5Npd +rm /tmp/xlcLI57mTN +rm /tmp/xlcW02F8mZr +rm /tmp/xlcW1xG0Ns2 +rm /tmp/xlcW2qVifWC +Linking CXX executable cmTC_f0c9c +"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_f0c9c.dir/link.txt --verbose=1 +/opt/ibm/xlC/16.1.0/bin/xlc++ -qthreaded -V -Wl,-export-dynamic CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_f0c9c +export XL_CONFIG=/opt/ibm/xlC/16.1.0/etc/xlc.cfg.centos.7.gcc.4.8.5:xlc++ +/usr/bin/ld --eh-frame-hdr -Qy -melf64lppc -dynamic-linker /lib64/ld64.so.2 --enable-new-dtags /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtbegin.o -L/opt/ibm/xlsmp/5.1.0/lib -L/opt/ibm/xlmass/9.1.0/lib -L/opt/ibm/xlC/16.1.0/lib -R/opt/ibm/lib -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../.. -export-dynamic CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_f0c9c -lxlopt -lxl -libmc++ -lstdc++ -lm -ldl -lgcc_s -lgcc --as-needed -lpthread --no-as-needed -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crtn.o +rm /tmp/xlcW0HSoDlw +rm /tmp/xlcW1dUcwR6 +rm /tmp/xlcW25pPonH +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-16.1.0.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-16.1.0.0.output new file mode 100644 index 0000000000..a34973c856 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-CXX-XL-16.1.0.0.output @@ -0,0 +1 @@ +/opt/ibm/xlsmp/5.1.0/include;/opt/ibm/xlmass/9.1.0/include;/opt/ibm/xlC/16.1.0/include;/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5;/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ppc64le-redhat-linux;/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward;/opt/ibm/xlC/16.1.0/include;/usr/local/include;/opt/ibm/xlC/16.1.0/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-GNU-7.3.0.input new file mode 100644 index 0000000000..4582433dee --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-GNU-7.3.0.input @@ -0,0 +1,76 @@ +CMAKE_LANG=Fortran +CMAKE_Fortran_COMPILER_ABI= +CMAKE_Fortran_COMPILER_AR=/usr/bin/gcc-ar-7 +CMAKE_Fortran_COMPILER_ARCHITECTURE_ID= +CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_Fortran_COMPILER_ID=GNU +CMAKE_Fortran_COMPILER_LAUNCHER= +CMAKE_Fortran_COMPILER_LOADED=1 +CMAKE_Fortran_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7 +CMAKE_Fortran_COMPILER_TARGET= +CMAKE_Fortran_COMPILER_VERSION=7.3.0 +CMAKE_Fortran_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_1cf45/fast" +/usr/bin/make -f CMakeFiles/cmTC_1cf45.dir/build.make CMakeFiles/cmTC_1cf45.dir/build +make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building Fortran object CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o +/usr/bin/f95 -v -c /proj/TableFS/data/chuck/cmake/f/share/cmake-3.13/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o +Using built-in specs. +COLLECT_GCC=/usr/bin/f95 +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) +COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/7/f951 /proj/TableFS/data/chuck/cmake/f/share/cmake-3.13/Modules/CMakeFortranCompilerABI.F -ffixed-form -cpp=/tmp/cc9yADLU.f90 -quiet -v -imultiarch x86_64-linux-gnu /proj/TableFS/data/chuck/cmake/f/share/cmake-3.13/Modules/CMakeFortranCompilerABI.F -quiet -dumpbase CMakeFortranCompilerABI.F -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o -version -fintrinsic-modules-path /usr/lib/gcc/x86_64-linux-gnu/7/finclude -o /tmp/ccH7qQQk.s +GNU Fortran (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu) + compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" +ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/lib/gcc/x86_64-linux-gnu/7/finclude + /usr/lib/gcc/x86_64-linux-gnu/7/include + /usr/local/include + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed + /usr/include/x86_64-linux-gnu + /usr/include +End of search list. +GNU Fortran2008 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu) + compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP + +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64' + as -v --64 -o CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o /tmp/ccH7qQQk.s +GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30 +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64' +Linking Fortran executable cmTC_1cf45 +/proj/TableFS/data/chuck/cmake/f/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1cf45.dir/link.txt --verbose=1 +/usr/bin/f95 -v CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o -o cmTC_1cf45 +Driving: /usr/bin/f95 -v CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o -o cmTC_1cf45 -l gfortran -l m -shared-libgcc +Using built-in specs. +COLLECT_GCC=/usr/bin/f95 +COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) +Reading specs from /usr/lib/gcc/x86_64-linux-gnu/7/libgfortran.spec +rename spec lib to liborig +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_1cf45' '-shared-libgcc' '-mtune=generic' '-march=x86-64' +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_1cf45' '-shared-libgcc' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper -plugin-opt=-fresolution=/tmp/ccS0UYIY.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_1cf45 /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_1cf45' '-shared-libgcc' '-mtune=generic' '-march=x86-64' +make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-GNU-7.3.0.output new file mode 100644 index 0000000000..d84842b6f1 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-GNU-7.3.0.output @@ -0,0 +1 @@ +/usr/lib/gcc/x86_64-linux-gnu/7/finclude;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-XL-14.1.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-XL-14.1.0.input new file mode 100644 index 0000000000..d80cedef71 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-XL-14.1.0.input @@ -0,0 +1,50 @@ +CMAKE_LANG=Fortran +CMAKE_Fortran_COMPILER_ABI=ELF +CMAKE_Fortran_COMPILER_AR= +CMAKE_Fortran_COMPILER_ARCHITECTURE_ID= +CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_Fortran_COMPILER_ID=XL +CMAKE_Fortran_COMPILER_LAUNCHER= +CMAKE_Fortran_COMPILER_LOADED=1 +CMAKE_Fortran_COMPILER_RANLIB= +CMAKE_Fortran_COMPILER_TARGET= +CMAKE_Fortran_COMPILER_VERSION=14.1.0 +CMAKE_Fortran_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_d05a9/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_d05a9.dir/build.make CMakeFiles/cmTC_d05a9.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building Fortran object CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o +/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/bin/xlf -qthreaded -qhalt=e -V -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/etc/xlf.cfg.rhel6.9.gcc447:xlf +export XLF_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/etc/V1R2M4.xlf.cfg.rhel6.9.gcc447 +export "XL_DIS=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/dis -o "CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o" "CMakeFortranCompilerABI.o"" +/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/cpp /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeFortranCompilerABI.F /tmp/F841970obBXFf -C -I/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include -I/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/include +/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfentry /tmp/F841970obBXFf /tmp/F841970QXWvB4 /tmp/F841970QXWvB4F.lst xlfsmsg.cat xlfmsg.cat /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeFortranCompilerABI.F "OSVAR(rhel.6.9)" NOZEROSIZE SAVE "ALIAS(intptr)" "POSITION(appendold)" "XLF90(noautodealloc,nosignedzero,oldpad)" "XLF77(intarg,intxor,persistent,noleadzero,gedit77,noblankpad,oldboz,softeof)" "XLF2003(nopolymorphic,nobozlitargs,nostopexcept,novolatile,noautorealloc,oldnaninf)" "XLF2008(nocheckpresence)" 64 "GNU_VERSION(4.4.7)" "SAVEOPTFILE(/tmp/optf.41970mydp8V)" "SAVEVERSIONFILE(/tmp/version.41970sjsfYH)" THREADED "HALT(e)" "WSTREAMS(/tmp/F8419704oFzOth1,/tmp/F8419704oFzOtb1,/tmp/F8419704oFzOts1)" "DEFMSG(/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/msg/en_US)" -I/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include -I/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/include +COMMAND LINE 1520-061 (W) The XLF77(PERSISTENT) option stores entities in static storage. This may affect the thread safety of your code. +COMMAND LINE 1520-061 (W) The SAVE option stores entities in static storage. This may affect the thread safety of your code. +** cmakefortrancompilerabi === End of Compilation 1 === +rm /tmp/F841970obBXFf +export XL_FRONTEND=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfentry +export XL_ASTI=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfhot +export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfcode +export XL_LINKER=/usr/bin/ld +export XL_BOLT=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/bolt +/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfhot /tmp/F8419704oFzOth1 /tmp/F8419704oFzOth2 /tmp/F8419704oFzOtb1 /tmp/F8419704oFzOtb2 /tmp/F8419704oFzOts1 /tmp/F8419704oFzOts2 /tmp/F841970QXWvB4 /tmp/F841970QXWvB4A.lst +export XL_FRONTEND=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfentry +export XL_ASTI=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfhot +export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfcode +export XL_LINKER=/usr/bin/ld +export XL_BOLT=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/bolt +/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfcode /tmp/F8419704oFzOth2 /tmp/F8419704oFzOtb2 CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o /tmp/F841970QXWvB4B.lst /tmp/F8419704oFzOts2 +1501-510 Compilation successful for file CMakeFortranCompilerABI.F. +rm /tmp/optf.41970mydp8V +Linking Fortran executable cmTC_d05a9 +/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d05a9.dir/link.txt --verbose=1 +/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/bin/xlf -V -qthreaded -qhalt=e CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o -o cmTC_d05a9 -Wl,-export-dynamic +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/etc/xlf.cfg.rhel6.9.gcc447:xlf +export XLF_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/etc/V1R2M4.xlf.cfg.rhel6.9.gcc447 +/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o -o cmTC_d05a9 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlf90 -lxlopt -lxlomp_ser -lxl -lxlfmath -lgcc_s -ldl -lrt -lpthread -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o +rm /tmp/optf.419839KEged +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-XL-14.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-XL-14.1.0.output new file mode 100644 index 0000000000..39a28a46bc --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux-Fortran-XL-14.1.0.output @@ -0,0 +1 @@ +/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include;/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-C-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-C-XL-12.1.0.input new file mode 100644 index 0000000000..8b1e2860b9 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-C-XL-12.1.0.input @@ -0,0 +1,42 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=XL +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=12.1.0 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_b8c4a/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_b8c4a.dir/build.make CMakeFiles/cmTC_b8c4a.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qnostdinc -V -o CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +export XL_ASMOBJFILES=/tmp/xlcASEFMkoN +export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o"" +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlcentry -qosvar=rhel.6.9 -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qnostdinc -qasm_as=/usr/bin/as -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qvac_include_path=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -oCMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c /tmp/xlcW0cUFNRj /tmp/xlcW1YJsgzt /dev/null /tmp/xlcLI4MvwXF.lst /dev/null /tmp/xlcW2sIonhD +export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode +export XL_LINKER=/usr/bin/ld +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -qtls -qnostdinc /tmp/xlcW0cUFNRj /tmp/xlcW1YJsgzt CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o /tmp/xlcLI4MvwXB.lst /tmp/xlcW2sIonhD +rm /tmp/xlcASEFMkoN +rm /tmp/xlcLI4MvwX +rm /tmp/xlcW0cUFNRj +rm /tmp/xlcW1YJsgzt +rm /tmp/xlcW2sIonhD +Linking C executable cmTC_b8c4a +/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b8c4a.dir/link.txt --verbose=1 +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qnostdinc -V CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o -o cmTC_b8c4a -Wl,-export-dynamic +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o -o cmTC_b8c4a -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o +rm /tmp/xlcW03gDCly +rm /tmp/xlcW1oa6XxW +rm /tmp/xlcW2fQXnKk +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-C-XL-12.1.0.output new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-C-XL-12.1.0.output diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-CXX-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-CXX-XL-12.1.0.input new file mode 100644 index 0000000000..f6b5d91114 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-CXX-XL-12.1.0.input @@ -0,0 +1,42 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=XL +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=12.1.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_98791/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_98791.dir/build.make CMakeFiles/cmTC_98791.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlC -+ -qnostdinc -V -o CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlC +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +export XL_ASMOBJFILES=/tmp/xlcAS82INiZ +export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o"" +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/exe/xlCentry -qosvar=rhel.6.9 -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qnostdinc -qasm_as=/usr/bin/as -qcpp_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/include -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_cpp_stdinc=/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ppc64-redhat-linux:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -oCMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW0SEqGeR /tmp/xlcW1AfQ1jy /dev/null /tmp/xlcLmUAPcJF.lst /dev/null /tmp/xlcW2OCErpf +export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode +export XL_LINKER=/usr/bin/ld +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qalias=ansi -qtls -qtls -qnostdinc /tmp/xlcW0SEqGeR /tmp/xlcW1AfQ1jy CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcLmUAPcJB.lst /tmp/xlcW2OCErpf +rm /tmp/xlcAS82INiZ +rm /tmp/xlcLmUAPcJ +rm /tmp/xlcW0SEqGeR +rm /tmp/xlcW1AfQ1jy +rm /tmp/xlcW2OCErpf +Linking CXX executable cmTC_98791 +/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_98791.dir/link.txt --verbose=1 +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlC -qnostdinc -V CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_98791 -Wl,-export-dynamic +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlC +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_98791 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -libmc++ -lxlopt -lxl -lstdc++ -lm -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o +rm /tmp/xlcW0DcBWi8 +rm /tmp/xlcW14NqGs6 +rm /tmp/xlcW2Z8nuC4 +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-CXX-XL-12.1.0.output new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc-CXX-XL-12.1.0.output diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-C-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-C-XL-12.1.0.input new file mode 100644 index 0000000000..a552d70521 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-C-XL-12.1.0.input @@ -0,0 +1,42 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=XL +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=12.1.0 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_76ec2/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_76ec2.dir/build.make CMakeFiles/cmTC_76ec2.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qnostdinc -I/tmp/ii/test_c -V -o CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +export XL_ASMOBJFILES=/tmp/xlcASknvctJ +export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o"" +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlcentry -qosvar=rhel.6.9 -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qnostdinc -I/tmp/ii/test_c -qasm_as=/usr/bin/as -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qvac_include_path=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -oCMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c /tmp/xlcW0buijl3 /tmp/xlcW1Cx9kxW /dev/null /tmp/xlcLVbqvUBF.lst /dev/null /tmp/xlcW2hWVoJP +export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode +export XL_LINKER=/usr/bin/ld +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -qtls -qnostdinc /tmp/xlcW0buijl3 /tmp/xlcW1Cx9kxW CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o /tmp/xlcLVbqvUBB.lst /tmp/xlcW2hWVoJP +rm /tmp/xlcASknvctJ +rm /tmp/xlcLVbqvUB +rm /tmp/xlcW0buijl3 +rm /tmp/xlcW1Cx9kxW +rm /tmp/xlcW2hWVoJP +Linking C executable cmTC_76ec2 +/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_76ec2.dir/link.txt --verbose=1 +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qnostdinc -I/tmp/ii/test_c -V CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o -o cmTC_76ec2 -Wl,-export-dynamic +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o -o cmTC_76ec2 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o +rm /tmp/xlcW0ka8GHg +rm /tmp/xlcW1k1R1fn +rm /tmp/xlcW2s4HnOt +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-C-XL-12.1.0.output new file mode 100644 index 0000000000..38f0b37343 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-C-XL-12.1.0.output @@ -0,0 +1 @@ +/tmp/ii/test_c diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-CXX-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-CXX-XL-12.1.0.input new file mode 100644 index 0000000000..4b20f2ee47 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-CXX-XL-12.1.0.input @@ -0,0 +1,42 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=XL +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=12.1.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/gmake" "cmTC_026f6/fast" +/usr/bin/gmake -f CMakeFiles/cmTC_026f6.dir/build.make CMakeFiles/cmTC_026f6.dir/build +gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlC -+ -qnostdinc -I/tmp/ii/test_c -I/tmp/ii/test_cxx -V -o CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlC +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +export XL_ASMOBJFILES=/tmp/xlcAS6jiX2k +export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o"" +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/exe/xlCentry -qosvar=rhel.6.9 -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qnostdinc -I/tmp/ii/test_c -I/tmp/ii/test_cxx -qasm_as=/usr/bin/as -qcpp_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/include -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_cpp_stdinc=/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ppc64-redhat-linux:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -oCMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW00ICris /tmp/xlcW1eYwBrK /dev/null /tmp/xlcLG2pVwDF.lst /dev/null /tmp/xlcW2YVJhA2 +export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode +export XL_LINKER=/usr/bin/ld +/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qalias=ansi -qtls -qtls -qnostdinc /tmp/xlcW00ICris /tmp/xlcW1eYwBrK CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcLG2pVwDB.lst /tmp/xlcW2YVJhA2 +rm /tmp/xlcAS6jiX2k +rm /tmp/xlcLG2pVwD +rm /tmp/xlcW00ICris +rm /tmp/xlcW1eYwBrK +rm /tmp/xlcW2YVJhA2 +Linking CXX executable cmTC_026f6 +/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_026f6.dir/link.txt --verbose=1 +/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlC -qnostdinc -I/tmp/ii/test_c -I/tmp/ii/test_cxx -V CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_026f6 -Wl,-export-dynamic +export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlC +export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447 +/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_026f6 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -libmc++ -lxlopt -lxl -lstdc++ -lm -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o +rm /tmp/xlcW0rO54CG +rm /tmp/xlcW1Q6xB5c +rm /tmp/xlcW2TnvdyJ +gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-CXX-XL-12.1.0.output new file mode 100644 index 0000000000..727afdbc04 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/linux_nostdinc_i-CXX-XL-12.1.0.output @@ -0,0 +1 @@ +/tmp/ii/test_c;/tmp/ii/test_cxx diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-C-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-C-GNU-4.9.3.input new file mode 100644 index 0000000000..df96c59efd --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-C-GNU-4.9.3.input @@ -0,0 +1,70 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI= +CMAKE_C_COMPILER_AR=C:/MinGW/bin/gcc-ar.exe +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=GNU +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB=C:/MinGW/bin/gcc-ranlib.exe +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=4.9.3 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: C:/tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_ab097/fast" +C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_ab097.dir\build.make CMakeFiles/cmTC_ab097.dir/build +mingw32-make.exe[1]: Entering directory 'C:/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_ab097.dir/CMakeCCompilerABI.c.obj +C:\MinGW\bin\gcc.exe -v -o CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj -c "C:\CMake\Modules\CMakeCCompilerABI.c" +Using built-in specs. +COLLECT_GCC=C:\MinGW\bin\gcc.exe +Target: mingw32 +Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls +Thread model: win32 +gcc version 4.9.3 (GCC) +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586' + c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/cc1.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.9.3/ C:\CMake\Modules\CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=i586 -auxbase-strip CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj -version -o C:\Users\DASHBO~1\AppData\Local\Temp\ccKRBU4I.s +GNU C (GCC) version 4.9.3 (mingw32) + compiled by GNU C version 4.9.3, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.2 +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.9.3/../../../../mingw32/include" +ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include" +ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.9.3/../../../../include" +ignoring duplicate directory "c:/mingw/lib/gcc/../../include" +ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include-fixed" +ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/../../../../mingw32/include" +ignoring duplicate directory "/mingw/include" +#include "..." search starts here: +#include <...> search starts here: + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/include + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/../../../../include + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/include-fixed +End of search list. +GNU C (GCC) version 4.9.3 (mingw32) + compiled by GNU C version 4.9.3, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.2 +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +Compiler executable checksum: 32bccaa1a45d39107471fe656e1c3cd5 +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586' + c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/as.exe -v -o CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj C:\Users\DASHBO~1\AppData\Local\Temp\ccKRBU4I.s +GNU assembler version 2.25.1 (mingw32) using BFD version (GNU Binutils) 2.25.1 +COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ +LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../ +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586' +Linking C executable cmTC_ab097.exe +"C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_ab097.dir\link.txt --verbose=1 +"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_ab097.dir/objects.a +C:\MinGW\bin\ar.exe cr CMakeFiles\cmTC_ab097.dir/objects.a @CMakeFiles\cmTC_ab097.dir\objects1.rsp +C:\MinGW\bin\gcc.exe -v -Wl,--whole-archive CMakeFiles\cmTC_ab097.dir/objects.a -Wl,--no-whole-archive -o cmTC_ab097.exe -Wl,--out-implib,libcmTC_ab097.dll.a -Wl,--major-image-version,0,--minor-image-version,0 +Using built-in specs. +COLLECT_GCC=C:\MinGW\bin\gcc.exe +COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe +Target: mingw32 +Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls +Thread model: win32 +gcc version 4.9.3 (GCC) +COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ +LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../ +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_ab097.exe' '-mtune=generic' '-march=i586' + c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/collect2.exe -plugin c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/liblto_plugin-0.dll -plugin-opt=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\DASHBO~1\AppData\Local\Temp\ccEGcsW8.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -Bdynamic -o cmTC_ab097.exe c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.9.3/crtbegin.o -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../.. --whole-archive CMakeFiles\cmTC_ab097.dir/objects.a --no-whole-archive --out-implib libcmTC_ab097.dll.a --major-image-version 0 --minor-image-version 0 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.9.3/crtend.o +mingw32-make.exe[1]: Leaving directory 'C:/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-C-GNU-4.9.3.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-C-GNU-4.9.3.output new file mode 100644 index 0000000000..cdfb8b2822 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-C-GNU-4.9.3.output @@ -0,0 +1 @@ +c:/mingw/bin/../lib/gcc/mingw32/4.9.3/include;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../include;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/include-fixed diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-CXX-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-CXX-GNU-4.9.3.input new file mode 100644 index 0000000000..ba44889732 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-CXX-GNU-4.9.3.input @@ -0,0 +1,76 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR=C:/MinGW/bin/gcc-ar.exe +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=GNU +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB=C:/MinGW/bin/gcc-ranlib.exe +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=4.9.3 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: C:/tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_2b790/fast" +C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_2b790.dir\build.make CMakeFiles/cmTC_2b790.dir/build +mingw32-make.exe[1]: Entering directory 'C:/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_2b790.dir/CMakeCXXCompilerABI.cpp.obj +C:\MinGW\bin\g++.exe -v -o CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj -c "C:\CMake\Modules\CMakeCXXCompilerABI.cpp" +Using built-in specs. +COLLECT_GCC=C:\MinGW\bin\g++.exe +Target: mingw32 +Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls +Thread model: win32 +gcc version 4.9.3 (GCC) +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586' + c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/cc1plus.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.9.3/ C:\CMake\Modules\CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=i586 -auxbase-strip CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj -version -o C:\Users\DASHBO~1\AppData\Local\Temp\cceEHFvQ.s +GNU C++ (GCC) version 4.9.3 (mingw32) + compiled by GNU C version 4.9.3, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.2 +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.9.3/../../../../mingw32/include" +ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include/c++" +ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include/c++/mingw32" +ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include/c++/backward" +ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include" +ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.9.3/../../../../include" +ignoring duplicate directory "c:/mingw/lib/gcc/../../include" +ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include-fixed" +ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/../../../../mingw32/include" +ignoring duplicate directory "/mingw/include" +#include "..." search starts here: +#include <...> search starts here: + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/include/c++ + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/include/c++/mingw32 + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/include/c++/backward + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/include + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/../../../../include + c:\mingw\bin\../lib/gcc/mingw32/4.9.3/include-fixed +End of search list. +GNU C++ (GCC) version 4.9.3 (mingw32) + compiled by GNU C version 4.9.3, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.2 +GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 +Compiler executable checksum: 5086496b116ea21cdc0e479568243b88 +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586' + c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/as.exe -v -o CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj C:\Users\DASHBO~1\AppData\Local\Temp\cceEHFvQ.s +GNU assembler version 2.25.1 (mingw32) using BFD version (GNU Binutils) 2.25.1 +COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ +LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../ +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586' +Linking CXX executable cmTC_2b790.exe +"C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_2b790.dir\link.txt --verbose=1 +"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_2b790.dir/objects.a +C:\MinGW\bin\ar.exe cr CMakeFiles\cmTC_2b790.dir/objects.a @CMakeFiles\cmTC_2b790.dir\objects1.rsp +C:\MinGW\bin\g++.exe -v -Wl,--whole-archive CMakeFiles\cmTC_2b790.dir/objects.a -Wl,--no-whole-archive -o cmTC_2b790.exe -Wl,--out-implib,libcmTC_2b790.dll.a -Wl,--major-image-version,0,--minor-image-version,0 +Using built-in specs. +COLLECT_GCC=C:\MinGW\bin\g++.exe +COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe +Target: mingw32 +Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls +Thread model: win32 +gcc version 4.9.3 (GCC) +COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ +LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../ +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_2b790.exe' '-shared-libgcc' '-mtune=generic' '-march=i586' + c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/collect2.exe -plugin c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/liblto_plugin-0.dll -plugin-opt=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\DASHBO~1\AppData\Local\Temp\ccYpt7zh.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -Bdynamic -u ___register_frame_info -u ___deregister_frame_info -o cmTC_2b790.exe c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.9.3/crtbegin.o -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../.. --whole-archive CMakeFiles\cmTC_2b790.dir/objects.a --no-whole-archive --out-implib libcmTC_2b790.dll.a --major-image-version 0 --minor-image-version 0 -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.9.3/crtend.o +mingw32-make.exe[1]: Leaving directory 'C:/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-CXX-GNU-4.9.3.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-CXX-GNU-4.9.3.output new file mode 100644 index 0000000000..881a1a1369 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/mingw.org-CXX-GNU-4.9.3.output @@ -0,0 +1 @@ +c:/mingw/bin/../lib/gcc/mingw32/4.9.3/include/c++;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/include/c++/mingw32;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/include/c++/backward;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/include;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../include;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/include-fixed diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-C-GNU-4.8.5.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-C-GNU-4.8.5.input new file mode 100644 index 0000000000..b468484336 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-C-GNU-4.8.5.input @@ -0,0 +1,60 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR=CMAKE_C_COMPILER_AR-NOTFOUND +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=GNU +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB=CMAKE_C_COMPILER_RANLIB-NOTFOUND +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=4.8.5 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/pkg/bin/gmake" "cmTC_9a517/fast" +/usr/pkg/bin/gmake -f CMakeFiles/cmTC_9a517.dir/build.make CMakeFiles/cmTC_9a517.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o +/usr/bin/cc -v -o CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o -c /usr/pkg/share/cmake-3.9/Modules/CMakeCCompilerABI.c +Using built-in specs. +COLLECT_GCC=/usr/bin/cc +Target: i486--netbsdelf +Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386 +Thread model: posix +gcc version 4.8.5 (nb2 20150115) +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486' + /usr/libexec/cc1 -quiet -v /usr/pkg/share/cmake-3.9/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=nocona -march=i486 -auxbase-strip CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o -version -o /var/tmp//ccXQW9Zo.s +GNU C (nb2 20150115) version 4.8.5 (i486--netbsdelf) + compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803 +#include "..." search starts here: +#include <...> search starts here: + /usr/include/gcc-4.8 + /usr/include +End of search list. +GNU C (nb2 20150115) version 4.8.5 (i486--netbsdelf) + compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803 +Compiler executable checksum: 468b91b49af5cfeb6bb696ad20c66c1c +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486' + as -v -o CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o /var/tmp//ccXQW9Zo.s +GNU assembler version 2.23.2 (i486--netbsdelf) using BFD version (NetBSD Binutils nb1) 2.23.2 +COMPILER_PATH=/usr/libexec/ +LIBRARY_PATH=/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486' +Linking C executable cmTC_9a517 +/usr/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9a517.dir/link.txt --verbose=1 +/usr/bin/cc -v CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o -o cmTC_9a517 +Using built-in specs. +COLLECT_GCC=/usr/bin/cc +COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper +Target: i486--netbsdelf +Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386 +Thread model: posix +gcc version 4.8.5 (nb2 20150115) +COMPILER_PATH=/usr/libexec/ +LIBRARY_PATH=/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_9a517' '-mtune=nocona' '-march=i486' + ld --eh-frame-hdr -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o cmTC_9a517 /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-C-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-C-GNU-4.8.5.output new file mode 100644 index 0000000000..6b69b2d7c3 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-C-GNU-4.8.5.output @@ -0,0 +1 @@ +/usr/include/gcc-4.8;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-CXX-GNU-4.8.5.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-CXX-GNU-4.8.5.input new file mode 100644 index 0000000000..e3c5f72e97 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-CXX-GNU-4.8.5.input @@ -0,0 +1,62 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR=CMAKE_CXX_COMPILER_AR-NOTFOUND +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=GNU +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB=CMAKE_CXX_COMPILER_RANLIB-NOTFOUND +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=4.8.5 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/pkg/bin/gmake" "cmTC_cca06/fast" +/usr/pkg/bin/gmake -f CMakeFiles/cmTC_cca06.dir/build.make CMakeFiles/cmTC_cca06.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o +/usr/bin/c++ -v -o CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o -c /usr/pkg/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp +Using built-in specs. +COLLECT_GCC=/usr/bin/c++ +Target: i486--netbsdelf +Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386 +Thread model: posix +gcc version 4.8.5 (nb2 20150115) +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486' + /usr/libexec/cc1plus -quiet -v /usr/pkg/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=nocona -march=i486 -auxbase-strip CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o -version -o /var/tmp//ccqeRxzZ.s +GNU C++ (nb2 20150115) version 4.8.5 (i486--netbsdelf) + compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803 +#include "..." search starts here: +#include <...> search starts here: + /usr/include/g++ + /usr/include/g++/backward + /usr/include/gcc-4.8 + /usr/include +End of search list. +GNU C++ (nb2 20150115) version 4.8.5 (i486--netbsdelf) + compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803 +Compiler executable checksum: 961550adc452c84b614bf799df00d02b +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486' + as -v -o CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o /var/tmp//ccqeRxzZ.s +GNU assembler version 2.23.2 (i486--netbsdelf) using BFD version (NetBSD Binutils nb1) 2.23.2 +COMPILER_PATH=/usr/libexec/ +LIBRARY_PATH=/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486' +Linking CXX executable cmTC_cca06 +/usr/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cca06.dir/link.txt --verbose=1 +/usr/bin/c++ -v CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_cca06 +Using built-in specs. +COLLECT_GCC=/usr/bin/c++ +COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper +Target: i486--netbsdelf +Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386 +Thread model: posix +gcc version 4.8.5 (nb2 20150115) +COMPILER_PATH=/usr/libexec/ +LIBRARY_PATH=/usr/lib/ +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_cca06' '-shared-libgcc' '-mtune=nocona' '-march=i486' + ld --eh-frame-hdr -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o cmTC_cca06 /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm --as-needed -lgcc_s --no-as-needed -lgcc -lc --as-needed -lgcc_s --no-as-needed -lgcc /usr/lib/crtend.o /usr/lib/crtn.o +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-CXX-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-CXX-GNU-4.8.5.output new file mode 100644 index 0000000000..7b1e11ecea --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd-CXX-GNU-4.8.5.output @@ -0,0 +1 @@ +/usr/include/g++;/usr/include/g++/backward;/usr/include/gcc-4.8;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-C-GNU-4.8.5.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-C-GNU-4.8.5.input new file mode 100644 index 0000000000..cd5845ae56 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-C-GNU-4.8.5.input @@ -0,0 +1,58 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR=CMAKE_C_COMPILER_AR-NOTFOUND +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=GNU +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB=CMAKE_C_COMPILER_RANLIB-NOTFOUND +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=4.8.5 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/pkg/bin/gmake" "cmTC_b8d65/fast" +/usr/pkg/bin/gmake -f CMakeFiles/cmTC_b8d65.dir/build.make CMakeFiles/cmTC_b8d65.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o +/usr/bin/cc -nostdinc -v -o CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o -c /usr/pkg/share/cmake-3.9/Modules/CMakeCCompilerABI.c +Using built-in specs. +COLLECT_GCC=/usr/bin/cc +Target: i486--netbsdelf +Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386 +Thread model: posix +gcc version 4.8.5 (nb2 20150115) +COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486' + /usr/libexec/cc1 -quiet -nostdinc -v /usr/pkg/share/cmake-3.9/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=nocona -march=i486 -auxbase-strip CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o -version -o /var/tmp//ccPEfYnQ.s +GNU C (nb2 20150115) version 4.8.5 (i486--netbsdelf) + compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803 +#include "..." search starts here: +#include <...> search starts here: +End of search list. +GNU C (nb2 20150115) version 4.8.5 (i486--netbsdelf) + compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803 +Compiler executable checksum: 468b91b49af5cfeb6bb696ad20c66c1c +COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486' + as -v -o CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o /var/tmp//ccPEfYnQ.s +GNU assembler version 2.23.2 (i486--netbsdelf) using BFD version (NetBSD Binutils nb1) 2.23.2 +COMPILER_PATH=/usr/libexec/ +LIBRARY_PATH=/usr/lib/ +COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486' +Linking C executable cmTC_b8d65 +/usr/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b8d65.dir/link.txt --verbose=1 +/usr/bin/cc -nostdinc -v CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o -o cmTC_b8d65 +Using built-in specs. +COLLECT_GCC=/usr/bin/cc +COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper +Target: i486--netbsdelf +Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386 +Thread model: posix +gcc version 4.8.5 (nb2 20150115) +COMPILER_PATH=/usr/libexec/ +LIBRARY_PATH=/usr/lib/ +COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'cmTC_b8d65' '-mtune=nocona' '-march=i486' + ld --eh-frame-hdr -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o cmTC_b8d65 /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-C-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-C-GNU-4.8.5.output new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-C-GNU-4.8.5.output diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-CXX-GNU-4.8.5.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-CXX-GNU-4.8.5.input new file mode 100644 index 0000000000..b9a585cc16 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-CXX-GNU-4.8.5.input @@ -0,0 +1,58 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR=CMAKE_CXX_COMPILER_AR-NOTFOUND +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=GNU +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB=CMAKE_CXX_COMPILER_RANLIB-NOTFOUND +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=4.8.5 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/pkg/bin/gmake" "cmTC_bbb1e/fast" +/usr/pkg/bin/gmake -f CMakeFiles/cmTC_bbb1e.dir/build.make CMakeFiles/cmTC_bbb1e.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o +/usr/bin/c++ -nostdinc -v -o CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o -c /usr/pkg/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp +Using built-in specs. +COLLECT_GCC=/usr/bin/c++ +Target: i486--netbsdelf +Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386 +Thread model: posix +gcc version 4.8.5 (nb2 20150115) +COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486' + /usr/libexec/cc1plus -quiet -nostdinc -v /usr/pkg/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=nocona -march=i486 -auxbase-strip CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o -version -o /var/tmp//cclVebp0.s +GNU C++ (nb2 20150115) version 4.8.5 (i486--netbsdelf) + compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803 +#include "..." search starts here: +#include <...> search starts here: +End of search list. +GNU C++ (nb2 20150115) version 4.8.5 (i486--netbsdelf) + compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1 +GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803 +Compiler executable checksum: 961550adc452c84b614bf799df00d02b +COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486' + as -v -o CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o /var/tmp//cclVebp0.s +GNU assembler version 2.23.2 (i486--netbsdelf) using BFD version (NetBSD Binutils nb1) 2.23.2 +COMPILER_PATH=/usr/libexec/ +LIBRARY_PATH=/usr/lib/ +COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486' +Linking CXX executable cmTC_bbb1e +/usr/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_bbb1e.dir/link.txt --verbose=1 +/usr/bin/c++ -nostdinc -v CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_bbb1e +Using built-in specs. +COLLECT_GCC=/usr/bin/c++ +COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper +Target: i486--netbsdelf +Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386 +Thread model: posix +gcc version 4.8.5 (nb2 20150115) +COMPILER_PATH=/usr/libexec/ +LIBRARY_PATH=/usr/lib/ +COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'cmTC_bbb1e' '-shared-libgcc' '-mtune=nocona' '-march=i486' + ld --eh-frame-hdr -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o cmTC_bbb1e /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm --as-needed -lgcc_s --no-as-needed -lgcc -lc --as-needed -lgcc_s --no-as-needed -lgcc /usr/lib/crtend.o /usr/lib/crtn.o +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-CXX-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-CXX-GNU-4.8.5.output new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/netbsd_nostdinc-CXX-GNU-4.8.5.output diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-C-Clang-5.0.1.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-C-Clang-5.0.1.input new file mode 100644 index 0000000000..9f34f3d419 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-C-Clang-5.0.1.input @@ -0,0 +1,37 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI=ELF +CMAKE_C_COMPILER_AR=CMAKE_C_COMPILER_AR-NOTFOUND +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=Clang +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB=CMAKE_C_COMPILER_RANLIB-NOTFOUND +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=5.0.1 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_f5360/fast" +/usr/bin/make -f CMakeFiles/cmTC_f5360.dir/build.make CMakeFiles/cmTC_f5360.dir/build +Building C object CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o +/usr/bin/cc -v -o CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o -c /usr/local/share/cmake/Modules/CMakeCCompilerABI.c +OpenBSD clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1) +Target: amd64-unknown-openbsd6.3 +Thread model: posix +InstalledDir: /usr/bin + "/usr/bin/cc" -cc1 -triple amd64-unknown-openbsd6.3 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 1 -pic-is-pie -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.gcno -resource-dir /usr/lib/clang/5.0.1 -fdebug-compilation-dir /tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -femulated-tls -fwrapv -stack-protector 2 -fobjc-runtime=gnustep -fdiagnostics-show-option -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -o CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o -x c /usr/local/share/cmake/Modules/CMakeCCompilerABI.c +clang -cc1 version 5.0.1 based upon LLVM 5.0.1 default target amd64-unknown-openbsd6.3 +#include "..." search starts here: +#include <...> search starts here: + /usr/lib/clang/5.0.1/include + /usr/include +End of search list. +Linking C executable cmTC_f5360 +/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f5360.dir/link.txt --verbose=1 +/usr/bin/cc -v CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o -o cmTC_f5360 -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib +OpenBSD clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1) +Target: amd64-unknown-openbsd6.3 +Thread model: posix +InstalledDir: /usr/bin + "/usr/bin/ld" -e __start --eh-frame-hdr -Bdynamic -dynamic-linker /usr/libexec/ld.so -o cmTC_f5360 /usr/bin/../lib/crt0.o /usr/bin/../lib/crtbegin.o -L/usr/bin/../lib -L/usr/lib CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o -rpath-link /usr/X11R6/lib:/usr/local/lib -lcompiler_rt -lc -lcompiler_rt /usr/bin/../lib/crtend.o diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-C-Clang-5.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-C-Clang-5.0.1.output new file mode 100644 index 0000000000..60dbe246a9 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-C-Clang-5.0.1.output @@ -0,0 +1 @@ +/usr/lib/clang/5.0.1/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-CXX-Clang-5.0.1.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-CXX-Clang-5.0.1.input new file mode 100644 index 0000000000..93f1a95703 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-CXX-Clang-5.0.1.input @@ -0,0 +1,38 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI=ELF +CMAKE_CXX_COMPILER_AR=CMAKE_CXX_COMPILER_AR-NOTFOUND +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=Clang +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB=CMAKE_CXX_COMPILER_RANLIB-NOTFOUND +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=5.0.1 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/usr/bin/make" "cmTC_a2bf8/fast" +/usr/bin/make -f CMakeFiles/cmTC_a2bf8.dir/build.make CMakeFiles/cmTC_a2bf8.dir/build +Building CXX object CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o +/usr/bin/c++ -v -o CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/share/cmake/Modules/CMakeCXXCompilerABI.cpp +OpenBSD clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1) +Target: amd64-unknown-openbsd6.3 +Thread model: posix +InstalledDir: /usr/bin + "/usr/bin/c++" -cc1 -triple amd64-unknown-openbsd6.3 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 1 -pic-is-pie -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.gcno -resource-dir /usr/lib/clang/5.0.1 -internal-isystem /usr/include/c++/v1 -fdeprecated-macro -fdebug-compilation-dir /tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -femulated-tls -fwrapv -stack-protector 2 -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -o CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o -x c++ /usr/local/share/cmake/Modules/CMakeCXXCompilerABI.cpp +clang -cc1 version 5.0.1 based upon LLVM 5.0.1 default target amd64-unknown-openbsd6.3 +#include "..." search starts here: +#include <...> search starts here: + /usr/include/c++/v1 + /usr/lib/clang/5.0.1/include + /usr/include +End of search list. +Linking CXX executable cmTC_a2bf8 +/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a2bf8.dir/link.txt --verbose=1 +/usr/bin/c++ -v CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_a2bf8 -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib +OpenBSD clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1) +Target: amd64-unknown-openbsd6.3 +Thread model: posix +InstalledDir: /usr/bin + "/usr/bin/ld" -e __start --eh-frame-hdr -Bdynamic -dynamic-linker /usr/libexec/ld.so -o cmTC_a2bf8 /usr/bin/../lib/crt0.o /usr/bin/../lib/crtbegin.o -L/usr/bin/../lib -L/usr/lib CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o -rpath-link /usr/X11R6/lib:/usr/local/lib -lc++ -lc++abi -lpthread -lm -lcompiler_rt -lc -lcompiler_rt /usr/bin/../lib/crtend.o diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-CXX-Clang-5.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-CXX-Clang-5.0.1.output new file mode 100644 index 0000000000..6da139842f --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/openbsd-CXX-Clang-5.0.1.output @@ -0,0 +1 @@ +/usr/include/c++/v1;/usr/lib/clang/5.0.1/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-C-SunPro-5.13.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-C-SunPro-5.13.0.input new file mode 100644 index 0000000000..b0b504acbf --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-C-SunPro-5.13.0.input @@ -0,0 +1,35 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI= +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=SunPro +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=5.13.0 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/opt/csw/bin/gmake" "cmTC_55079/fast" +/opt/csw/bin/gmake -f CMakeFiles/cmTC_55079.dir/build.make CMakeFiles/cmTC_55079.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o +/opt/solarisstudio12.4/bin/cc -# -o CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c +### cc: Note: NLSPATH = /opt/solarisstudio12.4/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/solarisstudio12.4/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat +### command line files and options (expanded): +### -# -oCMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c +/opt/solarisstudio12.4/lib/compilers/acomp -Qy -std=c11 -i /tmp/CMake/Modules/CMakeCCompilerABI.c -D__SunOS_5_10 -D__SUNPRO_C=0x5130 -D__unix -D__SVR4 -D__sun -D__SunOS -D__sparcv8 -D__sparc -D__BUILTIN_VA_ARG_INCR -D__C11FEATURES__ -D__C99FEATURES__ -D__PRAGMA_REDEFINE_EXTNAME -Dunix -Dsun -Dsparc -D__RESTRICT -D__FLT_EVAL_METHOD__=0 -D__SUN_PREFETCH -D__NOVECTORSIZE__ -I-xbuiltin -I/opt/solarisstudio12.4/lib/compilers/include/cc -xbuiltin=%none -fsimple=0 -m32 -fparam_ir -fparam_ir -xdebuginfo=%none -xF=%none -xdbggen=dwarf+usedonly+incl -xldscope=global -xivdep=loop "-g/opt/solarisstudio12.4/bin/cc -c " -destination_ir=yabe -y-fbe -y/opt/solarisstudio12.4/bin/fbe -y-xmemalign=8i -y-verbose -y-comdat -y-xdebuginfo=%none -y-xarch=generic -y-m32 -y-comdat -y-xthreadvar=no%dynamic -y-xannotate=yes -y-o -yCMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o +Linking C executable cmTC_55079 +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_55079.dir/link.txt --verbose=1 +/opt/solarisstudio12.4/bin/cc -# CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -o cmTC_55079 +### cc: Note: NLSPATH = /opt/solarisstudio12.4/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/solarisstudio12.4/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat +### command line files and options (expanded): +### -# CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -ocmTC_55079 +### cc: Note: LD_LIBRARY_PATH = (null) +### cc: Note: LD_RUN_PATH = (null) +### cc: Note: LD_OPTIONS = (null) +ln -s /opt/solarisstudio12.4/lib/compilers /tmp/lib_link.1547820951.9061.01 +/usr/ccs/bin/ld -zld32=-S/tmp/lib_link.1547820951.9061.01/libldstab_ws.so -zld64=-S/tmp/lib_link.1547820951.9061.01/sparcv9/libldstab_ws.so -zld32=-S/tmp/lib_link.1547820951.9061.01/libld_annotate.so -zld64=-S/tmp/lib_link.1547820951.9061.01/sparcv9/libld_annotate.so /opt/solarisstudio12.4/lib/compilers/crti.o /opt/solarisstudio12.4/lib/compilers/crt1.o /opt/solarisstudio12.4/lib/compilers/misalign.o /opt/solarisstudio12.4/lib/compilers/values-xa.o CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -o cmTC_55079 -Y "P,/opt/solarisstudio12.4/lib/compilers/staticlib:/opt/solarisstudio12.4/lib/compilers/sparc:/opt/solarisstudio12.4/lib/compilers:/usr/ccs/lib:/lib:/usr/lib" -Qy -lc /opt/solarisstudio12.4/lib/compilers/crtn.o +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-C-SunPro-5.13.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-C-SunPro-5.13.0.output new file mode 100644 index 0000000000..27c452d269 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-C-SunPro-5.13.0.output @@ -0,0 +1 @@ +/opt/solarisstudio12.4/lib/compilers/include/cc;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-CXX-SunPro-5.13.0.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-CXX-SunPro-5.13.0.input new file mode 100644 index 0000000000..9abd06a281 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-CXX-SunPro-5.13.0.input @@ -0,0 +1,38 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI= +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=SunPro +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=5.13.0 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command:"/opt/csw/bin/gmake" "cmTC_cc4b2/fast" +/opt/csw/bin/gmake -f CMakeFiles/cmTC_cc4b2.dir/build.make CMakeFiles/cmTC_cc4b2.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o +/opt/solarisstudio12.4/bin/CC -v -o CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp +### CC: Note: NLSPATH = /opt/solarisstudio12.4/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/solarisstudio12.4/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat +### command line files and options (expanded): +### -v -oCMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp +/opt/solarisstudio12.4/lib/compilers/ccfe -D__SunOS_5_10 -D__SUNPRO_CC=0x5130 -D__unix -D__SVR4 -D__sun -D__SunOS -D__sparcv8 -D__sparc -D__BUILTIN_VA_ARG_INCR -Dunix -Dsun -Dsparc -D__SUN_PREFETCH -D__SUNPRO_CC_COMPAT=5 -D__NOVECTORSIZE__ -I-xbuiltin -I/opt/solarisstudio12.4/lib/compilers/include/CC/Cstd -I/opt/solarisstudio12.4/lib/compilers/include/CC -I/opt/solarisstudio12.4/lib/compilers/include/cc -ptf /tmp/ccfe.1547820952.9069.02.%1.%2 -ptx /opt/solarisstudio12.4/bin/CC -ptk "-v -c " -compat=5 -xdebuginfo=%none -instlib=/opt/solarisstudio12.4/lib/compilers/libCstd.a -xdbggen=dwarf+usedonly+incl -xF=%none -xbuiltin=%none -xldscope=global -xivdep=loop -O0 -xarrayloc /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp -ptb CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -y-fbe -y/opt/solarisstudio12.4/bin/fbe -y-xmemalign=8i -y-verbose -y-comdat -y-xdebuginfo=%none -y-xarch=generic -y-m32 -y-comdat -y-xthreadvar=no%dynamic -y-xannotate=yes -y-o -yCMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o 2> /tmp/ccfe.1547820952.9069.01.err +rm /tmp/ccfe.1547820952.9069.01.err +Linking CXX executable cmTC_cc4b2 +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cc4b2.dir/link.txt --verbose=1 +/opt/solarisstudio12.4/bin/CC -v CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_cc4b2 +### CC: Note: NLSPATH = /opt/solarisstudio12.4/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/solarisstudio12.4/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat +### command line files and options (expanded): +### -v CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -ocmTC_cc4b2 +### CC: Note: LD_LIBRARY_PATH = (null) +### CC: Note: LD_RUN_PATH = (null) +### CC: Note: LD_OPTIONS = (null) +ln -s /opt/solarisstudio12.4/lib/compilers /tmp/lib_link.1547820952.9076.01 +/usr/ccs/bin/ld -zld32=-S/tmp/lib_link.1547820952.9076.01/libldstab_ws.so -zld64=-S/tmp/lib_link.1547820952.9076.01/sparcv9/libldstab_ws.so -zld32=-S/tmp/lib_link.1547820952.9076.01/libld_annotate.so -zld64=-S/tmp/lib_link.1547820952.9076.01/sparcv9/libld_annotate.so -zld32=-S/tmp/lib_link.1547820952.9076.01/libCCexcept.so.1 -zld64=-S/tmp/lib_link.1547820952.9076.01/sparcv9/libCCexcept.so.1 /opt/solarisstudio12.4/lib/compilers/crti.o -u __1cH__CimplKcplus_init6F_v_ /opt/solarisstudio12.4/lib/compilers/CCrti.o /opt/solarisstudio12.4/lib/compilers/crt1.o /opt/solarisstudio12.4/lib/compilers/misalign.o /opt/solarisstudio12.4/lib/compilers/values-xa.o CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_cc4b2 -Y "P,/opt/solarisstudio12.4/lib/compilers/sparc:/opt/solarisstudio12.4/lib/compilers:/opt/solarisstudio12.4/lib/sparc:/opt/solarisstudio12.4/lib:/usr/ccs/lib:/lib:/usr/lib" -Qy "-R/opt/solarisstudio12.4/lib/sparc:/opt/solarisstudio12.4/lib" -lCstd -lCrun -lm -lc /opt/solarisstudio12.4/lib/compilers/CCrtn.o /opt/solarisstudio12.4/lib/compilers/crtn.o 2> /tmp/ld.1547820952.9076.02.err +rm /tmp/lib_link.1547820952.9076.01 +rm /tmp/ld.1547820952.9076.02.err +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-CXX-SunPro-5.13.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-CXX-SunPro-5.13.0.output new file mode 100644 index 0000000000..be851c2acd --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/sunos-CXX-SunPro-5.13.0.output @@ -0,0 +1 @@ +/opt/solarisstudio12.4/lib/compilers/include/CC/Cstd;/opt/solarisstudio12.4/lib/compilers/include/CC;/opt/solarisstudio12.4/lib/compilers/include/cc;/usr/include diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt index b1df6b04f7..9e6462bf4c 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt @@ -1,4 +1,20 @@ add_library(bar STATIC bar.cpp) add_library(foo STATIC foo.cpp) + +add_library(baz STATIC foo.cpp) +set_target_properties(baz PROPERTIES EXCLUDE_FROM_ALL OFF) + +file(GENERATE + OUTPUT "${CMAKE_BINARY_DIR}/main.txt" + CONTENT "$<TARGET_FILE_NAME:main>") + +file(GENERATE + OUTPUT "${CMAKE_BINARY_DIR}/bar.txt" + CONTENT "$<TARGET_FILE_NAME:bar>") + +file(GENERATE + OUTPUT "${CMAKE_BINARY_DIR}/baz.txt" + CONTENT "$<TARGET_FILE_NAME:baz>") + target_include_directories(foo PUBLIC .) diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake new file mode 100644 index 0000000000..14ec4827ff --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake @@ -0,0 +1,44 @@ +# Use globbing to check if exes / libs were built because determining +# exactly where these files will live inside a CMake -P script is +# pretty challenging. + +file(READ "${RunCMake_TEST_BINARY_DIR}/main.txt" main_exe) +file(READ "${RunCMake_TEST_BINARY_DIR}/bar.txt" bar_lib) +file(READ "${RunCMake_TEST_BINARY_DIR}/baz.txt" baz_lib) + +set(found_main FALSE) +file(GLOB_RECURSE files + LIST_DIRECTORIES FALSE + RELATIVE "${RunCMake_TEST_BINARY_DIR}" + "${RunCMake_TEST_BINARY_DIR}/*") +foreach (file IN LISTS files) + if (file MATCHES "${main_exe}") + set(found_main TRUE) + endif() +endforeach() +if (NOT found_main) + set(RunCMake_TEST_FAILED "'main' missing from ${RunCMake_TEST_BINARY_DIR}") +endif() + +set(found_bar FALSE) +set(found_baz FALSE) +file(GLOB_RECURSE files + LIST_DIRECTORIES FALSE + RELATIVE "${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll" + "${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll/*") +foreach (file IN LISTS files) + if (file MATCHES "${bar_lib}") + set(found_bar TRUE) + endif() + if (file MATCHES "${baz_lib}") + set(found_baz TRUE) + endif() +endforeach() +if (found_bar) + set(RunCMake_TEST_FAILED + "'bar' was not excluded from ${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll") +endif() +if (NOT found_baz) + set(RunCMake_TEST_FAILED + "'baz' missing from ${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll") +endif() diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index 343e65b59e..781e48371f 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -33,6 +33,7 @@ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(ExcludeFromAll) +set(RunCMake-check-file ExcludeFromAll/check.cmake) run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .) unset(RunCMake_TEST_BINARY_DIR) diff --git a/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt index c7f35c5ffe..c9111b0cfd 100644 --- a/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt +++ b/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt @@ -1,3 +1,2 @@ -Submit files \(using http\) - Using HTTP submit method - Drop site:http:// +Submit files + SubmitURL: http://-no-site- diff --git a/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt index 19f82347b3..2c67eb9db8 100644 --- a/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt +++ b/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt @@ -1,3 +1,2 @@ -Submit files \(using https\) - Using HTTP submit method - Drop site:https:// +Submit files + SubmitURL: https://-no-site- diff --git a/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake b/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake new file mode 100644 index 0000000000..777ef4e6c4 --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake @@ -0,0 +1,11 @@ +# Use COPY_ON_ERROR to handle the case where the source and destination +# directory are on different devices. Cross-device links are not permitted +# and the following command falls back to copying the file if link fails. +file(CREATE_LINK + ${CMAKE_CURRENT_LIST_FILE} TestCreateLink.cmake + RESULT result + COPY_ON_ERROR + ) +if(NOT result STREQUAL "0") + message(SEND_ERROR "COPY_ON_ERROR failed: '${result}'") +endif() diff --git a/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC-noexist.cmake b/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC-noexist.cmake new file mode 100644 index 0000000000..61aaf388f3 --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC-noexist.cmake @@ -0,0 +1,4 @@ +file(CREATE_LINK does_not_exist.txt TestSymLink.txt RESULT sym_result SYMBOLIC) +if(NOT sym_result STREQUAL "0") + message("Symlink fail: ${sym_result}") +endif() diff --git a/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC.cmake b/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC.cmake new file mode 100644 index 0000000000..77b899cff3 --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC.cmake @@ -0,0 +1,4 @@ +file(CREATE_LINK ${CMAKE_CURRENT_LIST_FILE} TestSymLink.cmake RESULT sym_result SYMBOLIC) +if(NOT sym_result STREQUAL "0") + message(SEND_ERROR "Symlink result='${sym_result}'") +endif() diff --git a/Tests/RunCMake/file/CREATE_LINK-noarg-result.txt b/Tests/RunCMake/file/CREATE_LINK-noarg-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK-noarg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/CREATE_LINK-noarg-stderr.txt b/Tests/RunCMake/file/CREATE_LINK-noarg-stderr.txt new file mode 100644 index 0000000000..12494f845a --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK-noarg-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CREATE_LINK-noarg\.cmake:[0-9]+ \(file\): + file CREATE_LINK must be called with at least two additional arguments +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/CREATE_LINK-noarg.cmake b/Tests/RunCMake/file/CREATE_LINK-noarg.cmake new file mode 100644 index 0000000000..65002fa779 --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK-noarg.cmake @@ -0,0 +1 @@ +file(CREATE_LINK ${CMAKE_CURRENT_LIST_FILE}) diff --git a/Tests/RunCMake/file/CREATE_LINK-noexist-stderr.txt b/Tests/RunCMake/file/CREATE_LINK-noexist-stderr.txt new file mode 100644 index 0000000000..97eee4fef4 --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK-noexist-stderr.txt @@ -0,0 +1 @@ +Hard link error: Cannot hard link 'does_not_exist.txt' as it does not exist. diff --git a/Tests/RunCMake/file/CREATE_LINK-noexist.cmake b/Tests/RunCMake/file/CREATE_LINK-noexist.cmake new file mode 100644 index 0000000000..5ee2580170 --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK-noexist.cmake @@ -0,0 +1,4 @@ +file(CREATE_LINK does_not_exist.txt TestLink.txt RESULT result) +if(NOT result STREQUAL "0") + message("Hard link error: ${result}") +endif() diff --git a/Tests/RunCMake/file/CREATE_LINK.cmake b/Tests/RunCMake/file/CREATE_LINK.cmake new file mode 100644 index 0000000000..ca616468a3 --- /dev/null +++ b/Tests/RunCMake/file/CREATE_LINK.cmake @@ -0,0 +1,11 @@ +# start with a file in the same directory to avoid cross-device links +set(test_file ${CMAKE_CURRENT_BINARY_DIR}/CreateLinkTest.txt) +file(TOUCH ${test_file}) + +file(CREATE_LINK + ${test_file} ${CMAKE_CURRENT_BINARY_DIR}/TestCreateLink.txt + RESULT result + ) +if(NOT result STREQUAL "0") + message(SEND_ERROR "Hard link result='${result}'") +endif() diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index b872824783..128e8f3839 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -1,5 +1,9 @@ include(RunCMake) +run_cmake(CREATE_LINK) +run_cmake(CREATE_LINK-COPY_ON_ERROR) +run_cmake(CREATE_LINK-noarg) +run_cmake(CREATE_LINK-noexist) run_cmake(DOWNLOAD-hash-mismatch) run_cmake(DOWNLOAD-unused-argument) run_cmake(DOWNLOAD-httpheader-not-set) @@ -53,6 +57,8 @@ run_cmake_command(GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake) if(NOT WIN32 OR CYGWIN) + run_cmake(CREATE_LINK-SYMBOLIC) + run_cmake(CREATE_LINK-SYMBOLIC-noexist) run_cmake(GLOB_RECURSE-cyclic-recursion) run_cmake(INSTALL-SYMLINK) run_cmake(READ_SYMLINK) diff --git a/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake new file mode 100644 index 0000000000..4496a051c0 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake @@ -0,0 +1 @@ +set(Resolved_DIR "${CMAKE_CURRENT_LIST_DIR}") diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index e9f35581a4..066523ec67 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -26,3 +26,6 @@ run_cmake(WrongVersionConfig) run_cmake(CMP0084-OLD) run_cmake(CMP0084-WARN) run_cmake(CMP0084-NEW) +if(UNIX) + run_cmake(SetFoundResolved) +endif() diff --git a/Tests/RunCMake/find_package/SetFoundResolved-stderr.txt b/Tests/RunCMake/find_package/SetFoundResolved-stderr.txt new file mode 100644 index 0000000000..ea94be5a92 --- /dev/null +++ b/Tests/RunCMake/find_package/SetFoundResolved-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning at SetFoundResolved.cmake:10 \(message\): + .*/Tests/RunCMake/find_package/symlink +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Warning at SetFoundResolved.cmake:15 \(message\): + .*/Tests/RunCMake/find_package/PackageRoot +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/SetFoundResolved.cmake b/Tests/RunCMake/find_package/SetFoundResolved.cmake new file mode 100644 index 0000000000..8d5651357e --- /dev/null +++ b/Tests/RunCMake/find_package/SetFoundResolved.cmake @@ -0,0 +1,17 @@ +# Create ./symlink pointing back here. +execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + PackageRoot "${CMAKE_CURRENT_SOURCE_DIR}/symlink") + +# Make find_package search through the symlink. +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/symlink") + +# Test preservation of symlinks. +find_package(Resolved) +message(WARNING "${Resolved_DIR}") + +# Test resolving symlinks. +set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS ON) +find_package(Resolved) +message(WARNING "${Resolved_DIR}") + +file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/symlink") diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index ac77ac3dec..54b858f926 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -11,8 +11,10 @@ set(expect_DIRECTORY "/path/to") set(expect_NAME "filename.ext.in") set(expect_EXT ".ext.in") set(expect_NAME_WE "filename") +set(expect_LAST_EXT ".in") +set(expect_NAME_WLE "filename.ext") set(expect_PATH "/path/to") -foreach(c DIRECTORY NAME EXT NAME_WE PATH) +foreach(c DIRECTORY NAME EXT NAME_WE LAST_EXT NAME_WLE PATH) get_filename_component(actual_${c} "${filename}" ${c}) check("${c}" "${actual_${c}}" "${expect_${c}}") list(APPEND non_cache_vars actual_${c}) diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py index edb5af6769..546ae4cc55 100644 --- a/Tests/Server/cmakelib.py +++ b/Tests/Server/cmakelib.py @@ -276,6 +276,10 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): index = cmakeoutput.index('\nGenerators\n\n') cmakeGenerators = [] for line in cmakeoutput[index + 12:].splitlines(): + if not line: + continue + if line[0] == '*': # default generator marker + line = ' ' + line[1:] if not line.startswith(' '): continue if line.startswith(' '): diff --git a/Tests/Tutorial/Complete/CMakeLists.txt b/Tests/Tutorial/Complete/CMakeLists.txt new file mode 100644 index 0000000000..9658e65365 --- /dev/null +++ b/Tests/Tutorial/Complete/CMakeLists.txt @@ -0,0 +1,116 @@ +cmake_minimum_required(VERSION 3.3) +project(Tutorial) + +# control where the static and shared libraries are built so that on windows +# we don't need to tinker with the path to run the executable +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + +if(APPLE) + set(CMAKE_INSTALL_RPATH "@executable_path/../lib") +elseif(UNIX) + set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") +endif() + +# configure a header file to pass the version number only +configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the MathFunctions library +add_subdirectory(MathFunctions) + +# add the executable +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial MathFunctions) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) + +# add the install targets +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) + +# enable testing +enable_testing() + +# does the application run +add_test(NAME Runs COMMAND Tutorial 25) + +# does the usage message work? +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endfunction(do_test) + +# do a bunch of result based tests +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") + +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +include(CPack) + +# install the configuration targets +install(EXPORT MathFunctionsTargets + FILE MathFunctionsTargets.cmake + DESTINATION lib/cmake/MathFunctions +) + +include(CMakePackageConfigHelpers) +# generate the config file that is includes the exports +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" + INSTALL_DESTINATION "lib/cmake/example" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) +# generate the version file for the config file +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" + VERSION "${Tutorial_VERSION_MAJOR}.${Tutorial_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion +) + +# install the configuration file +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake + DESTINATION lib/cmake/MathFunctions + ) + +# generate the export targets for the build tree +# needs to be after the install(TARGETS ) command +export(EXPORT MathFunctionsTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsTargets.cmake" +) diff --git a/Tests/Tutorial/Complete/Config.cmake.in b/Tests/Tutorial/Complete/Config.cmake.in new file mode 100644 index 0000000000..17cbabd99c --- /dev/null +++ b/Tests/Tutorial/Complete/Config.cmake.in @@ -0,0 +1,4 @@ + +@PACKAGE_INIT@ + +include ( "${CMAKE_CURRENT_LIST_DIR}/MathFunctionsTargets.cmake" ) diff --git a/Tests/Tutorial/Step6/License.txt b/Tests/Tutorial/Complete/License.txt index 673d724537..c62d00b9ea 100644 --- a/Tests/Tutorial/Step6/License.txt +++ b/Tests/Tutorial/Complete/License.txt @@ -1,2 +1,2 @@ This is the open source License.txt file introduced in -CMake/Tests/Tutorial/Step6... +CMake/Tutorial/Step7... diff --git a/Tests/Tutorial/Complete/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Complete/MathFunctions/CMakeLists.txt new file mode 100644 index 0000000000..161ad64492 --- /dev/null +++ b/Tests/Tutorial/Complete/MathFunctions/CMakeLists.txt @@ -0,0 +1,68 @@ + +# add the library that runs +add_library(MathFunctions MathFunctions.cxx) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(MathFunctions + INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + $<INSTALL_INTERFACE:include> + ) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) +if(USE_MYMATH) + + # does this system provide the log and exp functions? + include(CheckSymbolExists) + set(CMAKE_REQUIRED_LIBRARIES "m") + check_symbol_exists(log "math.h" HAVE_LOG) + check_symbol_exists(exp "math.h" HAVE_EXP) + + # first we add the executable that generates the table + add_executable(MakeTable MakeTable.cxx) + + # add the command to generate the source code + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + + # library that just does sqrt + add_library(SqrtLibrary STATIC + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + + # state that we depend on our binary dir to find Table.h + target_include_directories(SqrtLibrary PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + ) + + set_target_properties(SqrtLibrary PROPERTIES + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} + ) + + target_compile_definitions(SqrtLibrary PRIVATE + "$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>" + "$<$<BOOL:${HAVE_EXP}>:HAVE_EXP>" + ) + target_link_libraries(MathFunctions PRIVATE SqrtLibrary) +endif() + +target_compile_definitions(MathFunctions PRIVATE "$<$<BOOL:${USE_MYMATH}>:USE_MYMATH>") + +# define the symbol stating we are using the declspec(dllexport) when +# building on windows +target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") + +# setup the version numbering +set_property(TARGET MathFunctions PROPERTY VERSION "1.0.0") +set_property(TARGET MathFunctions PROPERTY SOVERSION "1") + +install(TARGETS MathFunctions + DESTINATION lib + EXPORT MathFunctionsTargets) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Complete/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Complete/MathFunctions/MakeTable.cxx new file mode 100644 index 0000000000..ee585568cb --- /dev/null +++ b/Tests/Tutorial/Complete/MathFunctions/MakeTable.cxx @@ -0,0 +1,25 @@ +// A simple program that builds a sqrt table +#include <cmath> +#include <fstream> +#include <iostream> + +int main(int argc, char* argv[]) +{ + // make sure we have enough arguments + if (argc < 2) { + return 1; + } + + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); + } + return fileOpen ? 0 : 1; // return 0 if wrote the file +} diff --git a/Tests/Tutorial/Complete/MathFunctions/MathFunctions.cxx b/Tests/Tutorial/Complete/MathFunctions/MathFunctions.cxx new file mode 100644 index 0000000000..5351184be4 --- /dev/null +++ b/Tests/Tutorial/Complete/MathFunctions/MathFunctions.cxx @@ -0,0 +1,18 @@ + +#include "MathFunctions.h" +#include <cmath> + +#ifdef USE_MYMATH +# include "mysqrt.h" +#endif + +namespace mathfunctions { +double sqrt(double x) +{ +#ifdef USE_MYMATH + return detail::mysqrt(x); +#else + return std::sqrt(x); +#endif +} +} diff --git a/Tests/Tutorial/Complete/MathFunctions/MathFunctions.h b/Tests/Tutorial/Complete/MathFunctions/MathFunctions.h new file mode 100644 index 0000000000..3fb547b4a6 --- /dev/null +++ b/Tests/Tutorial/Complete/MathFunctions/MathFunctions.h @@ -0,0 +1,14 @@ + +#if defined(_WIN32) +# if defined(EXPORTING_MYMATH) +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC __declspec(dllimport) +# endif +#else // non windows +# define DECLSPEC +#endif + +namespace mathfunctions { +double DECLSPEC sqrt(double x); +} diff --git a/Tests/Tutorial/Complete/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Complete/MathFunctions/mysqrt.cxx new file mode 100644 index 0000000000..96d94212db --- /dev/null +++ b/Tests/Tutorial/Complete/MathFunctions/mysqrt.cxx @@ -0,0 +1,45 @@ +#include "MathFunctions.h" +#include <iostream> + +// include the generated table +#include "Table.h" + +#include <cmath> + +namespace mathfunctions { +namespace detail { +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) { + return 0; + } + + // if we have both log and exp then use them +#if defined(HAVE_LOG) && defined(HAVE_EXP) + double result = exp(log(x) * 0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" + << std::endl; +#else + // use the table to help find an initial value + double result = x; + if (x >= 1 && x < 10) { + result = sqrtTable[static_cast<int>(x)]; + } + + // if we have both log and exp then use them + + // do ten iterations + for (int i = 0; i < 10; ++i) { + if (result <= 0) { + result = 0.1; + } + double delta = x - (result * result); + result = result + 0.5 * delta / result; + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; + } +#endif + return result; +} +} +} diff --git a/Tests/Tutorial/Complete/MathFunctions/mysqrt.h b/Tests/Tutorial/Complete/MathFunctions/mysqrt.h new file mode 100644 index 0000000000..e1c42ef0c2 --- /dev/null +++ b/Tests/Tutorial/Complete/MathFunctions/mysqrt.h @@ -0,0 +1,6 @@ + +namespace mathfunctions { +namespace detail { +double mysqrt(double x); +} +} diff --git a/Tests/Tutorial/Complete/TutorialConfig.h.in b/Tests/Tutorial/Complete/TutorialConfig.h.in new file mode 100644 index 0000000000..8cd2fc9c63 --- /dev/null +++ b/Tests/Tutorial/Complete/TutorialConfig.h.in @@ -0,0 +1,3 @@ +// the configured version number +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Tests/Tutorial/Complete/tutorial.cxx b/Tests/Tutorial/Complete/tutorial.cxx new file mode 100644 index 0000000000..443d195554 --- /dev/null +++ b/Tests/Tutorial/Complete/tutorial.cxx @@ -0,0 +1,25 @@ +// A simple program that computes the square root of a number +#include <iostream> +#include <sstream> +#include <string> + +#include "MathFunctions.h" +#include "TutorialConfig.h" + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + double inputValue = std::stod(argv[1]); + + const double outputValue = mathfunctions::sqrt(inputValue); + + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; + return 0; +} diff --git a/Tests/Tutorial/Consumer/CMakeLists.txt b/Tests/Tutorial/Consumer/CMakeLists.txt new file mode 100644 index 0000000000..4033b4da83 --- /dev/null +++ b/Tests/Tutorial/Consumer/CMakeLists.txt @@ -0,0 +1,51 @@ +cmake_minimum_required(VERSION 3.3) + +if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED True) +endif() + + +function(find_external_dependency name) + set(${name}_ROOT "" CACHE PATH "Root directory to find ${name}") + mark_as_advanced(${name}_DIR) + find_package(${name} PATHS ${${name}_ROOT} REQUIRED) +endfunction() + + +project(Consumer) + +find_external_dependency(MathFunctions) + +add_library(consumer consumer.cxx) +target_link_libraries(consumer PUBLIC MathFunctions) + +# install the consumer library +install(TARGETS consumer DESTINATION bin EXPORT ConsumerTargets) + +# install the configuration targets +install(EXPORT ConsumerTargets + FILE ConsumerTargets.cmake + DESTINATION lib/cmake/Consumer +) + +include(CMakePackageConfigHelpers) +# generate the config file that is includes the exports +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/ConsumerConfig.cmake" + INSTALL_DESTINATION "lib/cmake/example" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) + +# install the configuration file +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/ConsumerConfig.cmake + DESTINATION lib/cmake/Consumer + ) + +# generate the export targets for the build tree +# needs to be after the install(TARGETS ) command +export(EXPORT ConsumerTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/ConsumerTargets.cmake" +) diff --git a/Tests/Tutorial/Consumer/Config.cmake.in b/Tests/Tutorial/Consumer/Config.cmake.in new file mode 100644 index 0000000000..0b3f1e4ef0 --- /dev/null +++ b/Tests/Tutorial/Consumer/Config.cmake.in @@ -0,0 +1,14 @@ + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +function(find_external_dependency name) + set(${name}_ROOT "" CACHE PATH "Root directory to find ${name}") + mark_as_advanced(${name}_DIR) + find_dependency(${name} PATHS ${${name}_ROOT} REQUIRED) +endfunction() + +find_external_dependency(MathFunctions) + +include ( "${CMAKE_CURRENT_LIST_DIR}/ConsumerTargets.cmake" ) diff --git a/Tests/Tutorial/Consumer/consumer.cxx b/Tests/Tutorial/Consumer/consumer.cxx new file mode 100644 index 0000000000..ae7877b5ab --- /dev/null +++ b/Tests/Tutorial/Consumer/consumer.cxx @@ -0,0 +1,11 @@ +// A simple function that computes the square root of a number +#include <iostream> +#include <sstream> +#include <string> + +#include "MathFunctions.h" + +double string_square_root(std::string const& value) +{ + return mathfunctions::sqrt(std::stod(value)); +} diff --git a/Tests/Tutorial/Consumer/directions.txt b/Tests/Tutorial/Consumer/directions.txt new file mode 100644 index 0000000000..6a70aab5ee --- /dev/null +++ b/Tests/Tutorial/Consumer/directions.txt @@ -0,0 +1,6 @@ +# Import a CMake Project# + +This examples shows how a project can find other CMake packages that +generated Config.cmake files. + +It also shows how to state a projects external dependencies when generating a Config.cmake. diff --git a/Tests/Tutorial/MultiPackage/CMakeLists.txt b/Tests/Tutorial/MultiPackage/CMakeLists.txt new file mode 100644 index 0000000000..067e807295 --- /dev/null +++ b/Tests/Tutorial/MultiPackage/CMakeLists.txt @@ -0,0 +1,109 @@ +cmake_minimum_required(VERSION 3.3) +project(Tutorial) + +# control how we mark up Debug libraries compared to Release libraries +set(CMAKE_DEBUG_POSTFIX "-d") + +# control where the static and shared libraries are built so that on windows +# we don't need to tinker with the path to run the executable +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + +# configure a header file to pass the version number only +configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the MathFunctions library +add_subdirectory(MathFunctions) + +# add the executable +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial MathFunctions) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) + +# add the install targets +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) + +# enable testing +enable_testing() + +# does the application run +add_test(NAME Runs COMMAND Tutorial 25) + +# does the usage message work? +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endfunction(do_test) + +# do a bunch of result based tests +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") + +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +include(CPack) + +# install the configuration targets +install(EXPORT MathFunctionsTargets + FILE MathFunctionsTargets.cmake + DESTINATION lib/cmake/MathFunctions +) + +include(CMakePackageConfigHelpers) +# generate the config file that is includes the exports +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" + INSTALL_DESTINATION "lib/cmake/example" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) +# generate the version file for the config file +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" + VERSION "${Tutorial_VERSION_MAJOR}.${Tutorial_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion +) + +# install the configuration file +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake + DESTINATION lib/cmake/MathFunctions + ) + +# generate the export targets for the build tree +# needs to be after the install(TARGETS ) command +export(EXPORT MathFunctionsTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsTargets.cmake" +) diff --git a/Tests/Tutorial/MultiPackage/Config.cmake.in b/Tests/Tutorial/MultiPackage/Config.cmake.in new file mode 100644 index 0000000000..17cbabd99c --- /dev/null +++ b/Tests/Tutorial/MultiPackage/Config.cmake.in @@ -0,0 +1,4 @@ + +@PACKAGE_INIT@ + +include ( "${CMAKE_CURRENT_LIST_DIR}/MathFunctionsTargets.cmake" ) diff --git a/Tests/Tutorial/MultiPackage/License.txt b/Tests/Tutorial/MultiPackage/License.txt new file mode 100644 index 0000000000..c62d00b9ea --- /dev/null +++ b/Tests/Tutorial/MultiPackage/License.txt @@ -0,0 +1,2 @@ +This is the open source License.txt file introduced in +CMake/Tutorial/Step7... diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/CMakeLists.txt b/Tests/Tutorial/MultiPackage/MathFunctions/CMakeLists.txt new file mode 100644 index 0000000000..161ad64492 --- /dev/null +++ b/Tests/Tutorial/MultiPackage/MathFunctions/CMakeLists.txt @@ -0,0 +1,68 @@ + +# add the library that runs +add_library(MathFunctions MathFunctions.cxx) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(MathFunctions + INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + $<INSTALL_INTERFACE:include> + ) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) +if(USE_MYMATH) + + # does this system provide the log and exp functions? + include(CheckSymbolExists) + set(CMAKE_REQUIRED_LIBRARIES "m") + check_symbol_exists(log "math.h" HAVE_LOG) + check_symbol_exists(exp "math.h" HAVE_EXP) + + # first we add the executable that generates the table + add_executable(MakeTable MakeTable.cxx) + + # add the command to generate the source code + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + + # library that just does sqrt + add_library(SqrtLibrary STATIC + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + + # state that we depend on our binary dir to find Table.h + target_include_directories(SqrtLibrary PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + ) + + set_target_properties(SqrtLibrary PROPERTIES + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} + ) + + target_compile_definitions(SqrtLibrary PRIVATE + "$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>" + "$<$<BOOL:${HAVE_EXP}>:HAVE_EXP>" + ) + target_link_libraries(MathFunctions PRIVATE SqrtLibrary) +endif() + +target_compile_definitions(MathFunctions PRIVATE "$<$<BOOL:${USE_MYMATH}>:USE_MYMATH>") + +# define the symbol stating we are using the declspec(dllexport) when +# building on windows +target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") + +# setup the version numbering +set_property(TARGET MathFunctions PROPERTY VERSION "1.0.0") +set_property(TARGET MathFunctions PROPERTY SOVERSION "1") + +install(TARGETS MathFunctions + DESTINATION lib + EXPORT MathFunctionsTargets) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/MakeTable.cxx b/Tests/Tutorial/MultiPackage/MathFunctions/MakeTable.cxx new file mode 100644 index 0000000000..ee585568cb --- /dev/null +++ b/Tests/Tutorial/MultiPackage/MathFunctions/MakeTable.cxx @@ -0,0 +1,25 @@ +// A simple program that builds a sqrt table +#include <cmath> +#include <fstream> +#include <iostream> + +int main(int argc, char* argv[]) +{ + // make sure we have enough arguments + if (argc < 2) { + return 1; + } + + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); + } + return fileOpen ? 0 : 1; // return 0 if wrote the file +} diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.cxx b/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.cxx new file mode 100644 index 0000000000..5351184be4 --- /dev/null +++ b/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.cxx @@ -0,0 +1,18 @@ + +#include "MathFunctions.h" +#include <cmath> + +#ifdef USE_MYMATH +# include "mysqrt.h" +#endif + +namespace mathfunctions { +double sqrt(double x) +{ +#ifdef USE_MYMATH + return detail::mysqrt(x); +#else + return std::sqrt(x); +#endif +} +} diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.h b/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.h new file mode 100644 index 0000000000..3fb547b4a6 --- /dev/null +++ b/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.h @@ -0,0 +1,14 @@ + +#if defined(_WIN32) +# if defined(EXPORTING_MYMATH) +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC __declspec(dllimport) +# endif +#else // non windows +# define DECLSPEC +#endif + +namespace mathfunctions { +double DECLSPEC sqrt(double x); +} diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.cxx b/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.cxx new file mode 100644 index 0000000000..96d94212db --- /dev/null +++ b/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.cxx @@ -0,0 +1,45 @@ +#include "MathFunctions.h" +#include <iostream> + +// include the generated table +#include "Table.h" + +#include <cmath> + +namespace mathfunctions { +namespace detail { +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) { + return 0; + } + + // if we have both log and exp then use them +#if defined(HAVE_LOG) && defined(HAVE_EXP) + double result = exp(log(x) * 0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" + << std::endl; +#else + // use the table to help find an initial value + double result = x; + if (x >= 1 && x < 10) { + result = sqrtTable[static_cast<int>(x)]; + } + + // if we have both log and exp then use them + + // do ten iterations + for (int i = 0; i < 10; ++i) { + if (result <= 0) { + result = 0.1; + } + double delta = x - (result * result); + result = result + 0.5 * delta / result; + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; + } +#endif + return result; +} +} +} diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.h b/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.h new file mode 100644 index 0000000000..e1c42ef0c2 --- /dev/null +++ b/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.h @@ -0,0 +1,6 @@ + +namespace mathfunctions { +namespace detail { +double mysqrt(double x); +} +} diff --git a/Tests/Tutorial/MultiPackage/MultiCPackConfig.cmake b/Tests/Tutorial/MultiPackage/MultiCPackConfig.cmake new file mode 100644 index 0000000000..403b633e11 --- /dev/null +++ b/Tests/Tutorial/MultiPackage/MultiCPackConfig.cmake @@ -0,0 +1,7 @@ + +include("release/CPackConfig.cmake") + +set(CPACK_INSTALL_CMAKE_PROJECTS + "debug;Tutorial;ALL;/" + "release;Tutorial;ALL;/" + ) diff --git a/Tests/Tutorial/MultiPackage/TutorialConfig.h.in b/Tests/Tutorial/MultiPackage/TutorialConfig.h.in new file mode 100644 index 0000000000..8cd2fc9c63 --- /dev/null +++ b/Tests/Tutorial/MultiPackage/TutorialConfig.h.in @@ -0,0 +1,3 @@ +// the configured version number +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Tests/Tutorial/MultiPackage/directions.txt b/Tests/Tutorial/MultiPackage/directions.txt new file mode 100644 index 0000000000..c3102bb10e --- /dev/null +++ b/Tests/Tutorial/MultiPackage/directions.txt @@ -0,0 +1,34 @@ +# Packaging Debug and Release # + +By default CMake is model is that a build directory only contains a single +configuration, be it Debug, Release, MinSizeRel, or RelWithDebInfo. + +But it is possible to setup CPack to bundle multiple build directories at the same +time to build a package that contains multiple configurations of the same project. + +First we need to ahead and construct a directory called 'multi_config' this +will contain all the builds that we want to package together. + +Second create a 'debug' and 'release' directory underneath 'multi_config'. At +the end you should have a layout that looks like: + +─ multi_config + ├── debug + └── release + +Now we need to setup debug and release builds, which would roughly entail +the following: + + cd debug + cmake -DCMAKE_BUILD_TYPE=Debug ../../MultiPackage/ + cmake --build . + cd ../release + cmake -DCMAKE_BUILD_TYPE=Release ../../MultiPackage/ + cmake --build . + cd .. + + +Now that both the debug and release builds are complete we can now use +the custom MultiCPackConfig to package both builds into a single release. + + cpack --config ../../MultiPackage/MultiCPackConfig.cmake diff --git a/Tests/Tutorial/MultiPackage/tutorial.cxx b/Tests/Tutorial/MultiPackage/tutorial.cxx new file mode 100644 index 0000000000..443d195554 --- /dev/null +++ b/Tests/Tutorial/MultiPackage/tutorial.cxx @@ -0,0 +1,25 @@ +// A simple program that computes the square root of a number +#include <iostream> +#include <sstream> +#include <string> + +#include "MathFunctions.h" +#include "TutorialConfig.h" + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + double inputValue = std::stod(argv[1]); + + const double outputValue = mathfunctions::sqrt(inputValue); + + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; + return 0; +} diff --git a/Tests/Tutorial/Readme.txt b/Tests/Tutorial/Readme.txt new file mode 100644 index 0000000000..74eb01ae53 --- /dev/null +++ b/Tests/Tutorial/Readme.txt @@ -0,0 +1,16 @@ + +Step 0: A Starting Point +Step 1: Configure a File and C++11 Controls +Step 2: Adding a Library +Step 3: Usage Requirements for Library +Step 4: Installing and Testing +Step 5: System Introspection +Step 6: Custom Command and Generated File +Step 7: Building an Installer +Step 8: CDash submission +Step 9: Mixing Static and Shared +Step 10: Generator Expressions +Step 11: Adding Export Configuration +Complete: End result of Step 11 +Consumer: Example of Import Packages +MultiPackage: How to package Debug and Release versions diff --git a/Tests/Tutorial/Step1/CMakeLists.txt b/Tests/Tutorial/Step1/CMakeLists.txt index e461d3c8b3..141f0c27a0 100644 --- a/Tests/Tutorial/Step1/CMakeLists.txt +++ b/Tests/Tutorial/Step1/CMakeLists.txt @@ -1,20 +1,3 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) - -# configure a header file to pass some of the CMake settings -# to the source code -configure_file ( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) - -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories("${PROJECT_BINARY_DIR}") - -# add the executable add_executable(Tutorial tutorial.cxx) diff --git a/Tests/Tutorial/Step1/directions.txt b/Tests/Tutorial/Step1/directions.txt new file mode 100644 index 0000000000..827d7754d5 --- /dev/null +++ b/Tests/Tutorial/Step1/directions.txt @@ -0,0 +1,95 @@ +# Adding a Version Number and Configured Header File # + +The first feature we will add is to provide our executable and project with a +version number. While we could do this exclusively in the source code, using +CMakeLists provides more flexibility. + +To add a version number we modify the CMakeLists file as follows: + + cmake_minimum_required(VERSION 3.3) + project(Tutorial) + + # the version number. + set(Tutorial_VERSION_MAJOR 1) + set(Tutorial_VERSION_MINOR 0) + + # configure a header file to pass some of the CMake settings + # to the source code + configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + + # add the executable + add_executable(Tutorial tutorial.cxx) + + # add the binary tree to the search path for include files + # so that we will find TutorialConfig.h + target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) + + +We then create a TutorialConfig.h.in file in the source tree with the +following contents: + + // the configured options and settings for Tutorial + #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ + #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ + +When CMake configures this header file the values for @Tutorial_VERSION_MAJOR@ +and @Tutorial_VERSION_MINOR@ will be replaced by the values from the CMakeLists +file. Next we modify tutorial.cxx to include the configured header file and to +make use of the version numbers. The resulting source code is listed below. + + // A simple program that computes the square root of a number + #include <cmath> + #include <iostream> + #include <string> + #include <sstream> + + #include "TutorialConfig.h" + + int main (int argc, char *argv[]) + { + if (argc < 2) { + std::cout << argv[0] << " Version " + << Tutorial_VERSION_MAJOR << "." << Tutorial_VERSION_MINOR + << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + double inputValue = atof(argv[1]); + + double outputValue = sqrt(inputValue); + std::cout << "The square root of " + << inputValue << " is " << outputValue << std::endl; + return 0; + } + +# Adding C++11 support # + +Let's add some C++11 features to our project. We will need to explicitly state +in the CMake code that it should use the correct flags. The easiest way to +enable C++11 support for CMake is by using the CMAKE_CXX_STANDARD +and CMAKE_CXX_STANDARD_REQUIRED variables. + +First, replace `atof` with `std::stod` in tutorial.cxx. + +Then, add the CMAKE_CXX_STANDARD and CMAKE_CXX_STANDARD_REQUIRED variables to +the CMakeLists file. The STANADARD value should be set to 11, and REQUIRED +should be set to True. + + +# Build and Test # + +Run cmake or cmake-gui to configure the project and then build it with your +chosen build tool + +cd to the directory where Tutorial was built (likely the make directory or +a Debug or Release build configuration subdirectory) and run these commands: + + Tutorial 4294967296 + Tutorial 10 + Tutorial diff --git a/Tests/Tutorial/Step1/tutorial.cxx b/Tests/Tutorial/Step1/tutorial.cxx index 7a13376cbd..f8dd0c6c81 100644 --- a/Tests/Tutorial/Step1/tutorial.cxx +++ b/Tests/Tutorial/Step1/tutorial.cxx @@ -1,19 +1,20 @@ // A simple program that computes the square root of a number -#include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> +#include <cmath> +#include <cstdlib> +#include <iostream> +#include <string> int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } + double inputValue = atof(argv[1]); + double outputValue = sqrt(inputValue); - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step10/CMakeLists.txt b/Tests/Tutorial/Step10/CMakeLists.txt new file mode 100644 index 0000000000..b1d46c4b9d --- /dev/null +++ b/Tests/Tutorial/Step10/CMakeLists.txt @@ -0,0 +1,77 @@ +cmake_minimum_required(VERSION 3.3) +project(Tutorial) + +# control where the static and shared libraries are built so that on windows +# we don't need to tinker with the path to run the executable +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + +# configure a header file to pass the version number only +configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the MathFunctions library +add_subdirectory(MathFunctions) + +# add the executable +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial MathFunctions) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) + +# add the install targets +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) + +# enable testing +enable_testing() + +# does the application run +add_test(NAME Runs COMMAND Tutorial 25) + +# does the usage message work? +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endfunction(do_test) + +# do a bunch of result based tests +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") + +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +include(CPack) diff --git a/Tests/Tutorial/Step10/License.txt b/Tests/Tutorial/Step10/License.txt new file mode 100644 index 0000000000..c62d00b9ea --- /dev/null +++ b/Tests/Tutorial/Step10/License.txt @@ -0,0 +1,2 @@ +This is the open source License.txt file introduced in +CMake/Tutorial/Step7... diff --git a/Tests/Tutorial/Step10/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step10/MathFunctions/CMakeLists.txt new file mode 100644 index 0000000000..7a23505723 --- /dev/null +++ b/Tests/Tutorial/Step10/MathFunctions/CMakeLists.txt @@ -0,0 +1,61 @@ + +# add the library that runs +add_library(MathFunctions MathFunctions.cxx) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + ) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) +if(USE_MYMATH) + + # does this system provide the log and exp functions? + include(CheckSymbolExists) + set(CMAKE_REQUIRED_LIBRARIES "m") + check_symbol_exists(log "math.h" HAVE_LOG) + check_symbol_exists(exp "math.h" HAVE_EXP) + + # first we add the executable that generates the table + add_executable(MakeTable MakeTable.cxx) + + # add the command to generate the source code + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + + # library that just does sqrt + add_library(SqrtLibrary STATIC + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + + # state that we depend on our binary dir to find Table.h + target_include_directories(SqrtLibrary PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + ) + + # state that SqrtLibrary need PIC when the default is shared libraries + set_target_properties(SqrtLibrary PROPERTIES + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} + ) + + target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") + if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(SqrtLibrary + PRIVATE "HAVE_LOG" "HAVE_EXP") + endif() + + target_link_libraries(MathFunctions PRIVATE SqrtLibrary) +endif() + +# define the symbol stating we are using the declspec(dllexport) when +# building on windows +target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") + +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step10/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step10/MathFunctions/MakeTable.cxx new file mode 100644 index 0000000000..ee585568cb --- /dev/null +++ b/Tests/Tutorial/Step10/MathFunctions/MakeTable.cxx @@ -0,0 +1,25 @@ +// A simple program that builds a sqrt table +#include <cmath> +#include <fstream> +#include <iostream> + +int main(int argc, char* argv[]) +{ + // make sure we have enough arguments + if (argc < 2) { + return 1; + } + + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); + } + return fileOpen ? 0 : 1; // return 0 if wrote the file +} diff --git a/Tests/Tutorial/Step10/MathFunctions/MathFunctions.cxx b/Tests/Tutorial/Step10/MathFunctions/MathFunctions.cxx new file mode 100644 index 0000000000..5351184be4 --- /dev/null +++ b/Tests/Tutorial/Step10/MathFunctions/MathFunctions.cxx @@ -0,0 +1,18 @@ + +#include "MathFunctions.h" +#include <cmath> + +#ifdef USE_MYMATH +# include "mysqrt.h" +#endif + +namespace mathfunctions { +double sqrt(double x) +{ +#ifdef USE_MYMATH + return detail::mysqrt(x); +#else + return std::sqrt(x); +#endif +} +} diff --git a/Tests/Tutorial/Step10/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step10/MathFunctions/MathFunctions.h new file mode 100644 index 0000000000..3fb547b4a6 --- /dev/null +++ b/Tests/Tutorial/Step10/MathFunctions/MathFunctions.h @@ -0,0 +1,14 @@ + +#if defined(_WIN32) +# if defined(EXPORTING_MYMATH) +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC __declspec(dllimport) +# endif +#else // non windows +# define DECLSPEC +#endif + +namespace mathfunctions { +double DECLSPEC sqrt(double x); +} diff --git a/Tests/Tutorial/Step10/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step10/MathFunctions/mysqrt.cxx new file mode 100644 index 0000000000..96d94212db --- /dev/null +++ b/Tests/Tutorial/Step10/MathFunctions/mysqrt.cxx @@ -0,0 +1,45 @@ +#include "MathFunctions.h" +#include <iostream> + +// include the generated table +#include "Table.h" + +#include <cmath> + +namespace mathfunctions { +namespace detail { +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) { + return 0; + } + + // if we have both log and exp then use them +#if defined(HAVE_LOG) && defined(HAVE_EXP) + double result = exp(log(x) * 0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" + << std::endl; +#else + // use the table to help find an initial value + double result = x; + if (x >= 1 && x < 10) { + result = sqrtTable[static_cast<int>(x)]; + } + + // if we have both log and exp then use them + + // do ten iterations + for (int i = 0; i < 10; ++i) { + if (result <= 0) { + result = 0.1; + } + double delta = x - (result * result); + result = result + 0.5 * delta / result; + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; + } +#endif + return result; +} +} +} diff --git a/Tests/Tutorial/Step10/MathFunctions/mysqrt.h b/Tests/Tutorial/Step10/MathFunctions/mysqrt.h new file mode 100644 index 0000000000..e1c42ef0c2 --- /dev/null +++ b/Tests/Tutorial/Step10/MathFunctions/mysqrt.h @@ -0,0 +1,6 @@ + +namespace mathfunctions { +namespace detail { +double mysqrt(double x); +} +} diff --git a/Tests/Tutorial/Step10/TutorialConfig.h.in b/Tests/Tutorial/Step10/TutorialConfig.h.in new file mode 100644 index 0000000000..8cd2fc9c63 --- /dev/null +++ b/Tests/Tutorial/Step10/TutorialConfig.h.in @@ -0,0 +1,3 @@ +// the configured version number +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Tests/Tutorial/Step10/directions.txt b/Tests/Tutorial/Step10/directions.txt new file mode 100644 index 0000000000..5317b5430a --- /dev/null +++ b/Tests/Tutorial/Step10/directions.txt @@ -0,0 +1,38 @@ +# Adding Generator Expressions # + +Generator expressions are evaluated during build system generation to produce +information specific to each build configuration. + +Generator expressions are allowed in the context of many target properties, such +as LINK_LIBRARIES, INCLUDE_DIRECTORIES, COMPILE_DEFINITIONS and others. They may +also be used when using commands to populate those properties, such as +target_link_libraries(), target_include_directories(), +target_compile_definitions() and others. + +Generator expressions may to used to enable conditional linking, conditional +definitions used when compiling, and conditional include directories and more. +The conditions may be based on the build configuration, target properties, +platform information or any other queryable information. + +There are different types of generator expressions including Logical, +Informational, and Output expressions. + +Logical expressions are used to create conditional output. The basic expressions +are the 0 and 1 expressions. A "$<0:...>" results in the empty string, and +"$<1:...>" results in the content of "...". They can also be nested. +For example: + + if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(SqrtLibrary + PRIVATE "HAVE_LOG" "HAVE_EXP") + endif() + +Can be rewritten with generator expressions: + + target_compile_definitions(SqrtLibrary PRIVATE + "$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>" + "$<$<BOOL:${HAVE_EXP}>:HAVE_EXP>" + ) + +Note that "${HAVE_LOG}" is evaluated at CMake configure time while +"$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>" is evaluated at build system generation time. diff --git a/Tests/Tutorial/Step10/tutorial.cxx b/Tests/Tutorial/Step10/tutorial.cxx new file mode 100644 index 0000000000..443d195554 --- /dev/null +++ b/Tests/Tutorial/Step10/tutorial.cxx @@ -0,0 +1,25 @@ +// A simple program that computes the square root of a number +#include <iostream> +#include <sstream> +#include <string> + +#include "MathFunctions.h" +#include "TutorialConfig.h" + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + double inputValue = std::stod(argv[1]); + + const double outputValue = mathfunctions::sqrt(inputValue); + + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; + return 0; +} diff --git a/Tests/Tutorial/Step11/CMakeLists.txt b/Tests/Tutorial/Step11/CMakeLists.txt new file mode 100644 index 0000000000..b1d46c4b9d --- /dev/null +++ b/Tests/Tutorial/Step11/CMakeLists.txt @@ -0,0 +1,77 @@ +cmake_minimum_required(VERSION 3.3) +project(Tutorial) + +# control where the static and shared libraries are built so that on windows +# we don't need to tinker with the path to run the executable +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + +# configure a header file to pass the version number only +configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the MathFunctions library +add_subdirectory(MathFunctions) + +# add the executable +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial MathFunctions) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) + +# add the install targets +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) + +# enable testing +enable_testing() + +# does the application run +add_test(NAME Runs COMMAND Tutorial 25) + +# does the usage message work? +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endfunction(do_test) + +# do a bunch of result based tests +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") + +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +include(CPack) diff --git a/Tests/Tutorial/Step11/License.txt b/Tests/Tutorial/Step11/License.txt new file mode 100644 index 0000000000..c62d00b9ea --- /dev/null +++ b/Tests/Tutorial/Step11/License.txt @@ -0,0 +1,2 @@ +This is the open source License.txt file introduced in +CMake/Tutorial/Step7... diff --git a/Tests/Tutorial/Step11/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step11/MathFunctions/CMakeLists.txt new file mode 100644 index 0000000000..760d6a57ce --- /dev/null +++ b/Tests/Tutorial/Step11/MathFunctions/CMakeLists.txt @@ -0,0 +1,60 @@ + +# add the library that runs +add_library(MathFunctions MathFunctions.cxx) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + ) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) +if(USE_MYMATH) + + # does this system provide the log and exp functions? + include(CheckSymbolExists) + set(CMAKE_REQUIRED_LIBRARIES "m") + check_symbol_exists(log "math.h" HAVE_LOG) + check_symbol_exists(exp "math.h" HAVE_EXP) + + # first we add the executable that generates the table + add_executable(MakeTable MakeTable.cxx) + + # add the command to generate the source code + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + + # library that just does sqrt + add_library(SqrtLibrary STATIC + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + + # state that we depend on our binary dir to find Table.h + target_include_directories(SqrtLibrary PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + ) + + set_target_properties(SqrtLibrary PROPERTIES + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} + ) + + target_compile_definitions(SqrtLibrary PRIVATE + "$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>" + "$<$<BOOL:${HAVE_EXP}>:HAVE_EXP>" + ) + target_link_libraries(MathFunctions PRIVATE SqrtLibrary) +endif() + +target_compile_definitions(MathFunctions PRIVATE "$<$<BOOL:${USE_MYMATH}>:USE_MYMATH>") + +# define the symbol stating we are using the declspec(dllexport) when +#building on windows +target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") + +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step11/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step11/MathFunctions/MakeTable.cxx new file mode 100644 index 0000000000..ee585568cb --- /dev/null +++ b/Tests/Tutorial/Step11/MathFunctions/MakeTable.cxx @@ -0,0 +1,25 @@ +// A simple program that builds a sqrt table +#include <cmath> +#include <fstream> +#include <iostream> + +int main(int argc, char* argv[]) +{ + // make sure we have enough arguments + if (argc < 2) { + return 1; + } + + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); + } + return fileOpen ? 0 : 1; // return 0 if wrote the file +} diff --git a/Tests/Tutorial/Step11/MathFunctions/MathFunctions.cxx b/Tests/Tutorial/Step11/MathFunctions/MathFunctions.cxx new file mode 100644 index 0000000000..5351184be4 --- /dev/null +++ b/Tests/Tutorial/Step11/MathFunctions/MathFunctions.cxx @@ -0,0 +1,18 @@ + +#include "MathFunctions.h" +#include <cmath> + +#ifdef USE_MYMATH +# include "mysqrt.h" +#endif + +namespace mathfunctions { +double sqrt(double x) +{ +#ifdef USE_MYMATH + return detail::mysqrt(x); +#else + return std::sqrt(x); +#endif +} +} diff --git a/Tests/Tutorial/Step11/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step11/MathFunctions/MathFunctions.h new file mode 100644 index 0000000000..3fb547b4a6 --- /dev/null +++ b/Tests/Tutorial/Step11/MathFunctions/MathFunctions.h @@ -0,0 +1,14 @@ + +#if defined(_WIN32) +# if defined(EXPORTING_MYMATH) +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC __declspec(dllimport) +# endif +#else // non windows +# define DECLSPEC +#endif + +namespace mathfunctions { +double DECLSPEC sqrt(double x); +} diff --git a/Tests/Tutorial/Step11/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step11/MathFunctions/mysqrt.cxx new file mode 100644 index 0000000000..96d94212db --- /dev/null +++ b/Tests/Tutorial/Step11/MathFunctions/mysqrt.cxx @@ -0,0 +1,45 @@ +#include "MathFunctions.h" +#include <iostream> + +// include the generated table +#include "Table.h" + +#include <cmath> + +namespace mathfunctions { +namespace detail { +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) { + return 0; + } + + // if we have both log and exp then use them +#if defined(HAVE_LOG) && defined(HAVE_EXP) + double result = exp(log(x) * 0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" + << std::endl; +#else + // use the table to help find an initial value + double result = x; + if (x >= 1 && x < 10) { + result = sqrtTable[static_cast<int>(x)]; + } + + // if we have both log and exp then use them + + // do ten iterations + for (int i = 0; i < 10; ++i) { + if (result <= 0) { + result = 0.1; + } + double delta = x - (result * result); + result = result + 0.5 * delta / result; + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; + } +#endif + return result; +} +} +} diff --git a/Tests/Tutorial/Step11/MathFunctions/mysqrt.h b/Tests/Tutorial/Step11/MathFunctions/mysqrt.h new file mode 100644 index 0000000000..e1c42ef0c2 --- /dev/null +++ b/Tests/Tutorial/Step11/MathFunctions/mysqrt.h @@ -0,0 +1,6 @@ + +namespace mathfunctions { +namespace detail { +double mysqrt(double x); +} +} diff --git a/Tests/Tutorial/Step11/TutorialConfig.h.in b/Tests/Tutorial/Step11/TutorialConfig.h.in new file mode 100644 index 0000000000..8cd2fc9c63 --- /dev/null +++ b/Tests/Tutorial/Step11/TutorialConfig.h.in @@ -0,0 +1,3 @@ +// the configured version number +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Tests/Tutorial/Step11/directions.txt b/Tests/Tutorial/Step11/directions.txt new file mode 100644 index 0000000000..ebb5defff7 --- /dev/null +++ b/Tests/Tutorial/Step11/directions.txt @@ -0,0 +1,104 @@ +# Adding Export Configuration # + +During Step 4 of the tutorial we added the ability for CMake to install the +library and headers of the project. During Step 7 we added the ability +to package up this information so it could be distributed to other people. + +The next step is to add the necessary information so that other CMake projects +can use our project, be it from a build directory, a local install or when +packaged. + +The first step is to update our install(TARGETS) commands to not only specify +a DESTINATION but also an EXPORT. The EXPORT keyword generates and installs a +CMake file containing code to import all targets listed in the install command +from the installation tree. So let's go ahead and explicitly EXPORT the +MathFunctions library by updating the install command in +MathFunctions/CMakeLists.txt to look like: + + install(TARGETS MathFunctions DESTINATION lib EXPORT MathFunctionsTargets) + +Now that we have MathFunctions being exported, we also need to explicitly install +the generated MathFunctionsTargets.cmake file. This is done by adding +the following to the bottom of the top-level CMakeLists.txt: + + # install the configuration targets + install(EXPORT MathFunctionsTargets + FILE MathFunctionsTargets.cmake + DESTINATION lib/cmake/MathFunctions + ) + +At this point you should try and run CMake. If everything is setup properly +you will see that CMake will generate an error that looks like: + + Target "MathFunctions" INTERFACE_INCLUDE_DIRECTORIES property contains + path: + + "/Users/robert/Documents/CMakeClass/Tutorial/Step11/MathFunctions" + + which is prefixed in the source directory. + +What CMake is trying to say is that during generating the export information +it will export a path that is intrinsically tied to the current machine and +will not be valid on other machines. The solution to this is to update the +MathFunctions target_include_directories to understand that it needs different +INTERFACE locations when being used from within the build directory and from an +install / package. This means converting the target_include_directories +call for MathFunctions to look like: + + target_include_directories(MathFunctions + INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + $<INSTALL_INTERFACE:include> + ) + +Once this has been updated, we can re-run CMake and see verify that it doesn't +warn anymore. + +At this point, we have CMake properly packaging the target information that is +required but we will still need to generate a MathFunctionsConfig.cmake, so +that the CMake find_package command can find our project. So let's go ahead and +add a new file to the top-level of the project called Config.cmake.in with the +following contents: + + @PACKAGE_INIT@ + + include ( "${CMAKE_CURRENT_LIST_DIR}/MathFunctionsTargets.cmake" ) + +Then, to properly configure and install that file, add the following to the +bottom of the top-level CMakeLists: + + include(CMakePackageConfigHelpers) + # generate the config file that is includes the exports + configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" + INSTALL_DESTINATION "lib/cmake/example" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) + # generate the version file for the config file + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" + VERSION "${Tutorial_VERSION_MAJOR}.${Tutorial_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion + ) + + # install the configuration file + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake + DESTINATION lib/cmake/MathFunctions + ) + +At this point, we have generated a relocatable CMake Configuration for our project +that can be used after the project has been installed or packaged. If we want +our project to also be used from a build directory we only have to add +the following to the bottom of the top level CMakeLists: + + # generate the export targets for the build tree + # needs to be after the install(TARGETS ) command + export(EXPORT MathFunctionsTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsTargets.cmake" + ) + +With this export call we now generate a Targets.cmake, allowing the configured +MathFunctionsConfig.cmake in the build directory to be used by other projects, +without needing it to be installed. diff --git a/Tests/Tutorial/Step11/tutorial.cxx b/Tests/Tutorial/Step11/tutorial.cxx new file mode 100644 index 0000000000..3768855269 --- /dev/null +++ b/Tests/Tutorial/Step11/tutorial.cxx @@ -0,0 +1,25 @@ +// A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + +#include "MathFunctions.h" +#include "TutorialConfig.h" + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + double inputValue = std::stod(argv[1]); + + const double outputValue = mathfunctions::sqrt(inputValue); + + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; + return 0; +} diff --git a/Tests/Tutorial/Step2/CMakeLists.txt b/Tests/Tutorial/Step2/CMakeLists.txt index cf1d30ee29..48afaa327f 100644 --- a/Tests/Tutorial/Step2/CMakeLists.txt +++ b/Tests/Tutorial/Step2/CMakeLists.txt @@ -1,31 +1,25 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) -# should we use our own math functions -option(USE_MYMATH "Use tutorial provided math implementation" ON) +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) +# add the executable +add_executable(Tutorial tutorial.cxx) + # add the binary tree to the search path for include files # so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - -# add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () - -# add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) diff --git a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx index 2710f92205..7d9379e43e 100644 --- a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx @@ -1,5 +1,5 @@ #include "MathFunctions.h" -#include <stdio.h> +#include <iostream> // a hack square root calculation using simple operations double mysqrt(double x) @@ -8,19 +8,16 @@ double mysqrt(double x) return 0; } - double result; - double delta; - result = x; + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } return result; } diff --git a/Tests/Tutorial/Step2/TutorialConfig.h.in b/Tests/Tutorial/Step2/TutorialConfig.h.in index 25a06020ac..5395a06710 100644 --- a/Tests/Tutorial/Step2/TutorialConfig.h.in +++ b/Tests/Tutorial/Step2/TutorialConfig.h.in @@ -1,5 +1,4 @@ // the configured options and settings for Tutorial #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ -#cmakedefine USE_MYMATH diff --git a/Tests/Tutorial/Step2/directions.txt b/Tests/Tutorial/Step2/directions.txt new file mode 100644 index 0000000000..bb6662c7e6 --- /dev/null +++ b/Tests/Tutorial/Step2/directions.txt @@ -0,0 +1,102 @@ +# Adding a Library # + +Now we will add a library to our project. This library will contain our own +implementation for computing the square root of a number. The executable can +then use this library instead of the standard square root function provided by +the compiler. + +For this tutorial we will put the library into a subdirectory +called MathFunctions. It will have the following one line CMakeLists file: + + add_library(MathFunctions mysqrt.cxx) + +The source file mysqrt.cxx has one function called mysqrt that provides similar +functionality to the compiler’s sqrt function. To make use of the new library +we add an add_subdirectory call in the top-level CMakeLists file so that the +library will get built. We add the new library to the executable, and add the +MathFunctions as an include directory so that mqsqrt.h header file can be +found. The last few lines of the top-level CMakeLists file now look like: + + + add_subdirectory(MathFunctions) + + #add the executable + add_executable(Tutorial tutorial.cxx) + + target_link_libraries(Tutorial ${EXTRA_LIBS}) + + +Now let us make the MathFunctions library optional. While for the tutorial +there really isn’t any need to do so, but with larger projects this is a common +occurrence. The first step is to add an option to the top-level CMakeLists file. + + option (USE_MYMATH + "Use tutorial provided math implementation" ON) + +This will show up in CMake GUI and ccmake with a default value of ON that can +be changed by the user. This setting will be stored so that the user does not +need to set the value each time they run CMake on this build directory. + +The next change is to make building and linking the MathFunctions library +conditional. To do this we change the top-level CMakeLists file to look like +the following: + + cmake_minimum_required(VERSION 3.3) + project(Tutorial) + + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED True) + + # the version number. + set(Tutorial_VERSION_MAJOR 1) + set(Tutorial_VERSION_MINOR 0) + + # configure a header file to pass some of the CMake settings + # to the source code + configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + + # should we use our own math functions + option(USE_MYMATH "Use tutorial provided math implementation" ON) + + # add the MathFunctions library? + if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) + list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions") + endif(USE_MYMATH) + + # add the executable + add_executable(Tutorial tutorial.cxx) + + target_link_libraries(Tutorial ${EXTRA_LIBS}) + + # add the binary tree to the search path for include files + # so that we will find TutorialConfig.h + target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ${EXTRA_INCLUDES} + ) + +Note the use of the variables EXTRA_LIBS, and EXTRA_INCLUDES to collect +up any optional libraries to later be linked into the executable. This is a +classic approach when dealing with many optional components, we will cover the +modern approach in the next step. For now the corresponding changes to the +source code are fairly straightforward and leave us with: + + #ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); + #else + double outputValue = sqrt(inputValue); + #endif + +Since the source code now requires USE_MYMATH we can add it to the +TutorialConfig.h.in. Simply add the following line: + #cmakedefine USE_MYMATH + +Run cmake or cmake-gui to configure the project and then build it with your +chosen build tool and then run the built Tutorial executable. + +Which function gives better results, Step1’s sqrt or Step2’s mysqrt? diff --git a/Tests/Tutorial/Step2/tutorial.cxx b/Tests/Tutorial/Step2/tutorial.cxx index 37f6ac4567..75b7d67b04 100644 --- a/Tests/Tutorial/Step2/tutorial.cxx +++ b/Tests/Tutorial/Step2/tutorial.cxx @@ -1,33 +1,23 @@ // A simple program that computes the square root of a number -#include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> +#include <cmath> +#include <iostream> +#include <string> -#ifdef USE_MYMATH -# include "MathFunctions.h" -#endif +#include "TutorialConfig.h" int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; - - if (inputValue >= 0) { -#ifdef USE_MYMATH - outputValue = mysqrt(inputValue); -#else - outputValue = sqrt(inputValue); -#endif - } + double inputValue = std::stod(argv[1]); - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + double outputValue = sqrt(inputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step3/CMakeLists.txt b/Tests/Tutorial/Step3/CMakeLists.txt index 762302bc57..f904ea7486 100644 --- a/Tests/Tutorial/Step3/CMakeLists.txt +++ b/Tests/Tutorial/Step3/CMakeLists.txt @@ -1,68 +1,38 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) + list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions") +endif(USE_MYMATH) # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) - -# add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) - - -# enable testing -enable_testing () - -# does the application run -add_test (TutorialRuns Tutorial 25) +add_executable(Tutorial tutorial.cxx) -# does it sqrt of 25 -add_test (TutorialComp25 Tutorial 25) -set_tests_properties (TutorialComp25 - PROPERTIES PASS_REGULAR_EXPRESSION "25 is 5" - ) - -# does it handle negative numbers -add_test (TutorialNegative Tutorial -25) -set_tests_properties (TutorialNegative - PROPERTIES PASS_REGULAR_EXPRESSION "-25 is 0" - ) - -# does it handle small numbers -add_test (TutorialSmall Tutorial 0.0001) -set_tests_properties (TutorialSmall - PROPERTIES PASS_REGULAR_EXPRESSION "0.0001 is 0.01" - ) +target_link_libraries(Tutorial ${EXTRA_LIBS}) -# does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" - ) +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ${EXTRA_INCLUDES} + ) diff --git a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt index f386036c3a..8b443a6599 100644 --- a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt @@ -1,4 +1 @@ add_library(MathFunctions mysqrt.cxx) - -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx index 2710f92205..7d9379e43e 100644 --- a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx @@ -1,5 +1,5 @@ #include "MathFunctions.h" -#include <stdio.h> +#include <iostream> // a hack square root calculation using simple operations double mysqrt(double x) @@ -8,19 +8,16 @@ double mysqrt(double x) return 0; } - double result; - double delta; - result = x; + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } return result; } diff --git a/Tests/Tutorial/Step3/directions.txt b/Tests/Tutorial/Step3/directions.txt new file mode 100644 index 0000000000..54d0318063 --- /dev/null +++ b/Tests/Tutorial/Step3/directions.txt @@ -0,0 +1,26 @@ +# Adding Usage Requirements for Library # + +Usage requirements allow for far better control over a library / executable's +link and include line. While also giving more control over the transitive +property of targets inside CMake. The primary commands that leverage usage +requirements are: + + - target_compile_definitions + - target_compile_options + - target_include_directories + - target_link_libraries + +First up is MathFunctions. We first state that anybody linking to MathFunctions +needs to include the current source directory, while MathFunctions itself +doesn't. So this can become an INTERFACE usage requirement. + +Remember INTERFACE means things that consumers require but the producer doesn't. + + target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + +Now that we've specified usage requirements for MathFunctions we can safely remove +our uses of the EXTRA_INCLUDES variable. + +Run cmake or cmake-gui to configure the project and then build it with your +chosen build tool. diff --git a/Tests/Tutorial/Step3/tutorial.cxx b/Tests/Tutorial/Step3/tutorial.cxx index 37f6ac4567..1d5742d2d1 100644 --- a/Tests/Tutorial/Step3/tutorial.cxx +++ b/Tests/Tutorial/Step3/tutorial.cxx @@ -1,8 +1,9 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH # include "MathFunctions.h" @@ -11,23 +12,21 @@ int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step4/CMakeLists.txt b/Tests/Tutorial/Step4/CMakeLists.txt index 6994aa1ceb..34eab55581 100644 --- a/Tests/Tutorial/Step4/CMakeLists.txt +++ b/Tests/Tutorial/Step4/CMakeLists.txt @@ -1,68 +1,36 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) - -# does this system provide the log and exp functions? -include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -check_function_exists (log HAVE_LOG) -check_function_exists (exp HAVE_EXP) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif(USE_MYMATH) # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) - -# add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) - -# enable testing -enable_testing () +add_executable(Tutorial tutorial.cxx) -# does the application run -add_test (TutorialRuns Tutorial 25) - -# does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" - ) - -#define a macro to simplify adding tests -macro (do_test arg result) - add_test (TutorialComp${arg} Tutorial ${arg}) - set_tests_properties (TutorialComp${arg} - PROPERTIES PASS_REGULAR_EXPRESSION ${result} - ) -endmacro () - -# do a bunch of result based tests -do_test (25 "25 is 5") -do_test (-25 "-25 is 0") -do_test (0.0001 "0.0001 is 0.01") +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) diff --git a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt index f386036c3a..0515852a0c 100644 --- a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt @@ -1,4 +1,7 @@ add_library(MathFunctions mysqrt.cxx) -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + ) diff --git a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx index 6ca264f765..7d9379e43e 100644 --- a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx @@ -1,8 +1,5 @@ #include "MathFunctions.h" -#include "TutorialConfig.h" -#include <stdio.h> - -#include <math.h> +#include <iostream> // a hack square root calculation using simple operations double mysqrt(double x) @@ -11,26 +8,16 @@ double mysqrt(double x) return 0; } - double result; - -// if we have both log and exp then use them -#if defined(HAVE_LOG) && defined(HAVE_EXP) - result = exp(log(x) * 0.5); - fprintf(stdout, "Computing sqrt of %g to be %g using log\n", x, result); -#else - double delta; - result = x; + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } -#endif return result; } diff --git a/Tests/Tutorial/Step4/TutorialConfig.h.in b/Tests/Tutorial/Step4/TutorialConfig.h.in index a0912656a6..25a06020ac 100644 --- a/Tests/Tutorial/Step4/TutorialConfig.h.in +++ b/Tests/Tutorial/Step4/TutorialConfig.h.in @@ -3,7 +3,3 @@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH -// does the platform provide exp and log functions? -#cmakedefine HAVE_LOG -#cmakedefine HAVE_EXP - diff --git a/Tests/Tutorial/Step4/directions.txt b/Tests/Tutorial/Step4/directions.txt new file mode 100644 index 0000000000..91e4043da2 --- /dev/null +++ b/Tests/Tutorial/Step4/directions.txt @@ -0,0 +1,72 @@ +# Installing and Testing # + +Now we can start adding testing support and install rules to our project. + +The install rules are fairly simple; for MathFunctions we install the library +and header file, for the application we install the executable and configured +header. + +So to MathFunctions/CMakeLists.txt we add: + + install (TARGETS MathFunctions DESTINATION bin) + install (FILES MathFunctions.h DESTINATION include) + +And the to top-level CMakeLists.txt we add: + + install(TARGETS Tutorial DESTINATION bin) + install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) + +That is all that is needed to create a basic local install of the tutorial. + +Run cmake or cmake-gui to configure the project and then build it with your +chosen build tool. Then build the “install” target by typing 'make install' +from the command line or build the INSTALL target from an IDE. This will +install the appropriate header files, libraries, and executables. + +Verify that the installed Tutorial runs. Note: The CMake variable +CMAKE_INSTALL_PREFIX is used to determine the root of where the files will +be installed. + +Next let's test our application. Adding testing is an easy process. At the +end of the top-level CMakeLists file we can add a number of basic tests to +verify that the application is working correctly. + + # enable testing + enable_testing() + + # does the application run + add_test(NAME Runs COMMAND Tutorial 25) + + # does the usage message work? + add_test(NAME Usage COMMAND Tutorial) + set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + + # define a function to simplify adding tests + function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) + endfunction(do_test) + + # do a bunch of result based tests + do_test(Tutorial 25 "25 is 5") + do_test(Tutorial -25 "-25 is [-nan|nan|0]") + do_test(Tutorial 0.0001 "0.0001 is 0.01") + +The first test simply verifies that the application runs, does not segfault or +otherwise crash, and has a zero return value. This is the basic form of a CTest +test. + +The Usage test uses a regular expression to verify that the usage message +is printed when an incorrect number of arguments are provided. + +Lastly, we have a function called do_test that simplifies running the +application and verifying that the computed square root is correct for given +input. + +To run tests, cd to the binary directory and run “ctest -N” and “ctest -VV”. diff --git a/Tests/Tutorial/Step4/tutorial.cxx b/Tests/Tutorial/Step4/tutorial.cxx index 37f6ac4567..1d5742d2d1 100644 --- a/Tests/Tutorial/Step4/tutorial.cxx +++ b/Tests/Tutorial/Step4/tutorial.cxx @@ -1,8 +1,9 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH # include "MathFunctions.h" @@ -11,23 +12,21 @@ int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step5/CMakeLists.txt b/Tests/Tutorial/Step5/CMakeLists.txt index e40b676b49..63e5410564 100644 --- a/Tests/Tutorial/Step5/CMakeLists.txt +++ b/Tests/Tutorial/Step5/CMakeLists.txt @@ -1,72 +1,70 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) - -# does this system provide the log and exp functions? -include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -check_function_exists (log HAVE_LOG) -check_function_exists (exp HAVE_EXP) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif() # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) # add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) # enable testing -enable_testing () +enable_testing() # does the application run -add_test (TutorialRuns Tutorial 25) +add_test(NAME Runs COMMAND Tutorial 25) # does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" ) -#define a macro to simplify adding tests -macro (do_test arg result) - add_test (TutorialComp${arg} Tutorial ${arg}) - set_tests_properties (TutorialComp${arg} +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} PROPERTIES PASS_REGULAR_EXPRESSION ${result} ) -endmacro () +endfunction(do_test) # do a bunch of result based tests -do_test (4 "4 is 2") -do_test (9 "9 is 3") -do_test (5 "5 is 2.236") -do_test (7 "7 is 2.645") -do_test (25 "25 is 5") -do_test (-25 "-25 is 0") -do_test (0.0001 "0.0001 is 0.01") - +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt index 453a46332e..11cf4127b5 100644 --- a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt @@ -1,17 +1,10 @@ -# first we add the executable that generates the table -# add the binary tree directory to the search path for include files -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +add_library(MathFunctions mysqrt.cxx) -add_executable(MakeTable MakeTable.cxx ) -# add the command to generate the source code -add_custom_command ( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h - COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h - DEPENDS MakeTable - ) +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + ) -# add the main library -add_library(MathFunctions mysqrt.cxx ${CMAKE_CURRENT_BINARY_DIR}/Table.h ) - -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx index cebd50fcc1..ee585568cb 100644 --- a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx +++ b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx @@ -1,32 +1,25 @@ // A simple program that builds a sqrt table -#include <math.h> -#include <stdio.h> +#include <cmath> +#include <fstream> +#include <iostream> int main(int argc, char* argv[]) { - int i; - double result; - // make sure we have enough arguments if (argc < 2) { return 1; } - // open the output file - FILE* fout = fopen(argv[1], "w"); - if (!fout) { - return 1; + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); } - - // create a source file with a table of square roots - fprintf(fout, "double sqrtTable[] = {\n"); - for (i = 0; i < 10; ++i) { - result = sqrt(static_cast<double>(i)); - fprintf(fout, "%g,\n", result); - } - - // close the table with a zero - fprintf(fout, "0};\n"); - fclose(fout); - return 0; + return fileOpen ? 0 : 1; // return 0 if wrote the file } diff --git a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx index 458ed63a15..7d9379e43e 100644 --- a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx @@ -1,11 +1,5 @@ #include "MathFunctions.h" -#include "TutorialConfig.h" -#include <stdio.h> - -// include the generated table -#include "Table.h" - -#include <math.h> +#include <iostream> // a hack square root calculation using simple operations double mysqrt(double x) @@ -14,27 +8,16 @@ double mysqrt(double x) return 0; } - double result; - - // if we have both log and exp then use them - double delta; - - // use the table to help find an initial value - result = x; - if (x >= 1 && x < 10) { - result = sqrtTable[static_cast<int>(x)]; - } + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } - return result; } diff --git a/Tests/Tutorial/Step5/TutorialConfig.h.in b/Tests/Tutorial/Step5/TutorialConfig.h.in index a0912656a6..25a06020ac 100644 --- a/Tests/Tutorial/Step5/TutorialConfig.h.in +++ b/Tests/Tutorial/Step5/TutorialConfig.h.in @@ -3,7 +3,3 @@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH -// does the platform provide exp and log functions? -#cmakedefine HAVE_LOG -#cmakedefine HAVE_EXP - diff --git a/Tests/Tutorial/Step5/directions.txt b/Tests/Tutorial/Step5/directions.txt new file mode 100644 index 0000000000..e6f51975cd --- /dev/null +++ b/Tests/Tutorial/Step5/directions.txt @@ -0,0 +1,69 @@ +# Adding System Introspection # + +Let us consider adding some code to our project that depends on features the +target platform may not have. For this example, we will add some code that +depends on whether or not the target platform has the log and exp functions. Of +course almost every platform has these functions but for this tutorial assume +that they are not common. + +If the platform has log and exp then we will use them to compute the square +root in the mysqrt function. We first test for the availability of these +functions using the CheckSymbolExists.cmake macro in the top-level CMakeLists +file as follows: + + # does this system provide the log and exp functions? + include(CheckSymbolExists) + set(CMAKE_REQUIRED_LIBRARIES "m") + check_symbol_exists(log "math.h" HAVE_LOG) + check_symbol_exists(exp "math.h" HAVE_EXP) + +Now let's add these defines to TutorialConfig.h.in so that we can use them +from mysqrt.cxx: + + // does the platform provide exp and log functions? + #cmakedefine HAVE_LOG + #cmakedefine HAVE_EXP + +Modify mysqrt.cxx to include math.h. Next, in the mysqrt function we can +provide an alternate implementation based on log and exp if they are available +on the system using the following code: + + // if we have both log and exp then use them + #if defined(HAVE_LOG) && defined (HAVE_EXP) + double result = exp(log(x)*0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" << std::endl; + #else + ... + +Run cmake or cmake-gui to configure the project and then build it with your +chosen build tool. + +You will notice that even though HAVE_LOG and HAVE_EXP are both defined mysqrt +isn't using them. We should realize quickly that we have forgotten to include +TutorialConfig.h in mysqrt.cxx. We will also need to update +MathFunctions/CMakeLists.txt with where it is located. + +So let's go ahead and update MathFunctions/CMakeLists.txt to look like: + + add_library(MathFunctions mysqrt.cxx) + + target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${Tutorial_BINARY_DIR} + ) + + install(TARGETS MathFunctions DESTINATION lib) + install(FILES MathFunctions.h DESTINATION include) + +Now all we need to do is include TutorialConfig.h in mysqrt.cxx + +At this point you should go ahead and build the project again. + +Run the built Tutorial executable. Which function gives better results now, +Step1’s sqrt or Step5’s mysqrt? + +Exercise: Why is it important that we configure TutorialConfig.h.in after the +checks for HAVE_LOG and HAVE_EXP? What would happen if we inverted the two? + +Exercise: Is there a better place for us to save the HAVE_LOG and HAVE_EXP +values other than in TutorialConfig.h? diff --git a/Tests/Tutorial/Step5/tutorial.cxx b/Tests/Tutorial/Step5/tutorial.cxx index 37f6ac4567..1d5742d2d1 100644 --- a/Tests/Tutorial/Step5/tutorial.cxx +++ b/Tests/Tutorial/Step5/tutorial.cxx @@ -1,8 +1,9 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH # include "MathFunctions.h" @@ -11,23 +12,21 @@ int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step6/CMakeLists.txt b/Tests/Tutorial/Step6/CMakeLists.txt index 0fb7cac5f7..503a312905 100644 --- a/Tests/Tutorial/Step6/CMakeLists.txt +++ b/Tests/Tutorial/Step6/CMakeLists.txt @@ -1,78 +1,76 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) # does this system provide the log and exp functions? -include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -check_function_exists (log HAVE_LOG) -check_function_exists (exp HAVE_EXP) +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif() # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) # add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) # enable testing -enable_testing () +enable_testing() # does the application run -add_test (TutorialRuns Tutorial 25) +add_test(NAME Runs COMMAND Tutorial 25) # does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" ) -#define a macro to simplify adding tests -macro (do_test arg result) - add_test (TutorialComp${arg} Tutorial ${arg}) - set_tests_properties (TutorialComp${arg} +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} PROPERTIES PASS_REGULAR_EXPRESSION ${result} ) -endmacro () +endfunction(do_test) # do a bunch of result based tests -do_test (4 "4 is 2") -do_test (9 "9 is 3") -do_test (5 "5 is 2.236") -do_test (7 "7 is 2.645") -do_test (25 "25 is 5") -do_test (-25 "-25 is 0") -do_test (0.0001 "0.0001 is 0.01") - -# build a CPack driven installer package -include (InstallRequiredSystemLibraries) -set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") -set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") -set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") -include (CPack) +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt index 70a35f662e..2946075f1f 100644 --- a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt @@ -1,24 +1,14 @@ -# first we add the executable that generates the table -add_executable(MakeTable MakeTable.cxx) - -# add the command to generate the source code -add_custom_command ( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h - DEPENDS MakeTable - COMMAND MakeTable - ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h - ) - -set_source_files_properties ( - mysqrt.cxx PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h - ) +add_library(MathFunctions mysqrt.cxx) -# add the binary tree directory to the search path for include files -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the +# TutorialConfig.h include is an implementation detail -# add the main library -add_library(MathFunctions mysqrt.cxx) +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${Tutorial_BINARY_DIR} + ) -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx index cebd50fcc1..ee585568cb 100644 --- a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx +++ b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx @@ -1,32 +1,25 @@ // A simple program that builds a sqrt table -#include <math.h> -#include <stdio.h> +#include <cmath> +#include <fstream> +#include <iostream> int main(int argc, char* argv[]) { - int i; - double result; - // make sure we have enough arguments if (argc < 2) { return 1; } - // open the output file - FILE* fout = fopen(argv[1], "w"); - if (!fout) { - return 1; + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); } - - // create a source file with a table of square roots - fprintf(fout, "double sqrtTable[] = {\n"); - for (i = 0; i < 10; ++i) { - result = sqrt(static_cast<double>(i)); - fprintf(fout, "%g,\n", result); - } - - // close the table with a zero - fprintf(fout, "0};\n"); - fclose(fout); - return 0; + return fileOpen ? 0 : 1; // return 0 if wrote the file } diff --git a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx index 458ed63a15..b9ad20a848 100644 --- a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx @@ -1,11 +1,8 @@ #include "MathFunctions.h" #include "TutorialConfig.h" -#include <stdio.h> +#include <iostream> -// include the generated table -#include "Table.h" - -#include <math.h> +#include <cmath> // a hack square root calculation using simple operations double mysqrt(double x) @@ -14,27 +11,23 @@ double mysqrt(double x) return 0; } - double result; - // if we have both log and exp then use them - double delta; - - // use the table to help find an initial value - result = x; - if (x >= 1 && x < 10) { - result = sqrtTable[static_cast<int>(x)]; - } +#if defined(HAVE_LOG) && defined(HAVE_EXP) + double result = exp(log(x) * 0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" + << std::endl; +#else + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } - +#endif return result; } diff --git a/Tests/Tutorial/Step6/directions.txt b/Tests/Tutorial/Step6/directions.txt new file mode 100644 index 0000000000..42b9f06df8 --- /dev/null +++ b/Tests/Tutorial/Step6/directions.txt @@ -0,0 +1,104 @@ +# Adding a Custom Command and Generated File # + +In this section we will show how you can add a generated source file into the +build process of an application. For this example, we will create a table of +precomputed square roots as part of the build process, and then compile that +table into our application. + +To accomplish this, we first need a program that will generate the table. In the +MathFunctions subdirectory a new source file named MakeTable.cxx will do just that. + + // A simple program that builds a sqrt table + #include <iostream> + #include <fstream> + #include <cmath> + + int main (int argc, char *argv[]) + { + // make sure we have enough arguments + if (argc < 2) { + return 1; + } + + std::ofstream fout(argv[1],std::ios_base::out); + const bool fileOpen = fout.is_open(); + if(fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); + } + return fileOpen ? 0 : 1; // return 0 if wrote the file + } + +Note that the table is produced as valid C++ code and that the output filename +is passed in as an argument. + +The next step is to add the appropriate commands to MathFunctions’ CMakeLists +file to build the MakeTable executable and then run it as part of the build +process. A few commands are needed to accomplish this, as shown below: + + # first we add the executable that generates the table + add_executable(MakeTable MakeTable.cxx) + + # add the command to generate the source code + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + + # add the main library + add_library(MathFunctions + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + + target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC ${Tutorial_BINARY_DIR} + # add the binary tree directory to the search path for include files + ${CMAKE_CURRENT_BINARY_DIR} + ) + + install(TARGETS MathFunctions DESTINATION lib) + install(FILES MathFunctions.h DESTINATION include) + +First, the executable for MakeTable is added as any other executable would be +added. Then we add a custom command that specifies how to produce Table.h by +running MakeTable. Next we have to let CMake know that mysqrt.cxx depends on +the generated file Table.h. This is done by adding the generated Table.h to the +list of sources for the library MathFunctions. We also have to add the current +binary directory to the list of include directories so that Table.h can be +found and included by mysqrt.cxx. + +Now let's use the generated table. First, modify mysqrt.cxx to include Table.h. +Next, we can rewrite the mysqrt function to use the table: + + if (x <= 0) { + return 0; + } + + // use the table to help find an initial value + double result = x; + if (x >= 1 && x < 10) { + result = sqrtTable[static_cast<int>(x)]; + } + + // do ten iterations + for (int i = 0; i < 10; ++i) { + if (result <= 0) { + result = 0.1; + } + double delta = x - (result*result); + result = result + 0.5*delta/result; + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; + } + +Run cmake or cmake-gui to configure the project and then build it with your +chosen build tool. When this project is built it will first build the MakeTable +executable. It will then run MakeTable to produce Table.h. Finally, it will +compile mysqrt.cxx which includes Table.h to produce the MathFunctions library. diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Tests/Tutorial/Step6/tutorial.cxx index 37f6ac4567..1d5742d2d1 100644 --- a/Tests/Tutorial/Step6/tutorial.cxx +++ b/Tests/Tutorial/Step6/tutorial.cxx @@ -1,8 +1,9 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH # include "MathFunctions.h" @@ -11,23 +12,21 @@ int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step7/CMakeLists.txt b/Tests/Tutorial/Step7/CMakeLists.txt index d9a92fbef0..f2d3839b70 100644 --- a/Tests/Tutorial/Step7/CMakeLists.txt +++ b/Tests/Tutorial/Step7/CMakeLists.txt @@ -1,82 +1,76 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) # does this system provide the log and exp functions? -include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -check_function_exists (log HAVE_LOG) -check_function_exists (exp HAVE_EXP) +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif(USE_MYMATH) # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) # add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) # enable testing -enable_testing () +enable_testing() # does the application run -add_test (TutorialRuns Tutorial 25) +add_test(NAME Runs COMMAND Tutorial 25) # does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" ) -#define a macro to simplify adding tests -macro (do_test arg result) - add_test (TutorialComp${arg} Tutorial ${arg}) - set_tests_properties (TutorialComp${arg} +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} PROPERTIES PASS_REGULAR_EXPRESSION ${result} ) -endmacro () +endfunction(do_test) # do a bunch of result based tests -do_test (4 "4 is 2") -do_test (9 "9 is 3") -do_test (5 "5 is 2.236") -do_test (7 "7 is 2.645") -do_test (25 "25 is 5") -do_test (-25 "-25 is 0") -do_test (0.0001 "0.0001 is 0.01") - -# build a CPack driven installer package -include (InstallRequiredSystemLibraries) -set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") -set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") -set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") -set (CPACK_PACKAGE_CONTACT "foo@bar.org") -include (CPack) - -# enable dashboard scripting -include (CTest) +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Tests/Tutorial/Step7/License.txt b/Tests/Tutorial/Step7/License.txt index 673d724537..c62d00b9ea 100644 --- a/Tests/Tutorial/Step7/License.txt +++ b/Tests/Tutorial/Step7/License.txt @@ -1,2 +1,2 @@ This is the open source License.txt file introduced in -CMake/Tests/Tutorial/Step6... +CMake/Tutorial/Step7... diff --git a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt index 70a35f662e..dc3eb9822a 100644 --- a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt @@ -2,23 +2,28 @@ add_executable(MakeTable MakeTable.cxx) # add the command to generate the source code -add_custom_command ( +add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h DEPENDS MakeTable - COMMAND MakeTable - ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h ) -set_source_files_properties ( - mysqrt.cxx PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h - ) - -# add the binary tree directory to the search path for include files -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) - # add the main library -add_library(MathFunctions mysqrt.cxx) +add_library(MathFunctions + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the +# TutorialConfig.h include is an implementation detail +# state that we depend on our binary dir to find Table.h +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${Tutorial_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx index cebd50fcc1..ee585568cb 100644 --- a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx +++ b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx @@ -1,32 +1,25 @@ // A simple program that builds a sqrt table -#include <math.h> -#include <stdio.h> +#include <cmath> +#include <fstream> +#include <iostream> int main(int argc, char* argv[]) { - int i; - double result; - // make sure we have enough arguments if (argc < 2) { return 1; } - // open the output file - FILE* fout = fopen(argv[1], "w"); - if (!fout) { - return 1; + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); } - - // create a source file with a table of square roots - fprintf(fout, "double sqrtTable[] = {\n"); - for (i = 0; i < 10; ++i) { - result = sqrt(static_cast<double>(i)); - fprintf(fout, "%g,\n", result); - } - - // close the table with a zero - fprintf(fout, "0};\n"); - fclose(fout); - return 0; + return fileOpen ? 0 : 1; // return 0 if wrote the file } diff --git a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx index 458ed63a15..5272f56f22 100644 --- a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx @@ -1,11 +1,11 @@ #include "MathFunctions.h" #include "TutorialConfig.h" -#include <stdio.h> +#include <iostream> // include the generated table #include "Table.h" -#include <math.h> +#include <cmath> // a hack square root calculation using simple operations double mysqrt(double x) @@ -14,26 +14,20 @@ double mysqrt(double x) return 0; } - double result; - - // if we have both log and exp then use them - double delta; - // use the table to help find an initial value - result = x; + double result = x; if (x >= 1 && x < 10) { result = sqrtTable[static_cast<int>(x)]; } // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } return result; diff --git a/Tests/Tutorial/Step7/directions.txt b/Tests/Tutorial/Step7/directions.txt new file mode 100644 index 0000000000..7d7c2eacde --- /dev/null +++ b/Tests/Tutorial/Step7/directions.txt @@ -0,0 +1,40 @@ +# Building an Installer # + +Next suppose that we want to distribute our project to other people so that they +can use it. We want to provide both binary and source distributions on a variety +of platforms. This is a little different from the install we did previously in +the Installing and Testing section (Step 4), where we were installing the +binaries that we had built from the source code. In this example we will be +building installation packages that support binary installations and package +management features. To accomplish this we will use CPack to create platform +specific installers. Specifically we need to add a few lines to the bottom of +our top-level CMakeLists.txt file. + + include(InstallRequiredSystemLibraries) + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") + set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") + set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") + include(CPack) + +That is all there is to it. We start by including InstallRequiredSystemLibraries. +This module will include any runtime libraries that are needed by the project +for the current platform. Next we set some CPack variables to where we have +stored the license and version information for this project. The version +information makes use of the variables we set earlier in this tutorial. Finally +we include the CPack module which will use these variables and some other +properties of the system you are on to setup an installer. + +The next step is to build the project in the usual manner and then run CPack +on it. To build a binary distribution you would run: + + cpack + +To create a source distribution you would type: + + cpack -C CPackSourceConfig.cmake + +Alternatively, run “make package” or right click the Package target and +“Build Project” from an IDE. + +Run the installer executable found in the binary directory. Then run the +installed executable and verify that it works. diff --git a/Tests/Tutorial/Step7/tutorial.cxx b/Tests/Tutorial/Step7/tutorial.cxx index 37f6ac4567..1d5742d2d1 100644 --- a/Tests/Tutorial/Step7/tutorial.cxx +++ b/Tests/Tutorial/Step7/tutorial.cxx @@ -1,8 +1,9 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH # include "MathFunctions.h" @@ -11,23 +12,21 @@ int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step8/CMakeLists.txt b/Tests/Tutorial/Step8/CMakeLists.txt new file mode 100644 index 0000000000..c66bf96e34 --- /dev/null +++ b/Tests/Tutorial/Step8/CMakeLists.txt @@ -0,0 +1,82 @@ +cmake_minimum_required(VERSION 3.3) +project(Tutorial) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + +# does this system provide the log and exp functions? +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the MathFunctions library? +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif(USE_MYMATH) + +# add the executable +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) + +# add the install targets +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) + +# enable testing +enable_testing() + +# does the application run +add_test(NAME Runs COMMAND Tutorial 25) + +# does the usage message work? +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +# define a function to simplify adding tests +function(do_test target arg result) +add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endfunction(do_test) + +# do a bunch of result based tests +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") + +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +include(CPack) diff --git a/Tests/Tutorial/Step8/License.txt b/Tests/Tutorial/Step8/License.txt new file mode 100644 index 0000000000..c62d00b9ea --- /dev/null +++ b/Tests/Tutorial/Step8/License.txt @@ -0,0 +1,2 @@ +This is the open source License.txt file introduced in +CMake/Tutorial/Step7... diff --git a/Tests/Tutorial/Step8/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step8/MathFunctions/CMakeLists.txt new file mode 100644 index 0000000000..dc3eb9822a --- /dev/null +++ b/Tests/Tutorial/Step8/MathFunctions/CMakeLists.txt @@ -0,0 +1,29 @@ +# first we add the executable that generates the table +add_executable(MakeTable MakeTable.cxx) + +# add the command to generate the source code +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + +# add the main library +add_library(MathFunctions + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the +# TutorialConfig.h include is an implementation detail +# state that we depend on our binary dir to find Table.h +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${Tutorial_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) + +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step8/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step8/MathFunctions/MakeTable.cxx new file mode 100644 index 0000000000..ee585568cb --- /dev/null +++ b/Tests/Tutorial/Step8/MathFunctions/MakeTable.cxx @@ -0,0 +1,25 @@ +// A simple program that builds a sqrt table +#include <cmath> +#include <fstream> +#include <iostream> + +int main(int argc, char* argv[]) +{ + // make sure we have enough arguments + if (argc < 2) { + return 1; + } + + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); + } + return fileOpen ? 0 : 1; // return 0 if wrote the file +} diff --git a/Tests/Tutorial/Step8/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step8/MathFunctions/MathFunctions.h new file mode 100644 index 0000000000..cd36bccffd --- /dev/null +++ b/Tests/Tutorial/Step8/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/Tutorial/Step8/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step8/MathFunctions/mysqrt.cxx new file mode 100644 index 0000000000..5b862fbd57 --- /dev/null +++ b/Tests/Tutorial/Step8/MathFunctions/mysqrt.cxx @@ -0,0 +1,42 @@ +#include "MathFunctions.h" +#include "TutorialConfig.h" +#include <iostream> + +// include the generated table +#include "Table.h" + +#include <cmath> + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) { + return 0; + } + + // if we have both log and exp then use them +#if defined(HAVE_LOG) && defined(HAVE_EXP) + double result = exp(log(x) * 0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" + << std::endl; +#else + // use the table to help find an initial value + double result = x; + if (x >= 1 && x < 10) { + result = sqrtTable[static_cast<int>(x)]; + } + + // if we have both log and exp then use them + + // do ten iterations + for (int i = 0; i < 10; ++i) { + if (result <= 0) { + result = 0.1; + } + double delta = x - (result * result); + result = result + 0.5 * delta / result; + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; + } +#endif + return result; +} diff --git a/Tests/Tutorial/Step8/TutorialConfig.h.in b/Tests/Tutorial/Step8/TutorialConfig.h.in new file mode 100644 index 0000000000..e97ce24ea9 --- /dev/null +++ b/Tests/Tutorial/Step8/TutorialConfig.h.in @@ -0,0 +1,8 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH + +// does the platform provide exp and log functions? +#cmakedefine HAVE_LOG +#cmakedefine HAVE_EXP diff --git a/Tests/Tutorial/Step8/directions.txt b/Tests/Tutorial/Step8/directions.txt new file mode 100644 index 0000000000..588d9c6799 --- /dev/null +++ b/Tests/Tutorial/Step8/directions.txt @@ -0,0 +1,38 @@ +# Adding Support for a Dashboard # + +Adding support for submitting our test results to a dashboard is very easy. We +already defined a number of tests for our project in the earlier steps of this +tutorial. We just have to run those tests and submit them to a dashboard. To +include support for dashboards we include the CTest module in our top-level +CMakeLists.txt. + +Replace: + # enable testing + enable_testing() + +With: + # enable dashboard scripting + include(CTest) + +The CTest module will automatically call enable_testing(), so +we can remove it from our CMake files. + +We will also need to create a CTestConfig.cmake file where we can specify the +name of the project and where to submit the dashboard. + + set(CTEST_PROJECT_NAME "CMakeTutorial") + set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") + + set(CTEST_DROP_METHOD "http") + set(CTEST_DROP_SITE "my.cdash.org/") + set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial") + set(CTEST_DROP_SITE_CDASH TRUE) + +CTest will read in this file when it runs. To create a simple dashboard you can +run cmake or cmake-gui to configure the project, but do not build it yet. +Instead, change directory to the binary tree, and then run: + 'ctest [-VV] –D Experimental'. On Windows, build the EXPERIMENTAL target. + +Ctest will build and test the project and submit results to the Kitware public +dashboard. The results of your dashboard will be uploaded to Kitware's public +dashboard here: https://my.cdash.org/index.php?project=CMakeTutorial. diff --git a/Tests/Tutorial/Step8/tutorial.cxx b/Tests/Tutorial/Step8/tutorial.cxx new file mode 100644 index 0000000000..1d5742d2d1 --- /dev/null +++ b/Tests/Tutorial/Step8/tutorial.cxx @@ -0,0 +1,32 @@ +// A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + +#include "TutorialConfig.h" + +#ifdef USE_MYMATH +# include "MathFunctions.h" +#endif + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + double inputValue = std::stod(argv[1]); + +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; + return 0; +} diff --git a/Tests/Tutorial/Step9/CMakeLists.txt b/Tests/Tutorial/Step9/CMakeLists.txt new file mode 100644 index 0000000000..309d513ff8 --- /dev/null +++ b/Tests/Tutorial/Step9/CMakeLists.txt @@ -0,0 +1,81 @@ +cmake_minimum_required(VERSION 3.3) +project(Tutorial) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + +# does this system provide the log and exp functions? +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass the version number only +configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the MathFunctions library? +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif() + +# add the executable +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) + +# add the install targets +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) + +# enable testing +include(CTest) + +# does the application run +add_test(NAME Runs COMMAND Tutorial 25) + +# does the usage message work? +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endfunction(do_test) + +# do a bunch of result based tests +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") + +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +include(CPack) diff --git a/Tests/Tutorial/Step9/CTestConfig.cmake b/Tests/Tutorial/Step9/CTestConfig.cmake new file mode 100644 index 0000000000..7a927ac947 --- /dev/null +++ b/Tests/Tutorial/Step9/CTestConfig.cmake @@ -0,0 +1,15 @@ +## This file should be placed in the root directory of your project. +## Then modify the CMakeLists.txt file in the root directory of your +## project to incorporate the testing dashboard. +## +## # The following are required to submit to the CDash dashboard: +## ENABLE_TESTING() +## INCLUDE(CTest) + +set(CTEST_PROJECT_NAME "CMakeTutorial") +set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "my.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/Tutorial/Step9/License.txt b/Tests/Tutorial/Step9/License.txt new file mode 100644 index 0000000000..c62d00b9ea --- /dev/null +++ b/Tests/Tutorial/Step9/License.txt @@ -0,0 +1,2 @@ +This is the open source License.txt file introduced in +CMake/Tutorial/Step7... diff --git a/Tests/Tutorial/Step9/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step9/MathFunctions/CMakeLists.txt new file mode 100644 index 0000000000..e651a57487 --- /dev/null +++ b/Tests/Tutorial/Step9/MathFunctions/CMakeLists.txt @@ -0,0 +1,35 @@ +# first we add the executable that generates the table +add_executable(MakeTable MakeTable.cxx) + +# add the command to generate the source code +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + +# add the main library +add_library(MathFunctions + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +# state that we depend on our binary dir to find Table.h +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ) + +# use compile definitions to state if we have enabled USE_MYMATH +# and that anything that links to use will get this define +target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH") + +if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(MathFunctions + PRIVATE "HAVE_LOG" "HAVE_EXP") +endif() + +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step9/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step9/MathFunctions/MakeTable.cxx new file mode 100644 index 0000000000..ee585568cb --- /dev/null +++ b/Tests/Tutorial/Step9/MathFunctions/MakeTable.cxx @@ -0,0 +1,25 @@ +// A simple program that builds a sqrt table +#include <cmath> +#include <fstream> +#include <iostream> + +int main(int argc, char* argv[]) +{ + // make sure we have enough arguments + if (argc < 2) { + return 1; + } + + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); + } + return fileOpen ? 0 : 1; // return 0 if wrote the file +} diff --git a/Tests/Tutorial/Step9/MathFunctions/MathFunctions.cxx b/Tests/Tutorial/Step9/MathFunctions/MathFunctions.cxx new file mode 100644 index 0000000000..5351184be4 --- /dev/null +++ b/Tests/Tutorial/Step9/MathFunctions/MathFunctions.cxx @@ -0,0 +1,18 @@ + +#include "MathFunctions.h" +#include <cmath> + +#ifdef USE_MYMATH +# include "mysqrt.h" +#endif + +namespace mathfunctions { +double sqrt(double x) +{ +#ifdef USE_MYMATH + return detail::mysqrt(x); +#else + return std::sqrt(x); +#endif +} +} diff --git a/Tests/Tutorial/Step9/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step9/MathFunctions/MathFunctions.h new file mode 100644 index 0000000000..cd36bccffd --- /dev/null +++ b/Tests/Tutorial/Step9/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/Tutorial/Step9/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step9/MathFunctions/mysqrt.cxx new file mode 100644 index 0000000000..8b82141512 --- /dev/null +++ b/Tests/Tutorial/Step9/MathFunctions/mysqrt.cxx @@ -0,0 +1,41 @@ +#include "MathFunctions.h" +#include <iostream> + +// include the generated table +#include "Table.h" + +#include <cmath> + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) { + return 0; + } + + // if we have both log and exp then use them +#if defined(HAVE_LOG) && defined(HAVE_EXP) + double result = exp(log(x) * 0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" + << std::endl; +#else + // use the table to help find an initial value + double result = x; + if (x >= 1 && x < 10) { + result = sqrtTable[static_cast<int>(x)]; + } + + // if we have both log and exp then use them + + // do ten iterations + for (int i = 0; i < 10; ++i) { + if (result <= 0) { + result = 0.1; + } + double delta = x - (result * result); + result = result + 0.5 * delta / result; + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; + } +#endif + return result; +} diff --git a/Tests/Tutorial/Step9/MathFunctions/mysqrt.h b/Tests/Tutorial/Step9/MathFunctions/mysqrt.h new file mode 100644 index 0000000000..e1c42ef0c2 --- /dev/null +++ b/Tests/Tutorial/Step9/MathFunctions/mysqrt.h @@ -0,0 +1,6 @@ + +namespace mathfunctions { +namespace detail { +double mysqrt(double x); +} +} diff --git a/Tests/Tutorial/Step9/TutorialConfig.h.in b/Tests/Tutorial/Step9/TutorialConfig.h.in new file mode 100644 index 0000000000..8cd2fc9c63 --- /dev/null +++ b/Tests/Tutorial/Step9/TutorialConfig.h.in @@ -0,0 +1,3 @@ +// the configured version number +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Tests/Tutorial/Step9/directions.txt b/Tests/Tutorial/Step9/directions.txt new file mode 100644 index 0000000000..8771637d2a --- /dev/null +++ b/Tests/Tutorial/Step9/directions.txt @@ -0,0 +1,166 @@ +# Mixing Static and Shared # + +In this section we will show how by using the BUILD_SHARED_LIBS variable we can +control the default behavior of add_library, and allow control over how +libraries without an explicit type ( STATIC/SHARED/MODULE/OBJECT ) are built. + +To accomplish this we need to add BUILD_SHARED_LIBS to the top level +CMakeLists.txt. We use the option command as it allows users to optionally +select if the value should be On or Off. + +Next we are going to refactor MathFunctions to become a real library that +encapsulates using mysqrt or sqrt, instead of requiring the calling code +to do this logic. This will also mean that USE_MYMATH will not control building +MathFuctions, but instead will control the behavior of this library. + +The first step is to update the starting section of the top level CMakeLists.txt +to look like: + + cmake_minimum_required(VERSION 3.3) + project(Tutorial) + + # control where the static and shared libraries are built so that on windows + # we don't need to tinker with the path to run the executable + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED True) + + option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + + # the version number. + set(Tutorial_VERSION_MAJOR 1) + set(Tutorial_VERSION_MINOR 0) + + # configure a header file to pass the version number only + configure_file( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + + # add the MathFunctions library + add_subdirectory(MathFunctions) + + # add the executable + add_executable(Tutorial tutorial.cxx) + target_link_libraries(Tutorial PUBLIC MathFunctions) + +Now that we have made MathFunctions always be used, we will need to update +the logic of that library. So, in MathFunctions/CMakeLists.txt we need to +create a SqrtLibrary that will conditionally be built when USE_MYMATH is +enabled. Now, since this is a tutorial, we are going to explicitly require +that SqrtLibrary is built statically. + +The end result is that MathFunctions/CMakeLists.txt should look like: + + # add the library that runs + add_library(MathFunctions MathFunctions.cxx) + + # state that anybody linking to us needs to include the current source dir + # to find MathFunctions.h, while we don't. + target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + ) + + # should we use our own math functions + option(USE_MYMATH "Use tutorial provided math implementation" ON) + if(USE_MYMATH) + + # does this system provide the log and exp functions? + include(CheckSymbolExists) + set(CMAKE_REQUIRED_LIBRARIES "m") + check_symbol_exists(log "math.h" HAVE_LOG) + check_symbol_exists(exp "math.h" HAVE_EXP) + + # first we add the executable that generates the table + add_executable(MakeTable MakeTable.cxx) + + # add the command to generate the source code + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + + # library that just does sqrt + add_library(SqrtLibrary STATIC + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + + # state that we depend on our binary dir to find Table.h + target_include_directories(SqrtLibrary PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + ) + + target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") + if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(SqrtLibrary + PRIVATE "HAVE_LOG" "HAVE_EXP") + endif() + + target_link_libraries(MathFunctions PRIVATE SqrtLibrary) + endif() + + # define the symbol stating we are using the declspec(dllexport) when + # building on windows + target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") + + install(TARGETS MathFunctions DESTINATION lib) + install(FILES MathFunctions.h DESTINATION include) + +Next, update MathFunctions/mysqrt.cxx to use the mathfunctions and detail namespaces: + + #include <iostream> + #include "MathFunctions.h" + + // include the generated table + #include "Table.h" + + #include <cmath> + + namespace mathfunctions { + namespace detail { + // a hack square root calculation using simple operations + double mysqrt(double x) + { + ... + + return result; + } + } + } + +We also need to make some changes in tutorial.cxx, so that it no longer uses USE_MYMATH: +1. Always include MathFunctions.h +2. Always use mathfunctions::sqrt + +Finally, update MathFunctions/MathFunctions.h to use dll export defines: + + #if defined(_WIN32) + #if defined(EXPORTING_MYMATH) + #define DECLSPEC __declspec(dllexport) + #else + #define DECLSPEC __declspec(dllimport) + #endif + #else //non windows + #define DECLSPEC + #endif + + namespace mathfunctions + { + double DECLSPEC sqrt(double x); + } + +At this point, if you build everything, you will notice that linking fails +as we are combining a static library without position enabled code with a +library that has position enabled code. This solution to this is to explicitly +set the POSITION_INDEPENDENT_CODE target property of SqrtLibrary to be True no +matter the build type. + +Exercise: We modified MathFunctions.h to use dll export defines. Using CMake +documentation can you find a helper module to simplify this? + +Exercise: Determine what command is enabling PIC for SqrtLibrary. +What happens if we remove said command? diff --git a/Tests/Tutorial/Step9/tutorial.cxx b/Tests/Tutorial/Step9/tutorial.cxx new file mode 100644 index 0000000000..73e67a9c02 --- /dev/null +++ b/Tests/Tutorial/Step9/tutorial.cxx @@ -0,0 +1,33 @@ +// A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <sstream> +#include <string> + +#include "TutorialConfig.h" + +#ifdef USE_MYMATH +# include "MathFunctions.h" +#endif + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; + return 1; + } + + double inputValue = std::stod(argv[1]); + +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; + return 0; +} diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png Binary files differindex 7d95d4e081..c715e1bc73 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png Binary files differindex e26771cb33..65f91ac0f9 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png Binary files differindex 1eb0d9d528..460c0222d4 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png Binary files differindex 28810b7c0e..c2374581a8 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png Binary files differindex c951e031bd..8342565809 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png Binary files differindex dcb672712c..508c8a809a 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png Binary files differindex e0c59ac014..fcdbaf4ac6 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png Binary files differindex e93b89d600..06425c4b1f 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png Binary files differindex 550b1b5e8d..4cef0eb301 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png Binary files differindex 686e6b53f0..253503f045 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png Binary files differindex d4b5ede1b5..2ef050fb32 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png diff --git a/Tests/VSXaml/Assets/Logo.scale-100.png b/Tests/VSXaml/Assets/Logo.scale-100.png Binary files differindex e26771cb33..65f91ac0f9 100644 --- a/Tests/VSXaml/Assets/Logo.scale-100.png +++ b/Tests/VSXaml/Assets/Logo.scale-100.png diff --git a/Tests/VSXaml/Assets/SmallLogo.scale-100.png b/Tests/VSXaml/Assets/SmallLogo.scale-100.png Binary files differindex 1eb0d9d528..460c0222d4 100644 --- a/Tests/VSXaml/Assets/SmallLogo.scale-100.png +++ b/Tests/VSXaml/Assets/SmallLogo.scale-100.png diff --git a/Tests/VSXaml/Assets/SplashScreen.scale-100.png b/Tests/VSXaml/Assets/SplashScreen.scale-100.png Binary files differindex c951e031bd..8342565809 100644 --- a/Tests/VSXaml/Assets/SplashScreen.scale-100.png +++ b/Tests/VSXaml/Assets/SplashScreen.scale-100.png diff --git a/Tests/VSXaml/Assets/StoreLogo.scale-100.png b/Tests/VSXaml/Assets/StoreLogo.scale-100.png Binary files differindex dcb672712c..508c8a809a 100644 --- a/Tests/VSXaml/Assets/StoreLogo.scale-100.png +++ b/Tests/VSXaml/Assets/StoreLogo.scale-100.png diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index aee8a6949d..482a08dd82 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -97,7 +97,7 @@ { include: [ "<json/writer.h>", private, "\"cm_jsoncpp_writer.h\"", public ] }, { include: [ "<rhash.h>", private, "\"cm_rhash.h\"", public ] }, { include: [ "<uv.h>", private, "\"cm_uv.h\"", public ] }, - { include: [ "@<uv-.+\\.h>", private, "\"cm_uv.h\"", public ] }, + { include: [ "@<uv[/-].+\\.h>", private, "\"cm_uv.h\"", public ] }, { include: [ "<kwiml/abi.h>", private, "\"cm_kwiml.h\"", public ] }, { include: [ "<kwiml/int.h>", private, "\"cm_kwiml.h\"", public ] }, { include: [ "<zconf.h>", private, "\"cm_zlib.h\"", public ] }, @@ -114,7 +114,7 @@ { include: [ "\"cmjsoncpp/include/json/writer.h\"", private, "\"cm_jsoncpp_writer.h\"", public ] }, { include: [ "\"cmlibrhash/librhash/rhash.h\"", private, "\"cm_rhash.h\"", public ] }, { include: [ "\"cmlibuv/include/uv.h\"", private, "\"cm_uv.h\"", public ] }, - { include: [ "@\"cmlibuv/include/uv-.+\\.h\"", private, "\"cm_uv.h\"", public ] }, + { include: [ "@\"cmlibuv/include/uv/.+\\.h\"", private, "\"cm_uv.h\"", public ] }, { include: [ "\"KWIML/include/kwiml/abi.h\"", private, "\"cm_kwiml.h\"", public ] }, { include: [ "\"KWIML/include/kwiml/int.h\"", private, "\"cm_kwiml.h\"", public ] }, { include: [ "\"cmzlib/cm_zlib_mangle.h\"", private, "\"cm_zlib.h\"", public ] }, diff --git a/Utilities/Sphinx/static/cmake-logo-16.png b/Utilities/Sphinx/static/cmake-logo-16.png Binary files differindex 9c95b75f39..db9458dc18 100644 --- a/Utilities/Sphinx/static/cmake-logo-16.png +++ b/Utilities/Sphinx/static/cmake-logo-16.png diff --git a/Utilities/cmlibuv/CMakeLists.txt b/Utilities/cmlibuv/CMakeLists.txt index a503041bec..a62c516ef0 100644 --- a/Utilities/cmlibuv/CMakeLists.txt +++ b/Utilities/cmlibuv/CMakeLists.txt @@ -14,16 +14,21 @@ set(uv_libraries ${CMAKE_THREAD_LIBS_INIT}) set(uv_includes include src) set(uv_headers include/uv.h - include/uv-errno.h - include/uv-threadpool.h - include/uv-version.h + include/uv/errno.h + include/uv/threadpool.h + include/uv/version.h ) set(uv_sources src/fs-poll.c src/heap-inl.h + src/idna.c + src/idna.h src/inet.c src/queue.h + src/strscpy.c + src/strscpy.h src/threadpool.c + src/timer.c src/uv-common.c src/uv-common.h src/uv-data-getter-setters.c @@ -45,7 +50,7 @@ if(WIN32) _WIN32_WINNT=0x0600 ) list(APPEND uv_headers - include/uv-win.h + include/uv/win.h include/tree.h ) list(APPEND uv_sources @@ -67,7 +72,6 @@ if(WIN32) src/win/poll.c src/win/process-stdio.c src/win/process.c - src/win/req.c src/win/req-inl.h src/win/signal.c src/win/snprintf.c @@ -75,7 +79,6 @@ if(WIN32) src/win/stream-inl.h src/win/tcp.c src/win/thread.c - src/win/timer.c src/win/tty.c src/win/udp.c src/win/util.c @@ -89,7 +92,7 @@ else() src/unix ) list(APPEND uv_headers - include/uv-unix.h + include/uv/unix.h ) list(APPEND uv_sources src/unix/async.c @@ -110,7 +113,6 @@ else() src/unix/stream.c src/unix/tcp.c src/unix/thread.c - src/unix/timer.c src/unix/tty.c src/unix/udp.c ) @@ -121,7 +123,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") perfstat ) list(APPEND uv_headers - include/uv-aix.h + include/uv/aix.h ) list(APPEND uv_defines _ALL_SOURCE @@ -139,7 +141,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") list(APPEND uv_libraries ) list(APPEND uv_headers - include/uv-posix.h + include/uv/posix.h ) list(APPEND uv_defines ) @@ -158,8 +160,7 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") list(APPEND uv_headers - include/uv-darwin.h - include/pthread-barrier.h + include/uv/darwin.h ) list(APPEND uv_defines _DARWIN_USE_64_BIT_INODE=1 @@ -178,7 +179,7 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux") list(APPEND uv_libraries dl rt) list(APPEND uv_headers - include/uv-linux.h + include/uv/linux.h ) list(APPEND uv_defines _GNU_SOURCE) list(APPEND uv_sources @@ -198,10 +199,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") kvm ) list(APPEND uv_headers - include/uv-bsd.h + include/uv/bsd.h ) list(APPEND uv_sources src/unix/bsd-ifaddrs.c + src/unix/bsd-proctitle.c src/unix/freebsd.c src/unix/kqueue.c src/unix/posix-hrtime.c @@ -214,10 +216,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD") kvm ) list(APPEND uv_headers - include/uv-bsd.h + include/uv/bsd.h ) list(APPEND uv_sources src/unix/bsd-ifaddrs.c + src/unix/bsd-proctitle.c src/unix/freebsd.c src/unix/kqueue.c src/unix/posix-hrtime.c @@ -229,10 +232,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") kvm ) list(APPEND uv_headers - include/uv-bsd.h + include/uv/bsd.h ) list(APPEND uv_sources src/unix/bsd-ifaddrs.c + src/unix/bsd-proctitle.c src/unix/netbsd.c src/unix/kqueue.c src/unix/posix-hrtime.c @@ -244,10 +248,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") kvm ) list(APPEND uv_headers - include/uv-bsd.h + include/uv/bsd.h ) list(APPEND uv_sources src/unix/bsd-ifaddrs.c + src/unix/bsd-proctitle.c src/unix/openbsd.c src/unix/kqueue.c src/unix/posix-hrtime.c @@ -263,7 +268,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") rt ) list(APPEND uv_headers - include/uv-sunos.h + include/uv/sunos.h ) list(APPEND uv_defines __EXTENSIONS__ diff --git a/Utilities/cmlibuv/include/pthread-barrier.h b/Utilities/cmlibuv/include/pthread-barrier.h deleted file mode 100644 index 07db9b8a6a..0000000000 --- a/Utilities/cmlibuv/include/pthread-barrier.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (c) 2016, Kari Tristan Helgason <kthelgason@gmail.com> - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#ifndef _UV_PTHREAD_BARRIER_ -#define _UV_PTHREAD_BARRIER_ -#include <errno.h> -#include <pthread.h> -#if !defined(__MVS__) -#include <semaphore.h> /* sem_t */ -#endif - -#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 -#define UV__PTHREAD_BARRIER_FALLBACK 1 - -/* - * To maintain ABI compatibility with - * libuv v1.x struct is padded according - * to target platform - */ -#if defined(__ANDROID__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - sizeof(pthread_cond_t) + \ - sizeof(unsigned int) - \ - sizeof(void *) -#elif defined(__APPLE__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - 2 * sizeof(sem_t) + \ - 2 * sizeof(unsigned int) - \ - sizeof(void *) -#else -# define UV_BARRIER_STRUCT_PADDING 0 -#endif - -typedef struct { - pthread_mutex_t mutex; - pthread_cond_t cond; - unsigned threshold; - unsigned in; - unsigned out; -} _uv_barrier; - -typedef struct { - _uv_barrier* b; - char _pad[UV_BARRIER_STRUCT_PADDING]; -} pthread_barrier_t; - -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count); - -int pthread_barrier_wait(pthread_barrier_t* barrier); -int pthread_barrier_destroy(pthread_barrier_t *barrier); - -#endif /* _UV_PTHREAD_BARRIER_ */ diff --git a/Utilities/cmlibuv/include/uv.h b/Utilities/cmlibuv/include/uv.h index 74fa00dfcd..e6dc7368ac 100644 --- a/Utilities/cmlibuv/include/uv.h +++ b/Utilities/cmlibuv/include/uv.h @@ -49,21 +49,21 @@ extern "C" { # define UV_EXTERN /* nothing */ #endif -#include "uv-errno.h" -#include "uv-version.h" +#include "uv/errno.h" +#include "uv/version.h" #include <stddef.h> #include <stdio.h> #if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" +# include "uv/stdint-msvc2008.h" #else # include <stdint.h> #endif #if defined(_WIN32) -# include "uv-win.h" +# include "uv/win.h" #else -# include "uv-unix.h" +# include "uv/unix.h" #endif /* Expand this list if necessary. */ @@ -146,6 +146,7 @@ extern "C" { XX(EHOSTDOWN, "host is down") \ XX(EREMOTEIO, "remote I/O error") \ XX(ENOTTY, "inappropriate ioctl for device") \ + XX(EFTYPE, "inappropriate file type or format") \ #define UV_HANDLE_TYPE_MAP(XX) \ XX(ASYNC, async) \ @@ -237,6 +238,7 @@ typedef struct uv_cpu_info_s uv_cpu_info_t; typedef struct uv_interface_address_s uv_interface_address_t; typedef struct uv_dirent_s uv_dirent_t; typedef struct uv_passwd_s uv_passwd_t; +typedef struct uv_utsname_s uv_utsname_t; typedef enum { UV_LOOP_BLOCK_SIGNAL @@ -373,7 +375,10 @@ typedef enum { UV_EXTERN int uv_translate_sys_error(int sys_errno); UV_EXTERN const char* uv_strerror(int err); +UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen); + UV_EXTERN const char* uv_err_name(int err); +UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen); #define UV_REQ_FIELDS \ @@ -507,7 +512,7 @@ UV_EXTERN int uv_try_write(uv_stream_t* handle, struct uv_write_s { UV_REQ_FIELDS uv_write_cb cb; - uv_stream_t* send_handle; + uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */ uv_stream_t* handle; UV_WRITE_PRIVATE_FIELDS }; @@ -869,7 +874,13 @@ typedef enum { * flags may be specified to create a duplex data stream. */ UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20 + UV_WRITABLE_PIPE = 0x20, + + /* + * Open the child pipe handle in overlapped mode on Windows. + * On Unix it is silently ignored. + */ + UV_OVERLAPPED_PIPE = 0x40 } uv_stdio_flags; typedef struct uv_stdio_container_s { @@ -970,11 +981,22 @@ enum uv_process_flags { */ UV_PROCESS_DETACHED = (1 << 3), /* + * Hide the subprocess window that would normally be created. This option is + * only meaningful on Windows systems. On Unix it is silently ignored. + */ + UV_PROCESS_WINDOWS_HIDE = (1 << 4), + /* * Hide the subprocess console window that would normally be created. This * option is only meaningful on Windows systems. On Unix it is silently * ignored. */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4) + UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5), + /* + * Hide the subprocess GUI window that would normally be created. This + * option is only meaningful on Windows systems. On Unix it is silently + * ignored. + */ + UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) }; /* @@ -1014,16 +1036,18 @@ UV_EXTERN int uv_queue_work(uv_loop_t* loop, UV_EXTERN int uv_cancel(uv_req_t* req); +struct uv_cpu_times_s { + uint64_t user; + uint64_t nice; + uint64_t sys; + uint64_t idle; + uint64_t irq; +}; + struct uv_cpu_info_s { char* model; int speed; - struct uv_cpu_times_s { - uint64_t user; - uint64_t nice; - uint64_t sys; - uint64_t idle; - uint64_t irq; - } cpu_times; + struct uv_cpu_times_s cpu_times; }; struct uv_interface_address_s { @@ -1048,6 +1072,16 @@ struct uv_passwd_s { char* homedir; }; +struct uv_utsname_s { + char sysname[256]; + char release[256]; + char version[256]; + char machine[256]; + /* This struct does not contain the nodename and domainname fields present in + the utsname type. domainname is a GNU extension. Both fields are referred + to as meaningless in the docs. */ +}; + typedef enum { UV_DIRENT_UNKNOWN, UV_DIRENT_FILE, @@ -1070,6 +1104,7 @@ UV_EXTERN int uv_set_process_title(const char* title); UV_EXTERN int uv_resident_set_memory(size_t* rss); UV_EXTERN int uv_uptime(double* uptime); UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); +UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd); typedef struct { long tv_sec; @@ -1104,6 +1139,16 @@ UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); UV_EXTERN uv_pid_t uv_os_getpid(void); UV_EXTERN uv_pid_t uv_os_getppid(void); +#define UV_PRIORITY_LOW 19 +#define UV_PRIORITY_BELOW_NORMAL 10 +#define UV_PRIORITY_NORMAL 0 +#define UV_PRIORITY_ABOVE_NORMAL -7 +#define UV_PRIORITY_HIGH -14 +#define UV_PRIORITY_HIGHEST -20 + +UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); +UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); + UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); UV_EXTERN int uv_cpumask_size(void); @@ -1119,6 +1164,8 @@ UV_EXTERN int uv_os_unsetenv(const char* name); UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); +UV_EXTERN int uv_os_uname(uv_utsname_t* buffer); + typedef enum { UV_FS_UNKNOWN = -1, @@ -1151,7 +1198,8 @@ typedef enum { UV_FS_CHOWN, UV_FS_FCHOWN, UV_FS_REALPATH, - UV_FS_COPYFILE + UV_FS_COPYFILE, + UV_FS_LCHOWN } uv_fs_type; /* uv_fs_t is a subclass of uv_req_t. */ @@ -1354,6 +1402,12 @@ UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb); +UV_EXTERN int uv_fs_lchown(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_uid_t uid, + uv_gid_t gid, + uv_fs_cb cb); enum uv_fs_event { diff --git a/Utilities/cmlibuv/include/uv-aix.h b/Utilities/cmlibuv/include/uv/aix.h index 7dc992fa6d..7dc992fa6d 100644 --- a/Utilities/cmlibuv/include/uv-aix.h +++ b/Utilities/cmlibuv/include/uv/aix.h diff --git a/Utilities/cmlibuv/include/android-ifaddrs.h b/Utilities/cmlibuv/include/uv/android-ifaddrs.h index 9cd19fec12..9cd19fec12 100644 --- a/Utilities/cmlibuv/include/android-ifaddrs.h +++ b/Utilities/cmlibuv/include/uv/android-ifaddrs.h diff --git a/Utilities/cmlibuv/include/uv-bsd.h b/Utilities/cmlibuv/include/uv/bsd.h index 2d72b3d771..2d72b3d771 100644 --- a/Utilities/cmlibuv/include/uv-bsd.h +++ b/Utilities/cmlibuv/include/uv/bsd.h diff --git a/Utilities/cmlibuv/include/uv-darwin.h b/Utilities/cmlibuv/include/uv/darwin.h index d226415820..d226415820 100644 --- a/Utilities/cmlibuv/include/uv-darwin.h +++ b/Utilities/cmlibuv/include/uv/darwin.h diff --git a/Utilities/cmlibuv/include/uv-errno.h b/Utilities/cmlibuv/include/uv/errno.h index aa4d4509f6..8eeb95de31 100644 --- a/Utilities/cmlibuv/include/uv-errno.h +++ b/Utilities/cmlibuv/include/uv/errno.h @@ -433,5 +433,11 @@ # define UV__ENOTTY (-4029) #endif +#if defined(EFTYPE) && !defined(_WIN32) +# define UV__EFTYPE UV__ERR(EFTYPE) +#else +# define UV__EFTYPE (-4028) +#endif + #endif /* UV_ERRNO_H_ */ diff --git a/Utilities/cmlibuv/include/uv-linux.h b/Utilities/cmlibuv/include/uv/linux.h index 9b38405a19..9b38405a19 100644 --- a/Utilities/cmlibuv/include/uv-linux.h +++ b/Utilities/cmlibuv/include/uv/linux.h diff --git a/Utilities/cmlibuv/include/uv-os390.h b/Utilities/cmlibuv/include/uv/os390.h index 0267d74cbd..0267d74cbd 100644 --- a/Utilities/cmlibuv/include/uv-os390.h +++ b/Utilities/cmlibuv/include/uv/os390.h diff --git a/Utilities/cmlibuv/include/uv-posix.h b/Utilities/cmlibuv/include/uv/posix.h index 9a96634db0..9a96634db0 100644 --- a/Utilities/cmlibuv/include/uv-posix.h +++ b/Utilities/cmlibuv/include/uv/posix.h diff --git a/Utilities/cmlibuv/include/stdint-msvc2008.h b/Utilities/cmlibuv/include/uv/stdint-msvc2008.h index d02608a597..d02608a597 100644 --- a/Utilities/cmlibuv/include/stdint-msvc2008.h +++ b/Utilities/cmlibuv/include/uv/stdint-msvc2008.h diff --git a/Utilities/cmlibuv/include/uv-sunos.h b/Utilities/cmlibuv/include/uv/sunos.h index 042166424e..042166424e 100644 --- a/Utilities/cmlibuv/include/uv-sunos.h +++ b/Utilities/cmlibuv/include/uv/sunos.h diff --git a/Utilities/cmlibuv/include/uv-threadpool.h b/Utilities/cmlibuv/include/uv/threadpool.h index 9708ebdd53..9708ebdd53 100644 --- a/Utilities/cmlibuv/include/uv-threadpool.h +++ b/Utilities/cmlibuv/include/uv/threadpool.h diff --git a/Utilities/cmlibuv/include/tree.h b/Utilities/cmlibuv/include/uv/tree.h index f936416e3d..f936416e3d 100644 --- a/Utilities/cmlibuv/include/tree.h +++ b/Utilities/cmlibuv/include/uv/tree.h diff --git a/Utilities/cmlibuv/include/uv-unix.h b/Utilities/cmlibuv/include/uv/unix.h index 455674d1a1..3c1b363694 100644 --- a/Utilities/cmlibuv/include/uv-unix.h +++ b/Utilities/cmlibuv/include/uv/unix.h @@ -42,34 +42,32 @@ #include <pthread.h> #include <signal.h> -#include "uv-threadpool.h" +#include "threadpool.h" #ifdef CMAKE_BOOTSTRAP -# include "uv-posix.h" +# include "posix.h" #elif defined(__linux__) -# include "uv-linux.h" +# include "linux.h" #elif defined (__MVS__) -# include "uv-os390.h" +# include "os390.h" #elif defined(__PASE__) -# include "uv-posix.h" +# include "posix.h" #elif defined(_AIX) -# include "uv-aix.h" +# include "aix.h" #elif defined(__sun) -# include "uv-sunos.h" +# include "sunos.h" #elif defined(__APPLE__) -# include "uv-darwin.h" +# include "darwin.h" #elif defined(__DragonFly__) || \ defined(__FreeBSD__) || \ defined(__FreeBSD_kernel__) || \ defined(__OpenBSD__) || \ defined(__NetBSD__) -# include "uv-bsd.h" +# include "bsd.h" #elif defined(__CYGWIN__) || defined(__MSYS__) -# include "uv-posix.h" -#endif - -#ifndef PTHREAD_BARRIER_SERIAL_THREAD -# include "pthread-barrier.h" +# include "posix.h" +#elif defined(__GNU__) +# include "posix.h" #endif #ifndef NI_MAXHOST @@ -149,9 +147,30 @@ typedef pthread_rwlock_t uv_rwlock_t; typedef UV_PLATFORM_SEM_T uv_sem_t; typedef pthread_cond_t uv_cond_t; typedef pthread_key_t uv_key_t; + +/* Note: guard clauses should match uv_barrier_init's in src/unix/thread.c. */ +#if defined(_AIX) || !defined(PTHREAD_BARRIER_SERIAL_THREAD) +/* TODO(bnoordhuis) Merge into uv_barrier_t in v2. */ +struct _uv_barrier { + uv_mutex_t mutex; + uv_cond_t cond; + unsigned threshold; + unsigned in; + unsigned out; +}; + +typedef struct { + struct _uv_barrier* b; +# if defined(PTHREAD_BARRIER_SERIAL_THREAD) + /* TODO(bnoordhuis) Remove padding in v2. */ + char pad[sizeof(pthread_barrier_t) - sizeof(struct _uv_barrier*)]; +# endif +} uv_barrier_t; +#else typedef pthread_barrier_t uv_barrier_t; #endif +#endif /* Platform-specific definitions for uv_spawn support. */ typedef gid_t uv_gid_t; diff --git a/Utilities/cmlibuv/include/uv-version.h b/Utilities/cmlibuv/include/uv/version.h index 06c6711c65..abc140a3bb 100644 --- a/Utilities/cmlibuv/include/uv-version.h +++ b/Utilities/cmlibuv/include/uv/version.h @@ -31,8 +31,8 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 20 -#define UV_VERSION_PATCH 3 +#define UV_VERSION_MINOR 24 +#define UV_VERSION_PATCH 2 #define UV_VERSION_IS_RELEASE 0 #define UV_VERSION_SUFFIX "dev" diff --git a/Utilities/cmlibuv/include/uv-win.h b/Utilities/cmlibuv/include/uv/win.h index 6486aabb36..f3d3809f38 100644 --- a/Utilities/cmlibuv/include/uv-win.h +++ b/Utilities/cmlibuv/include/uv/win.h @@ -25,6 +25,7 @@ #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) typedef intptr_t ssize_t; +# define SSIZE_MAX INTPTR_MAX # define _SSIZE_T_ # define _SSIZE_T_DEFINED #endif @@ -59,7 +60,7 @@ typedef struct pollfd { #endif #include "tree.h" -#include "uv-threadpool.h" +#include "threadpool.h" #define MAX_PIPENAME_LEN 256 @@ -86,8 +87,16 @@ typedef struct pollfd { #define SIGKILL 9 #define SIGWINCH 28 -/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */ -/* unix-like platforms. However MinGW doesn't define it, so we do. */ +/* Redefine NSIG to take SIGWINCH into consideration */ +#if defined(NSIG) && NSIG <= SIGWINCH +# undef NSIG +#endif +#ifndef NSIG +# define NSIG SIGWINCH + 1 +#endif + +/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like + * platforms. However MinGW doesn't define it, so we do. */ #ifndef SIGABRT_COMPAT # define SIGABRT_COMPAT 6 #endif @@ -255,7 +264,7 @@ typedef union { CRITICAL_SECTION waiters_count_lock; HANDLE signal_event; HANDLE broadcast_event; - } fallback; + } unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */ } uv_cond_t; typedef union { @@ -319,8 +328,6 @@ typedef struct { char* errmsg; } uv_lib_t; -RB_HEAD(uv_timer_tree_s, uv_timer_s); - #define UV_LOOP_PRIVATE_FIELDS \ /* The loop's I/O completion port */ \ HANDLE iocp; \ @@ -332,8 +339,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); uv_req_t* pending_reqs_tail; \ /* Head of a single-linked list of closed handles */ \ uv_handle_t* endgame_handles; \ - /* The head of the timers tree */ \ - struct uv_timer_tree_s timers; \ + /* TODO(bnoordhuis) Stop heap-allocating |timer_heap| in libuv v2.x. */ \ + void* timer_heap; \ /* Lists of active loop (prepare / check / idle) watchers */ \ uv_prepare_t* prepare_handles; \ uv_check_t* check_handles; \ @@ -379,10 +386,10 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); } u; \ struct uv_req_s* next_req; -#define UV_WRITE_PRIVATE_FIELDS \ - int ipc_header; \ - uv_buf_t write_buffer; \ - HANDLE event_handle; \ +#define UV_WRITE_PRIVATE_FIELDS \ + int coalesced; \ + uv_buf_t write_buffer; \ + HANDLE event_handle; \ HANDLE wait_handle; #define UV_CONNECT_PRIVATE_FIELDS \ @@ -470,16 +477,17 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); #define uv_pipe_connection_fields \ uv_timer_t* eof_timer; \ - uv_write_t ipc_header_write_req; \ - int ipc_pid; \ - uint64_t remaining_ipc_rawdata_bytes; \ - struct { \ - void* queue[2]; \ - int queue_len; \ - } pending_ipc_info; \ + uv_write_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ + DWORD ipc_remote_pid; \ + union { \ + uint32_t payload_remaining; \ + uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ + } ipc_data_frame; \ + void* ipc_xfer_queue[2]; \ + int ipc_xfer_queue_length; \ uv_write_t* non_overlapped_writes_tail; \ - uv_mutex_t readfile_mutex; \ - volatile HANDLE readfile_thread; + CRITICAL_SECTION readfile_thread_lock; \ + volatile HANDLE readfile_thread_handle; #define UV_PIPE_PRIVATE_FIELDS \ HANDLE handle; \ @@ -489,8 +497,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); struct { uv_pipe_connection_fields } conn; \ } pipe; -/* TODO: put the parser states in an union - TTY handles are always */ -/* half-duplex so read-state can safely overlap write-state. */ +/* TODO: put the parser states in an union - TTY handles are always half-duplex + * so read-state can safely overlap write-state. */ #define UV_TTY_PRIVATE_FIELDS \ HANDLE handle; \ union { \ @@ -539,8 +547,9 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); unsigned char events; #define UV_TIMER_PRIVATE_FIELDS \ - RB_ENTRY(uv_timer_s) tree_entry; \ - uint64_t due; \ + void* heap_node[3]; \ + int unused; \ + uint64_t timeout; \ uint64_t repeat; \ uint64_t start_id; \ uv_timer_cb timer_cb; diff --git a/Utilities/cmlibuv/src/fs-poll.c b/Utilities/cmlibuv/src/fs-poll.c index ee73d5a2e6..6c82dfc1d7 100644 --- a/Utilities/cmlibuv/src/fs-poll.c +++ b/Utilities/cmlibuv/src/fs-poll.c @@ -83,7 +83,7 @@ int uv_fs_poll_start(uv_fs_poll_t* handle, if (err < 0) goto error; - ctx->timer_handle.flags |= UV__HANDLE_INTERNAL; + ctx->timer_handle.flags |= UV_HANDLE_INTERNAL; uv__handle_unref(&ctx->timer_handle); err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb); @@ -248,7 +248,7 @@ static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b) { #include "win/handle-inl.h" void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); + assert(handle->flags & UV_HANDLE_CLOSING); assert(!(handle->flags & UV_HANDLE_CLOSED)); uv__handle_close(handle); } diff --git a/Utilities/cmlibuv/src/idna.c b/Utilities/cmlibuv/src/idna.c new file mode 100644 index 0000000000..13ffac6be8 --- /dev/null +++ b/Utilities/cmlibuv/src/idna.c @@ -0,0 +1,291 @@ +/* Copyright (c) 2011, 2018 Ben Noordhuis <info@bnoordhuis.nl> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* Derived from https://github.com/bnoordhuis/punycode + * but updated to support IDNA 2008. + */ + +#include "uv.h" +#include "idna.h" +#include <string.h> + +static unsigned uv__utf8_decode1_slow(const char** p, + const char* pe, + unsigned a) { + unsigned b; + unsigned c; + unsigned d; + unsigned min; + + if (a > 0xF7) + return -1; + + switch (*p - pe) { + default: + if (a > 0xEF) { + min = 0x10000; + a = a & 7; + b = (unsigned char) *(*p)++; + c = (unsigned char) *(*p)++; + d = (unsigned char) *(*p)++; + break; + } + /* Fall through. */ + case 2: + if (a > 0xDF) { + min = 0x800; + b = 0x80 | (a & 15); + c = (unsigned char) *(*p)++; + d = (unsigned char) *(*p)++; + a = 0; + break; + } + /* Fall through. */ + case 1: + if (a > 0xBF) { + min = 0x80; + b = 0x80; + c = 0x80 | (a & 31); + d = (unsigned char) *(*p)++; + a = 0; + break; + } + return -1; /* Invalid continuation byte. */ + } + + if (0x80 != (0xC0 & (b ^ c ^ d))) + return -1; /* Invalid sequence. */ + + b &= 63; + c &= 63; + d &= 63; + a = (a << 18) | (b << 12) | (c << 6) | d; + + if (a < min) + return -1; /* Overlong sequence. */ + + if (a > 0x10FFFF) + return -1; /* Four-byte sequence > U+10FFFF. */ + + if (a >= 0xD800 && a <= 0xDFFF) + return -1; /* Surrogate pair. */ + + return a; +} + +unsigned uv__utf8_decode1(const char** p, const char* pe) { + unsigned a; + + a = (unsigned char) *(*p)++; + + if (a < 128) + return a; /* ASCII, common case. */ + + return uv__utf8_decode1_slow(p, pe, a); +} + +#define foreach_codepoint(c, p, pe) \ + for (; (void) (*p <= pe && (c = uv__utf8_decode1(p, pe))), *p <= pe;) + +static int uv__idna_toascii_label(const char* s, const char* se, + char** d, char* de) { + static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz0123456789"; + const char* ss; + unsigned c; + unsigned h; + unsigned k; + unsigned n; + unsigned m; + unsigned q; + unsigned t; + unsigned x; + unsigned y; + unsigned bias; + unsigned delta; + unsigned todo; + int first; + + h = 0; + ss = s; + todo = 0; + + foreach_codepoint(c, &s, se) { + if (c < 128) + h++; + else if (c == (unsigned) -1) + return UV_EINVAL; + else + todo++; + } + + if (todo > 0) { + if (*d < de) *(*d)++ = 'x'; + if (*d < de) *(*d)++ = 'n'; + if (*d < de) *(*d)++ = '-'; + if (*d < de) *(*d)++ = '-'; + } + + x = 0; + s = ss; + foreach_codepoint(c, &s, se) { + if (c > 127) + continue; + + if (*d < de) + *(*d)++ = c; + + if (++x == h) + break; /* Visited all ASCII characters. */ + } + + if (todo == 0) + return h; + + /* Only write separator when we've written ASCII characters first. */ + if (h > 0) + if (*d < de) + *(*d)++ = '-'; + + n = 128; + bias = 72; + delta = 0; + first = 1; + + while (todo > 0) { + m = -1; + s = ss; + foreach_codepoint(c, &s, se) + if (c >= n) + if (c < m) + m = c; + + x = m - n; + y = h + 1; + + if (x > ~delta / y) + return UV_E2BIG; /* Overflow. */ + + delta += x * y; + n = m; + + s = ss; + foreach_codepoint(c, &s, se) { + if (c < n) + if (++delta == 0) + return UV_E2BIG; /* Overflow. */ + + if (c != n) + continue; + + for (k = 36, q = delta; /* empty */; k += 36) { + t = 1; + + if (k > bias) + t = k - bias; + + if (t > 26) + t = 26; + + if (q < t) + break; + + /* TODO(bnoordhuis) Since 1 <= t <= 26 and therefore + * 10 <= y <= 35, we can optimize the long division + * into a table-based reciprocal multiplication. + */ + x = q - t; + y = 36 - t; /* 10 <= y <= 35 since 1 <= t <= 26. */ + q = x / y; + t = t + x % y; /* 1 <= t <= 35 because of y. */ + + if (*d < de) + *(*d)++ = alphabet[t]; + } + + if (*d < de) + *(*d)++ = alphabet[q]; + + delta /= 2; + + if (first) { + delta /= 350; + first = 0; + } + + /* No overflow check is needed because |delta| was just + * divided by 2 and |delta+delta >= delta + delta/h|. + */ + h++; + delta += delta / h; + + for (bias = 0; delta > 35 * 26 / 2; bias += 36) + delta /= 35; + + bias += 36 * delta / (delta + 38); + delta = 0; + todo--; + } + + delta++; + n++; + } + + return 0; +} + +#undef foreach_codepoint + +long uv__idna_toascii(const char* s, const char* se, char* d, char* de) { + const char* si; + const char* st; + unsigned c; + char* ds; + int rc; + + ds = d; + + for (si = s; si < se; /* empty */) { + st = si; + c = uv__utf8_decode1(&si, se); + + if (c != '.') + if (c != 0x3002) /* 。 */ + if (c != 0xFF0E) /* . */ + if (c != 0xFF61) /* 。 */ + continue; + + rc = uv__idna_toascii_label(s, st, &d, de); + + if (rc < 0) + return rc; + + if (d < de) + *d++ = '.'; + + s = si; + } + + if (s < se) { + rc = uv__idna_toascii_label(s, se, &d, de); + + if (rc < 0) + return rc; + } + + if (d < de) + *d++ = '\0'; + + return d - ds; /* Number of bytes written. */ +} diff --git a/Utilities/cmlibuv/src/idna.h b/Utilities/cmlibuv/src/idna.h new file mode 100644 index 0000000000..8e0c592fe1 --- /dev/null +++ b/Utilities/cmlibuv/src/idna.h @@ -0,0 +1,31 @@ +/* Copyright (c) 2011, 2018 Ben Noordhuis <info@bnoordhuis.nl> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef UV_SRC_IDNA_H_ +#define UV_SRC_IDNA_H_ + +/* Decode a single codepoint. Returns the codepoint or UINT32_MAX on error. + * |p| is updated on success _and_ error, i.e., bad multi-byte sequences are + * skipped in their entirety, not just the first bad byte. + */ +unsigned uv__utf8_decode1(const char** p, const char* pe); + +/* Convert a UTF-8 domain name to IDNA 2008 / Punycode. A return value >= 0 + * is the number of bytes written to |d|, including the trailing nul byte. + * A return value < 0 is a libuv error code. |s| and |d| can not overlap. + */ +long uv__idna_toascii(const char* s, const char* se, char* d, char* de); + +#endif /* UV_SRC_IDNA_H_ */ diff --git a/Utilities/cmlibuv/src/inet.c b/Utilities/cmlibuv/src/inet.c index 7c75e43730..58238dcbb6 100644 --- a/Utilities/cmlibuv/src/inet.c +++ b/Utilities/cmlibuv/src/inet.c @@ -22,7 +22,7 @@ #include <string.h> #if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" +# include "uv/stdint-msvc2008.h" #else # include <stdint.h> #endif @@ -59,8 +59,7 @@ static int inet_ntop4(const unsigned char *src, char *dst, size_t size) { if (l <= 0 || (size_t) l >= size) { return UV_ENOSPC; } - strncpy(dst, tmp, size); - dst[size - 1] = '\0'; + uv__strscpy(dst, tmp, size); return 0; } @@ -142,14 +141,8 @@ static int inet_ntop6(const unsigned char *src, char *dst, size_t size) { if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words)) *tp++ = ':'; *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { + if (UV_E2BIG == uv__strscpy(dst, tmp, size)) return UV_ENOSPC; - } - strcpy(dst, tmp); return 0; } diff --git a/Utilities/cmlibuv/src/strscpy.c b/Utilities/cmlibuv/src/strscpy.c new file mode 100644 index 0000000000..2a2bdce745 --- /dev/null +++ b/Utilities/cmlibuv/src/strscpy.c @@ -0,0 +1,17 @@ +#include "strscpy.h" +#include <limits.h> /* SSIZE_MAX */ + +ssize_t uv__strscpy(char* d, const char* s, size_t n) { + size_t i; + + for (i = 0; i < n; i++) + if ('\0' == (d[i] = s[i])) + return i > SSIZE_MAX ? UV_E2BIG : (ssize_t) i; + + if (i == 0) + return 0; + + d[--i] = '\0'; + + return UV_E2BIG; +} diff --git a/Utilities/cmlibuv/src/strscpy.h b/Utilities/cmlibuv/src/strscpy.h new file mode 100644 index 0000000000..fbe0a393f2 --- /dev/null +++ b/Utilities/cmlibuv/src/strscpy.h @@ -0,0 +1,18 @@ +#ifndef UV_STRSCPY_H_ +#define UV_STRSCPY_H_ + +/* Include uv.h for its definitions of size_t and ssize_t. + * size_t can be obtained directly from <stddef.h> but ssize_t requires + * some hoop jumping on Windows that I didn't want to duplicate here. + */ +#include "uv.h" + +/* Copies up to |n-1| bytes from |d| to |s| and always zero-terminates + * the result, except when |n==0|. Returns the number of bytes copied + * or UV_E2BIG if |d| is too small. + * + * See https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html + */ +ssize_t uv__strscpy(char* d, const char* s, size_t n); + +#endif /* UV_STRSCPY_H_ */ diff --git a/Utilities/cmlibuv/src/threadpool.c b/Utilities/cmlibuv/src/threadpool.c index 413d1c204c..4258933c72 100644 --- a/Utilities/cmlibuv/src/threadpool.c +++ b/Utilities/cmlibuv/src/threadpool.c @@ -33,12 +33,18 @@ static uv_once_t once = UV_ONCE_INIT; static uv_cond_t cond; static uv_mutex_t mutex; static unsigned int idle_threads; +static unsigned int slow_io_work_running; static unsigned int nthreads; static uv_thread_t* threads; static uv_thread_t default_threads[4]; static QUEUE exit_message; static QUEUE wq; +static QUEUE run_slow_work_message; +static QUEUE slow_io_pending_wq; +static unsigned int slow_work_thread_threshold(void) { + return (nthreads + 1) / 2; +} static void uv__cancelled(struct uv__work* w) { abort(); @@ -51,34 +57,67 @@ static void uv__cancelled(struct uv__work* w) { static void worker(void* arg) { struct uv__work* w; QUEUE* q; + int is_slow_work; uv_sem_post((uv_sem_t*) arg); arg = NULL; + uv_mutex_lock(&mutex); for (;;) { - uv_mutex_lock(&mutex); - - while (QUEUE_EMPTY(&wq)) { + /* `mutex` should always be locked at this point. */ + + /* Keep waiting while either no work is present or only slow I/O + and we're at the threshold for that. */ + while (QUEUE_EMPTY(&wq) || + (QUEUE_HEAD(&wq) == &run_slow_work_message && + QUEUE_NEXT(&run_slow_work_message) == &wq && + slow_io_work_running >= slow_work_thread_threshold())) { idle_threads += 1; uv_cond_wait(&cond, &mutex); idle_threads -= 1; } q = QUEUE_HEAD(&wq); - - if (q == &exit_message) + if (q == &exit_message) { uv_cond_signal(&cond); - else { + uv_mutex_unlock(&mutex); + break; + } + + QUEUE_REMOVE(q); + QUEUE_INIT(q); /* Signal uv_cancel() that the work req is executing. */ + + is_slow_work = 0; + if (q == &run_slow_work_message) { + /* If we're at the slow I/O threshold, re-schedule until after all + other work in the queue is done. */ + if (slow_io_work_running >= slow_work_thread_threshold()) { + QUEUE_INSERT_TAIL(&wq, q); + continue; + } + + /* If we encountered a request to run slow I/O work but there is none + to run, that means it's cancelled => Start over. */ + if (QUEUE_EMPTY(&slow_io_pending_wq)) + continue; + + is_slow_work = 1; + slow_io_work_running++; + + q = QUEUE_HEAD(&slow_io_pending_wq); QUEUE_REMOVE(q); - QUEUE_INIT(q); /* Signal uv_cancel() that the work req is - executing. */ + QUEUE_INIT(q); + + /* If there is more slow I/O work, schedule it to be run as well. */ + if (!QUEUE_EMPTY(&slow_io_pending_wq)) { + QUEUE_INSERT_TAIL(&wq, &run_slow_work_message); + if (idle_threads > 0) + uv_cond_signal(&cond); + } } uv_mutex_unlock(&mutex); - if (q == &exit_message) - break; - w = QUEUE_DATA(q, struct uv__work, wq); w->work(w); @@ -88,12 +127,32 @@ static void worker(void* arg) { QUEUE_INSERT_TAIL(&w->loop->wq, &w->wq); uv_async_send(&w->loop->wq_async); uv_mutex_unlock(&w->loop->wq_mutex); + + /* Lock `mutex` since that is expected at the start of the next + * iteration. */ + uv_mutex_lock(&mutex); + if (is_slow_work) { + /* `slow_io_work_running` is protected by `mutex`. */ + slow_io_work_running--; + } } } -static void post(QUEUE* q) { +static void post(QUEUE* q, enum uv__work_kind kind) { uv_mutex_lock(&mutex); + if (kind == UV__WORK_SLOW_IO) { + /* Insert into a separate queue. */ + QUEUE_INSERT_TAIL(&slow_io_pending_wq, q); + if (!QUEUE_EMPTY(&run_slow_work_message)) { + /* Running slow I/O tasks is already scheduled => Nothing to do here. + The worker that runs said other task will schedule this one as well. */ + uv_mutex_unlock(&mutex); + return; + } + q = &run_slow_work_message; + } + QUEUE_INSERT_TAIL(&wq, q); if (idle_threads > 0) uv_cond_signal(&cond); @@ -108,7 +167,7 @@ UV_DESTRUCTOR(static void cleanup(void)) { if (nthreads == 0) return; - post(&exit_message); + post(&exit_message, UV__WORK_CPU); for (i = 0; i < nthreads; i++) if (uv_thread_join(threads + i)) @@ -156,6 +215,8 @@ static void init_threads(void) { abort(); QUEUE_INIT(&wq); + QUEUE_INIT(&slow_io_pending_wq); + QUEUE_INIT(&run_slow_work_message); if (uv_sem_init(&sem, 0)) abort(); @@ -194,13 +255,14 @@ static void init_once(void) { void uv__work_submit(uv_loop_t* loop, struct uv__work* w, + enum uv__work_kind kind, void (*work)(struct uv__work* w), void (*done)(struct uv__work* w, int status)) { uv_once(&once, init_once); w->loop = loop; w->work = work; w->done = done; - post(&w->wq); + post(&w->wq, kind); } @@ -284,7 +346,11 @@ int uv_queue_work(uv_loop_t* loop, req->loop = loop; req->work_cb = work_cb; req->after_work_cb = after_work_cb; - uv__work_submit(loop, &req->work_req, uv__queue_work, uv__queue_done); + uv__work_submit(loop, + &req->work_req, + UV__WORK_CPU, + uv__queue_work, + uv__queue_done); return 0; } diff --git a/Utilities/cmlibuv/src/unix/timer.c b/Utilities/cmlibuv/src/timer.c index 54dabfe7df..dd78bcbad9 100644 --- a/Utilities/cmlibuv/src/unix/timer.c +++ b/Utilities/cmlibuv/src/timer.c @@ -19,13 +19,22 @@ */ #include "uv.h" -#include "internal.h" +#include "uv-common.h" #include "heap-inl.h" #include <assert.h> #include <limits.h> +static struct heap *timer_heap(const uv_loop_t* loop) { +#ifdef _WIN32 + return (struct heap*) loop->timer_heap; +#else + return (struct heap*) &loop->timer_heap; +#endif +} + + static int timer_less_than(const struct heap_node* ha, const struct heap_node* hb) { const uv_timer_t* a; @@ -81,7 +90,7 @@ int uv_timer_start(uv_timer_t* handle, /* start_id is the second index to be compared in uv__timer_cmp() */ handle->start_id = handle->loop->timer_counter++; - heap_insert((struct heap*) &handle->loop->timer_heap, + heap_insert(timer_heap(handle->loop), (struct heap_node*) &handle->heap_node, timer_less_than); uv__handle_start(handle); @@ -94,7 +103,7 @@ int uv_timer_stop(uv_timer_t* handle) { if (!uv__is_active(handle)) return 0; - heap_remove((struct heap*) &handle->loop->timer_heap, + heap_remove(timer_heap(handle->loop), (struct heap_node*) &handle->heap_node, timer_less_than); uv__handle_stop(handle); @@ -131,7 +140,7 @@ int uv__next_timeout(const uv_loop_t* loop) { const uv_timer_t* handle; uint64_t diff; - heap_node = heap_min((const struct heap*) &loop->timer_heap); + heap_node = heap_min(timer_heap(loop)); if (heap_node == NULL) return -1; /* block indefinitely */ @@ -143,7 +152,7 @@ int uv__next_timeout(const uv_loop_t* loop) { if (diff > INT_MAX) diff = INT_MAX; - return diff; + return (int) diff; } @@ -152,7 +161,7 @@ void uv__run_timers(uv_loop_t* loop) { uv_timer_t* handle; for (;;) { - heap_node = heap_min((struct heap*) &loop->timer_heap); + heap_node = heap_min(timer_heap(loop)); if (heap_node == NULL) break; diff --git a/Utilities/cmlibuv/src/unix/aix-common.c b/Utilities/cmlibuv/src/unix/aix-common.c index 9c11c5dac2..e9697e9c27 100644 --- a/Utilities/cmlibuv/src/unix/aix-common.c +++ b/Utilities/cmlibuv/src/unix/aix-common.c @@ -166,8 +166,7 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { } -int uv_interface_addresses(uv_interface_address_t** addresses, - int* count) { +int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { uv_interface_address_t* address; int sockfd, inet6, size = 1; struct ifconf ifc; @@ -175,6 +174,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, struct sockaddr_dl* sa_addr; *count = 0; + *addresses = NULL; if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) { return UV__ERR(errno); @@ -217,6 +217,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses, (*count)++; } + if (*count == 0) { + uv__close(sockfd); + return 0; + } + /* Alloc the return interface structs */ *addresses = uv__malloc(*count * sizeof(uv_interface_address_t)); if (!(*addresses)) { @@ -290,3 +295,4 @@ void uv_free_interface_addresses(uv_interface_address_t* addresses, uv__free(addresses); } + diff --git a/Utilities/cmlibuv/src/unix/aix.c b/Utilities/cmlibuv/src/unix/aix.c index 92de814834..337e58e0ad 100644 --- a/Utilities/cmlibuv/src/unix/aix.c +++ b/Utilities/cmlibuv/src/unix/aix.c @@ -358,19 +358,15 @@ void uv_loadavg(double avg[3]) { #ifdef HAVE_SYS_AHAFS_EVPRODS_H -static char *uv__rawname(char *cp) { - static char rawbuf[FILENAME_MAX+1]; - char *dp = rindex(cp, '/'); +static char* uv__rawname(const char* cp, char (*dst)[FILENAME_MAX+1]) { + char* dp; + dp = rindex(cp, '/'); if (dp == 0) return 0; - *dp = 0; - strcpy(rawbuf, cp); - *dp = '/'; - strcat(rawbuf, "/r"); - strcat(rawbuf, dp+1); - return rawbuf; + snprintf(*dst, sizeof(*dst), "%.*s/r%s", (int) (dp - cp), cp, dp + 1); + return *dst; } @@ -399,6 +395,7 @@ static int uv__path_is_a_directory(char* filename) { * Returns 0 if AHAFS is mounted, or an error code < 0 on failure */ static int uv__is_ahafs_mounted(void){ + char rawbuf[FILENAME_MAX+1]; int rv, i = 2; struct vmount *p; int size_multiplier = 10; @@ -432,7 +429,7 @@ static int uv__is_ahafs_mounted(void){ obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */ stub = vmt2dataptr(vmt, VMT_STUB); /* mount point */ - if (EQ(obj, dev) || EQ(uv__rawname(obj), dev) || EQ(stub, dev)) { + if (EQ(obj, dev) || EQ(uv__rawname(obj, &rawbuf), dev) || EQ(stub, dev)) { uv__free(p); /* Found a match */ return 0; } @@ -453,7 +450,8 @@ static int uv__makedir_p(const char *dir) { size_t len; int err; - snprintf(tmp, sizeof(tmp),"%s",dir); + /* TODO(bnoordhuis) Check uv__strscpy() return value. */ + uv__strscpy(tmp, dir, sizeof(tmp)); len = strlen(tmp); if (tmp[len - 1] == '/') tmp[len - 1] = 0; @@ -557,7 +555,7 @@ static int uv__setup_ahafs(const char* filename, int *fd) { sprintf(mon_file_write_string, "CHANGED=YES;WAIT_TYPE=WAIT_IN_SELECT;INFO_LVL=1"); rc = write(*fd, mon_file_write_string, strlen(mon_file_write_string)+1); - if (rc < 0) + if (rc < 0 && errno != EBUSY) return UV__ERR(errno); return 0; @@ -702,9 +700,9 @@ static void uv__ahafs_event(uv_loop_t* loop, uv__io_t* event_watch, unsigned int else p++; } - strncpy(fname, p, sizeof(fname) - 1); - /* Just in case */ - fname[sizeof(fname) - 1] = '\0'; + + /* TODO(bnoordhuis) Check uv__strscpy() return value. */ + uv__strscpy(fname, p, sizeof(fname)); handle->cb(handle, fname, events, 0); } @@ -730,12 +728,19 @@ int uv_fs_event_start(uv_fs_event_t* handle, char cwd[PATH_MAX]; char absolute_path[PATH_MAX]; char readlink_cwd[PATH_MAX]; + struct timeval zt; + fd_set pollfd; /* Figure out whether filename is absolute or not */ - if (filename[0] == '/') { + if (filename[0] == '\0') { + /* Missing a pathname */ + return UV_ENOENT; + } + else if (filename[0] == '/') { /* We have absolute pathname */ - snprintf(absolute_path, sizeof(absolute_path), "%s", filename); + /* TODO(bnoordhuis) Check uv__strscpy() return value. */ + uv__strscpy(absolute_path, filename, sizeof(absolute_path)); } else { /* We have a relative pathname, compose the absolute pathname */ snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid()); @@ -769,6 +774,15 @@ int uv_fs_event_start(uv_fs_event_t* handle, uv__io_start(handle->loop, &handle->event_watcher, POLLIN); + /* AHAFS wants someone to poll for it to start mointoring. + * so kick-start it so that we don't miss an event in the + * eventuality of an event that occurs in the current loop. */ + do { + memset(&zt, 0, sizeof(zt)); + FD_ZERO(&pollfd); + FD_SET(fd, &pollfd); + rc = select(fd + 1, &pollfd, NULL, NULL, &zt); + } while (rc == -1 && errno == EINTR); return 0; #else return UV_ENOSYS; @@ -886,16 +900,20 @@ int uv_set_process_title(const char* title) { int uv_get_process_title(char* buffer, size_t size) { size_t len; - len = strlen(process_argv[0]); if (buffer == NULL || size == 0) return UV_EINVAL; - else if (size <= len) - return UV_ENOBUFS; uv_once(&process_title_mutex_once, init_process_title_mutex_once); uv_mutex_lock(&process_title_mutex); - memcpy(buffer, process_argv[0], len + 1); + len = strlen(process_argv[0]); + if (size <= len) { + uv_mutex_unlock(&process_title_mutex); + return UV_ENOBUFS; + } + + memcpy(buffer, process_argv[0], len); + buffer[len] = '\0'; uv_mutex_unlock(&process_title_mutex); @@ -982,7 +1000,8 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { return UV_ENOMEM; } - strcpy(cpu_id.name, FIRST_CPU); + /* TODO(bnoordhuis) Check uv__strscpy() return value. */ + uv__strscpy(cpu_id.name, FIRST_CPU, sizeof(cpu_id.name)); result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus); if (result == -1) { uv__free(ps_cpus); diff --git a/Utilities/cmlibuv/src/unix/android-ifaddrs.c b/Utilities/cmlibuv/src/unix/android-ifaddrs.c index bf30b14179..99fb25a43b 100644 --- a/Utilities/cmlibuv/src/unix/android-ifaddrs.c +++ b/Utilities/cmlibuv/src/unix/android-ifaddrs.c @@ -23,7 +23,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "android-ifaddrs.h" +#include "uv/android-ifaddrs.h" #include "uv-common.h" #include <string.h> diff --git a/Utilities/cmlibuv/src/unix/bsd-ifaddrs.c b/Utilities/cmlibuv/src/unix/bsd-ifaddrs.c index 0d02154486..3c2253f0c9 100644 --- a/Utilities/cmlibuv/src/unix/bsd-ifaddrs.c +++ b/Utilities/cmlibuv/src/unix/bsd-ifaddrs.c @@ -52,13 +52,10 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) { */ if (ent->ifa_addr->sa_family == AF_LINK) return 1; -#elif defined(__NetBSD__) +#elif defined(__NetBSD__) || defined(__OpenBSD__) if (ent->ifa_addr->sa_family != PF_INET && ent->ifa_addr->sa_family != PF_INET6) return 1; -#elif defined(__OpenBSD__) - if (ent->ifa_addr->sa_family != PF_INET) - return 1; #endif return 0; } @@ -69,11 +66,12 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { uv_interface_address_t* address; int i; + *count = 0; + *addresses = NULL; + if (getifaddrs(&addrs) != 0) return UV__ERR(errno); - *count = 0; - /* Count the number of interfaces */ for (ent = addrs; ent != NULL; ent = ent->ifa_next) { if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) @@ -81,6 +79,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { (*count)++; } + if (*count == 0) { + freeifaddrs(addrs); + return 0; + } + *addresses = uv__malloc(*count * sizeof(**addresses)); if (*addresses == NULL) { @@ -121,15 +124,17 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { address = *addresses; for (i = 0; i < *count; i++) { - if (strcmp(address->name, ent->ifa_name) == 0) { #if defined(__CYGWIN__) || defined(__MSYS__) - memset(address->phys_addr, 0, sizeof(address->phys_addr)); + memset(address->phys_addr, 0, sizeof(address->phys_addr)); #else + if (strcmp(address->name, ent->ifa_name) == 0) { struct sockaddr_dl* sa_addr; sa_addr = (struct sockaddr_dl*)(ent->ifa_addr); memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); -#endif + } else { + memset(address->phys_addr, 0, sizeof(address->phys_addr)); } +#endif address++; } } diff --git a/Utilities/cmlibuv/src/unix/bsd-proctitle.c b/Utilities/cmlibuv/src/unix/bsd-proctitle.c new file mode 100644 index 0000000000..0ce47c8f64 --- /dev/null +++ b/Utilities/cmlibuv/src/unix/bsd-proctitle.c @@ -0,0 +1,93 @@ +/* Copyright libuv project contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "internal.h" + +#include <sys/types.h> +#include <unistd.h> + + +static uv_mutex_t process_title_mutex; +static uv_once_t process_title_mutex_once = UV_ONCE_INIT; +static char* process_title; + + +static void init_process_title_mutex_once(void) { + if (uv_mutex_init(&process_title_mutex)) + abort(); +} + + +char** uv_setup_args(int argc, char** argv) { + process_title = argc > 0 ? uv__strdup(argv[0]) : NULL; + return argv; +} + + +int uv_set_process_title(const char* title) { + char* new_title; + + new_title = uv__strdup(title); + if (new_title == NULL) + return UV_ENOMEM; + + uv_once(&process_title_mutex_once, init_process_title_mutex_once); + uv_mutex_lock(&process_title_mutex); + + uv__free(process_title); + process_title = new_title; + setproctitle("%s", title); + + uv_mutex_unlock(&process_title_mutex); + + return 0; +} + + +int uv_get_process_title(char* buffer, size_t size) { + size_t len; + + if (buffer == NULL || size == 0) + return UV_EINVAL; + + uv_once(&process_title_mutex_once, init_process_title_mutex_once); + uv_mutex_lock(&process_title_mutex); + + if (process_title != NULL) { + len = strlen(process_title) + 1; + + if (size < len) { + uv_mutex_unlock(&process_title_mutex); + return UV_ENOBUFS; + } + + memcpy(buffer, process_title, len); + } else { + len = 0; + } + + uv_mutex_unlock(&process_title_mutex); + + buffer[len] = '\0'; + + return 0; +} diff --git a/Utilities/cmlibuv/src/unix/cmake-bootstrap.c b/Utilities/cmlibuv/src/unix/cmake-bootstrap.c index 4f32d03bc3..309ec79ce1 100644 --- a/Utilities/cmlibuv/src/unix/cmake-bootstrap.c +++ b/Utilities/cmlibuv/src/unix/cmake-bootstrap.c @@ -46,6 +46,7 @@ void uv__async_stop(uv_loop_t* loop) { } void uv__work_submit(uv_loop_t* loop, struct uv__work* w, + enum uv__work_kind kind, void (*work)(struct uv__work* w), void (*done)(struct uv__work* w, int status)) { abort(); diff --git a/Utilities/cmlibuv/src/unix/core.c b/Utilities/cmlibuv/src/unix/core.c index a357ef32de..a8d6adb423 100644 --- a/Utilities/cmlibuv/src/unix/core.c +++ b/Utilities/cmlibuv/src/unix/core.c @@ -41,6 +41,7 @@ #include <sys/resource.h> /* getrusage */ #include <pwd.h> #include <sched.h> +#include <sys/utsname.h> #ifdef __sun # include <netdb.h> /* MAXHOSTNAMELEN on Solaris */ @@ -119,7 +120,7 @@ uint64_t uv_hrtime(void) { void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { assert(!uv__is_closing(handle)); - handle->flags |= UV_CLOSING; + handle->flags |= UV_HANDLE_CLOSING; handle->close_cb = close_cb; switch (handle->type) { @@ -177,8 +178,8 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { case UV_SIGNAL: uv__signal_close((uv_signal_t*) handle); - /* Signal handles may not be closed immediately. The signal code will */ - /* itself close uv__make_close_pending whenever appropriate. */ + /* Signal handles may not be closed immediately. The signal code will + * itself close uv__make_close_pending whenever appropriate. */ return; default: @@ -217,8 +218,8 @@ int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) { } void uv__make_close_pending(uv_handle_t* handle) { - assert(handle->flags & UV_CLOSING); - assert(!(handle->flags & UV_CLOSED)); + assert(handle->flags & UV_HANDLE_CLOSING); + assert(!(handle->flags & UV_HANDLE_CLOSED)); handle->next_closing = handle->loop->closing_handles; handle->loop->closing_handles = handle; } @@ -244,15 +245,17 @@ int uv__getiovmax(void) { static void uv__finish_close(uv_handle_t* handle) { - /* Note: while the handle is in the UV_CLOSING state now, it's still possible - * for it to be active in the sense that uv__is_active() returns true. + /* Note: while the handle is in the UV_HANDLE_CLOSING state now, it's still + * possible for it to be active in the sense that uv__is_active() returns + * true. + * * A good example is when the user calls uv_shutdown(), immediately followed * by uv_close(). The handle is considered active at this point because the * completion of the shutdown req is still pending. */ - assert(handle->flags & UV_CLOSING); - assert(!(handle->flags & UV_CLOSED)); - handle->flags |= UV_CLOSED; + assert(handle->flags & UV_HANDLE_CLOSING); + assert(!(handle->flags & UV_HANDLE_CLOSED)); + handle->flags |= UV_HANDLE_CLOSED; switch (handle->type) { case UV_PREPARE: @@ -637,27 +640,6 @@ int uv__cloexec_fcntl(int fd, int set) { } -/* This function is not execve-safe, there is a race window - * between the call to dup() and fcntl(FD_CLOEXEC). - */ -int uv__dup(int fd) { - int err; - - fd = dup(fd); - - if (fd == -1) - return UV__ERR(errno); - - err = uv__cloexec(fd, 1); - if (err) { - uv__close(fd); - return err; - } - - return fd; -} - - ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) { struct cmsghdr* cmsg; ssize_t rc; @@ -930,6 +912,11 @@ int uv__io_active(const uv__io_t* w, unsigned int events) { } +int uv__fd_exists(uv_loop_t* loop, int fd) { + return (unsigned) fd < loop->nwatchers && loop->watchers[fd] != NULL; +} + + int uv_getrusage(uv_rusage_t* rusage) { struct rusage usage; @@ -1343,6 +1330,9 @@ uv_os_fd_t uv_get_osfhandle(int fd) { return fd; } +int uv_open_osfhandle(uv_os_fd_t os_fd) { + return os_fd; +} uv_pid_t uv_os_getpid(void) { return getpid(); @@ -1352,3 +1342,87 @@ uv_pid_t uv_os_getpid(void) { uv_pid_t uv_os_getppid(void) { return getppid(); } + + +int uv_os_getpriority(uv_pid_t pid, int* priority) { + int r; + + if (priority == NULL) + return UV_EINVAL; + + errno = 0; + r = getpriority(PRIO_PROCESS, (int) pid); + + if (r == -1 && errno != 0) + return UV__ERR(errno); + + *priority = r; + return 0; +} + + +int uv_os_setpriority(uv_pid_t pid, int priority) { + if (priority < UV_PRIORITY_HIGHEST || priority > UV_PRIORITY_LOW) + return UV_EINVAL; + + if (setpriority(PRIO_PROCESS, (int) pid, priority) != 0) + return UV__ERR(errno); + + return 0; +} + + +int uv_os_uname(uv_utsname_t* buffer) { + struct utsname buf; + int r; + + if (buffer == NULL) + return UV_EINVAL; + + if (uname(&buf) == -1) { + r = UV__ERR(errno); + goto error; + } + + r = uv__strscpy(buffer->sysname, buf.sysname, sizeof(buffer->sysname)); + if (r == UV_E2BIG) + goto error; + +#ifdef _AIX + r = snprintf(buffer->release, + sizeof(buffer->release), + "%s.%s", + buf.version, + buf.release); + if (r >= sizeof(buffer->release)) { + r = UV_E2BIG; + goto error; + } +#else + r = uv__strscpy(buffer->release, buf.release, sizeof(buffer->release)); + if (r == UV_E2BIG) + goto error; +#endif + + r = uv__strscpy(buffer->version, buf.version, sizeof(buffer->version)); + if (r == UV_E2BIG) + goto error; + +#if defined(_AIX) || defined(__PASE__) + r = uv__strscpy(buffer->machine, "ppc64", sizeof(buffer->machine)); +#else + r = uv__strscpy(buffer->machine, buf.machine, sizeof(buffer->machine)); +#endif + + if (r == UV_E2BIG) + goto error; + + return 0; + +error: + buffer->sysname[0] = '\0'; + buffer->release[0] = '\0'; + buffer->version[0] = '\0'; + buffer->machine[0] = '\0'; + return r; +} diff --git a/Utilities/cmlibuv/src/unix/cygwin.c b/Utilities/cmlibuv/src/unix/cygwin.c index 9fe4093ef4..9da20e203a 100644 --- a/Utilities/cmlibuv/src/unix/cygwin.c +++ b/Utilities/cmlibuv/src/unix/cygwin.c @@ -38,7 +38,7 @@ int uv_uptime(double* uptime) { int uv_resident_set_memory(size_t* rss) { /* FIXME: read /proc/meminfo? */ *rss = 0; - return UV_ENOSYS; + return 0; } int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { diff --git a/Utilities/cmlibuv/src/unix/darwin-proctitle.c b/Utilities/cmlibuv/src/unix/darwin-proctitle.c index dabde2239c..e505bdd23f 100644 --- a/Utilities/cmlibuv/src/unix/darwin-proctitle.c +++ b/Utilities/cmlibuv/src/unix/darwin-proctitle.c @@ -33,61 +33,56 @@ # include <ApplicationServices/ApplicationServices.h> #endif +#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8) -static int uv__pthread_setname_np(const char* name) { - int (*dynamic_pthread_setname_np)(const char* name); - char namebuf[64]; /* MAXTHREADNAMESIZE */ - int err; - - /* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */ - *(void **)(&dynamic_pthread_setname_np) = - dlsym(RTLD_DEFAULT, "pthread_setname_np"); - - if (dynamic_pthread_setname_np == NULL) - return UV_ENOSYS; - - strncpy(namebuf, name, sizeof(namebuf) - 1); - namebuf[sizeof(namebuf) - 1] = '\0'; - err = dynamic_pthread_setname_np(namebuf); - if (err) - return UV__ERR(err); +static int (*dynamic_pthread_setname_np)(const char* name); +#if !TARGET_OS_IPHONE +static CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef, + const char*, + CFStringEncoding); +static CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef); +static void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef); +static void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef); +static CFTypeRef (*pLSGetCurrentApplicationASN)(void); +static OSStatus (*pLSSetApplicationInformationItem)(int, + CFTypeRef, + CFStringRef, + CFStringRef, + CFDictionaryRef*); +static void* application_services_handle; +static void* core_foundation_handle; +static CFBundleRef launch_services_bundle; +static CFStringRef* display_name_key; +static CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef); +static CFBundleRef (*pCFBundleGetMainBundle)(void); +static CFBundleRef hi_services_bundle; +static OSStatus (*pSetApplicationIsDaemon)(int); +static CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef); +static void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t, + void*); + + +UV_DESTRUCTOR(static void uv__set_process_title_platform_fini(void)) { + if (core_foundation_handle != NULL) { + dlclose(core_foundation_handle); + core_foundation_handle = NULL; + } - return 0; + if (application_services_handle != NULL) { + dlclose(application_services_handle); + application_services_handle = NULL; + } } +#endif /* !TARGET_OS_IPHONE */ -int uv__set_process_title(const char* title) { -#if TARGET_OS_IPHONE - return uv__pthread_setname_np(title); -#else - CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef, - const char*, - CFStringEncoding); - CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef); - void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef); - void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef); - CFTypeRef (*pLSGetCurrentApplicationASN)(void); - OSStatus (*pLSSetApplicationInformationItem)(int, - CFTypeRef, - CFStringRef, - CFStringRef, - CFDictionaryRef*); - void* application_services_handle; - void* core_foundation_handle; - CFBundleRef launch_services_bundle; - CFStringRef* display_name_key; - CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef); - CFBundleRef (*pCFBundleGetMainBundle)(void); - CFBundleRef hi_services_bundle; - OSStatus (*pSetApplicationIsDaemon)(int); - CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef); - void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t, - void*); - CFTypeRef asn; - int err; - - err = UV_ENOENT; +void uv__set_process_title_platform_init(void) { + /* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */ + *(void **)(&dynamic_pthread_setname_np) = + dlsym(RTLD_DEFAULT, "pthread_setname_np"); + +#if !TARGET_OS_IPHONE application_services_handle = dlopen("/System/Library/Frameworks/" "ApplicationServices.framework/" "Versions/A/ApplicationServices", @@ -116,8 +111,6 @@ int uv__set_process_title(const char* title) { goto out; } -#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8) - launch_services_bundle = pCFBundleGetBundleWithIdentifier(S("com.apple.LaunchServices")); @@ -148,13 +141,14 @@ int uv__set_process_title(const char* title) { "CFBundleGetInfoDictionary"); *(void **)(&pCFBundleGetMainBundle) = dlsym(core_foundation_handle, "CFBundleGetMainBundle"); + if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL) goto out; /* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */ hi_services_bundle = pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices")); - err = UV_ENOENT; + if (hi_services_bundle == NULL) goto out; @@ -168,42 +162,37 @@ int uv__set_process_title(const char* title) { pCFBundleGetFunctionPointerForName( launch_services_bundle, S("_LSSetApplicationLaunchServicesServerConnectionStatus")); + if (pSetApplicationIsDaemon == NULL || pLSApplicationCheckIn == NULL || pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) { goto out; } - if (pSetApplicationIsDaemon(1) != noErr) - goto out; - - pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL); - - /* Check into process manager?! */ - pLSApplicationCheckIn(-2, - pCFBundleGetInfoDictionary(pCFBundleGetMainBundle())); - - asn = pLSGetCurrentApplicationASN(); - - err = UV_EINVAL; - if (pLSSetApplicationInformationItem(-2, /* Magic value. */ - asn, - *display_name_key, - S(title), - NULL) != noErr) { - goto out; - } - - uv__pthread_setname_np(title); /* Don't care if it fails. */ - err = 0; + return; out: - if (core_foundation_handle != NULL) - dlclose(core_foundation_handle); + uv__set_process_title_platform_fini(); +#endif /* !TARGET_OS_IPHONE */ +} - if (application_services_handle != NULL) - dlclose(application_services_handle); - return err; +void uv__set_process_title(const char* title) { +#if !TARGET_OS_IPHONE + if (core_foundation_handle != NULL && pSetApplicationIsDaemon(1) != noErr) { + CFTypeRef asn; + pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL); + pLSApplicationCheckIn(/* Magic value */ -2, + pCFBundleGetInfoDictionary(pCFBundleGetMainBundle())); + asn = pLSGetCurrentApplicationASN(); + pLSSetApplicationInformationItem(/* Magic value */ -2, asn, + *display_name_key, S(title), NULL); + } #endif /* !TARGET_OS_IPHONE */ + + if (dynamic_pthread_setname_np != NULL) { + char namebuf[64]; /* MAXTHREADNAMESIZE */ + uv__strscpy(namebuf, title, sizeof(namebuf)); + dynamic_pthread_setname_np(namebuf); + } } diff --git a/Utilities/cmlibuv/src/unix/freebsd.c b/Utilities/cmlibuv/src/unix/freebsd.c index 70ccb13042..0f729cfd47 100644 --- a/Utilities/cmlibuv/src/unix/freebsd.c +++ b/Utilities/cmlibuv/src/unix/freebsd.c @@ -47,15 +47,6 @@ # define CP_INTR 4 #endif -static uv_mutex_t process_title_mutex; -static uv_once_t process_title_mutex_once = UV_ONCE_INIT; -static char *process_title; - - -static void init_process_title_mutex_once(void) { - uv_mutex_init(&process_title_mutex); -} - int uv__platform_loop_init(uv_loop_t* loop) { return uv__kqueue_init(loop); @@ -159,76 +150,6 @@ void uv_loadavg(double avg[3]) { } -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - int oid[4]; - char* new_title; - - new_title = uv__strdup(title); - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title == NULL) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOMEM; - } - - uv__free(process_title); - process_title = new_title; - - oid[0] = CTL_KERN; - oid[1] = KERN_PROC; - oid[2] = KERN_PROC_ARGS; - oid[3] = getpid(); - - sysctl(oid, - ARRAY_SIZE(oid), - NULL, - NULL, - process_title, - strlen(process_title) + 1); - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOBUFS; - } - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - uv_mutex_unlock(&process_title_mutex); - - buffer[len] = '\0'; - - return 0; -} - int uv_resident_set_memory(size_t* rss) { struct kinfo_proc kinfo; size_t page_size; diff --git a/Utilities/cmlibuv/src/unix/fs.c b/Utilities/cmlibuv/src/unix/fs.c index a6cc6dbd1f..bffc956b54 100644 --- a/Utilities/cmlibuv/src/unix/fs.c +++ b/Utilities/cmlibuv/src/unix/fs.c @@ -43,7 +43,6 @@ #include <pthread.h> #include <unistd.h> #include <fcntl.h> -#include <utime.h> #include <poll.h> #if defined(__DragonFly__) || \ @@ -62,11 +61,20 @@ #if defined(__APPLE__) # include <copyfile.h> +# include <sys/sysctl.h> #elif defined(__linux__) && !defined(FICLONE) # include <sys/ioctl.h> # define FICLONE _IOW(0x94, 9, int) #endif +#if defined(_AIX) && !defined(_AIX71) +# include <utime.h> +#endif + +#if defined(_AIX) && _XOPEN_SOURCE <= 600 +extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */ +#endif + #define INIT(subtype) \ do { \ if (req == NULL) \ @@ -120,7 +128,11 @@ do { \ if (cb != NULL) { \ uv__req_register(loop, req); \ - uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ + uv__work_submit(loop, \ + &req->work_req, \ + UV__WORK_FAST_IO, \ + uv__fs_work, \ + uv__fs_done); \ return 0; \ } \ else { \ @@ -143,7 +155,7 @@ static ssize_t uv__fs_fsync(uv_fs_t* req) { int r; r = fcntl(req->file, F_FULLFSYNC); - if (r != 0 && errno == ENOTTY) + if (r != 0) r = fsync(req->file); return r; #else @@ -165,59 +177,17 @@ static ssize_t uv__fs_fdatasync(uv_fs_t* req) { static ssize_t uv__fs_futime(uv_fs_t* req) { -#if defined(__linux__) +#if defined(__linux__) \ + || defined(_AIX71) /* utimesat() has nanosecond resolution but we stick to microseconds * for the sake of consistency with other platforms. */ - static int no_utimesat; struct timespec ts[2]; - struct timeval tv[2]; - char path[sizeof("/proc/self/fd/") + 3 * sizeof(int)]; - int r; - - if (no_utimesat) - goto skip; - ts[0].tv_sec = req->atime; ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; ts[1].tv_sec = req->mtime; ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; - - r = uv__utimesat(req->file, NULL, ts, 0); - if (r == 0) - return r; - - if (errno != ENOSYS) - return r; - - no_utimesat = 1; - -skip: - - tv[0].tv_sec = req->atime; - tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000; - tv[1].tv_sec = req->mtime; - tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000; - snprintf(path, sizeof(path), "/proc/self/fd/%d", (int) req->file); - - r = utimes(path, tv); - if (r == 0) - return r; - - switch (errno) { - case ENOENT: - if (fcntl(req->file, F_GETFL) == -1 && errno == EBADF) - break; - /* Fall through. */ - - case EACCES: - case ENOTDIR: - errno = ENOSYS; - break; - } - - return r; - + return futimens(req->file, ts); #elif defined(__APPLE__) \ || defined(__DragonFly__) \ || defined(__FreeBSD__) \ @@ -235,13 +205,6 @@ skip: # else return futimes(req->file, tv); # endif -#elif defined(_AIX71) - struct timespec ts[2]; - ts[0].tv_sec = req->atime; - ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; - ts[1].tv_sec = req->mtime; - ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; - return futimens(req->file, ts); #elif defined(__MVS__) attrib_t atr; memset(&atr, 0, sizeof(atr)); @@ -314,17 +277,13 @@ static ssize_t uv__fs_read(uv_fs_t* req) { #if defined(__linux__) static int no_preadv; #endif + unsigned int iovmax; ssize_t result; -#if defined(_AIX) - struct stat buf; - if(fstat(req->file, &buf)) - return -1; - if(S_ISDIR(buf.st_mode)) { - errno = EISDIR; - return -1; - } -#endif /* defined(_AIX) */ + iovmax = uv__getiovmax(); + if (req->nbufs > iovmax) + req->nbufs = iovmax; + if (req->off < 0) { if (req->nbufs == 1) result = read(req->file, req->bufs[0].base, req->bufs[0].len); @@ -343,25 +302,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) { if (no_preadv) retry: # endif { - off_t nread; - size_t index; - - nread = 0; - index = 0; - result = 1; - do { - if (req->bufs[index].len > 0) { - result = pread(req->file, - req->bufs[index].base, - req->bufs[index].len, - req->off + nread); - if (result > 0) - nread += result; - } - index++; - } while (index < req->nbufs && result > 0); - if (nread > 0) - result = nread; + result = pread(req->file, req->bufs[0].base, req->bufs[0].len, req->off); } # if defined(__linux__) else { @@ -379,6 +320,13 @@ static ssize_t uv__fs_read(uv_fs_t* req) { } done: + /* Early cleanup of bufs allocation, since we're done with it. */ + if (req->bufs != req->bufsml) + uv__free(req->bufs); + + req->bufs = NULL; + req->nbufs = 0; + return result; } @@ -446,8 +394,10 @@ static ssize_t uv__fs_pathmax_size(const char* path) { } static ssize_t uv__fs_readlink(uv_fs_t* req) { + ssize_t maxlen; ssize_t len; char* buf; + char* newbuf; #if defined(UV__FS_PATH_MAX_FALLBACK) /* We may not have a real PATH_MAX. Read size of link. */ @@ -461,17 +411,17 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { return -1; } - len = st.st_size; + maxlen = st.st_size; /* According to readlink(2) lstat can report st_size == 0 for some symlinks, such as those in /proc or /sys. */ - if (len == 0) - len = uv__fs_pathmax_size(req->path); + if (maxlen == 0) + maxlen = uv__fs_pathmax_size(req->path); #else - len = uv__fs_pathmax_size(req->path); + maxlen = uv__fs_pathmax_size(req->path); #endif - buf = uv__malloc(len + 1); + buf = uv__malloc(maxlen); if (buf == NULL) { errno = ENOMEM; @@ -479,17 +429,28 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) { } #if defined(__MVS__) - len = os390_readlink(req->path, buf, len); + len = os390_readlink(req->path, buf, maxlen); #else - len = readlink(req->path, buf, len); + len = readlink(req->path, buf, maxlen); #endif - if (len == -1) { uv__free(buf); return -1; } + /* Uncommon case: resize to make room for the trailing nul byte. */ + if (len == maxlen) { + newbuf = uv__realloc(buf, len + 1); + + if (newbuf == NULL) { + uv__free(buf); + return -1; + } + + buf = newbuf; + } + buf[len] = '\0'; req->ptr = buf; @@ -739,10 +700,48 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) { static ssize_t uv__fs_utime(uv_fs_t* req) { +#if defined(__linux__) \ + || defined(_AIX71) \ + || defined(__sun) + /* utimesat() has nanosecond resolution but we stick to microseconds + * for the sake of consistency with other platforms. + */ + struct timespec ts[2]; + ts[0].tv_sec = req->atime; + ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; + ts[1].tv_sec = req->mtime; + ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; + return utimensat(AT_FDCWD, req->path, ts, 0); +#elif defined(__APPLE__) \ + || defined(__DragonFly__) \ + || defined(__FreeBSD__) \ + || defined(__FreeBSD_kernel__) \ + || defined(__NetBSD__) \ + || defined(__OpenBSD__) + struct timeval tv[2]; + tv[0].tv_sec = req->atime; + tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000; + tv[1].tv_sec = req->mtime; + tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000; + return utimes(req->path, tv); +#elif defined(_AIX) \ + && !defined(_AIX71) struct utimbuf buf; buf.actime = req->atime; buf.modtime = req->mtime; - return utime(req->path, &buf); /* TODO use utimes() where available */ + return utime(req->path, &buf); +#elif defined(__MVS__) + attrib_t atr; + memset(&atr, 0, sizeof(atr)); + atr.att_mtimechg = 1; + atr.att_atimechg = 1; + atr.att_mtime = req->mtime; + atr.att_atime = req->atime; + return __lchattr((char*) req->path, &atr, sizeof(atr)); +#else + errno = ENOSYS; + return -1; +#endif } @@ -780,25 +779,7 @@ static ssize_t uv__fs_write(uv_fs_t* req) { if (no_pwritev) retry: # endif { - off_t written; - size_t index; - - written = 0; - index = 0; - r = 0; - do { - if (req->bufs[index].len > 0) { - r = pwrite(req->file, - req->bufs[index].base, - req->bufs[index].len, - req->off + written); - if (r > 0) - written += r; - } - index++; - } while (index < req->nbufs && r >= 0); - if (written > 0) - r = written; + r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off); } # if defined(__linux__) else { @@ -827,26 +808,41 @@ done: static ssize_t uv__fs_copyfile(uv_fs_t* req) { #if defined(__APPLE__) && !TARGET_OS_IPHONE /* On macOS, use the native copyfile(3). */ + static int can_clone; copyfile_flags_t flags; + char buf[64]; + size_t len; + int major; flags = COPYFILE_ALL; if (req->flags & UV_FS_COPYFILE_EXCL) flags |= COPYFILE_EXCL; -#ifdef COPYFILE_CLONE - if (req->flags & UV_FS_COPYFILE_FICLONE) - flags |= COPYFILE_CLONE; -#endif - + /* Check OS version. Cloning is only supported on macOS >= 10.12. */ if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) { -#ifdef COPYFILE_CLONE_FORCE - flags |= COPYFILE_CLONE_FORCE; -#else - return UV_ENOSYS; -#endif + if (can_clone == 0) { + len = sizeof(buf); + if (sysctlbyname("kern.osrelease", buf, &len, NULL, 0)) + return UV__ERR(errno); + + if (1 != sscanf(buf, "%d", &major)) + abort(); + + can_clone = -1 + 2 * (major >= 16); /* macOS >= 10.12 */ + } + + if (can_clone < 0) + return UV_ENOSYS; } + /* copyfile() simply ignores COPYFILE_CLONE if it's not supported. */ + if (req->flags & UV_FS_COPYFILE_FICLONE) + flags |= 1 << 24; /* COPYFILE_CLONE */ + + if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) + flags |= 1 << 25; /* COPYFILE_CLONE_FORCE */ + return copyfile(req->path, req->new_path, NULL, flags); #else uv_fs_t fs_req; @@ -906,9 +902,11 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { /* If an error occurred that the sendfile fallback also won't handle, or this is a force clone then exit. Otherwise, fall through to try using sendfile(). */ - if ((errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) || - req->flags & UV_FS_COPYFILE_FICLONE_FORCE) { - err = -errno; + if (errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) { + err = UV__ERR(errno); + goto out; + } else if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) { + err = UV_ENOTSUP; goto out; } } else { @@ -968,7 +966,11 @@ out: } } - return result; + if (result == 0) + return 0; + + errno = UV__ERR(result); + return -1; #endif } @@ -1084,9 +1086,21 @@ static int uv__fs_fstat(int fd, uv_stat_t *buf) { return ret; } +static size_t uv__fs_buf_offset(uv_buf_t* bufs, size_t size) { + size_t offset; + /* Figure out which bufs are done */ + for (offset = 0; size > 0 && bufs[offset].len <= size; ++offset) + size -= bufs[offset].len; + + /* Fix a partial read/write */ + if (size > 0) { + bufs[offset].base += size; + bufs[offset].len -= size; + } + return offset; +} -typedef ssize_t (*uv__fs_buf_iter_processor)(uv_fs_t* req); -static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process) { +static ssize_t uv__fs_write_all(uv_fs_t* req) { unsigned int iovmax; unsigned int nbufs; uv_buf_t* bufs; @@ -1103,7 +1117,10 @@ static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process) if (req->nbufs > iovmax) req->nbufs = iovmax; - result = process(req); + do + result = uv__fs_write(req); + while (result < 0 && errno == EINTR); + if (result <= 0) { if (total == 0) total = result; @@ -1113,14 +1130,12 @@ static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process) if (req->off >= 0) req->off += result; + req->nbufs = uv__fs_buf_offset(req->bufs, result); req->bufs += req->nbufs; nbufs -= req->nbufs; total += result; } - if (errno == EINTR && total == -1) - return total; - if (bufs != req->bufsml) uv__free(bufs); @@ -1137,7 +1152,8 @@ static void uv__fs_work(struct uv__work* w) { ssize_t r; req = container_of(w, uv_fs_t, work_req); - retry_on_eintr = !(req->fs_type == UV_FS_CLOSE); + retry_on_eintr = !(req->fs_type == UV_FS_CLOSE || + req->fs_type == UV_FS_READ); do { errno = 0; @@ -1155,6 +1171,7 @@ static void uv__fs_work(struct uv__work* w) { X(COPYFILE, uv__fs_copyfile(req)); X(FCHMOD, fchmod(req->file, req->mode)); X(FCHOWN, fchown(req->file, req->uid, req->gid)); + X(LCHOWN, lchown(req->path, req->uid, req->gid)); X(FDATASYNC, uv__fs_fdatasync(req)); X(FSTAT, uv__fs_fstat(req->file, &req->statbuf)); X(FSYNC, uv__fs_fsync(req)); @@ -1165,7 +1182,7 @@ static void uv__fs_work(struct uv__work* w) { X(MKDIR, mkdir(req->path, req->mode)); X(MKDTEMP, uv__fs_mkdtemp(req)); X(OPEN, uv__fs_open(req)); - X(READ, uv__fs_buf_iter(req, uv__fs_read)); + X(READ, uv__fs_read(req)); X(SCANDIR, uv__fs_scandir(req)); X(READLINK, uv__fs_readlink(req)); X(REALPATH, uv__fs_realpath(req)); @@ -1176,7 +1193,7 @@ static void uv__fs_work(struct uv__work* w) { X(SYMLINK, symlink(req->path, req->new_path)); X(UNLINK, unlink(req->path)); X(UTIME, uv__fs_utime(req)); - X(WRITE, uv__fs_buf_iter(req, uv__fs_write)); + X(WRITE, uv__fs_write_all(req)); default: abort(); } #undef X @@ -1281,6 +1298,20 @@ int uv_fs_fchown(uv_loop_t* loop, } +int uv_fs_lchown(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_uid_t uid, + uv_gid_t gid, + uv_fs_cb cb) { + INIT(LCHOWN); + PATH; + req->uid = uid; + req->gid = gid; + POST; +} + + int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { INIT(FDATASYNC); req->file = file; diff --git a/Utilities/cmlibuv/src/unix/fsevents.c b/Utilities/cmlibuv/src/unix/fsevents.c index 47d8024b6d..c430562b37 100644 --- a/Utilities/cmlibuv/src/unix/fsevents.c +++ b/Utilities/cmlibuv/src/unix/fsevents.c @@ -255,42 +255,55 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, path = paths[i]; len = strlen(path); + if (handle->realpath_len == 0) + continue; /* This should be unreachable */ + /* Filter out paths that are outside handle's request */ - if (strncmp(path, handle->realpath, handle->realpath_len) != 0) + if (len < handle->realpath_len) + continue; + + if (handle->realpath_len != len && + path[handle->realpath_len] != '/') + /* Make sure that realpath actually named a directory, + * or that we matched the whole string */ continue; - if (handle->realpath_len > 1 || *handle->realpath != '/') { + if (memcmp(path, handle->realpath, handle->realpath_len) != 0) + continue; + + if (!(handle->realpath_len == 1 && handle->realpath[0] == '/')) { + /* Remove common prefix, unless the watched folder is "/" */ path += handle->realpath_len; len -= handle->realpath_len; - /* Skip forward slash */ - if (*path != '\0') { + /* Ignore events with path equal to directory itself */ + if (len <= 1 && (flags & kFSEventStreamEventFlagItemIsDir)) + continue; + + if (len == 0) { + /* Since we're using fsevents to watch the file itself, + * realpath == path, and we now need to get the basename of the file back + * (for commonality with other codepaths and platforms). */ + while (len < handle->realpath_len && path[-1] != '/') { + path--; + len++; + } + /* Created and Removed seem to be always set, but don't make sense */ + flags &= ~kFSEventsRenamed; + } else { + /* Skip forward slash */ path++; len--; } } -#ifdef MAC_OS_X_VERSION_10_7 - /* Ignore events with path equal to directory itself */ - if (len == 0) - continue; -#else - if (len == 0 && (flags & kFSEventStreamEventFlagItemIsDir)) - continue; -#endif /* MAC_OS_X_VERSION_10_7 */ - /* Do not emit events from subdirectories (without option set) */ - if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != 0) { + if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != '\0') { pos = strchr(path + 1, '/'); if (pos != NULL) continue; } -#ifndef MAC_OS_X_VERSION_10_7 - path = ""; - len = 0; -#endif /* MAC_OS_X_VERSION_10_7 */ - event = uv__malloc(sizeof(*event) + len); if (event == NULL) break; @@ -299,22 +312,11 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, memcpy(event->path, path, len + 1); event->events = UV_RENAME; -#ifdef MAC_OS_X_VERSION_10_7 - if (0 != (flags & kFSEventsModified) && - 0 == (flags & kFSEventsRenamed)) { - event->events = UV_CHANGE; - } -#else - if (0 != (flags & kFSEventsModified) && - 0 != (flags & kFSEventStreamEventFlagItemIsDir) && - 0 == (flags & kFSEventStreamEventFlagItemRenamed)) { - event->events = UV_CHANGE; - } - if (0 == (flags & kFSEventStreamEventFlagItemIsDir) && - 0 == (flags & kFSEventStreamEventFlagItemRenamed)) { - event->events = UV_CHANGE; + if (0 == (flags & kFSEventsRenamed)) { + if (0 != (flags & kFSEventsModified) || + 0 == (flags & kFSEventStreamEventFlagItemIsDir)) + event->events = UV_CHANGE; } -#endif /* MAC_OS_X_VERSION_10_7 */ QUEUE_INSERT_TAIL(&head, &event->member); } @@ -836,7 +838,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) { handle->cf_cb->data = handle; uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb); - handle->cf_cb->flags |= UV__HANDLE_INTERNAL; + handle->cf_cb->flags |= UV_HANDLE_INTERNAL; uv_unref((uv_handle_t*) handle->cf_cb); err = uv_mutex_init(&handle->cf_mutex); diff --git a/Utilities/cmlibuv/src/unix/getaddrinfo.c b/Utilities/cmlibuv/src/unix/getaddrinfo.c index 10e8afd75e..6d23fbe02a 100644 --- a/Utilities/cmlibuv/src/unix/getaddrinfo.c +++ b/Utilities/cmlibuv/src/unix/getaddrinfo.c @@ -27,6 +27,7 @@ #include "uv.h" #include "internal.h" +#include "idna.h" #include <errno.h> #include <stddef.h> /* NULL */ @@ -141,15 +142,34 @@ int uv_getaddrinfo(uv_loop_t* loop, const char* hostname, const char* service, const struct addrinfo* hints) { + char hostname_ascii[256]; size_t hostname_len; size_t service_len; size_t hints_len; size_t len; char* buf; + long rc; if (req == NULL || (hostname == NULL && service == NULL)) return UV_EINVAL; + /* FIXME(bnoordhuis) IDNA does not seem to work z/OS, + * probably because it uses EBCDIC rather than ASCII. + */ +#ifdef __MVS__ + (void) &hostname_ascii; +#else + if (hostname != NULL) { + rc = uv__idna_toascii(hostname, + hostname + strlen(hostname), + hostname_ascii, + hostname_ascii + sizeof(hostname_ascii)); + if (rc < 0) + return rc; + hostname = hostname_ascii; + } +#endif + hostname_len = hostname ? strlen(hostname) + 1 : 0; service_len = service ? strlen(service) + 1 : 0; hints_len = hints ? sizeof(*hints) : 0; @@ -186,6 +206,7 @@ int uv_getaddrinfo(uv_loop_t* loop, if (cb) { uv__work_submit(loop, &req->work_req, + UV__WORK_SLOW_IO, uv__getaddrinfo_work, uv__getaddrinfo_done); return 0; diff --git a/Utilities/cmlibuv/src/unix/getnameinfo.c b/Utilities/cmlibuv/src/unix/getnameinfo.c index d9e6f79d47..b695081b47 100644 --- a/Utilities/cmlibuv/src/unix/getnameinfo.c +++ b/Utilities/cmlibuv/src/unix/getnameinfo.c @@ -109,6 +109,7 @@ int uv_getnameinfo(uv_loop_t* loop, if (getnameinfo_cb) { uv__work_submit(loop, &req->work_req, + UV__WORK_SLOW_IO, uv__getnameinfo_work, uv__getnameinfo_done); return 0; diff --git a/Utilities/cmlibuv/src/unix/ibmi.c b/Utilities/cmlibuv/src/unix/ibmi.c index 02e90fb1fc..13fed6cc01 100644 --- a/Utilities/cmlibuv/src/unix/ibmi.c +++ b/Utilities/cmlibuv/src/unix/ibmi.c @@ -72,7 +72,8 @@ void uv_loadavg(double avg[3]) { int uv_resident_set_memory(size_t* rss) { - return UV_ENOSYS; + *rss = 0; + return 0; } diff --git a/Utilities/cmlibuv/src/unix/internal.h b/Utilities/cmlibuv/src/unix/internal.h index 89c6eb13d7..48fe6e8b19 100644 --- a/Utilities/cmlibuv/src/unix/internal.h +++ b/Utilities/cmlibuv/src/unix/internal.h @@ -137,26 +137,6 @@ int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset); typedef struct uv__stream_queued_fds_s uv__stream_queued_fds_t; -/* handle flags */ -enum { - UV_CLOSING = 0x01, /* uv_close() called but not finished. */ - UV_CLOSED = 0x02, /* close(2) finished. */ - UV_STREAM_READING = 0x04, /* uv_read_start() called. */ - UV_STREAM_SHUTTING = 0x08, /* uv_shutdown() called but not complete. */ - UV_STREAM_SHUT = 0x10, /* Write side closed. */ - UV_STREAM_READABLE = 0x20, /* The stream is readable */ - UV_STREAM_WRITABLE = 0x40, /* The stream is writable */ - UV_STREAM_BLOCKING = 0x80, /* Synchronous writes. */ - UV_STREAM_READ_PARTIAL = 0x100, /* read(2) read less than requested. */ - UV_STREAM_READ_EOF = 0x200, /* read(2) read EOF. */ - UV_TCP_NODELAY = 0x400, /* Disable Nagle. */ - UV_TCP_KEEPALIVE = 0x800, /* Turn on keep-alive. */ - UV_TCP_SINGLE_ACCEPT = 0x1000, /* Only accept() when idle. */ - UV_HANDLE_IPV6 = 0x10000, /* Handle is bound to a IPv6 socket. */ - UV_UDP_PROCESSING = 0x20000, /* Handle is running the send callback queue. */ - UV_HANDLE_BOUND = 0x40000 /* Handle is bound to an address and port */ -}; - /* loop flags */ enum { UV_LOOP_BLOCK_SIGPROF = 1 @@ -215,7 +195,6 @@ int uv__nonblock_fcntl(int fd, int set); int uv__close(int fd); /* preserves errno */ int uv__close_nocheckstdio(int fd); int uv__socket(int domain, int type, int protocol); -int uv__dup(int fd); ssize_t uv__recvmsg(int fd, struct msghdr *msg, int flags); void uv__make_close_pending(uv_handle_t* handle); int uv__getiovmax(void); @@ -229,6 +208,7 @@ int uv__io_active(const uv__io_t* w, unsigned int events); int uv__io_check_fd(uv_loop_t* loop, int fd); void uv__io_poll(uv_loop_t* loop, int timeout); /* in milliseconds or -1 */ int uv__io_fork(uv_loop_t* loop); +int uv__fd_exists(uv_loop_t* loop, int fd); /* async */ void uv__async_stop(uv_loop_t* loop); @@ -261,10 +241,6 @@ int uv__tcp_keepalive(int fd, int on, unsigned int delay); /* pipe */ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); -/* timer */ -void uv__run_timers(uv_loop_t* loop); -int uv__next_timeout(const uv_loop_t* loop); - /* signal */ void uv__signal_close(uv_signal_t* handle); void uv__signal_global_once_init(void); @@ -289,7 +265,6 @@ void uv__prepare_close(uv_prepare_t* handle); void uv__process_close(uv_process_t* handle); void uv__stream_close(uv_stream_t* handle); void uv__tcp_close(uv_tcp_t* handle); -void uv__timer_close(uv_timer_t* handle); void uv__udp_close(uv_udp_t* handle); void uv__udp_finish_close(uv_udp_t* handle); uv_handle_type uv__handle_type(int fd); @@ -319,24 +294,6 @@ int uv__fsevents_init(uv_fs_event_t* handle); int uv__fsevents_close(uv_fs_event_t* handle); void uv__fsevents_loop_delete(uv_loop_t* loop); -/* OSX < 10.7 has no file events, polyfill them */ -#ifndef MAC_OS_X_VERSION_10_7 - -static const int kFSEventStreamCreateFlagFileEvents = 0x00000010; -static const int kFSEventStreamEventFlagItemCreated = 0x00000100; -static const int kFSEventStreamEventFlagItemRemoved = 0x00000200; -static const int kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400; -static const int kFSEventStreamEventFlagItemRenamed = 0x00000800; -static const int kFSEventStreamEventFlagItemModified = 0x00001000; -static const int kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000; -static const int kFSEventStreamEventFlagItemChangeOwner = 0x00004000; -static const int kFSEventStreamEventFlagItemXattrMod = 0x00008000; -static const int kFSEventStreamEventFlagItemIsFile = 0x00010000; -static const int kFSEventStreamEventFlagItemIsDir = 0x00020000; -static const int kFSEventStreamEventFlagItemIsSymlink = 0x00040000; - -#endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 */ - #endif /* defined(__APPLE__) */ UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) { diff --git a/Utilities/cmlibuv/src/unix/kqueue.c b/Utilities/cmlibuv/src/unix/kqueue.c index a30fd730ff..c24f96e139 100644 --- a/Utilities/cmlibuv/src/unix/kqueue.c +++ b/Utilities/cmlibuv/src/unix/kqueue.c @@ -261,8 +261,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { w = loop->watchers[fd]; if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. */ - /* TODO batch up */ + /* File descriptor that we've stopped watching, disarm it. + * TODO: batch up. */ struct kevent events[1]; EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); @@ -452,49 +452,48 @@ int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, const char* path, unsigned int flags) { -#if defined(__APPLE__) - struct stat statbuf; -#endif /* defined(__APPLE__) */ int fd; if (uv__is_active(handle)) return UV_EINVAL; - /* TODO open asynchronously - but how do we report back errors? */ - fd = open(path, O_RDONLY); - if (fd == -1) - return UV__ERR(errno); - - uv__handle_start(handle); - uv__io_init(&handle->event_watcher, uv__fs_event, fd); - handle->path = uv__strdup(path); - handle->cb = cb; - #if defined(__APPLE__) - if (uv__has_forked_with_cfrunloop) - goto fallback; - /* Nullify field to perform checks later */ handle->cf_cb = NULL; handle->realpath = NULL; handle->realpath_len = 0; handle->cf_flags = flags; - if (fstat(fd, &statbuf)) - goto fallback; - /* FSEvents works only with directories */ - if (!(statbuf.st_mode & S_IFDIR)) - goto fallback; - - /* The fallback fd is no longer needed */ - uv__close(fd); - handle->event_watcher.fd = -1; - - return uv__fsevents_init(handle); - -fallback: + if (!uv__has_forked_with_cfrunloop) { + int r; + /* The fallback fd is not used */ + handle->event_watcher.fd = -1; + handle->path = uv__strdup(path); + if (handle->path == NULL) + return UV_ENOMEM; + handle->cb = cb; + r = uv__fsevents_init(handle); + if (r == 0) { + uv__handle_start(handle); + } else { + uv__free(handle->path); + handle->path = NULL; + } + return r; + } #endif /* defined(__APPLE__) */ + /* TODO open asynchronously - but how do we report back errors? */ + fd = open(path, O_RDONLY); + if (fd == -1) + return UV__ERR(errno); + + handle->path = uv__strdup(path); + if (handle->path == NULL) + return UV_ENOMEM; + handle->cb = cb; + uv__handle_start(handle); + uv__io_init(&handle->event_watcher, uv__fs_event, fd); uv__io_start(handle->loop, &handle->event_watcher, POLLIN); return 0; @@ -502,29 +501,29 @@ fallback: int uv_fs_event_stop(uv_fs_event_t* handle) { + int r; + r = 0; + if (!uv__is_active(handle)) return 0; uv__handle_stop(handle); #if defined(__APPLE__) - if (uv__has_forked_with_cfrunloop || uv__fsevents_close(handle)) -#endif /* defined(__APPLE__) */ - { - uv__io_close(handle->loop, &handle->event_watcher); - } - - uv__free(handle->path); - handle->path = NULL; + if (!uv__has_forked_with_cfrunloop) + r = uv__fsevents_close(handle); +#endif if (handle->event_watcher.fd != -1) { - /* When FSEvents is used, we don't use the event_watcher's fd under certain - * confitions. (see uv_fs_event_start) */ + uv__io_close(handle->loop, &handle->event_watcher); uv__close(handle->event_watcher.fd); handle->event_watcher.fd = -1; } - return 0; + uv__free(handle->path); + handle->path = NULL; + + return r; } diff --git a/Utilities/cmlibuv/src/unix/linux-core.c b/Utilities/cmlibuv/src/unix/linux-core.c index b63c25f3c2..3341b94e1f 100644 --- a/Utilities/cmlibuv/src/unix/linux-core.c +++ b/Utilities/cmlibuv/src/unix/linux-core.c @@ -20,7 +20,7 @@ /* We lean on the fact that POLL{IN,OUT,ERR,HUP} correspond with their * EPOLL* counterparts. We use the POLL* variants in this file because that - * is what libuv uses elsewhere and it avoids a dependency on <sys/epoll.h>. + * is what libuv uses elsewhere. */ #include "uv.h" @@ -34,6 +34,7 @@ #include <errno.h> #include <net/if.h> +#include <sys/epoll.h> #include <sys/param.h> #include <sys/prctl.h> #include <sys/sysinfo.h> @@ -51,7 +52,7 @@ #ifdef HAVE_IFADDRS_H # if defined(__ANDROID__) -# include "android-ifaddrs.h" +# include "uv/android-ifaddrs.h" # else # include <ifaddrs.h> # endif @@ -84,13 +85,13 @@ static unsigned long read_cpufreq(unsigned int cpunum); int uv__platform_loop_init(uv_loop_t* loop) { int fd; - fd = uv__epoll_create1(UV__EPOLL_CLOEXEC); + fd = epoll_create1(EPOLL_CLOEXEC); /* epoll_create1() can fail either because it's not implemented (old kernel) * or because it doesn't understand the EPOLL_CLOEXEC flag. */ if (fd == -1 && (errno == ENOSYS || errno == EINVAL)) { - fd = uv__epoll_create(256); + fd = epoll_create(256); if (fd != -1) uv__cloexec(fd, 1); @@ -134,20 +135,20 @@ void uv__platform_loop_delete(uv_loop_t* loop) { void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct uv__epoll_event* events; - struct uv__epoll_event dummy; + struct epoll_event* events; + struct epoll_event dummy; uintptr_t i; uintptr_t nfds; assert(loop->watchers != NULL); - events = (struct uv__epoll_event*) loop->watchers[loop->nwatchers]; + events = (struct epoll_event*) loop->watchers[loop->nwatchers]; nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; if (events != NULL) /* Invalidate events with same file descriptor */ for (i = 0; i < nfds; i++) - if ((int) events[i].data == fd) - events[i].data = -1; + if (events[i].data.fd == fd) + events[i].data.fd = -1; /* Remove the file descriptor from the epoll. * This avoids a problem where the same file description remains open @@ -160,25 +161,26 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { * has the EPOLLWAKEUP flag set generates spurious audit syslog warnings. */ memset(&dummy, 0, sizeof(dummy)); - uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &dummy); + epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, fd, &dummy); } } int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct uv__epoll_event e; + struct epoll_event e; int rc; + memset(&e, 0, sizeof(e)); e.events = POLLIN; - e.data = -1; + e.data.fd = -1; rc = 0; - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_ADD, fd, &e)) + if (epoll_ctl(loop->backend_fd, EPOLL_CTL_ADD, fd, &e)) if (errno != EEXIST) rc = UV__ERR(errno); if (rc == 0) - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &e)) + if (epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, fd, &e)) abort(); return rc; @@ -195,16 +197,14 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { * that being the largest value I have seen in the wild (and only once.) */ static const int max_safe_timeout = 1789569; - static int no_epoll_pwait; - static int no_epoll_wait; - struct uv__epoll_event events[1024]; - struct uv__epoll_event* pe; - struct uv__epoll_event e; + struct epoll_event events[1024]; + struct epoll_event* pe; + struct epoll_event e; int real_timeout; QUEUE* q; uv__io_t* w; sigset_t sigset; - uint64_t sigmask; + sigset_t* psigset; uint64_t base; int have_signals; int nevents; @@ -219,6 +219,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { return; } + memset(&e, 0, sizeof(e)); + while (!QUEUE_EMPTY(&loop->watcher_queue)) { q = QUEUE_HEAD(&loop->watcher_queue); QUEUE_REMOVE(q); @@ -230,35 +232,35 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { assert(w->fd < (int) loop->nwatchers); e.events = w->pevents; - e.data = w->fd; + e.data.fd = w->fd; if (w->events == 0) - op = UV__EPOLL_CTL_ADD; + op = EPOLL_CTL_ADD; else - op = UV__EPOLL_CTL_MOD; + op = EPOLL_CTL_MOD; /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching * events, skip the syscall and squelch the events after epoll_wait(). */ - if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) { + if (epoll_ctl(loop->backend_fd, op, w->fd, &e)) { if (errno != EEXIST) abort(); - assert(op == UV__EPOLL_CTL_ADD); + assert(op == EPOLL_CTL_ADD); /* We've reactivated a file descriptor that's been watched before. */ - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_MOD, w->fd, &e)) + if (epoll_ctl(loop->backend_fd, EPOLL_CTL_MOD, w->fd, &e)) abort(); } w->events = w->pevents; } - sigmask = 0; + psigset = NULL; if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { sigemptyset(&sigset); sigaddset(&sigset, SIGPROF); - sigmask |= 1 << (SIGPROF - 1); + psigset = &sigset; } assert(timeout >= -1); @@ -273,30 +275,11 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (sizeof(int32_t) == sizeof(long) && timeout >= max_safe_timeout) timeout = max_safe_timeout; - if (sigmask != 0 && no_epoll_pwait != 0) - if (pthread_sigmask(SIG_BLOCK, &sigset, NULL)) - abort(); - - if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) { - nfds = uv__epoll_pwait(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout, - sigmask); - if (nfds == -1 && errno == ENOSYS) - no_epoll_pwait = 1; - } else { - nfds = uv__epoll_wait(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout); - if (nfds == -1 && errno == ENOSYS) - no_epoll_wait = 1; - } - - if (sigmask != 0 && no_epoll_pwait != 0) - if (pthread_sigmask(SIG_UNBLOCK, &sigset, NULL)) - abort(); + nfds = epoll_pwait(loop->backend_fd, + events, + ARRAY_SIZE(events), + timeout, + psigset); /* Update loop->time unconditionally. It's tempting to skip the update when * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the @@ -317,12 +300,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { } if (nfds == -1) { - if (errno == ENOSYS) { - /* epoll_wait() or epoll_pwait() failed, try the other system call. */ - assert(no_epoll_wait == 0 || no_epoll_pwait == 0); - continue; - } - if (errno != EINTR) abort(); @@ -344,7 +321,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; for (i = 0; i < nfds; i++) { pe = events + i; - fd = pe->data; + fd = pe->data.fd; /* Skip invalidated events, see uv__platform_invalidate_fd */ if (fd == -1) @@ -361,7 +338,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { * Ignore all errors because we may be racing with another thread * when the file descriptor is closed. */ - uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, pe); + epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, fd, pe); continue; } @@ -388,7 +365,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { * free when we switch over to edge-triggered I/O. */ if (pe->events == POLLERR || pe->events == POLLHUP) - pe->events |= w->pevents & (POLLIN | POLLOUT | UV__POLLPRI); + pe->events |= + w->pevents & (POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI); if (pe->events != 0) { /* Run signal watchers last. This also affects child process watchers @@ -851,9 +829,10 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) { return !exclude_type; } -int uv_interface_addresses(uv_interface_address_t** addresses, - int* count) { +int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { #ifndef HAVE_IFADDRS_H + *count = 0; + *addresses = NULL; return UV_ENOSYS; #else struct ifaddrs *addrs, *ent; @@ -861,12 +840,12 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int i; struct sockaddr_ll *sll; - if (getifaddrs(&addrs)) - return UV__ERR(errno); - *count = 0; *addresses = NULL; + if (getifaddrs(&addrs)) + return UV__ERR(errno); + /* Count the number of interfaces */ for (ent = addrs; ent != NULL; ent = ent->ifa_next) { if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) @@ -875,8 +854,10 @@ int uv_interface_addresses(uv_interface_address_t** addresses, (*count)++; } - if (*count == 0) + if (*count == 0) { + freeifaddrs(addrs); return 0; + } *addresses = uv__malloc(*count * sizeof(**addresses)); if (!(*addresses)) { @@ -920,6 +901,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses, if (strcmp(address->name, ent->ifa_name) == 0) { sll = (struct sockaddr_ll*)ent->ifa_addr; memcpy(address->phys_addr, sll->sll_addr, sizeof(address->phys_addr)); + } else { + memset(address->phys_addr, 0, sizeof(address->phys_addr)); } address++; } diff --git a/Utilities/cmlibuv/src/unix/linux-inotify.c b/Utilities/cmlibuv/src/unix/linux-inotify.c index bcad630fab..9b26202fb3 100644 --- a/Utilities/cmlibuv/src/unix/linux-inotify.c +++ b/Utilities/cmlibuv/src/unix/linux-inotify.c @@ -19,7 +19,7 @@ */ #include "uv.h" -#include "tree.h" +#include "uv/tree.h" #include "internal.h" #include <stdint.h> @@ -278,6 +278,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, const char* path, unsigned int flags) { struct watcher_list* w; + size_t len; int events; int err; int wd; @@ -306,12 +307,13 @@ int uv_fs_event_start(uv_fs_event_t* handle, if (w) goto no_insert; - w = uv__malloc(sizeof(*w) + strlen(path) + 1); + len = strlen(path) + 1; + w = uv__malloc(sizeof(*w) + len); if (w == NULL) return UV_ENOMEM; w->wd = wd; - w->path = strcpy((char*)(w + 1), path); + w->path = memcpy(w + 1, path, len); QUEUE_INIT(&w->watchers); w->iterating = 0; RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w); diff --git a/Utilities/cmlibuv/src/unix/linux-syscalls.c b/Utilities/cmlibuv/src/unix/linux-syscalls.c index 89998ded26..bfd7544879 100644 --- a/Utilities/cmlibuv/src/unix/linux-syscalls.c +++ b/Utilities/cmlibuv/src/unix/linux-syscalls.c @@ -77,56 +77,6 @@ # endif #endif /* __NR_eventfd2 */ -#ifndef __NR_epoll_create -# if defined(__x86_64__) -# define __NR_epoll_create 213 -# elif defined(__i386__) -# define __NR_epoll_create 254 -# elif defined(__arm__) -# define __NR_epoll_create (UV_SYSCALL_BASE + 250) -# endif -#endif /* __NR_epoll_create */ - -#ifndef __NR_epoll_create1 -# if defined(__x86_64__) -# define __NR_epoll_create1 291 -# elif defined(__i386__) -# define __NR_epoll_create1 329 -# elif defined(__arm__) -# define __NR_epoll_create1 (UV_SYSCALL_BASE + 357) -# endif -#endif /* __NR_epoll_create1 */ - -#ifndef __NR_epoll_ctl -# if defined(__x86_64__) -# define __NR_epoll_ctl 233 /* used to be 214 */ -# elif defined(__i386__) -# define __NR_epoll_ctl 255 -# elif defined(__arm__) -# define __NR_epoll_ctl (UV_SYSCALL_BASE + 251) -# endif -#endif /* __NR_epoll_ctl */ - -#ifndef __NR_epoll_wait -# if defined(__x86_64__) -# define __NR_epoll_wait 232 /* used to be 215 */ -# elif defined(__i386__) -# define __NR_epoll_wait 256 -# elif defined(__arm__) -# define __NR_epoll_wait (UV_SYSCALL_BASE + 252) -# endif -#endif /* __NR_epoll_wait */ - -#ifndef __NR_epoll_pwait -# if defined(__x86_64__) -# define __NR_epoll_pwait 281 -# elif defined(__i386__) -# define __NR_epoll_pwait 319 -# elif defined(__arm__) -# define __NR_epoll_pwait (UV_SYSCALL_BASE + 346) -# endif -#endif /* __NR_epoll_pwait */ - #ifndef __NR_inotify_init # if defined(__x86_64__) # define __NR_inotify_init 253 @@ -285,76 +235,6 @@ int uv__eventfd2(unsigned int count, int flags) { } -int uv__epoll_create(int size) { -#if defined(__NR_epoll_create) - return syscall(__NR_epoll_create, size); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_create1(int flags) { -#if defined(__NR_epoll_create1) - return syscall(__NR_epoll_create1, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event* events) { -#if defined(__NR_epoll_ctl) - return syscall(__NR_epoll_ctl, epfd, op, fd, events); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_wait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout) { -#if defined(__NR_epoll_wait) - int result; - result = syscall(__NR_epoll_wait, epfd, events, nevents, timeout); -#if MSAN_ACTIVE - if (result > 0) - __msan_unpoison(events, sizeof(events[0]) * result); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_pwait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout, - uint64_t sigmask) { -#if defined(__NR_epoll_pwait) - int result; - result = syscall(__NR_epoll_pwait, - epfd, - events, - nevents, - timeout, - &sigmask, - sizeof(sigmask)); -#if MSAN_ACTIVE - if (result > 0) - __msan_unpoison(events, sizeof(events[0]) * result); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - int uv__inotify_init(void) { #if defined(__NR_inotify_init) return syscall(__NR_inotify_init); @@ -431,19 +311,6 @@ int uv__recvmmsg(int fd, } -int uv__utimesat(int dirfd, - const char* path, - const struct timespec times[2], - int flags) -{ -#if defined(__NR_utimensat) - return syscall(__NR_utimensat, dirfd, path, times, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset) { #if defined(__NR_preadv) return syscall(__NR_preadv, fd, iov, iovcnt, (long)offset, (long)(offset >> 32)); diff --git a/Utilities/cmlibuv/src/unix/linux-syscalls.h b/Utilities/cmlibuv/src/unix/linux-syscalls.h index 4c095e9b53..3dfd329d6c 100644 --- a/Utilities/cmlibuv/src/unix/linux-syscalls.h +++ b/Utilities/cmlibuv/src/unix/linux-syscalls.h @@ -66,12 +66,6 @@ # define UV__SOCK_NONBLOCK UV__O_NONBLOCK #endif -/* epoll flags */ -#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC -#define UV__EPOLL_CTL_ADD 1 -#define UV__EPOLL_CTL_DEL 2 -#define UV__EPOLL_CTL_MOD 3 - /* inotify flags */ #define UV__IN_ACCESS 0x001 #define UV__IN_MODIFY 0x002 @@ -86,18 +80,6 @@ #define UV__IN_DELETE_SELF 0x400 #define UV__IN_MOVE_SELF 0x800 -#if defined(__x86_64__) -struct uv__epoll_event { - uint32_t events; - uint64_t data; -} __attribute__((packed)); -#else -struct uv__epoll_event { - uint32_t events; - uint64_t data; -}; -#endif - struct uv__inotify_event { int32_t wd; uint32_t mask; @@ -113,18 +95,6 @@ struct uv__mmsghdr { int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags); int uv__eventfd(unsigned int count); -int uv__epoll_create(int size); -int uv__epoll_create1(int flags); -int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event *ev); -int uv__epoll_wait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout); -int uv__epoll_pwait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout, - uint64_t sigmask); int uv__eventfd2(unsigned int count, int flags); int uv__inotify_init(void); int uv__inotify_init1(int flags); @@ -140,10 +110,6 @@ int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen, unsigned int flags); -int uv__utimesat(int dirfd, - const char* path, - const struct timespec times[2], - int flags); ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset); ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset); int uv__dup3(int oldfd, int newfd, int flags); diff --git a/Utilities/cmlibuv/src/unix/loop.c b/Utilities/cmlibuv/src/unix/loop.c index 99ead6cbc0..c2a03d770f 100644 --- a/Utilities/cmlibuv/src/unix/loop.c +++ b/Utilities/cmlibuv/src/unix/loop.c @@ -20,7 +20,7 @@ */ #include "uv.h" -#include "tree.h" +#include "uv/tree.h" #include "internal.h" #include "heap-inl.h" #include <stdlib.h> @@ -74,7 +74,7 @@ int uv_loop_init(uv_loop_t* loop) { goto fail_signal_init; uv__handle_unref(&loop->child_watcher); - loop->child_watcher.flags |= UV__HANDLE_INTERNAL; + loop->child_watcher.flags |= UV_HANDLE_INTERNAL; QUEUE_INIT(&loop->process_handles); err = uv_rwlock_init(&loop->cloexec_lock); @@ -90,7 +90,7 @@ int uv_loop_init(uv_loop_t* loop) { goto fail_async_init; uv__handle_unref(&loop->wq_async); - loop->wq_async.flags |= UV__HANDLE_INTERNAL; + loop->wq_async.flags |= UV_HANDLE_INTERNAL; return 0; diff --git a/Utilities/cmlibuv/src/unix/netbsd.c b/Utilities/cmlibuv/src/unix/netbsd.c index 2605c114bc..a2a4e52154 100644 --- a/Utilities/cmlibuv/src/unix/netbsd.c +++ b/Utilities/cmlibuv/src/unix/netbsd.c @@ -40,15 +40,6 @@ #include <unistd.h> #include <time.h> -static uv_mutex_t process_title_mutex; -static uv_once_t process_title_mutex_once = UV_ONCE_INIT; -static char *process_title; - - -static void init_process_title_mutex_once(void) { - uv_mutex_init(&process_title_mutex); -} - int uv__platform_loop_init(uv_loop_t* loop) { return uv__kqueue_init(loop); @@ -96,7 +87,8 @@ int uv_exepath(char* buffer, size_t* size) { /* Copy string from the intermediate buffer to outer one with appropriate * length. */ - strlcpy(buffer, int_buf, *size); + /* TODO(bnoordhuis) Check uv__strscpy() return value. */ + uv__strscpy(buffer, int_buf, *size); /* Set new size. */ *size = strlen(buffer); @@ -134,65 +126,6 @@ uint64_t uv_get_total_memory(void) { } -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - char* new_title; - - new_title = uv__strdup(title); - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title == NULL) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOMEM; - } - - uv__free(process_title); - process_title = new_title; - setproctitle("%s", title); - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOBUFS; - } - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - uv_mutex_unlock(&process_title_mutex); - - buffer[len] = '\0'; - - return 0; -} - - int uv_resident_set_memory(size_t* rss) { kvm_t *kd = NULL; struct kinfo_proc2 *kinfo = NULL; diff --git a/Utilities/cmlibuv/src/unix/openbsd.c b/Utilities/cmlibuv/src/unix/openbsd.c index ce937cd3ef..bffb58bcd9 100644 --- a/Utilities/cmlibuv/src/unix/openbsd.c +++ b/Utilities/cmlibuv/src/unix/openbsd.c @@ -36,16 +36,6 @@ #include <unistd.h> -static uv_mutex_t process_title_mutex; -static uv_once_t process_title_mutex_once = UV_ONCE_INIT; -static char *process_title; - - -static void init_process_title_mutex_once(void) { - uv_mutex_init(&process_title_mutex); -} - - int uv__platform_loop_init(uv_loop_t* loop) { return uv__kqueue_init(loop); } @@ -146,65 +136,6 @@ uint64_t uv_get_total_memory(void) { } -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - char* new_title; - - new_title = uv__strdup(title); - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title == NULL) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOMEM; - } - - uv__free(process_title); - process_title = new_title; - setproctitle("%s", title); - - uv_mutex_unlock(&process_title_mutex); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv_once(&process_title_mutex_once, init_process_title_mutex_once); - uv_mutex_lock(&process_title_mutex); - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) { - uv_mutex_unlock(&process_title_mutex); - return UV_ENOBUFS; - } - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - uv_mutex_unlock(&process_title_mutex); - - buffer[len] = '\0'; - - return 0; -} - - int uv_resident_set_memory(size_t* rss) { struct kinfo_proc kinfo; size_t page_size = getpagesize(); diff --git a/Utilities/cmlibuv/src/unix/os390-syscalls.c b/Utilities/cmlibuv/src/unix/os390-syscalls.c index a5dd34426d..1040d66979 100644 --- a/Utilities/cmlibuv/src/unix/os390-syscalls.c +++ b/Utilities/cmlibuv/src/unix/os390-syscalls.c @@ -141,7 +141,7 @@ static void init_message_queue(uv__os390_epoll* lst) { } msg; /* initialize message queue */ - lst->msg_queue = msgget(IPC_PRIVATE, 0622 | IPC_CREAT); + lst->msg_queue = msgget(IPC_PRIVATE, 0600 | IPC_CREAT); if (lst->msg_queue == -1) abort(); @@ -255,12 +255,13 @@ int epoll_ctl(uv__os390_epoll* lst, lst->items[fd].events = event->events; lst->items[fd].revents = 0; } else if (op == EPOLL_CTL_MOD) { - if (fd >= lst->size || lst->items[fd].fd == -1) { + if (fd >= lst->size - 1 || lst->items[fd].fd == -1) { uv_mutex_unlock(&global_epoll_lock); errno = ENOENT; return -1; } lst->items[fd].events = event->events; + lst->items[fd].revents = 0; } else abort(); @@ -275,8 +276,9 @@ int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events, struct pollfd* pfds; int pollret; int reventcount; + int nevents; - size = _SET_FDS_MSGS(size, 1, lst->size - 1); + _SET_FDS_MSGS(size, 1, lst->size - 1); pfds = lst->items; pollret = poll(pfds, size, timeout); if (pollret <= 0) @@ -285,19 +287,28 @@ int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events, pollret = _NFDS(pollret) + _NMSGS(pollret); reventcount = 0; + nevents = 0; for (int i = 0; i < lst->size && i < maxevents && reventcount < pollret; ++i) { struct epoll_event ev; + struct pollfd* pfd; - if (pfds[i].fd == -1 || pfds[i].revents == 0) + pfd = &pfds[i]; + if (pfd->fd == -1 || pfd->revents == 0) continue; - ev.fd = pfds[i].fd; - ev.events = pfds[i].revents; - events[reventcount++] = ev; + ev.fd = pfd->fd; + ev.events = pfd->revents; + if (pfd->revents & POLLIN && pfd->revents & POLLOUT) + reventcount += 2; + else if (pfd->revents & (POLLIN | POLLOUT)) + ++reventcount; + + pfd->revents = 0; + events[nevents++] = ev; } - return reventcount; + return nevents; } @@ -493,7 +504,7 @@ ssize_t os390_readlink(const char* path, char* buf, size_t len) { size_t strnlen(const char* str, size_t maxlen) { - void* p = memchr(str, 0, maxlen); + char* p = memchr(str, 0, maxlen); if (p == NULL) return maxlen; else diff --git a/Utilities/cmlibuv/src/unix/os390-syscalls.h b/Utilities/cmlibuv/src/unix/os390-syscalls.h index 6e34a88cb9..ea599107b3 100644 --- a/Utilities/cmlibuv/src/unix/os390-syscalls.h +++ b/Utilities/cmlibuv/src/unix/os390-syscalls.h @@ -36,10 +36,6 @@ #define MAX_ITEMS_PER_EPOLL 1024 #define UV__O_CLOEXEC 0x80000 -#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC -#define UV__EPOLL_CTL_ADD EPOLL_CTL_ADD -#define UV__EPOLL_CTL_DEL EPOLL_CTL_DEL -#define UV__EPOLL_CTL_MOD EPOLL_CTL_MOD struct epoll_event { int events; diff --git a/Utilities/cmlibuv/src/unix/os390.c b/Utilities/cmlibuv/src/unix/os390.c index f766b39339..dc146e3110 100644 --- a/Utilities/cmlibuv/src/unix/os390.c +++ b/Utilities/cmlibuv/src/unix/os390.c @@ -229,15 +229,15 @@ static int getexe(const int pid, char* buf, size_t len) { assert(((Output_buf.Output_data.offsetPath >>24) & 0xFF) == 'A'); /* Get the offset from the lowest 3 bytes */ - Output_path = (char*)(&Output_buf) + - (Output_buf.Output_data.offsetPath & 0x00FFFFFF); + Output_path = (struct Output_path_type*) ((char*) (&Output_buf) + + (Output_buf.Output_data.offsetPath & 0x00FFFFFF)); if (Output_path->len >= len) { errno = ENOBUFS; return -1; } - strncpy(buf, Output_path->path, len); + uv__strscpy(buf, Output_path->path, len); return 0; } @@ -357,13 +357,11 @@ uint64_t uv_get_total_memory(void) { int uv_resident_set_memory(size_t* rss) { - char* psa; char* ascb; char* rax; size_t nframes; - psa = PSA_PTR; - ascb = *(char* __ptr32 *)(psa + PSAAOLD); + ascb = *(char* __ptr32 *)(PSA_PTR + PSAAOLD); rax = *(char* __ptr32 *)(ascb + ASCBRSME); nframes = *(unsigned int*)(rax + RAXFMCT); @@ -512,7 +510,7 @@ static int uv__interface_addresses_v6(uv_interface_address_t** addresses, /* TODO: Retrieve netmask using SIOCGIFNETMASK ioctl */ address->is_internal = flg.__nif6e_flags & _NIF6E_FLAGS_LOOPBACK ? 1 : 0; - + memset(address->phys_addr, 0, sizeof(address->phys_addr)); address++; } @@ -531,12 +529,14 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { struct ifreq* p; int count_v6; + *count = 0; + *addresses = NULL; + /* get the ipv6 addresses first */ uv_interface_address_t* addresses_v6; uv__interface_addresses_v6(&addresses_v6, &count_v6); /* now get the ipv4 addresses */ - *count = 0; /* Assume maximum buffer size allowable */ maxsize = 16384; @@ -578,6 +578,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { (*count)++; } + if (*count == 0) { + uv__close(sockfd); + return 0; + } + /* Alloc the return interface structs */ *addresses = uv__malloc((*count + count_v6) * sizeof(uv_interface_address_t)); @@ -624,6 +629,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { } address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0; + memset(address->phys_addr, 0, sizeof(address->phys_addr)); address++; } @@ -662,7 +668,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { /* Remove the file descriptor from the epoll. */ if (loop->ep != NULL) - epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, &dummy); + epoll_ctl(loop->ep, EPOLL_CTL_DEL, fd, &dummy); } @@ -751,7 +757,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { memcpy(reg_struct.__rfis_rftok, handle->rfis_rftok, sizeof(handle->rfis_rftok)); - /* + /* * This call will take "/" as the path argument in case we * don't care to supply the correct path. The system will simply * ignore it. @@ -838,9 +844,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { e.fd = w->fd; if (w->events == 0) - op = UV__EPOLL_CTL_ADD; + op = EPOLL_CTL_ADD; else - op = UV__EPOLL_CTL_MOD; + op = EPOLL_CTL_MOD; /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching * events, skip the syscall and squelch the events after epoll_wait(). @@ -849,10 +855,10 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (errno != EEXIST) abort(); - assert(op == UV__EPOLL_CTL_ADD); + assert(op == EPOLL_CTL_ADD); /* We've reactivated a file descriptor that's been watched before. */ - if (epoll_ctl(loop->ep, UV__EPOLL_CTL_MOD, w->fd, &e)) + if (epoll_ctl(loop->ep, EPOLL_CTL_MOD, w->fd, &e)) abort(); } @@ -934,7 +940,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { * Ignore all errors because we may be racing with another thread * when the file descriptor is closed. */ - epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, pe); + epoll_ctl(loop->ep, EPOLL_CTL_DEL, fd, pe); continue; } @@ -987,7 +993,7 @@ void uv__set_process_title(const char* title) { } int uv__io_fork(uv_loop_t* loop) { - /* + /* Nullify the msg queue but don't close it because it is still being used by the parent. */ diff --git a/Utilities/cmlibuv/src/unix/pipe.c b/Utilities/cmlibuv/src/unix/pipe.c index 42846b927a..9657bc9141 100644 --- a/Utilities/cmlibuv/src/unix/pipe.c +++ b/Utilities/cmlibuv/src/unix/pipe.c @@ -64,8 +64,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) { sockfd = err; memset(&saddr, 0, sizeof saddr); - strncpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path) - 1); - saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0'; + uv__strscpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path)); saddr.sun_family = AF_UNIX; if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) { @@ -130,7 +129,20 @@ void uv__pipe_close(uv_pipe_t* handle) { int uv_pipe_open(uv_pipe_t* handle, uv_file fd) { + int flags; + int mode; int err; + flags = 0; + + if (uv__fd_exists(handle->loop, fd)) + return UV_EEXIST; + + do + mode = fcntl(fd, F_GETFL); + while (mode == -1 && errno == EINTR); + + if (mode == -1) + return UV__ERR(errno); /* according to docs, must be EBADF */ err = uv__nonblock(fd, 1); if (err) @@ -142,9 +154,13 @@ int uv_pipe_open(uv_pipe_t* handle, uv_file fd) { return err; #endif /* defined(__APPLE__) */ - return uv__stream_open((uv_stream_t*)handle, - fd, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); + mode &= O_ACCMODE; + if (mode != O_WRONLY) + flags |= UV_HANDLE_READABLE; + if (mode != O_RDONLY) + flags |= UV_HANDLE_WRITABLE; + + return uv__stream_open((uv_stream_t*)handle, fd, flags); } @@ -167,8 +183,7 @@ void uv_pipe_connect(uv_connect_t* req, } memset(&saddr, 0, sizeof saddr); - strncpy(saddr.sun_path, name, sizeof(saddr.sun_path) - 1); - saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0'; + uv__strscpy(saddr.sun_path, name, sizeof(saddr.sun_path)); saddr.sun_family = AF_UNIX; do { @@ -194,7 +209,7 @@ void uv_pipe_connect(uv_connect_t* req, if (new_sock) { err = uv__stream_open((uv_stream_t*)handle, uv__stream_fd(handle), - UV_STREAM_READABLE | UV_STREAM_WRITABLE); + UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); } if (err == 0) diff --git a/Utilities/cmlibuv/src/unix/poll.c b/Utilities/cmlibuv/src/unix/poll.c index f3b0bf4e43..3d5022b22e 100644 --- a/Utilities/cmlibuv/src/unix/poll.c +++ b/Utilities/cmlibuv/src/unix/poll.c @@ -68,6 +68,9 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { int err; + if (uv__fd_exists(loop, fd)) + return UV_EEXIST; + err = uv__io_check_fd(loop, fd); if (err) return err; diff --git a/Utilities/cmlibuv/src/unix/process.c b/Utilities/cmlibuv/src/unix/process.c index f2a5065ba8..e9579f5ed9 100644 --- a/Utilities/cmlibuv/src/unix/process.c +++ b/Utilities/cmlibuv/src/unix/process.c @@ -250,9 +250,9 @@ static int uv__process_open_stream(uv_stdio_container_t* container, flags = 0; if (container->flags & UV_WRITABLE_PIPE) - flags |= UV_STREAM_READABLE; + flags |= UV_HANDLE_READABLE; if (container->flags & UV_READABLE_PIPE) - flags |= UV_STREAM_WRITABLE; + flags |= UV_HANDLE_WRITABLE; return uv__stream_open(container->data.stream, pipefds[0], flags); } diff --git a/Utilities/cmlibuv/src/unix/proctitle.c b/Utilities/cmlibuv/src/unix/proctitle.c index 1a8c7a7090..a5ce2030c5 100644 --- a/Utilities/cmlibuv/src/unix/proctitle.c +++ b/Utilities/cmlibuv/src/unix/proctitle.c @@ -24,6 +24,7 @@ #include <stdlib.h> #include <string.h> +extern void uv__set_process_title_platform_init(void); extern void uv__set_process_title(const char* title); static uv_mutex_t process_title_mutex; @@ -38,6 +39,9 @@ static struct { static void init_process_title_mutex_once(void) { uv_mutex_init(&process_title_mutex); +#ifdef __APPLE__ + uv__set_process_title_platform_init(); +#endif } diff --git a/Utilities/cmlibuv/src/unix/signal.c b/Utilities/cmlibuv/src/unix/signal.c index b9d0a56084..01aa55f3fe 100644 --- a/Utilities/cmlibuv/src/unix/signal.c +++ b/Utilities/cmlibuv/src/unix/signal.c @@ -54,8 +54,7 @@ static void uv__signal_unregister_handler(int signum); static uv_once_t uv__signal_global_init_guard = UV_ONCE_INIT; static struct uv__signal_tree_s uv__signal_tree = RB_INITIALIZER(uv__signal_tree); -static int uv__signal_lock_pipefd[2]; - +static int uv__signal_lock_pipefd[2] = { -1, -1 }; RB_GENERATE_STATIC(uv__signal_tree_s, uv_signal_s, tree_entry, @@ -64,7 +63,7 @@ RB_GENERATE_STATIC(uv__signal_tree_s, static void uv__signal_global_reinit(void); static void uv__signal_global_init(void) { - if (!uv__signal_lock_pipefd[0]) + if (uv__signal_lock_pipefd[0] == -1) /* pthread_atfork can register before and after handlers, one * for each child. This only registers one for the child. That * state is both persistent and cumulative, so if we keep doing @@ -74,15 +73,11 @@ static void uv__signal_global_init(void) { if (pthread_atfork(NULL, NULL, &uv__signal_global_reinit)) abort(); - if (uv__make_pipe(uv__signal_lock_pipefd, 0)) - abort(); - - if (uv__signal_unlock()) - abort(); + uv__signal_global_reinit(); } -static void uv__signal_global_reinit(void) { +UV_DESTRUCTOR(static void uv__signal_global_fini(void)) { /* We can only use signal-safe functions here. * That includes read/write and close, fortunately. * We do all of this directly here instead of resetting @@ -90,11 +85,26 @@ static void uv__signal_global_reinit(void) { * uv__signal_global_once_init is only called from uv_loop_init * and this needs to function in existing loops. */ - uv__close(uv__signal_lock_pipefd[0]); - uv__signal_lock_pipefd[0] = -1; - uv__close(uv__signal_lock_pipefd[1]); - uv__signal_lock_pipefd[1] = -1; - uv__signal_global_init(); + if (uv__signal_lock_pipefd[0] != -1) { + uv__close(uv__signal_lock_pipefd[0]); + uv__signal_lock_pipefd[0] = -1; + } + + if (uv__signal_lock_pipefd[1] != -1) { + uv__close(uv__signal_lock_pipefd[1]); + uv__signal_lock_pipefd[1] = -1; + } +} + + +static void uv__signal_global_reinit(void) { + uv__signal_global_fini(); + + if (uv__make_pipe(uv__signal_lock_pipefd, 0)) + abort(); + + if (uv__signal_unlock()) + abort(); } @@ -103,7 +113,6 @@ void uv__signal_global_once_init(void) { } - static int uv__signal_lock(void) { int r; char data; @@ -387,7 +396,7 @@ static int uv__signal_start(uv_signal_t* handle, */ first_handle = uv__signal_first_handle(signum); if (first_handle == NULL || - (!oneshot && (first_handle->flags & UV__SIGNAL_ONE_SHOT))) { + (!oneshot && (first_handle->flags & UV_SIGNAL_ONE_SHOT))) { err = uv__signal_register_handler(signum, oneshot); if (err) { /* Registering the signal handler failed. Must be an invalid signal. */ @@ -398,7 +407,7 @@ static int uv__signal_start(uv_signal_t* handle, handle->signum = signum; if (oneshot) - handle->flags |= UV__SIGNAL_ONE_SHOT; + handle->flags |= UV_SIGNAL_ONE_SHOT; RB_INSERT(uv__signal_tree_s, &uv__signal_tree, handle); @@ -455,20 +464,20 @@ static void uv__signal_event(uv_loop_t* loop, handle = msg->handle; if (msg->signum == handle->signum) { - assert(!(handle->flags & UV_CLOSING)); + assert(!(handle->flags & UV_HANDLE_CLOSING)); handle->signal_cb(handle, handle->signum); } handle->dispatched_signals++; - if (handle->flags & UV__SIGNAL_ONE_SHOT) + if (handle->flags & UV_SIGNAL_ONE_SHOT) uv__signal_stop(handle); /* If uv_close was called while there were caught signals that were not * yet dispatched, the uv__finish_close was deferred. Make close pending * now if this has happened. */ - if ((handle->flags & UV_CLOSING) && + if ((handle->flags & UV_HANDLE_CLOSING) && (handle->caught_signals == handle->dispatched_signals)) { uv__make_close_pending((uv_handle_t*) handle); } @@ -496,11 +505,11 @@ static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) { if (w1->signum < w2->signum) return -1; if (w1->signum > w2->signum) return 1; - /* Handlers without UV__SIGNAL_ONE_SHOT set will come first, so if the first + /* Handlers without UV_SIGNAL_ONE_SHOT set will come first, so if the first * handler returned is a one-shot handler, the rest will be too. */ - f1 = w1->flags & UV__SIGNAL_ONE_SHOT; - f2 = w2->flags & UV__SIGNAL_ONE_SHOT; + f1 = w1->flags & UV_SIGNAL_ONE_SHOT; + f2 = w2->flags & UV_SIGNAL_ONE_SHOT; if (f1 < f2) return -1; if (f1 > f2) return 1; @@ -549,8 +558,8 @@ static void uv__signal_stop(uv_signal_t* handle) { if (first_handle == NULL) { uv__signal_unregister_handler(handle->signum); } else { - rem_oneshot = handle->flags & UV__SIGNAL_ONE_SHOT; - first_oneshot = first_handle->flags & UV__SIGNAL_ONE_SHOT; + rem_oneshot = handle->flags & UV_SIGNAL_ONE_SHOT; + first_oneshot = first_handle->flags & UV_SIGNAL_ONE_SHOT; if (first_oneshot && !rem_oneshot) { ret = uv__signal_register_handler(handle->signum, 1); assert(ret == 0); diff --git a/Utilities/cmlibuv/src/unix/stream.c b/Utilities/cmlibuv/src/unix/stream.c index 9bdd1c507f..4b9123f1aa 100644 --- a/Utilities/cmlibuv/src/unix/stream.c +++ b/Utilities/cmlibuv/src/unix/stream.c @@ -58,11 +58,19 @@ struct uv__stream_select_s { fd_set* swrite; size_t swrite_sz; }; -# define WRITE_RETRY_ON_ERROR(send_handle) \ + +/* Due to a possible kernel bug at least in OS X 10.10 "Yosemite", + * EPROTOTYPE can be returned while trying to write to a socket that is + * shutting down. If we retry the write, we should get the expected EPIPE + * instead. + */ +# define RETRY_ON_WRITE_ERROR(errno) (errno == EINTR || errno == EPROTOTYPE) +# define IS_TRANSIENT_WRITE_ERROR(errno, send_handle) \ (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || \ - (errno == EMSGSIZE && send_handle)) + (errno == EMSGSIZE && send_handle != NULL)) #else -# define WRITE_RETRY_ON_ERROR(send_handle) \ +# define RETRY_ON_WRITE_ERROR(errno) (errno == EINTR) +# define IS_TRANSIENT_WRITE_ERROR(errno, send_handle) \ (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) #endif /* defined(__APPLE__) */ @@ -220,7 +228,7 @@ static void uv__stream_osx_select(void* arg) { uv_sem_wait(&s->async_sem); /* Should be processed at this stage */ - assert((s->events == 0) || (stream->flags & UV_CLOSING)); + assert((s->events == 0) || (stream->flags & UV_HANDLE_CLOSING)); } } } @@ -248,7 +256,7 @@ static void uv__stream_osx_select_cb(uv_async_t* handle) { if ((events & POLLOUT) && uv__io_active(&stream->io_watcher, POLLOUT)) uv__stream_io(stream->loop, &stream->io_watcher, POLLOUT); - if (stream->flags & UV_CLOSING) + if (stream->flags & UV_HANDLE_CLOSING) return; /* NOTE: It is important to do it here, otherwise `select()` might be called @@ -342,7 +350,7 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) { if (err) goto failed_async_init; - s->async.flags |= UV__HANDLE_INTERNAL; + s->async.flags |= UV_HANDLE_INTERNAL; uv__handle_unref(&s->async); err = uv_sem_init(&s->close_sem, 0); @@ -407,12 +415,14 @@ int uv__stream_open(uv_stream_t* stream, int fd, int flags) { stream->flags |= flags; if (stream->type == UV_TCP) { - if ((stream->flags & UV_TCP_NODELAY) && uv__tcp_nodelay(fd, 1)) + if ((stream->flags & UV_HANDLE_TCP_NODELAY) && uv__tcp_nodelay(fd, 1)) return UV__ERR(errno); /* TODO Use delay the user passed in. */ - if ((stream->flags & UV_TCP_KEEPALIVE) && uv__tcp_keepalive(fd, 1, 60)) + if ((stream->flags & UV_HANDLE_TCP_KEEPALIVE) && + uv__tcp_keepalive(fd, 1, 60)) { return UV__ERR(errno); + } } #if defined(__APPLE__) @@ -447,7 +457,7 @@ void uv__stream_flush_write_queue(uv_stream_t* stream, int error) { void uv__stream_destroy(uv_stream_t* stream) { assert(!uv__io_active(&stream->io_watcher, POLLIN | POLLOUT)); - assert(stream->flags & UV_CLOSED); + assert(stream->flags & UV_HANDLE_CLOSED); if (stream->connect_req) { uv__req_unregister(stream->loop, stream->connect_req); @@ -522,7 +532,7 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { stream = container_of(w, uv_stream_t, io_watcher); assert(events & POLLIN); assert(stream->accepted_fd == -1); - assert(!(stream->flags & UV_CLOSING)); + assert(!(stream->flags & UV_HANDLE_CLOSING)); uv__io_start(stream->loop, &stream->io_watcher, POLLIN); @@ -565,7 +575,8 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { return; } - if (stream->type == UV_TCP && (stream->flags & UV_TCP_SINGLE_ACCEPT)) { + if (stream->type == UV_TCP && + (stream->flags & UV_HANDLE_TCP_SINGLE_ACCEPT)) { /* Give other processes a chance to accept connections. */ struct timespec timeout = { 0, 1 }; nanosleep(&timeout, NULL); @@ -590,7 +601,7 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) { case UV_TCP: err = uv__stream_open(client, server->accepted_fd, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); + UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); if (err) { /* TODO handle error */ uv__close(server->accepted_fd); @@ -674,14 +685,14 @@ static void uv__drain(uv_stream_t* stream) { uv__stream_osx_interrupt_select(stream); /* Shutdown? */ - if ((stream->flags & UV_STREAM_SHUTTING) && - !(stream->flags & UV_CLOSING) && - !(stream->flags & UV_STREAM_SHUT)) { + if ((stream->flags & UV_HANDLE_SHUTTING) && + !(stream->flags & UV_HANDLE_CLOSING) && + !(stream->flags & UV_HANDLE_SHUT)) { assert(stream->shutdown_req); req = stream->shutdown_req; stream->shutdown_req = NULL; - stream->flags &= ~UV_STREAM_SHUTTING; + stream->flags &= ~UV_HANDLE_SHUTTING; uv__req_unregister(stream->loop, req); err = 0; @@ -689,7 +700,7 @@ static void uv__drain(uv_stream_t* stream) { err = UV__ERR(errno); if (err == 0) - stream->flags |= UV_STREAM_SHUT; + stream->flags |= UV_HANDLE_SHUT; if (req->cb != NULL) req->cb(req, err); @@ -697,6 +708,14 @@ static void uv__drain(uv_stream_t* stream) { } +static ssize_t uv__writev(int fd, struct iovec* vec, size_t n) { + if (n == 1) + return write(fd, vec->iov_base, vec->iov_len); + else + return writev(fd, vec, n); +} + + static size_t uv__write_req_size(uv_write_t* req) { size_t size; @@ -709,6 +728,37 @@ static size_t uv__write_req_size(uv_write_t* req) { } +/* Returns 1 if all write request data has been written, or 0 if there is still + * more data to write. + * + * Note: the return value only says something about the *current* request. + * There may still be other write requests sitting in the queue. + */ +static int uv__write_req_update(uv_stream_t* stream, + uv_write_t* req, + size_t n) { + uv_buf_t* buf; + size_t len; + + assert(n <= stream->write_queue_size); + stream->write_queue_size -= n; + + buf = req->bufs + req->write_index; + + while (n > 0) { + len = n < buf->len ? n : buf->len; + buf->base += len; + buf->len -= len; + buf += (buf->len == 0); /* Advance to next buffer if this one is empty. */ + n -= len; + } + + req->write_index = buf - req->bufs; + + return req->write_index == req->nbufs; +} + + static void uv__write_req_finish(uv_write_t* req) { uv_stream_t* stream = req->handle; @@ -829,102 +879,32 @@ start: *pi = fd_to_send; } - do { + do n = sendmsg(uv__stream_fd(stream), &msg, 0); - } -#if defined(__APPLE__) - /* - * Due to a possible kernel bug at least in OS X 10.10 "Yosemite", - * EPROTOTYPE can be returned while trying to write to a socket that is - * shutting down. If we retry the write, we should get the expected EPIPE - * instead. - */ - while (n == -1 && (errno == EINTR || errno == EPROTOTYPE)); -#else - while (n == -1 && errno == EINTR); -#endif - } else { - do { - if (iovcnt == 1) { - n = write(uv__stream_fd(stream), iov[0].iov_base, iov[0].iov_len); - } else { - n = writev(uv__stream_fd(stream), iov, iovcnt); - } - } -#if defined(__APPLE__) - /* - * Due to a possible kernel bug at least in OS X 10.10 "Yosemite", - * EPROTOTYPE can be returned while trying to write to a socket that is - * shutting down. If we retry the write, we should get the expected EPIPE - * instead. - */ - while (n == -1 && (errno == EINTR || errno == EPROTOTYPE)); -#else - while (n == -1 && errno == EINTR); -#endif - } + while (n == -1 && RETRY_ON_WRITE_ERROR(errno)); - if (n < 0) { - if (!WRITE_RETRY_ON_ERROR(req->send_handle)) { - err = UV__ERR(errno); - goto error; - } else if (stream->flags & UV_STREAM_BLOCKING) { - /* If this is a blocking stream, try again. */ - goto start; - } + /* Ensure the handle isn't sent again in case this is a partial write. */ + if (n >= 0) + req->send_handle = NULL; } else { - /* Successful write */ - - while (n >= 0) { - uv_buf_t* buf = &(req->bufs[req->write_index]); - size_t len = buf->len; - - assert(req->write_index < req->nbufs); - - if ((size_t)n < len) { - buf->base += n; - buf->len -= n; - stream->write_queue_size -= n; - n = 0; - - /* There is more to write. */ - if (stream->flags & UV_STREAM_BLOCKING) { - /* - * If we're blocking then we should not be enabling the write - * watcher - instead we need to try again. - */ - goto start; - } else { - /* Break loop and ensure the watcher is pending. */ - break; - } - - } else { - /* Finished writing the buf at index req->write_index. */ - req->write_index++; - - assert((size_t)n >= len); - n -= len; - - assert(stream->write_queue_size >= len); - stream->write_queue_size -= len; + do + n = uv__writev(uv__stream_fd(stream), iov, iovcnt); + while (n == -1 && RETRY_ON_WRITE_ERROR(errno)); + } - if (req->write_index == req->nbufs) { - /* Then we're done! */ - assert(n == 0); - uv__write_req_finish(req); - /* TODO: start trying to write the next request. */ - return; - } - } - } + if (n == -1 && !IS_TRANSIENT_WRITE_ERROR(errno, req->send_handle)) { + err = UV__ERR(errno); + goto error; } - /* Either we've counted n down to zero or we've got EAGAIN. */ - assert(n == 0 || n == -1); + if (n > 0 && uv__write_req_update(stream, req, n)) { + uv__write_req_finish(req); + return; /* TODO(bnoordhuis) Start trying to write the next request. */ + } - /* Only non-blocking streams should use the write_watcher. */ - assert(!(stream->flags & UV_STREAM_BLOCKING)); + /* If this is a blocking stream, try again. */ + if (stream->flags & UV_HANDLE_BLOCKING_WRITES) + goto start; /* We're not done. */ uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); @@ -947,10 +927,16 @@ error: static void uv__write_callbacks(uv_stream_t* stream) { uv_write_t* req; QUEUE* q; + QUEUE pq; + + if (QUEUE_EMPTY(&stream->write_completed_queue)) + return; + + QUEUE_MOVE(&stream->write_completed_queue, &pq); - while (!QUEUE_EMPTY(&stream->write_completed_queue)) { + while (!QUEUE_EMPTY(&pq)) { /* Pop a req off write_completed_queue. */ - q = QUEUE_HEAD(&stream->write_completed_queue); + q = QUEUE_HEAD(&pq); req = QUEUE_DATA(q, uv_write_t, queue); QUEUE_REMOVE(q); uv__req_unregister(stream->loop, req); @@ -966,8 +952,6 @@ static void uv__write_callbacks(uv_stream_t* stream) { if (req->cb) req->cb(req, req->error); } - - assert(QUEUE_EMPTY(&stream->write_completed_queue)); } @@ -1015,13 +999,13 @@ uv_handle_type uv__handle_type(int fd) { static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) { - stream->flags |= UV_STREAM_READ_EOF; + stream->flags |= UV_HANDLE_READ_EOF; uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); if (!uv__io_active(&stream->io_watcher, POLLOUT)) uv__handle_stop(stream); uv__stream_osx_interrupt_select(stream); stream->read_cb(stream, UV_EOF, buf); - stream->flags &= ~UV_STREAM_READING; + stream->flags &= ~UV_HANDLE_READING; } @@ -1121,6 +1105,7 @@ static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) { #ifdef __clang__ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wgnu-folding-constant" +# pragma clang diagnostic ignored "-Wvla-extension" #endif static void uv__read(uv_stream_t* stream) { @@ -1132,7 +1117,7 @@ static void uv__read(uv_stream_t* stream) { int err; int is_ipc; - stream->flags &= ~UV_STREAM_READ_PARTIAL; + stream->flags &= ~UV_HANDLE_READ_PARTIAL; /* Prevent loop starvation when the data comes in as fast as (or faster than) * we can read it. XXX Need to rearm fd if we switch to edge-triggered I/O. @@ -1141,11 +1126,11 @@ static void uv__read(uv_stream_t* stream) { is_ipc = stream->type == UV_NAMED_PIPE && ((uv_pipe_t*) stream)->ipc; - /* XXX: Maybe instead of having UV_STREAM_READING we just test if + /* XXX: Maybe instead of having UV_HANDLE_READING we just test if * tcp->read_cb is NULL or not? */ while (stream->read_cb - && (stream->flags & UV_STREAM_READING) + && (stream->flags & UV_HANDLE_READING) && (count-- > 0)) { assert(stream->alloc_cb != NULL); @@ -1186,7 +1171,7 @@ static void uv__read(uv_stream_t* stream) { /* Error */ if (errno == EAGAIN || errno == EWOULDBLOCK) { /* Wait for the next one. */ - if (stream->flags & UV_STREAM_READING) { + if (stream->flags & UV_HANDLE_READING) { uv__io_start(stream->loop, &stream->io_watcher, POLLIN); uv__stream_osx_interrupt_select(stream); } @@ -1199,8 +1184,8 @@ static void uv__read(uv_stream_t* stream) { } else { /* Error. User should call uv_close(). */ stream->read_cb(stream, UV__ERR(errno), &buf); - if (stream->flags & UV_STREAM_READING) { - stream->flags &= ~UV_STREAM_READING; + if (stream->flags & UV_HANDLE_READING) { + stream->flags &= ~UV_HANDLE_READING; uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); if (!uv__io_active(&stream->io_watcher, POLLOUT)) uv__handle_stop(stream); @@ -1250,7 +1235,7 @@ static void uv__read(uv_stream_t* stream) { /* Return if we didn't fill the buffer, there is no more data to read. */ if (nread < buflen) { - stream->flags |= UV_STREAM_READ_PARTIAL; + stream->flags |= UV_HANDLE_READ_PARTIAL; return; } } @@ -1271,9 +1256,9 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) { stream->type == UV_TTY || stream->type == UV_NAMED_PIPE); - if (!(stream->flags & UV_STREAM_WRITABLE) || - stream->flags & UV_STREAM_SHUT || - stream->flags & UV_STREAM_SHUTTING || + if (!(stream->flags & UV_HANDLE_WRITABLE) || + stream->flags & UV_HANDLE_SHUT || + stream->flags & UV_HANDLE_SHUTTING || uv__is_closing(stream)) { return UV_ENOTCONN; } @@ -1285,7 +1270,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) { req->handle = stream; req->cb = cb; stream->shutdown_req = req; - stream->flags |= UV_STREAM_SHUTTING; + stream->flags |= UV_HANDLE_SHUTTING; uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); uv__stream_osx_interrupt_select(stream); @@ -1302,7 +1287,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE || stream->type == UV_TTY); - assert(!(stream->flags & UV_CLOSING)); + assert(!(stream->flags & UV_HANDLE_CLOSING)); if (stream->connect_req) { uv__stream_connect(stream); @@ -1311,7 +1296,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { assert(uv__stream_fd(stream) >= 0); - /* Ignore POLLHUP here. Even it it's set, there may still be data to read. */ + /* Ignore POLLHUP here. Even if it's set, there may still be data to read. */ if (events & (POLLIN | POLLERR | POLLHUP)) uv__read(stream); @@ -1325,9 +1310,9 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { * report the EOF yet because there is still data to read. */ if ((events & POLLHUP) && - (stream->flags & UV_STREAM_READING) && - (stream->flags & UV_STREAM_READ_PARTIAL) && - !(stream->flags & UV_STREAM_READ_EOF)) { + (stream->flags & UV_HANDLE_READING) && + (stream->flags & UV_HANDLE_READ_PARTIAL) && + !(stream->flags & UV_HANDLE_READ_EOF)) { uv_buf_t buf = { NULL, 0 }; uv__stream_eof(stream, &buf); } @@ -1417,7 +1402,7 @@ int uv_write2(uv_write_t* req, if (uv__stream_fd(stream) < 0) return UV_EBADF; - if (!(stream->flags & UV_STREAM_WRITABLE)) + if (!(stream->flags & UV_HANDLE_WRITABLE)) return -EPIPE; if (send_handle) { @@ -1487,7 +1472,7 @@ int uv_write2(uv_write_t* req, * if this assert fires then somehow the blocking stream isn't being * sufficiently flushed in uv__write. */ - assert(!(stream->flags & UV_STREAM_BLOCKING)); + assert(!(stream->flags & UV_HANDLE_BLOCKING_WRITES)); uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); uv__stream_osx_interrupt_select(stream); } @@ -1568,16 +1553,16 @@ int uv_read_start(uv_stream_t* stream, assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE || stream->type == UV_TTY); - if (stream->flags & UV_CLOSING) + if (stream->flags & UV_HANDLE_CLOSING) return UV_EINVAL; - if (!(stream->flags & UV_STREAM_READABLE)) + if (!(stream->flags & UV_HANDLE_READABLE)) return -ENOTCONN; - /* The UV_STREAM_READING flag is irrelevant of the state of the tcp - it just + /* The UV_HANDLE_READING flag is irrelevant of the state of the tcp - it just * expresses the desired state of the user. */ - stream->flags |= UV_STREAM_READING; + stream->flags |= UV_HANDLE_READING; /* TODO: try to do the read inline? */ /* TODO: keep track of tcp state. If we've gotten a EOF then we should @@ -1598,10 +1583,10 @@ int uv_read_start(uv_stream_t* stream, int uv_read_stop(uv_stream_t* stream) { - if (!(stream->flags & UV_STREAM_READING)) + if (!(stream->flags & UV_HANDLE_READING)) return 0; - stream->flags &= ~UV_STREAM_READING; + stream->flags &= ~UV_HANDLE_READING; uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); if (!uv__io_active(&stream->io_watcher, POLLOUT)) uv__handle_stop(stream); @@ -1614,12 +1599,12 @@ int uv_read_stop(uv_stream_t* stream) { int uv_is_readable(const uv_stream_t* stream) { - return !!(stream->flags & UV_STREAM_READABLE); + return !!(stream->flags & UV_HANDLE_READABLE); } int uv_is_writable(const uv_stream_t* stream) { - return !!(stream->flags & UV_STREAM_WRITABLE); + return !!(stream->flags & UV_HANDLE_WRITABLE); } @@ -1668,6 +1653,7 @@ void uv__stream_close(uv_stream_t* handle) { uv__io_close(handle->loop, &handle->io_watcher); uv_read_stop(handle); uv__handle_stop(handle); + handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); if (handle->io_watcher.fd != -1) { /* Don't close stdio file descriptors. Nothing good comes from it. */ diff --git a/Utilities/cmlibuv/src/unix/sunos.c b/Utilities/cmlibuv/src/unix/sunos.c index b92888e108..aac650411f 100644 --- a/Utilities/cmlibuv/src/unix/sunos.c +++ b/Utilities/cmlibuv/src/unix/sunos.c @@ -696,6 +696,8 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { #ifdef SUNOS_NO_IFADDRS int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { + *count = 0; + *addresses = NULL; return UV_ENOSYS; } #else /* SUNOS_NO_IFADDRS */ @@ -709,13 +711,14 @@ static int uv__set_phys_addr(uv_interface_address_t* address, struct sockaddr_dl* sa_addr; int sockfd; - int i; + size_t i; struct arpreq arpreq; /* This appears to only work as root */ sa_addr = (struct sockaddr_dl*)(ent->ifa_addr); memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); for (i = 0; i < sizeof(address->phys_addr); i++) { + /* Check that all bytes of phys_addr are zero. */ if (address->phys_addr[i] != 0) return 0; } @@ -762,11 +765,12 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { struct ifaddrs* addrs; struct ifaddrs* ent; + *count = 0; + *addresses = NULL; + if (getifaddrs(&addrs)) return UV__ERR(errno); - *count = 0; - /* Count the number of interfaces */ for (ent = addrs; ent != NULL; ent = ent->ifa_next) { if (uv__ifaddr_exclude(ent)) @@ -774,6 +778,11 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { (*count)++; } + if (*count == 0) { + freeifaddrs(addrs); + return 0; + } + *addresses = uv__malloc(*count * sizeof(**addresses)); if (!(*addresses)) { freeifaddrs(addrs); diff --git a/Utilities/cmlibuv/src/unix/tcp.c b/Utilities/cmlibuv/src/unix/tcp.c index 9a46793fdb..2982851dc6 100644 --- a/Utilities/cmlibuv/src/unix/tcp.c +++ b/Utilities/cmlibuv/src/unix/tcp.c @@ -216,7 +216,7 @@ int uv__tcp_connect(uv_connect_t* req, err = maybe_new_socket(handle, addr->sa_family, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); + UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); if (err) return err; @@ -263,13 +263,16 @@ int uv__tcp_connect(uv_connect_t* req, int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) { int err; + if (uv__fd_exists(handle->loop, sock)) + return UV_EEXIST; + err = uv__nonblock(sock, 1); if (err) return err; return uv__stream_open((uv_stream_t*)handle, sock, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); + UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); } @@ -331,7 +334,7 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) { } if (single_accept) - tcp->flags |= UV_TCP_SINGLE_ACCEPT; + tcp->flags |= UV_HANDLE_TCP_SINGLE_ACCEPT; flags = 0; #if defined(__MVS__) @@ -398,9 +401,9 @@ int uv_tcp_nodelay(uv_tcp_t* handle, int on) { } if (on) - handle->flags |= UV_TCP_NODELAY; + handle->flags |= UV_HANDLE_TCP_NODELAY; else - handle->flags &= ~UV_TCP_NODELAY; + handle->flags &= ~UV_HANDLE_TCP_NODELAY; return 0; } @@ -416,9 +419,9 @@ int uv_tcp_keepalive(uv_tcp_t* handle, int on, unsigned int delay) { } if (on) - handle->flags |= UV_TCP_KEEPALIVE; + handle->flags |= UV_HANDLE_TCP_KEEPALIVE; else - handle->flags &= ~UV_TCP_KEEPALIVE; + handle->flags &= ~UV_HANDLE_TCP_KEEPALIVE; /* TODO Store delay if uv__stream_fd(handle) == -1 but don't want to enlarge * uv_tcp_t with an int that's almost never used... @@ -430,9 +433,9 @@ int uv_tcp_keepalive(uv_tcp_t* handle, int on, unsigned int delay) { int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) { if (enable) - handle->flags &= ~UV_TCP_SINGLE_ACCEPT; + handle->flags &= ~UV_HANDLE_TCP_SINGLE_ACCEPT; else - handle->flags |= UV_TCP_SINGLE_ACCEPT; + handle->flags |= UV_HANDLE_TCP_SINGLE_ACCEPT; return 0; } diff --git a/Utilities/cmlibuv/src/unix/thread.c b/Utilities/cmlibuv/src/unix/thread.c index 303bc6ec84..29004707a4 100644 --- a/Utilities/cmlibuv/src/unix/thread.c +++ b/Utilities/cmlibuv/src/unix/thread.c @@ -44,108 +44,119 @@ #undef NANOSEC #define NANOSEC ((uint64_t) 1e9) +#if defined(PTHREAD_BARRIER_SERIAL_THREAD) +STATIC_ASSERT(sizeof(uv_barrier_t) == sizeof(pthread_barrier_t)); +#endif -#if defined(UV__PTHREAD_BARRIER_FALLBACK) -/* TODO: support barrier_attr */ -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count) { +/* Note: guard clauses should match uv_barrier_t's in include/uv/uv-unix.h. */ +#if defined(_AIX) || !defined(PTHREAD_BARRIER_SERIAL_THREAD) +int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { + struct _uv_barrier* b; int rc; - _uv_barrier* b; if (barrier == NULL || count == 0) - return EINVAL; - - if (barrier_attr != NULL) - return ENOTSUP; + return UV_EINVAL; b = uv__malloc(sizeof(*b)); if (b == NULL) - return ENOMEM; + return UV_ENOMEM; b->in = 0; b->out = 0; b->threshold = count; - if ((rc = pthread_mutex_init(&b->mutex, NULL)) != 0) + rc = uv_mutex_init(&b->mutex); + if (rc != 0) goto error2; - if ((rc = pthread_cond_init(&b->cond, NULL)) != 0) + + rc = uv_cond_init(&b->cond); + if (rc != 0) goto error; barrier->b = b; return 0; error: - pthread_mutex_destroy(&b->mutex); + uv_mutex_destroy(&b->mutex); error2: uv__free(b); return rc; } -int pthread_barrier_wait(pthread_barrier_t* barrier) { - int rc; - _uv_barrier* b; + +int uv_barrier_wait(uv_barrier_t* barrier) { + struct _uv_barrier* b; + int last; if (barrier == NULL || barrier->b == NULL) - return EINVAL; + return UV_EINVAL; b = barrier->b; - /* Lock the mutex*/ - if ((rc = pthread_mutex_lock(&b->mutex)) != 0) - return rc; + uv_mutex_lock(&b->mutex); - /* Increment the count. If this is the first thread to reach the threshold, - wake up waiters, unlock the mutex, then return - PTHREAD_BARRIER_SERIAL_THREAD. */ if (++b->in == b->threshold) { b->in = 0; - b->out = b->threshold - 1; - rc = pthread_cond_signal(&b->cond); - assert(rc == 0); - - pthread_mutex_unlock(&b->mutex); - return PTHREAD_BARRIER_SERIAL_THREAD; + b->out = b->threshold; + uv_cond_signal(&b->cond); + } else { + do + uv_cond_wait(&b->cond, &b->mutex); + while (b->in != 0); } - /* Otherwise, wait for other threads until in is set to 0, - then return 0 to indicate this is not the first thread. */ - do { - if ((rc = pthread_cond_wait(&b->cond, &b->mutex)) != 0) - break; - } while (b->in != 0); - - /* mark thread exit */ - b->out--; - pthread_cond_signal(&b->cond); - pthread_mutex_unlock(&b->mutex); - return rc; + + last = (--b->out == 0); + if (!last) + uv_cond_signal(&b->cond); /* Not needed for last thread. */ + + uv_mutex_unlock(&b->mutex); + return last; } -int pthread_barrier_destroy(pthread_barrier_t* barrier) { - int rc; - _uv_barrier* b; - if (barrier == NULL || barrier->b == NULL) - return EINVAL; +void uv_barrier_destroy(uv_barrier_t* barrier) { + struct _uv_barrier* b; b = barrier->b; + uv_mutex_lock(&b->mutex); - if ((rc = pthread_mutex_lock(&b->mutex)) != 0) - return rc; + assert(b->in == 0); + assert(b->out == 0); - if (b->in > 0 || b->out > 0) - rc = EBUSY; - - pthread_mutex_unlock(&b->mutex); + if (b->in != 0 || b->out != 0) + abort(); - if (rc) - return rc; + uv_mutex_unlock(&b->mutex); + uv_mutex_destroy(&b->mutex); + uv_cond_destroy(&b->cond); - pthread_cond_destroy(&b->cond); - pthread_mutex_destroy(&b->mutex); uv__free(barrier->b); barrier->b = NULL; - return 0; } + +#else + +int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { + return UV__ERR(pthread_barrier_init(barrier, NULL, count)); +} + + +int uv_barrier_wait(uv_barrier_t* barrier) { + int rc; + + rc = pthread_barrier_wait(barrier); + if (rc != 0) + if (rc != PTHREAD_BARRIER_SERIAL_THREAD) + abort(); + + return rc == PTHREAD_BARRIER_SERIAL_THREAD; +} + + +void uv_barrier_destroy(uv_barrier_t* barrier) { + if (pthread_barrier_destroy(barrier)) + abort(); +} + #endif @@ -771,25 +782,6 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { } -int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { - return UV__ERR(pthread_barrier_init(barrier, NULL, count)); -} - - -void uv_barrier_destroy(uv_barrier_t* barrier) { - if (pthread_barrier_destroy(barrier)) - abort(); -} - - -int uv_barrier_wait(uv_barrier_t* barrier) { - int r = pthread_barrier_wait(barrier); - if (r && r != PTHREAD_BARRIER_SERIAL_THREAD) - abort(); - return r == PTHREAD_BARRIER_SERIAL_THREAD; -} - - int uv_key_create(uv_key_t* key) { return UV__ERR(pthread_key_create(key, NULL)); } diff --git a/Utilities/cmlibuv/src/unix/tty.c b/Utilities/cmlibuv/src/unix/tty.c index e8ea302f2c..b8bc2838d6 100644 --- a/Utilities/cmlibuv/src/unix/tty.c +++ b/Utilities/cmlibuv/src/unix/tty.c @@ -92,13 +92,15 @@ static int uv__tty_is_slave(const int fd) { return result; } -int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) { +int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int unused) { uv_handle_type type; int flags = 0; int newfd = -1; int r; int saved_flags; + int mode; char path[256]; + (void)unused; /* deprecated parameter is no longer needed */ /* File descriptors that refer to files cannot be monitored with epoll. * That restriction also applies to character devices like /dev/random @@ -108,6 +110,15 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) { if (type == UV_FILE || type == UV_UNKNOWN_HANDLE) return UV_EINVAL; + /* Save the fd flags in case we need to restore them due to an error. */ + do + saved_flags = fcntl(fd, F_GETFL); + while (saved_flags == -1 && errno == EINTR); + + if (saved_flags == -1) + return UV__ERR(errno); + mode = saved_flags & O_ACCMODE; + /* Reopen the file descriptor when it refers to a tty. This lets us put the * tty in non-blocking mode without affecting other processes that share it * with us. @@ -125,14 +136,14 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) { * slave device. */ if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0) - r = uv__open_cloexec(path, O_RDWR); + r = uv__open_cloexec(path, mode); else r = -1; if (r < 0) { /* fallback to using blocking writes */ - if (!readable) - flags |= UV_STREAM_BLOCKING; + if (mode != O_RDONLY) + flags |= UV_HANDLE_BLOCKING_WRITES; goto skip; } @@ -151,22 +162,6 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) { fd = newfd; } -#if defined(__APPLE__) - /* Save the fd flags in case we need to restore them due to an error. */ - do - saved_flags = fcntl(fd, F_GETFL); - while (saved_flags == -1 && errno == EINTR); - - if (saved_flags == -1) { - if (newfd != -1) - uv__close(newfd); - return UV__ERR(errno); - } -#endif - - /* Pacify the compiler. */ - (void) &saved_flags; - skip: uv__stream_init(loop, (uv_stream_t*) tty, UV_TTY); @@ -174,7 +169,7 @@ skip: * the handle queue, since it was added by uv__handle_init in uv_stream_init. */ - if (!(flags & UV_STREAM_BLOCKING)) + if (!(flags & UV_HANDLE_BLOCKING_WRITES)) uv__nonblock(fd, 1); #if defined(__APPLE__) @@ -191,10 +186,10 @@ skip: } #endif - if (readable) - flags |= UV_STREAM_READABLE; - else - flags |= UV_STREAM_WRITABLE; + if (mode != O_WRONLY) + flags |= UV_HANDLE_READABLE; + if (mode != O_RDONLY) + flags |= UV_HANDLE_WRITABLE; uv__stream_open((uv_stream_t*) tty, fd, flags); tty->mode = UV_TTY_MODE_NORMAL; diff --git a/Utilities/cmlibuv/src/unix/udp.c b/Utilities/cmlibuv/src/unix/udp.c index 74d613b684..ec337ec8b8 100644 --- a/Utilities/cmlibuv/src/unix/udp.c +++ b/Utilities/cmlibuv/src/unix/udp.c @@ -92,8 +92,8 @@ static void uv__udp_run_completed(uv_udp_t* handle) { uv_udp_send_t* req; QUEUE* q; - assert(!(handle->flags & UV_UDP_PROCESSING)); - handle->flags |= UV_UDP_PROCESSING; + assert(!(handle->flags & UV_HANDLE_UDP_PROCESSING)); + handle->flags |= UV_HANDLE_UDP_PROCESSING; while (!QUEUE_EMPTY(&handle->write_completed_queue)) { q = QUEUE_HEAD(&handle->write_completed_queue); @@ -128,7 +128,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) { uv__handle_stop(handle); } - handle->flags &= ~UV_UDP_PROCESSING; + handle->flags &= ~UV_HANDLE_UDP_PROCESSING; } @@ -427,7 +427,7 @@ int uv__udp_send(uv_udp_send_t* req, QUEUE_INSERT_TAIL(&handle->write_queue, &req->queue); uv__handle_start(handle); - if (empty_queue && !(handle->flags & UV_UDP_PROCESSING)) { + if (empty_queue && !(handle->flags & UV_HANDLE_UDP_PROCESSING)) { uv__udp_sendmsg(handle); /* `uv__udp_sendmsg` may not be able to do non-blocking write straight @@ -624,6 +624,9 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { if (handle->io_watcher.fd != -1) return UV_EBUSY; + if (uv__fd_exists(handle->loop, sock)) + return UV_EEXIST; + err = uv__nonblock(sock, 1); if (err) return err; @@ -757,14 +760,16 @@ int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) { * IP_MULTICAST_TTL, so hardcode the size of the option in the IPv6 case, * and use the general uv__setsockopt_maybe_char call otherwise. */ -#if defined(__sun) || defined(_AIX) || defined(__MVS__) +#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ + defined(__MVS__) if (handle->flags & UV_HANDLE_IPV6) return uv__setsockopt(handle, IP_MULTICAST_TTL, IPV6_MULTICAST_HOPS, &ttl, sizeof(ttl)); -#endif /* defined(__sun) || defined(_AIX) || defined(__MVS__) */ +#endif /* defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ + defined(__MVS__) */ return uv__setsockopt_maybe_char(handle, IP_MULTICAST_TTL, @@ -780,14 +785,16 @@ int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) { * IP_MULTICAST_LOOP, so hardcode the size of the option in the IPv6 case, * and use the general uv__setsockopt_maybe_char call otherwise. */ -#if defined(__sun) || defined(_AIX) || defined(__MVS__) +#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ + defined(__MVS__) if (handle->flags & UV_HANDLE_IPV6) return uv__setsockopt(handle, IP_MULTICAST_LOOP, IPV6_MULTICAST_LOOP, &on, sizeof(on)); -#endif /* defined(__sun) || defined(_AIX) || defined(__MVS__) */ +#endif /* defined(__sun) || defined(_AIX) ||defined(__OpenBSD__) || + defined(__MVS__) */ return uv__setsockopt_maybe_char(handle, IP_MULTICAST_LOOP, diff --git a/Utilities/cmlibuv/src/uv-common.c b/Utilities/cmlibuv/src/uv-common.c index 15dec082ff..907ebf2f2e 100644 --- a/Utilities/cmlibuv/src/uv-common.c +++ b/Utilities/cmlibuv/src/uv-common.c @@ -72,7 +72,9 @@ char* uv__strndup(const char* s, size_t n) { } void* uv__malloc(size_t size) { - return uv__allocator.local_malloc(size); + if (size > 0) + return uv__allocator.local_malloc(size); + return NULL; } void uv__free(void* ptr) { @@ -91,7 +93,10 @@ void* uv__calloc(size_t count, size_t size) { } void* uv__realloc(void* ptr, size_t size) { - return uv__allocator.local_realloc(ptr, size); + if (size > 0) + return uv__allocator.local_realloc(ptr, size); + uv__free(ptr); + return NULL; } int uv_replace_allocator(uv_malloc_func malloc_func, @@ -155,6 +160,18 @@ static const char* uv__unknown_err_code(int err) { return copy != NULL ? copy : "Unknown system error"; } +#define UV_ERR_NAME_GEN_R(name, _) \ +case UV_## name: \ + uv__strscpy(buf, #name, buflen); break; +char* uv_err_name_r(int err, char* buf, size_t buflen) { + switch (err) { + UV_ERRNO_MAP(UV_ERR_NAME_GEN_R) + default: snprintf(buf, buflen, "Unknown system error %d", err); + } + return buf; +} +#undef UV_ERR_NAME_GEN_R + #define UV_ERR_NAME_GEN(name, _) case UV_ ## name: return #name; const char* uv_err_name(int err) { @@ -166,6 +183,19 @@ const char* uv_err_name(int err) { #undef UV_ERR_NAME_GEN +#define UV_STRERROR_GEN_R(name, msg) \ +case UV_ ## name: \ + snprintf(buf, buflen, "%s", msg); break; +char* uv_strerror_r(int err, char* buf, size_t buflen) { + switch (err) { + UV_ERRNO_MAP(UV_STRERROR_GEN_R) + default: snprintf(buf, buflen, "Unknown system error %d", err); + } + return buf; +} +#undef UV_STRERROR_GEN_R + + #define UV_STRERROR_GEN(name, msg) case UV_ ## name: return msg; const char* uv_strerror(int err) { switch (err) { @@ -359,7 +389,7 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) { QUEUE_REMOVE(q); QUEUE_INSERT_TAIL(&loop->handle_queue, q); - if (h->flags & UV__HANDLE_INTERNAL) continue; + if (h->flags & UV_HANDLE_INTERNAL) continue; walk_cb(h, arg); } } @@ -388,9 +418,9 @@ static void uv__print_handles(uv_loop_t* loop, int only_active, FILE* stream) { fprintf(stream, "[%c%c%c] %-8s %p\n", - "R-"[!(h->flags & UV__HANDLE_REF)], - "A-"[!(h->flags & UV__HANDLE_ACTIVE)], - "I-"[!(h->flags & UV__HANDLE_INTERNAL)], + "R-"[!(h->flags & UV_HANDLE_REF)], + "A-"[!(h->flags & UV_HANDLE_ACTIVE)], + "I-"[!(h->flags & UV_HANDLE_INTERNAL)], type, (void*)h); } @@ -634,7 +664,7 @@ int uv_loop_close(uv_loop_t* loop) { QUEUE_FOREACH(q, &loop->handle_queue) { h = QUEUE_DATA(q, uv_handle_t, handle_queue); - if (!(h->flags & UV__HANDLE_INTERNAL)) + if (!(h->flags & UV_HANDLE_INTERNAL)) return UV_EBUSY; } diff --git a/Utilities/cmlibuv/src/uv-common.h b/Utilities/cmlibuv/src/uv-common.h index c497d014fd..15ac4d02c1 100644 --- a/Utilities/cmlibuv/src/uv-common.h +++ b/Utilities/cmlibuv/src/uv-common.h @@ -32,14 +32,15 @@ #include <stddef.h> #if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" +# include "uv/stdint-msvc2008.h" #else # include <stdint.h> #endif #include "uv.h" -#include "tree.h" +#include "uv/tree.h" #include "queue.h" +#include "strscpy.h" #if EDOM > 0 # define UV__ERR(x) (-(x)) @@ -59,22 +60,67 @@ extern int snprintf(char*, size_t, const char*, ...); #define STATIC_ASSERT(expr) \ void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)]) -#ifndef _WIN32 +/* Handle flags. Some flags are specific to Windows or UNIX. */ enum { - UV__SIGNAL_ONE_SHOT = 0x80000, /* On signal reception remove sighandler */ - UV__HANDLE_INTERNAL = 0x8000, - UV__HANDLE_ACTIVE = 0x4000, - UV__HANDLE_REF = 0x2000, - UV__HANDLE_CLOSING = 0 /* no-op on unix */ + /* Used by all handles. */ + UV_HANDLE_CLOSING = 0x00000001, + UV_HANDLE_CLOSED = 0x00000002, + UV_HANDLE_ACTIVE = 0x00000004, + UV_HANDLE_REF = 0x00000008, + UV_HANDLE_INTERNAL = 0x00000010, + UV_HANDLE_ENDGAME_QUEUED = 0x00000020, + + /* Used by streams. */ + UV_HANDLE_LISTENING = 0x00000040, + UV_HANDLE_CONNECTION = 0x00000080, + UV_HANDLE_SHUTTING = 0x00000100, + UV_HANDLE_SHUT = 0x00000200, + UV_HANDLE_READ_PARTIAL = 0x00000400, + UV_HANDLE_READ_EOF = 0x00000800, + + /* Used by streams and UDP handles. */ + UV_HANDLE_READING = 0x00001000, + UV_HANDLE_BOUND = 0x00002000, + UV_HANDLE_READABLE = 0x00004000, + UV_HANDLE_WRITABLE = 0x00008000, + UV_HANDLE_READ_PENDING = 0x00010000, + UV_HANDLE_SYNC_BYPASS_IOCP = 0x00020000, + UV_HANDLE_ZERO_READ = 0x00040000, + UV_HANDLE_EMULATE_IOCP = 0x00080000, + UV_HANDLE_BLOCKING_WRITES = 0x00100000, + UV_HANDLE_CANCELLATION_PENDING = 0x00200000, + + /* Used by uv_tcp_t and uv_udp_t handles */ + UV_HANDLE_IPV6 = 0x00400000, + + /* Only used by uv_tcp_t handles. */ + UV_HANDLE_TCP_NODELAY = 0x01000000, + UV_HANDLE_TCP_KEEPALIVE = 0x02000000, + UV_HANDLE_TCP_SINGLE_ACCEPT = 0x04000000, + UV_HANDLE_TCP_ACCEPT_STATE_CHANGING = 0x08000000, + UV_HANDLE_TCP_SOCKET_CLOSED = 0x10000000, + UV_HANDLE_SHARED_TCP_SOCKET = 0x20000000, + + /* Only used by uv_udp_t handles. */ + UV_HANDLE_UDP_PROCESSING = 0x01000000, + + /* Only used by uv_pipe_t handles. */ + UV_HANDLE_NON_OVERLAPPED_PIPE = 0x01000000, + UV_HANDLE_PIPESERVER = 0x02000000, + + /* Only used by uv_tty_t handles. */ + UV_HANDLE_TTY_READABLE = 0x01000000, + UV_HANDLE_TTY_RAW = 0x02000000, + UV_HANDLE_TTY_SAVED_POSITION = 0x04000000, + UV_HANDLE_TTY_SAVED_ATTRIBUTES = 0x08000000, + + /* Only used by uv_signal_t handles. */ + UV_SIGNAL_ONE_SHOT_DISPATCHED = 0x01000000, + UV_SIGNAL_ONE_SHOT = 0x02000000, + + /* Only used by uv_poll_t handles. */ + UV_HANDLE_POLL_SLOW = 0x01000000 }; -#else -# define UV__SIGNAL_ONE_SHOT_DISPATCHED 0x200 -# define UV__SIGNAL_ONE_SHOT 0x100 -# define UV__HANDLE_INTERNAL 0x80 -# define UV__HANDLE_ACTIVE 0x40 -# define UV__HANDLE_REF 0x20 -# define UV__HANDLE_CLOSING 0x01 -#endif int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap); @@ -119,8 +165,15 @@ void uv__fs_poll_close(uv_fs_poll_t* handle); int uv__getaddrinfo_translate_error(int sys_err); /* EAI_* error. */ +enum uv__work_kind { + UV__WORK_CPU, + UV__WORK_FAST_IO, + UV__WORK_SLOW_IO +}; + void uv__work_submit(uv_loop_t* loop, struct uv__work *w, + enum uv__work_kind kind, void (*work)(struct uv__work *w), void (*done)(struct uv__work *w, int status)); @@ -132,6 +185,10 @@ int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value); void uv__fs_scandir_cleanup(uv_fs_t* req); +int uv__next_timeout(const uv_loop_t* loop); +void uv__run_timers(uv_loop_t* loop); +void uv__timer_close(uv_timer_t* handle); + #define uv__has_active_reqs(loop) \ ((loop)->active_reqs.count > 0) @@ -164,49 +221,47 @@ void uv__fs_scandir_cleanup(uv_fs_t* req); while (0) #define uv__is_active(h) \ - (((h)->flags & UV__HANDLE_ACTIVE) != 0) + (((h)->flags & UV_HANDLE_ACTIVE) != 0) #define uv__is_closing(h) \ - (((h)->flags & (UV_CLOSING | UV_CLOSED)) != 0) + (((h)->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED)) != 0) #define uv__handle_start(h) \ do { \ - assert(((h)->flags & UV__HANDLE_CLOSING) == 0); \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) break; \ - (h)->flags |= UV__HANDLE_ACTIVE; \ - if (((h)->flags & UV__HANDLE_REF) != 0) uv__active_handle_add(h); \ + if (((h)->flags & UV_HANDLE_ACTIVE) != 0) break; \ + (h)->flags |= UV_HANDLE_ACTIVE; \ + if (((h)->flags & UV_HANDLE_REF) != 0) uv__active_handle_add(h); \ } \ while (0) #define uv__handle_stop(h) \ do { \ - assert(((h)->flags & UV__HANDLE_CLOSING) == 0); \ - if (((h)->flags & UV__HANDLE_ACTIVE) == 0) break; \ - (h)->flags &= ~UV__HANDLE_ACTIVE; \ - if (((h)->flags & UV__HANDLE_REF) != 0) uv__active_handle_rm(h); \ + if (((h)->flags & UV_HANDLE_ACTIVE) == 0) break; \ + (h)->flags &= ~UV_HANDLE_ACTIVE; \ + if (((h)->flags & UV_HANDLE_REF) != 0) uv__active_handle_rm(h); \ } \ while (0) #define uv__handle_ref(h) \ do { \ - if (((h)->flags & UV__HANDLE_REF) != 0) break; \ - (h)->flags |= UV__HANDLE_REF; \ - if (((h)->flags & UV__HANDLE_CLOSING) != 0) break; \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) uv__active_handle_add(h); \ + if (((h)->flags & UV_HANDLE_REF) != 0) break; \ + (h)->flags |= UV_HANDLE_REF; \ + if (((h)->flags & UV_HANDLE_CLOSING) != 0) break; \ + if (((h)->flags & UV_HANDLE_ACTIVE) != 0) uv__active_handle_add(h); \ } \ while (0) #define uv__handle_unref(h) \ do { \ - if (((h)->flags & UV__HANDLE_REF) == 0) break; \ - (h)->flags &= ~UV__HANDLE_REF; \ - if (((h)->flags & UV__HANDLE_CLOSING) != 0) break; \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) uv__active_handle_rm(h); \ + if (((h)->flags & UV_HANDLE_REF) == 0) break; \ + (h)->flags &= ~UV_HANDLE_REF; \ + if (((h)->flags & UV_HANDLE_CLOSING) != 0) break; \ + if (((h)->flags & UV_HANDLE_ACTIVE) != 0) uv__active_handle_rm(h); \ } \ while (0) #define uv__has_ref(h) \ - (((h)->flags & UV__HANDLE_REF) != 0) + (((h)->flags & UV_HANDLE_REF) != 0) #if defined(_WIN32) # define uv__handle_platform_init(h) ((h)->u.fd = -1) @@ -218,7 +273,7 @@ void uv__fs_scandir_cleanup(uv_fs_t* req); do { \ (h)->loop = (loop_); \ (h)->type = (type_); \ - (h)->flags = UV__HANDLE_REF; /* Ref the loop when active. */ \ + (h)->flags = UV_HANDLE_REF; /* Ref the loop when active. */ \ QUEUE_INSERT_TAIL(&(loop_)->handle_queue, &(h)->handle_queue); \ uv__handle_platform_init(h); \ } \ diff --git a/Utilities/cmlibuv/src/uv-data-getter-setters.c b/Utilities/cmlibuv/src/uv-data-getter-setters.c index 533e4a2fe1..b7fcd4a7fd 100644 --- a/Utilities/cmlibuv/src/uv-data-getter-setters.c +++ b/Utilities/cmlibuv/src/uv-data-getter-setters.c @@ -3,11 +3,11 @@ const char* uv_handle_type_name(uv_handle_type type) { switch (type) { #define XX(uc,lc) case UV_##uc: return #lc; - UV_HANDLE_TYPE_MAP(XX) + UV_HANDLE_TYPE_MAP(XX) #undef XX - case UV_FILE: return "file"; - case UV_HANDLE_TYPE_MAX: - case UV_UNKNOWN_HANDLE: return NULL; + case UV_FILE: return "file"; + case UV_HANDLE_TYPE_MAX: + case UV_UNKNOWN_HANDLE: return NULL; } return NULL; } @@ -31,10 +31,12 @@ void uv_handle_set_data(uv_handle_t* handle, void* data) { const char* uv_req_type_name(uv_req_type type) { switch (type) { #define XX(uc,lc) case UV_##uc: return #lc; - UV_REQ_TYPE_MAP(XX) + UV_REQ_TYPE_MAP(XX) #undef XX - case UV_REQ_TYPE_MAX: - case UV_UNKNOWN_REQ: return NULL; + case UV_REQ_TYPE_MAX: + case UV_UNKNOWN_REQ: + default: /* UV_REQ_TYPE_PRIVATE */ + return NULL; } return NULL; } diff --git a/Utilities/cmlibuv/src/win/async.c b/Utilities/cmlibuv/src/win/async.c index 0b636ed1e9..d787f6604e 100644 --- a/Utilities/cmlibuv/src/win/async.c +++ b/Utilities/cmlibuv/src/win/async.c @@ -29,7 +29,7 @@ void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING && + if (handle->flags & UV_HANDLE_CLOSING && !handle->async_sent) { assert(!(handle->flags & UV_HANDLE_CLOSED)); uv__handle_close(handle); @@ -71,9 +71,9 @@ int uv_async_send(uv_async_t* handle) { return -1; } - /* The user should make sure never to call uv_async_send to a closing */ - /* or closed handle. */ - assert(!(handle->flags & UV__HANDLE_CLOSING)); + /* The user should make sure never to call uv_async_send to a closing or + * closed handle. */ + assert(!(handle->flags & UV_HANDLE_CLOSING)); if (!uv__atomic_exchange_set(&handle->async_sent)) { POST_COMPLETION_FOR_REQ(loop, &handle->async_req); @@ -90,7 +90,7 @@ void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle, handle->async_sent = 0; - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { uv_want_endgame(loop, (uv_handle_t*)handle); } else if (handle->async_cb != NULL) { handle->async_cb(handle); diff --git a/Utilities/cmlibuv/src/win/atomicops-inl.h b/Utilities/cmlibuv/src/win/atomicops-inl.h index 6d8126f692..52713cf305 100644 --- a/Utilities/cmlibuv/src/win/atomicops-inl.h +++ b/Utilities/cmlibuv/src/win/atomicops-inl.h @@ -29,10 +29,10 @@ /* Atomic set operation on char */ #ifdef _MSC_VER /* MSVC */ -/* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less */ -/* efficient than InterlockedExchange, but InterlockedExchange8 does not */ -/* exist, and interlocked operations on larger targets might require the */ -/* target to be aligned. */ +/* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less + * efficient than InterlockedExchange, but InterlockedExchange8 does not exist, + * and interlocked operations on larger targets might require the target to be + * aligned. */ #pragma intrinsic(_InterlockedOr8) static char INLINE uv__atomic_exchange_set(char volatile* target) { diff --git a/Utilities/cmlibuv/src/win/core.c b/Utilities/cmlibuv/src/win/core.c index b8aad11b73..58309c6966 100644 --- a/Utilities/cmlibuv/src/win/core.c +++ b/Utilities/cmlibuv/src/win/core.c @@ -33,6 +33,7 @@ #include "internal.h" #include "queue.h" #include "handle-inl.h" +#include "heap-inl.h" #include "req-inl.h" /* uv_once initialization guards */ @@ -221,6 +222,7 @@ static void uv_init(void) { int uv_loop_init(uv_loop_t* loop) { + struct heap* timer_heap; int err; /* Initialize libuv itself first */ @@ -246,7 +248,13 @@ int uv_loop_init(uv_loop_t* loop) { loop->endgame_handles = NULL; - RB_INIT(&loop->timers); + loop->timer_heap = timer_heap = uv__malloc(sizeof(*timer_heap)); + if (timer_heap == NULL) { + err = UV_ENOMEM; + goto fail_timers_alloc; + } + + heap_init(timer_heap); loop->check_handles = NULL; loop->prepare_handles = NULL; @@ -273,7 +281,7 @@ int uv_loop_init(uv_loop_t* loop) { goto fail_async_init; uv__handle_unref(&loop->wq_async); - loop->wq_async.flags |= UV__HANDLE_INTERNAL; + loop->wq_async.flags |= UV_HANDLE_INTERNAL; err = uv__loops_add(loop); if (err) @@ -285,6 +293,10 @@ fail_async_init: uv_mutex_destroy(&loop->wq_mutex); fail_mutex_init: + uv__free(timer_heap); + loop->timer_heap = NULL; + +fail_timers_alloc: CloseHandle(loop->iocp); loop->iocp = INVALID_HANDLE_VALUE; @@ -292,6 +304,13 @@ fail_mutex_init: } +void uv_update_time(uv_loop_t* loop) { + uint64_t new_time = uv__hrtime(1000); + assert(new_time >= loop->time); + loop->time = new_time; +} + + void uv__once_init(void) { uv_once(&uv_init_guard_, uv_init); } @@ -320,6 +339,9 @@ void uv__loop_close(uv_loop_t* loop) { uv_mutex_unlock(&loop->wq_mutex); uv_mutex_destroy(&loop->wq_mutex); + uv__free(loop->timer_heap); + loop->timer_heap = NULL; + CloseHandle(loop->iocp); } @@ -359,7 +381,7 @@ int uv_backend_timeout(const uv_loop_t* loop) { } -static void uv_poll(uv_loop_t* loop, DWORD timeout) { +static void uv__poll_wine(uv_loop_t* loop, DWORD timeout) { DWORD bytes; ULONG_PTR key; OVERLAPPED* overlapped; @@ -410,7 +432,7 @@ static void uv_poll(uv_loop_t* loop, DWORD timeout) { } -static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) { +static void uv__poll(uv_loop_t* loop, DWORD timeout) { BOOL success; uv_req_t* req; OVERLAPPED_ENTRY overlappeds[128]; @@ -422,12 +444,12 @@ static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) { timeout_time = loop->time + timeout; for (repeat = 0; ; repeat++) { - success = pGetQueuedCompletionStatusEx(loop->iocp, - overlappeds, - ARRAY_SIZE(overlappeds), - &count, - timeout, - FALSE); + success = GetQueuedCompletionStatusEx(loop->iocp, + overlappeds, + ARRAY_SIZE(overlappeds), + &count, + timeout, + FALSE); if (success) { for (i = 0; i < count; i++) { @@ -485,12 +507,6 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) { DWORD timeout; int r; int ran_pending; - void (*poll)(uv_loop_t* loop, DWORD timeout); - - if (pGetQueuedCompletionStatusEx) - poll = &uv_poll_ex; - else - poll = &uv_poll; r = uv__loop_alive(loop); if (!r) @@ -498,7 +514,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) { while (r != 0 && loop->stop_flag == 0) { uv_update_time(loop); - uv_process_timers(loop); + uv__run_timers(loop); ran_pending = uv_process_reqs(loop); uv_idle_invoke(loop); @@ -508,7 +524,11 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) { if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT) timeout = uv_backend_timeout(loop); - (*poll)(loop, timeout); + if (pGetQueuedCompletionStatusEx) + uv__poll(loop, timeout); + else + uv__poll_wine(loop, timeout); + uv_check_invoke(loop); uv_process_endgames(loop); @@ -522,7 +542,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) { * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from * the check. */ - uv_process_timers(loop); + uv__run_timers(loop); } r = uv__loop_alive(loop); diff --git a/Utilities/cmlibuv/src/win/dl.c b/Utilities/cmlibuv/src/win/dl.c index 97ac1c1ad1..676be4dc7b 100644 --- a/Utilities/cmlibuv/src/win/dl.c +++ b/Utilities/cmlibuv/src/win/dl.c @@ -64,7 +64,8 @@ void uv_dlclose(uv_lib_t* lib) { int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) { - *ptr = (void*) GetProcAddress(lib->handle, name); + /* Cast though integer to suppress pedantic warning about forbidden cast. */ + *ptr = (void*)(uintptr_t) GetProcAddress(lib->handle, name); return uv__dlerror(lib, "", *ptr ? 0 : GetLastError()); } @@ -75,8 +76,9 @@ const char* uv_dlerror(const uv_lib_t* lib) { static void uv__format_fallback_error(uv_lib_t* lib, int errorno){ - DWORD_PTR args[1] = { (DWORD_PTR) errorno }; - LPSTR fallback_error = "error: %1!d!"; + static const CHAR fallback_error[] = "error: %1!d!"; + DWORD_PTR args[1]; + args[0] = (DWORD_PTR) errorno; FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY | @@ -107,7 +109,8 @@ static int uv__dlerror(uv_lib_t* lib, const char* filename, DWORD errorno) { MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (LPSTR) &lib->errmsg, 0, NULL); - if (!res && GetLastError() == ERROR_MUI_FILE_NOT_FOUND) { + if (!res && (GetLastError() == ERROR_MUI_FILE_NOT_FOUND || + GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND)) { res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, diff --git a/Utilities/cmlibuv/src/win/error.c b/Utilities/cmlibuv/src/win/error.c index 9b03bfef6b..24924ba81e 100644 --- a/Utilities/cmlibuv/src/win/error.c +++ b/Utilities/cmlibuv/src/win/error.c @@ -46,8 +46,8 @@ void uv_fatal_error(const int errorno, const char* syscall) { errmsg = "Unknown error"; } - /* FormatMessage messages include a newline character already, */ - /* so don't add another. */ + /* FormatMessage messages include a newline character already, so don't add + * another. */ if (syscall) { fprintf(stderr, "%s: (%d) %s", syscall, errorno, errmsg); } else { diff --git a/Utilities/cmlibuv/src/win/fs-event.c b/Utilities/cmlibuv/src/win/fs-event.c index 14c9af9ad7..acf8e1107e 100644 --- a/Utilities/cmlibuv/src/win/fs-event.c +++ b/Utilities/cmlibuv/src/win/fs-event.c @@ -83,7 +83,7 @@ static void uv_relative_path(const WCHAR* filename, static int uv_split_path(const WCHAR* filename, WCHAR** dir, WCHAR** file) { size_t len, i; - + if (filename == NULL) { if (dir != NULL) *dir = NULL; @@ -215,11 +215,11 @@ int uv_fs_event_start(uv_fs_event_t* handle, uv__free(long_path); long_path = NULL; } - } - if (long_path) { - uv__free(pathw); - pathw = long_path; + if (long_path) { + uv__free(pathw); + pathw = long_path; + } } dir_to_watch = pathw; @@ -230,8 +230,11 @@ int uv_fs_event_start(uv_fs_event_t* handle, */ /* Convert to short path. */ - short_path = short_path_buffer; - if (!GetShortPathNameW(pathw, short_path, ARRAY_SIZE(short_path))) { + if (GetShortPathNameW(pathw, + short_path_buffer, + ARRAY_SIZE(short_path_buffer))) { + short_path = short_path_buffer; + } else { short_path = NULL; } @@ -419,7 +422,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, * - We are not active, just ignore the callback */ if (!uv__is_active(handle)) { - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { uv_want_endgame(loop, (uv_handle_t*) handle); } return; @@ -543,7 +546,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, } offset = file_info->NextEntryOffset; - } while (offset && !(handle->flags & UV__HANDLE_CLOSING)); + } while (offset && !(handle->flags & UV_HANDLE_CLOSING)); } else { handle->cb(handle, NULL, UV_CHANGE, 0); } @@ -552,7 +555,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, handle->cb(handle, NULL, 0, uv_translate_sys_error(err)); } - if (!(handle->flags & UV__HANDLE_CLOSING)) { + if (!(handle->flags & UV_HANDLE_CLOSING)) { uv_fs_event_queue_readdirchanges(loop, handle); } else { uv_want_endgame(loop, (uv_handle_t*)handle); @@ -573,7 +576,7 @@ void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) { void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) { - if ((handle->flags & UV__HANDLE_CLOSING) && !handle->req_pending) { + if ((handle->flags & UV_HANDLE_CLOSING) && !handle->req_pending) { assert(!(handle->flags & UV_HANDLE_CLOSED)); if (handle->buffer) { diff --git a/Utilities/cmlibuv/src/win/fs.c b/Utilities/cmlibuv/src/win/fs.c index 30b87ac515..65d936bf08 100644 --- a/Utilities/cmlibuv/src/win/fs.c +++ b/Utilities/cmlibuv/src/win/fs.c @@ -55,7 +55,11 @@ do { \ if (cb != NULL) { \ uv__req_register(loop, req); \ - uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ + uv__work_submit(loop, \ + &req->work_req, \ + UV__WORK_FAST_IO, \ + uv__fs_work, \ + uv__fs_done); \ return 0; \ } else { \ uv__fs_work(&req->work_req); \ @@ -92,14 +96,17 @@ return; \ } +#define MILLIONu (1000U * 1000U) +#define BILLIONu (1000U * 1000U * 1000U) + #define FILETIME_TO_UINT(filetime) \ - (*((uint64_t*) &(filetime)) - 116444736000000000ULL) + (*((uint64_t*) &(filetime)) - (uint64_t) 116444736 * BILLIONu) #define FILETIME_TO_TIME_T(filetime) \ - (FILETIME_TO_UINT(filetime) / 10000000ULL) + (FILETIME_TO_UINT(filetime) / (10u * MILLIONu)) #define FILETIME_TO_TIME_NS(filetime, secs) \ - ((FILETIME_TO_UINT(filetime) - (secs * 10000000ULL)) * 100) + ((FILETIME_TO_UINT(filetime) - (secs * (uint64_t) 10 * MILLIONu)) * 100U) #define FILETIME_TO_TIMESPEC(ts, filetime) \ do { \ @@ -109,8 +116,8 @@ #define TIME_T_TO_FILETIME(time, filetime_ptr) \ do { \ - uint64_t bigtime = ((uint64_t) ((time) * 10000000ULL)) + \ - 116444736000000000ULL; \ + uint64_t bigtime = ((uint64_t) ((time) * (uint64_t) 10 * MILLIONu)) + \ + (uint64_t) 116444736 * BILLIONu; \ (filetime_ptr)->dwLowDateTime = bigtime & 0xFFFFFFFF; \ (filetime_ptr)->dwHighDateTime = bigtime >> 32; \ } while(0) @@ -326,12 +333,11 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr, reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR); - /* Real symlinks can contain pretty much everything, but the only thing */ - /* we really care about is undoing the implicit conversion to an NT */ - /* namespaced path that CreateSymbolicLink will perform on absolute */ - /* paths. If the path is win32-namespaced then the user must have */ - /* explicitly made it so, and we better just return the unmodified */ - /* reparse data. */ + /* Real symlinks can contain pretty much everything, but the only thing we + * really care about is undoing the implicit conversion to an NT namespaced + * path that CreateSymbolicLink will perform on absolute paths. If the path + * is win32-namespaced then the user must have explicitly made it so, and + * we better just return the unmodified reparse data. */ if (w_target_len >= 4 && w_target[0] == L'\\' && w_target[1] == L'?' && @@ -352,8 +358,8 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr, (w_target[5] == L'N' || w_target[5] == L'n') && (w_target[6] == L'C' || w_target[6] == L'c') && w_target[7] == L'\\') { - /* \??\UNC\<server>\<share>\ - make sure the final path looks like */ - /* \\<server>\<share>\ */ + /* \??\UNC\<server>\<share>\ - make sure the final path looks like + * \\<server>\<share>\ */ w_target += 6; w_target[0] = L'\\'; w_target_len -= 6; @@ -368,11 +374,11 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr, w_target_len = reparse_data->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR); - /* Only treat junctions that look like \??\<drive>:\ as symlink. */ - /* Junctions can also be used as mount points, like \??\Volume{<guid>}, */ - /* but that's confusing for programs since they wouldn't be able to */ - /* actually understand such a path when returned by uv_readlink(). */ - /* UNC paths are never valid for junctions so we don't care about them. */ + /* Only treat junctions that look like \??\<drive>:\ as symlink. Junctions + * can also be used as mount points, like \??\Volume{<guid>}, but that's + * confusing for programs since they wouldn't be able to actually + * understand such a path when returned by uv_readlink(). UNC paths are + * never valid for junctions so we don't care about them. */ if (!(w_target_len >= 6 && w_target[0] == L'\\' && w_target[1] == L'?' && @@ -409,8 +415,8 @@ void fs__open(uv_fs_t* req) { int fd, current_umask; int flags = req->fs.info.file_flags; - /* Obtain the active umask. umask() never fails and returns the previous */ - /* umask. */ + /* Obtain the active umask. umask() never fails and returns the previous + * umask. */ current_umask = umask(0); umask(current_umask); @@ -502,6 +508,33 @@ void fs__open(uv_fs_t* req) { } if (flags & UV_FS_O_DIRECT) { + /* + * FILE_APPEND_DATA and FILE_FLAG_NO_BUFFERING are mutually exclusive. + * Windows returns 87, ERROR_INVALID_PARAMETER if these are combined. + * + * FILE_APPEND_DATA is included in FILE_GENERIC_WRITE: + * + * FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | + * FILE_WRITE_DATA | + * FILE_WRITE_ATTRIBUTES | + * FILE_WRITE_EA | + * FILE_APPEND_DATA | + * SYNCHRONIZE + * + * Note: Appends are also permitted by FILE_WRITE_DATA. + * + * In order for direct writes and direct appends to succeed, we therefore + * exclude FILE_APPEND_DATA if FILE_WRITE_DATA is specified, and otherwise + * fail if the user's sole permission is a direct append, since this + * particular combination is invalid. + */ + if (access & FILE_APPEND_DATA) { + if (access & FILE_WRITE_DATA) { + access &= ~FILE_APPEND_DATA; + } else { + goto einval; + } + } attributes |= FILE_FLAG_NO_BUFFERING; } @@ -530,8 +563,8 @@ void fs__open(uv_fs_t* req) { DWORD error = GetLastError(); if (error == ERROR_FILE_EXISTS && (flags & UV_FS_O_CREAT) && !(flags & UV_FS_O_EXCL)) { - /* Special case: when ERROR_FILE_EXISTS happens and UV_FS_O_CREAT was */ - /* specified, it means the path referred to a directory. */ + /* Special case: when ERROR_FILE_EXISTS happens and UV_FS_O_CREAT was + * specified, it means the path referred to a directory. */ SET_REQ_UV_ERROR(req, UV_EISDIR, error); } else { SET_REQ_WIN32_ERROR(req, GetLastError()); @@ -756,9 +789,9 @@ void fs__unlink(uv_fs_t* req) { } if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - /* Do not allow deletion of directories, unless it is a symlink. When */ - /* the path refers to a non-symlink directory, report EPERM as mandated */ - /* by POSIX.1. */ + /* Do not allow deletion of directories, unless it is a symlink. When the + * path refers to a non-symlink directory, report EPERM as mandated by + * POSIX.1. */ /* Check if it is a reparse point. If it's not, it's a normal directory. */ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { @@ -767,8 +800,8 @@ void fs__unlink(uv_fs_t* req) { return; } - /* Read the reparse point and check if it is a valid symlink. */ - /* If not, don't unlink. */ + /* Read the reparse point and check if it is a valid symlink. If not, don't + * unlink. */ if (fs__readlink_handle(handle, NULL, NULL) < 0) { DWORD error = GetLastError(); if (error == ERROR_SYMLINK_NOT_SUPPORTED) @@ -783,9 +816,8 @@ void fs__unlink(uv_fs_t* req) { /* Remove read-only attribute */ FILE_BASIC_INFORMATION basic = { 0 }; - basic.FileAttributes = info.dwFileAttributes - & ~(FILE_ATTRIBUTE_READONLY) - | FILE_ATTRIBUTE_ARCHIVE; + basic.FileAttributes = (info.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY) | + FILE_ATTRIBUTE_ARCHIVE; status = pNtSetInformationFile(handle, &iosb, @@ -1196,7 +1228,7 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, /* st_blocks contains the on-disk allocation size in 512-byte units. */ statbuf->st_blocks = - file_info.StandardInformation.AllocationSize.QuadPart >> 9ULL; + (uint64_t) file_info.StandardInformation.AllocationSize.QuadPart >> 9; statbuf->st_nlink = file_info.StandardInformation.NumberOfLinks; @@ -1490,6 +1522,7 @@ static void fs__chmod(uv_fs_t* req) { static void fs__fchmod(uv_fs_t* req) { int fd = req->file.fd; + int clear_archive_flag; HANDLE handle; NTSTATUS nt_status; IO_STATUS_BLOCK io_status; @@ -1497,7 +1530,11 @@ static void fs__fchmod(uv_fs_t* req) { VERIFY_FD(fd, req); - handle = uv__get_osfhandle(fd); + handle = ReOpenFile(uv__get_osfhandle(fd), FILE_WRITE_ATTRIBUTES, 0, 0); + if (handle == INVALID_HANDLE_VALUE) { + SET_REQ_WIN32_ERROR(req, GetLastError()); + return; + } nt_status = pNtQueryInformationFile(handle, &io_status, @@ -1507,7 +1544,27 @@ static void fs__fchmod(uv_fs_t* req) { if (!NT_SUCCESS(nt_status)) { SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); - return; + goto fchmod_cleanup; + } + + /* Test if the Archive attribute is cleared */ + if ((file_info.FileAttributes & FILE_ATTRIBUTE_ARCHIVE) == 0) { + /* Set Archive flag, otherwise setting or clearing the read-only + flag will not work */ + file_info.FileAttributes |= FILE_ATTRIBUTE_ARCHIVE; + nt_status = pNtSetInformationFile(handle, + &io_status, + &file_info, + sizeof file_info, + FileBasicInformation); + if (!NT_SUCCESS(nt_status)) { + SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); + goto fchmod_cleanup; + } + /* Remeber to clear the flag later on */ + clear_archive_flag = 1; + } else { + clear_archive_flag = 0; } if (req->fs.info.mode & _S_IWRITE) { @@ -1524,10 +1581,28 @@ static void fs__fchmod(uv_fs_t* req) { if (!NT_SUCCESS(nt_status)) { SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); - return; + goto fchmod_cleanup; + } + + if (clear_archive_flag) { + file_info.FileAttributes &= ~FILE_ATTRIBUTE_ARCHIVE; + if (file_info.FileAttributes == 0) { + file_info.FileAttributes = FILE_ATTRIBUTE_NORMAL; + } + nt_status = pNtSetInformationFile(handle, + &io_status, + &file_info, + sizeof file_info, + FileBasicInformation); + if (!NT_SUCCESS(nt_status)) { + SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); + goto fchmod_cleanup; + } } SET_REQ_SUCCESS(req); +fchmod_cleanup: + CloseHandle(handle); } @@ -1787,17 +1862,13 @@ static void fs__symlink(uv_fs_t* req) { fs__create_junction(req, pathw, new_pathw); return; } - if (!pCreateSymbolicLinkW) { - SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED); - return; - } if (req->fs.info.file_flags & UV_FS_SYMLINK_DIR) flags = SYMBOLIC_LINK_FLAG_DIRECTORY | uv__file_symlink_usermode_flag; else flags = uv__file_symlink_usermode_flag; - if (pCreateSymbolicLinkW(new_pathw, pathw, flags)) { + if (CreateSymbolicLinkW(new_pathw, pathw, flags)) { SET_REQ_RESULT(req, 0); return; } @@ -1848,13 +1919,13 @@ static void fs__readlink(uv_fs_t* req) { } -static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { +static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { int r; DWORD w_realpath_len; WCHAR* w_realpath_ptr = NULL; WCHAR* w_realpath_buf; - w_realpath_len = pGetFinalPathNameByHandleW(handle, NULL, 0, VOLUME_NAME_DOS); + w_realpath_len = GetFinalPathNameByHandleW(handle, NULL, 0, VOLUME_NAME_DOS); if (w_realpath_len == 0) { return -1; } @@ -1866,10 +1937,8 @@ static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { } w_realpath_ptr = w_realpath_buf; - if (pGetFinalPathNameByHandleW(handle, - w_realpath_ptr, - w_realpath_len, - VOLUME_NAME_DOS) == 0) { + if (GetFinalPathNameByHandleW( + handle, w_realpath_ptr, w_realpath_len, VOLUME_NAME_DOS) == 0) { uv__free(w_realpath_buf); SetLastError(ERROR_INVALID_HANDLE); return -1; @@ -1901,11 +1970,6 @@ static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { static void fs__realpath(uv_fs_t* req) { HANDLE handle; - if (!pGetFinalPathNameByHandleW) { - SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED); - return; - } - handle = CreateFileW(req->file.pathw, 0, 0, @@ -1940,6 +2004,10 @@ static void fs__fchown(uv_fs_t* req) { } +static void fs__lchown(uv_fs_t* req) { + req->result = 0; +} + static void uv__fs_work(struct uv__work* w) { uv_fs_t* req; @@ -1977,6 +2045,7 @@ static void uv__fs_work(struct uv__work* w) { XX(REALPATH, realpath) XX(CHOWN, chown) XX(FCHOWN, fchown); + XX(LCHOWN, lchown); default: assert(!"bad uv_fs_type"); } @@ -2262,6 +2331,19 @@ int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid, } +int uv_fs_lchown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, + uv_gid_t gid, uv_fs_cb cb) { + int err; + + INIT(UV_FS_LCHOWN); + err = fs__capture_path(req, path, NULL, cb != NULL); + if (err) { + return uv_translate_sys_error(err); + } + POST; +} + + int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { int err; diff --git a/Utilities/cmlibuv/src/win/getaddrinfo.c b/Utilities/cmlibuv/src/win/getaddrinfo.c index 5adc7663bd..dfab860a73 100644 --- a/Utilities/cmlibuv/src/win/getaddrinfo.c +++ b/Utilities/cmlibuv/src/win/getaddrinfo.c @@ -24,6 +24,7 @@ #include "uv.h" #include "internal.h" #include "req-inl.h" +#include "idna.h" /* EAI_* constants. */ #include <winsock2.h> @@ -71,8 +72,8 @@ int uv__getaddrinfo_translate_error(int sys_err) { #endif -/* adjust size value to be multiple of 4. Use to keep pointer aligned */ -/* Do we need different versions of this for different architectures? */ +/* Adjust size value to be multiple of 4. Use to keep pointer aligned. + * Do we need different versions of this for different architectures? */ #define ALIGNED_SIZE(X) ((((X) + 3) >> 2) << 2) #ifndef NDIS_IF_MAX_STRING_SIZE @@ -124,8 +125,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { } if (req->retcode == 0) { - /* convert addrinfoW to addrinfo */ - /* first calculate required length */ + /* Convert addrinfoW to addrinfo. First calculate required length. */ addrinfow_ptr = req->addrinfow; while (addrinfow_ptr != NULL) { addrinfo_len += addrinfo_struct_len + @@ -260,11 +260,13 @@ int uv_getaddrinfo(uv_loop_t* loop, const char* node, const char* service, const struct addrinfo* hints) { + char hostname_ascii[256]; int nodesize = 0; int servicesize = 0; int hintssize = 0; char* alloc_ptr = NULL; int err; + long rc; if (req == NULL || (node == NULL && service == NULL)) { return UV_EINVAL; @@ -278,12 +280,19 @@ int uv_getaddrinfo(uv_loop_t* loop, /* calculate required memory size for all input values */ if (node != NULL) { - nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, node, -1, NULL, 0) * - sizeof(WCHAR)); + rc = uv__idna_toascii(node, + node + strlen(node), + hostname_ascii, + hostname_ascii + sizeof(hostname_ascii)); + if (rc < 0) + return rc; + nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, hostname_ascii, + -1, NULL, 0) * sizeof(WCHAR)); if (nodesize == 0) { err = GetLastError(); goto error; } + node = hostname_ascii; } if (service != NULL) { @@ -313,8 +322,8 @@ int uv_getaddrinfo(uv_loop_t* loop, /* save alloc_ptr now so we can free if error */ req->alloc = (void*)alloc_ptr; - /* convert node string to UTF16 into allocated memory and save pointer in */ - /* the request. */ + /* Convert node string to UTF16 into allocated memory and save pointer in the + * request. */ if (node != NULL) { req->node = (WCHAR*)alloc_ptr; if (MultiByteToWideChar(CP_UTF8, @@ -331,8 +340,8 @@ int uv_getaddrinfo(uv_loop_t* loop, req->node = NULL; } - /* convert service string to UTF16 into allocated memory and save pointer */ - /* in the req. */ + /* Convert service string to UTF16 into allocated memory and save pointer in + * the req. */ if (service != NULL) { req->service = (WCHAR*)alloc_ptr; if (MultiByteToWideChar(CP_UTF8, @@ -369,6 +378,7 @@ int uv_getaddrinfo(uv_loop_t* loop, if (getaddrinfo_cb) { uv__work_submit(loop, &req->work_req, + UV__WORK_SLOW_IO, uv__getaddrinfo_work, uv__getaddrinfo_done); return 0; @@ -392,21 +402,15 @@ int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) { DWORD bufsize; int r; - uv__once_init(); - if (buffer == NULL || size == NULL || *size == 0) return UV_EINVAL; - if (pConvertInterfaceIndexToLuid == NULL) - return UV_ENOSYS; - r = pConvertInterfaceIndexToLuid(ifindex, &luid); + r = ConvertInterfaceIndexToLuid(ifindex, &luid); if (r != 0) return uv_translate_sys_error(r); - if (pConvertInterfaceLuidToNameW == NULL) - return UV_ENOSYS; - r = pConvertInterfaceLuidToNameW(&luid, wname, ARRAY_SIZE(wname)); + r = ConvertInterfaceLuidToNameW(&luid, wname, ARRAY_SIZE(wname)); if (r != 0) return uv_translate_sys_error(r); diff --git a/Utilities/cmlibuv/src/win/getnameinfo.c b/Utilities/cmlibuv/src/win/getnameinfo.c index 9f10cd2a5a..b3773380c2 100644 --- a/Utilities/cmlibuv/src/win/getnameinfo.c +++ b/Utilities/cmlibuv/src/win/getnameinfo.c @@ -42,7 +42,7 @@ static void uv__getnameinfo_work(struct uv__work* w) { uv_getnameinfo_t* req; WCHAR host[NI_MAXHOST]; WCHAR service[NI_MAXSERV]; - int ret = 0; + int ret; req = container_of(w, uv_getnameinfo_t, work_req); if (GetNameInfoW((struct sockaddr*)&req->storage, @@ -53,27 +53,34 @@ static void uv__getnameinfo_work(struct uv__work* w) { ARRAY_SIZE(service), req->flags)) { ret = WSAGetLastError(); + req->retcode = uv__getaddrinfo_translate_error(ret); + return; + } + + ret = WideCharToMultiByte(CP_UTF8, + 0, + host, + -1, + req->host, + sizeof(req->host), + NULL, + NULL); + if (ret == 0) { + req->retcode = uv_translate_sys_error(GetLastError()); + return; + } + + ret = WideCharToMultiByte(CP_UTF8, + 0, + service, + -1, + req->service, + sizeof(req->service), + NULL, + NULL); + if (ret == 0) { + req->retcode = uv_translate_sys_error(GetLastError()); } - req->retcode = uv__getaddrinfo_translate_error(ret); - - /* convert results to UTF-8 */ - WideCharToMultiByte(CP_UTF8, - 0, - host, - -1, - req->host, - sizeof(req->host), - NULL, - NULL); - - WideCharToMultiByte(CP_UTF8, - 0, - service, - -1, - req->service, - sizeof(req->service), - NULL, - NULL); } @@ -138,6 +145,7 @@ int uv_getnameinfo(uv_loop_t* loop, if (getnameinfo_cb) { uv__work_submit(loop, &req->work_req, + UV__WORK_SLOW_IO, uv__getnameinfo_work, uv__getnameinfo_done); return 0; diff --git a/Utilities/cmlibuv/src/win/handle-inl.h b/Utilities/cmlibuv/src/win/handle-inl.h index 8d0334cc52..82c657d579 100644 --- a/Utilities/cmlibuv/src/win/handle-inl.h +++ b/Utilities/cmlibuv/src/win/handle-inl.h @@ -32,7 +32,7 @@ #define DECREASE_ACTIVE_COUNT(loop, handle) \ do { \ if (--(handle)->activecnt == 0 && \ - !((handle)->flags & UV__HANDLE_CLOSING)) { \ + !((handle)->flags & UV_HANDLE_CLOSING)) { \ uv__handle_stop((handle)); \ } \ assert((handle)->activecnt >= 0); \ @@ -53,7 +53,7 @@ assert(handle->reqs_pending > 0); \ handle->reqs_pending--; \ \ - if (handle->flags & UV__HANDLE_CLOSING && \ + if (handle->flags & UV_HANDLE_CLOSING && \ handle->reqs_pending == 0) { \ uv_want_endgame(loop, (uv_handle_t*)handle); \ } \ @@ -62,14 +62,14 @@ #define uv__handle_closing(handle) \ do { \ - assert(!((handle)->flags & UV__HANDLE_CLOSING)); \ + assert(!((handle)->flags & UV_HANDLE_CLOSING)); \ \ - if (!(((handle)->flags & UV__HANDLE_ACTIVE) && \ - ((handle)->flags & UV__HANDLE_REF))) \ + if (!(((handle)->flags & UV_HANDLE_ACTIVE) && \ + ((handle)->flags & UV_HANDLE_REF))) \ uv__active_handle_add((uv_handle_t*) (handle)); \ \ - (handle)->flags |= UV__HANDLE_CLOSING; \ - (handle)->flags &= ~UV__HANDLE_ACTIVE; \ + (handle)->flags |= UV_HANDLE_CLOSING; \ + (handle)->flags &= ~UV_HANDLE_ACTIVE; \ } while (0) @@ -126,7 +126,8 @@ INLINE static void uv_process_endgames(uv_loop_t* loop) { break; case UV_TIMER: - uv_timer_endgame(loop, (uv_timer_t*) handle); + uv__timer_close((uv_timer_t*) handle); + uv__handle_close(handle); break; case UV_PREPARE: @@ -164,10 +165,10 @@ INLINE static void uv_process_endgames(uv_loop_t* loop) { INLINE static HANDLE uv__get_osfhandle(int fd) { - /* _get_osfhandle() raises an assert in debug builds if the FD is invalid. */ - /* But it also correctly checks the FD and returns INVALID_HANDLE_VALUE */ - /* for invalid FDs in release builds (or if you let the assert continue). */ - /* So this wrapper function disables asserts when calling _get_osfhandle. */ + /* _get_osfhandle() raises an assert in debug builds if the FD is invalid. + * But it also correctly checks the FD and returns INVALID_HANDLE_VALUE for + * invalid FDs in release builds (or if you let the assert continue). So this + * wrapper function disables asserts when calling _get_osfhandle. */ HANDLE handle; UV_BEGIN_DISABLE_CRT_ASSERT(); diff --git a/Utilities/cmlibuv/src/win/handle.c b/Utilities/cmlibuv/src/win/handle.c index 39150702dd..9d76c3f542 100644 --- a/Utilities/cmlibuv/src/win/handle.c +++ b/Utilities/cmlibuv/src/win/handle.c @@ -59,15 +59,15 @@ uv_handle_type uv_guess_handle(uv_file file) { int uv_is_active(const uv_handle_t* handle) { - return (handle->flags & UV__HANDLE_ACTIVE) && - !(handle->flags & UV__HANDLE_CLOSING); + return (handle->flags & UV_HANDLE_ACTIVE) && + !(handle->flags & UV_HANDLE_CLOSING); } void uv_close(uv_handle_t* handle, uv_close_cb cb) { uv_loop_t* loop = handle->loop; - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { assert(0); return; } @@ -150,10 +150,14 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) { int uv_is_closing(const uv_handle_t* handle) { - return !!(handle->flags & (UV__HANDLE_CLOSING | UV_HANDLE_CLOSED)); + return !!(handle->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED)); } uv_os_fd_t uv_get_osfhandle(int fd) { return uv__get_osfhandle(fd); } + +int uv_open_osfhandle(uv_os_fd_t os_fd) { + return _open_osfhandle((intptr_t) os_fd, 0); +} diff --git a/Utilities/cmlibuv/src/win/internal.h b/Utilities/cmlibuv/src/win/internal.h index 849bc82908..206ab5f623 100644 --- a/Utilities/cmlibuv/src/win/internal.h +++ b/Utilities/cmlibuv/src/win/internal.h @@ -29,7 +29,7 @@ #include "uv.h" #include "../uv-common.h" -#include "tree.h" +#include "uv/tree.h" #include "winapi.h" #include "winsock.h" @@ -62,77 +62,19 @@ extern UV_THREAD_LOCAL int uv__crt_assert_enabled; #endif /* - * Handles - * (also see handle-inl.h) - */ - -/* Used by all handles. */ -#define UV_HANDLE_CLOSED 0x00000002 -#define UV_HANDLE_ENDGAME_QUEUED 0x00000008 - -/* uv-common.h: #define UV__HANDLE_CLOSING 0x00000001 */ -/* uv-common.h: #define UV__HANDLE_ACTIVE 0x00000040 */ -/* uv-common.h: #define UV__HANDLE_REF 0x00000020 */ -/* uv-common.h: #define UV_HANDLE_INTERNAL 0x00000080 */ - -/* Used by streams and UDP handles. */ -#define UV_HANDLE_READING 0x00000100 -#define UV_HANDLE_BOUND 0x00000200 -#define UV_HANDLE_LISTENING 0x00000800 -#define UV_HANDLE_CONNECTION 0x00001000 -#define UV_HANDLE_READABLE 0x00008000 -#define UV_HANDLE_WRITABLE 0x00010000 -#define UV_HANDLE_READ_PENDING 0x00020000 -#define UV_HANDLE_SYNC_BYPASS_IOCP 0x00040000 -#define UV_HANDLE_ZERO_READ 0x00080000 -#define UV_HANDLE_EMULATE_IOCP 0x00100000 -#define UV_HANDLE_BLOCKING_WRITES 0x00200000 -#define UV_HANDLE_CANCELLATION_PENDING 0x00400000 - -/* Used by uv_tcp_t and uv_udp_t handles */ -#define UV_HANDLE_IPV6 0x01000000 - -/* Only used by uv_tcp_t handles. */ -#define UV_HANDLE_TCP_NODELAY 0x02000000 -#define UV_HANDLE_TCP_KEEPALIVE 0x04000000 -#define UV_HANDLE_TCP_SINGLE_ACCEPT 0x08000000 -#define UV_HANDLE_TCP_ACCEPT_STATE_CHANGING 0x10000000 -#define UV_HANDLE_TCP_SOCKET_CLOSED 0x20000000 -#define UV_HANDLE_SHARED_TCP_SOCKET 0x40000000 - -/* Only used by uv_pipe_t handles. */ -#define UV_HANDLE_NON_OVERLAPPED_PIPE 0x01000000 -#define UV_HANDLE_PIPESERVER 0x02000000 -#define UV_HANDLE_PIPE_READ_CANCELABLE 0x04000000 - -/* Only used by uv_tty_t handles. */ -#define UV_HANDLE_TTY_READABLE 0x01000000 -#define UV_HANDLE_TTY_RAW 0x02000000 -#define UV_HANDLE_TTY_SAVED_POSITION 0x04000000 -#define UV_HANDLE_TTY_SAVED_ATTRIBUTES 0x08000000 - -/* Only used by uv_poll_t handles. */ -#define UV_HANDLE_POLL_SLOW 0x02000000 - - -/* - * Requests: see req-inl.h - */ - - -/* - * Streams: see stream-inl.h - */ - - -/* * TCP */ +typedef enum { + UV__IPC_SOCKET_XFER_NONE = 0, + UV__IPC_SOCKET_XFER_TCP_CONNECTION, + UV__IPC_SOCKET_XFER_TCP_SERVER +} uv__ipc_socket_xfer_type_t; + typedef struct { WSAPROTOCOL_INFOW socket_info; - int delayed_error; -} uv__ipc_socket_info_ex; + uint32_t delayed_error; +} uv__ipc_socket_xfer_info_t; int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb); int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client); @@ -154,11 +96,13 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp); void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle); -int uv_tcp_import(uv_tcp_t* tcp, uv__ipc_socket_info_ex* socket_info_ex, - int tcp_connection); - -int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, - LPWSAPROTOCOL_INFOW protocol_info); +int uv__tcp_xfer_export(uv_tcp_t* handle, + int pid, + uv__ipc_socket_xfer_type_t* xfer_type, + uv__ipc_socket_xfer_info_t* xfer_info); +int uv__tcp_xfer_import(uv_tcp_t* tcp, + uv__ipc_socket_xfer_type_t xfer_type, + uv__ipc_socket_xfer_info_t* xfer_info); /* @@ -182,14 +126,14 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client); int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb); -int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb); -int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle, - uv_write_cb cb); -void uv__pipe_pause_read(uv_pipe_t* handle); -void uv__pipe_unpause_read(uv_pipe_t* handle); -void uv__pipe_stop_read(uv_pipe_t* handle); +void uv__pipe_read_stop(uv_pipe_t* handle); +int uv__pipe_write(uv_loop_t* loop, + uv_write_t* req, + uv_pipe_t* handle, + const uv_buf_t bufs[], + size_t nbufs, + uv_stream_t* send_handle, + uv_write_cb cb); void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, uv_req_t* req); @@ -252,15 +196,6 @@ void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle); /* - * Timers - */ -void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle); - -DWORD uv__next_timeout(const uv_loop_t* loop); -void uv_process_timers(uv_loop_t* loop); - - -/* * Loop watchers */ void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle); @@ -336,7 +271,6 @@ void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle); void uv__util_init(void); uint64_t uv__hrtime(double scale); -int uv_current_pid(void); __declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall); int uv__getpwuid_r(uv_passwd_t* pwd); int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8); diff --git a/Utilities/cmlibuv/src/win/loop-watcher.c b/Utilities/cmlibuv/src/win/loop-watcher.c index 20e4509f83..ad7fbea169 100644 --- a/Utilities/cmlibuv/src/win/loop-watcher.c +++ b/Utilities/cmlibuv/src/win/loop-watcher.c @@ -27,7 +27,7 @@ void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { assert(!(handle->flags & UV_HANDLE_CLOSED)); handle->flags |= UV_HANDLE_CLOSED; uv__handle_close(handle); diff --git a/Utilities/cmlibuv/src/win/pipe.c b/Utilities/cmlibuv/src/win/pipe.c index 83ee4f99ca..277f6497a2 100644 --- a/Utilities/cmlibuv/src/win/pipe.c +++ b/Utilities/cmlibuv/src/win/pipe.c @@ -21,39 +21,28 @@ #include <assert.h> #include <io.h> -#include <string.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> -#include "uv.h" -#include "internal.h" #include "handle-inl.h" -#include "stream-inl.h" +#include "internal.h" #include "req-inl.h" +#include "stream-inl.h" +#include "uv-common.h" +#include "uv.h" #include <aclapi.h> #include <accctrl.h> -typedef struct uv__ipc_queue_item_s uv__ipc_queue_item_t; - -struct uv__ipc_queue_item_s { - /* - * NOTE: It is important for socket_info_ex to be the first field, - * because we will we assigning it to the pending_ipc_info.socket_info - */ - uv__ipc_socket_info_ex socket_info_ex; - QUEUE member; - int tcp_connection; -}; - /* A zero-size buffer for use by uv_pipe_read */ static char uv_zero_[] = ""; /* Null uv_buf_t */ static const uv_buf_t uv_null_buf_ = { 0, NULL }; -/* The timeout that the pipe will wait for the remote end to write data */ -/* when the local ends wants to shut it down. */ +/* The timeout that the pipe will wait for the remote end to write data when + * the local ends wants to shut it down. */ static const int64_t eof_timeout = 50; /* ms */ static const int default_pending_pipe_instances = 4; @@ -62,22 +51,44 @@ static const int default_pending_pipe_instances = 4; static char pipe_prefix[] = "\\\\?\\pipe"; static const int pipe_prefix_len = sizeof(pipe_prefix) - 1; -/* IPC protocol flags. */ -#define UV_IPC_RAW_DATA 0x0001 -#define UV_IPC_TCP_SERVER 0x0002 -#define UV_IPC_TCP_CONNECTION 0x0004 +/* IPC incoming xfer queue item. */ +typedef struct { + uv__ipc_socket_xfer_type_t xfer_type; + uv__ipc_socket_xfer_info_t xfer_info; + QUEUE member; +} uv__ipc_xfer_queue_item_t; + +/* IPC frame header flags. */ +/* clang-format off */ +enum { + UV__IPC_FRAME_HAS_DATA = 0x01, + UV__IPC_FRAME_HAS_SOCKET_XFER = 0x02, + UV__IPC_FRAME_XFER_IS_TCP_CONNECTION = 0x04, + /* These are combinations of the flags above. */ + UV__IPC_FRAME_XFER_FLAGS = 0x06, + UV__IPC_FRAME_VALID_FLAGS = 0x07 +}; +/* clang-format on */ /* IPC frame header. */ typedef struct { - int flags; - uint64_t raw_data_length; -} uv_ipc_frame_header_t; - -/* IPC frame, which contains an imported TCP socket stream. */ + uint32_t flags; + uint32_t reserved1; /* Ignored. */ + uint32_t data_length; /* Must be zero if there is no data. */ + uint32_t reserved2; /* Must be zero. */ +} uv__ipc_frame_header_t; + +/* To implement the IPC protocol correctly, these structures must have exactly + * the right size. */ +STATIC_ASSERT(sizeof(uv__ipc_frame_header_t) == 16); +STATIC_ASSERT(sizeof(uv__ipc_socket_xfer_info_t) == 632); + +/* Coalesced write request. */ typedef struct { - uv_ipc_frame_header_t header; - uv__ipc_socket_info_ex socket_info_ex; -} uv_ipc_frame_uv_stream; + uv_write_t req; /* Internal heap-allocated write request. */ + uv_write_t* user_req; /* Pointer to user-specified uv_write_t. */ +} uv__coalesced_write_t; + static void eof_timer_init(uv_pipe_t* pipe); static void eof_timer_start(uv_pipe_t* pipe); @@ -98,15 +109,12 @@ int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) { handle->reqs_pending = 0; handle->handle = INVALID_HANDLE_VALUE; handle->name = NULL; - handle->pipe.conn.ipc_pid = 0; - handle->pipe.conn.remaining_ipc_rawdata_bytes = 0; - QUEUE_INIT(&handle->pipe.conn.pending_ipc_info.queue); - handle->pipe.conn.pending_ipc_info.queue_len = 0; + handle->pipe.conn.ipc_remote_pid = 0; + handle->pipe.conn.ipc_data_frame.payload_remaining = 0; + QUEUE_INIT(&handle->pipe.conn.ipc_xfer_queue); + handle->pipe.conn.ipc_xfer_queue_length = 0; handle->ipc = ipc; handle->pipe.conn.non_overlapped_writes_tail = NULL; - handle->pipe.conn.readfile_thread = NULL; - - UV_REQ_INIT(&handle->pipe.conn.ipc_header_write_req, UV_UNKNOWN_REQ); return 0; } @@ -117,10 +125,9 @@ static void uv_pipe_connection_init(uv_pipe_t* handle) { handle->read_req.data = handle; handle->pipe.conn.eof_timer = NULL; assert(!(handle->flags & UV_HANDLE_PIPESERVER)); - if (pCancelSynchronousIo && - handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - uv_mutex_init(&handle->pipe.conn.readfile_mutex); - handle->flags |= UV_HANDLE_PIPE_READ_CANCELABLE; + if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { + handle->pipe.conn.readfile_thread_handle = NULL; + InitializeCriticalSection(&handle->pipe.conn.readfile_thread_lock); } } @@ -347,12 +354,7 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) { NTSTATUS nt_status; IO_STATUS_BLOCK io_status; FILE_PIPE_LOCAL_INFORMATION pipe_info; - uv__ipc_queue_item_t* item; - - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - handle->flags &= ~UV_HANDLE_PIPE_READ_CANCELABLE; - uv_mutex_destroy(&handle->pipe.conn.readfile_mutex); - } + uv__ipc_xfer_queue_item_t* xfer_queue_item; if ((handle->flags & UV_HANDLE_CONNECTION) && handle->stream.conn.shutdown_req != NULL && @@ -362,7 +364,7 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) { /* Clear the shutdown_req field so we don't go here again. */ handle->stream.conn.shutdown_req = NULL; - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { UNREGISTER_HANDLE_REQ(loop, handle, req); /* Already closing. Cancel the shutdown. */ @@ -423,33 +425,33 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) { } } - if (handle->flags & UV__HANDLE_CLOSING && + if (handle->flags & UV_HANDLE_CLOSING && handle->reqs_pending == 0) { assert(!(handle->flags & UV_HANDLE_CLOSED)); if (handle->flags & UV_HANDLE_CONNECTION) { /* Free pending sockets */ - while (!QUEUE_EMPTY(&handle->pipe.conn.pending_ipc_info.queue)) { + while (!QUEUE_EMPTY(&handle->pipe.conn.ipc_xfer_queue)) { QUEUE* q; SOCKET socket; - q = QUEUE_HEAD(&handle->pipe.conn.pending_ipc_info.queue); + q = QUEUE_HEAD(&handle->pipe.conn.ipc_xfer_queue); QUEUE_REMOVE(q); - item = QUEUE_DATA(q, uv__ipc_queue_item_t, member); + xfer_queue_item = QUEUE_DATA(q, uv__ipc_xfer_queue_item_t, member); /* Materialize socket and close it */ socket = WSASocketW(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, - &item->socket_info_ex.socket_info, + &xfer_queue_item->xfer_info.socket_info, 0, WSA_FLAG_OVERLAPPED); - uv__free(item); + uv__free(xfer_queue_item); if (socket != INVALID_SOCKET) closesocket(socket); } - handle->pipe.conn.pending_ipc_info.queue_len = 0; + handle->pipe.conn.ipc_xfer_queue_length = 0; if (handle->flags & UV_HANDLE_EMULATE_IOCP) { if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) { @@ -461,6 +463,9 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) { handle->read_req.event_handle = NULL; } } + + if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) + DeleteCriticalSection(&handle->pipe.conn.readfile_thread_lock); } if (handle->flags & UV_HANDLE_PIPESERVER) { @@ -595,8 +600,8 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) { loop = handle->loop; assert(loop); - /* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. */ - /* We wait for the pipe to become available with WaitNamedPipe. */ + /* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. We wait + * for the pipe to become available with WaitNamedPipe. */ while (WaitNamedPipeW(handle->name, 30000)) { /* The pipe is now available, try to connect. */ pipeHandle = open_named_pipe(handle->name, &duplex_flags); @@ -706,55 +711,68 @@ error: } -void uv__pipe_pause_read(uv_pipe_t* handle) { - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - /* Pause the ReadFile task briefly, to work - around the Windows kernel bug that causes - any access to a NamedPipe to deadlock if - any process has called ReadFile */ - HANDLE h; - uv_mutex_lock(&handle->pipe.conn.readfile_mutex); - h = handle->pipe.conn.readfile_thread; - while (h) { - /* spinlock: we expect this to finish quickly, - or we are probably about to deadlock anyways - (in the kernel), so it doesn't matter */ - pCancelSynchronousIo(h); - SwitchToThread(); /* yield thread control briefly */ - h = handle->pipe.conn.readfile_thread; - } - } -} +void uv__pipe_interrupt_read(uv_pipe_t* handle) { + BOOL r; + + if (!(handle->flags & UV_HANDLE_READ_PENDING)) + return; /* No pending reads. */ + if (handle->flags & UV_HANDLE_CANCELLATION_PENDING) + return; /* Already cancelled. */ + if (handle->handle == INVALID_HANDLE_VALUE) + return; /* Pipe handle closed. */ + if (!(handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)) { + /* Cancel asynchronous read. */ + r = CancelIoEx(handle->handle, &handle->read_req.u.io.overlapped); + assert(r || GetLastError() == ERROR_NOT_FOUND); -void uv__pipe_unpause_read(uv_pipe_t* handle) { - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - uv_mutex_unlock(&handle->pipe.conn.readfile_mutex); + } else { + /* Cancel synchronous read (which is happening in the thread pool). */ + HANDLE thread; + volatile HANDLE* thread_ptr = &handle->pipe.conn.readfile_thread_handle; + + EnterCriticalSection(&handle->pipe.conn.readfile_thread_lock); + + thread = *thread_ptr; + if (thread == NULL) { + /* The thread pool thread has not yet reached the point of blocking, we + * can pre-empt it by setting thread_handle to INVALID_HANDLE_VALUE. */ + *thread_ptr = INVALID_HANDLE_VALUE; + + } else { + /* Spin until the thread has acknowledged (by setting the thread to + * INVALID_HANDLE_VALUE) that it is past the point of blocking. */ + while (thread != INVALID_HANDLE_VALUE) { + r = CancelSynchronousIo(thread); + assert(r || GetLastError() == ERROR_NOT_FOUND); + SwitchToThread(); /* Yield thread. */ + thread = *thread_ptr; + } + } + + LeaveCriticalSection(&handle->pipe.conn.readfile_thread_lock); } + + /* Set flag to indicate that read has been cancelled. */ + handle->flags |= UV_HANDLE_CANCELLATION_PENDING; } -void uv__pipe_stop_read(uv_pipe_t* handle) { - if (pCancelIoEx && - !(handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) && - !(handle->flags & UV_HANDLE_EMULATE_IOCP) && - handle->flags & UV_HANDLE_READING && - handle->read_req.type == UV_READ) { - pCancelIoEx(handle->handle, &handle->read_req.u.io.overlapped); - } +void uv__pipe_read_stop(uv_pipe_t* handle) { handle->flags &= ~UV_HANDLE_READING; - uv__pipe_pause_read((uv_pipe_t*)handle); - uv__pipe_unpause_read((uv_pipe_t*)handle); + DECREASE_ACTIVE_COUNT(handle->loop, handle); + + uv__pipe_interrupt_read(handle); } -/* Cleans up uv_pipe_t (server or connection) and all resources associated */ -/* with it. */ +/* Cleans up uv_pipe_t (server or connection) and all resources associated with + * it. */ void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle) { int i; HANDLE pipeHandle; - uv__pipe_stop_read(handle); + uv__pipe_interrupt_read(handle); if (handle->name) { uv__free(handle->name); @@ -864,23 +882,22 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) { uv_pipe_t* pipe_client; uv_pipe_accept_t* req; QUEUE* q; - uv__ipc_queue_item_t* item; + uv__ipc_xfer_queue_item_t* item; int err; if (server->ipc) { - if (QUEUE_EMPTY(&server->pipe.conn.pending_ipc_info.queue)) { + if (QUEUE_EMPTY(&server->pipe.conn.ipc_xfer_queue)) { /* No valid pending sockets. */ return WSAEWOULDBLOCK; } - q = QUEUE_HEAD(&server->pipe.conn.pending_ipc_info.queue); + q = QUEUE_HEAD(&server->pipe.conn.ipc_xfer_queue); QUEUE_REMOVE(q); - server->pipe.conn.pending_ipc_info.queue_len--; - item = QUEUE_DATA(q, uv__ipc_queue_item_t, member); + server->pipe.conn.ipc_xfer_queue_length--; + item = QUEUE_DATA(q, uv__ipc_xfer_queue_item_t, member); - err = uv_tcp_import((uv_tcp_t*)client, - &item->socket_info_ex, - item->tcp_connection); + err = uv__tcp_xfer_import( + (uv_tcp_t*) client, item->xfer_type, &item->xfer_info); if (err != 0) return err; @@ -889,8 +906,8 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) { } else { pipe_client = (uv_pipe_t*)client; - /* Find a connection instance that has been connected, but not yet */ - /* accepted. */ + /* Find a connection instance that has been connected, but not yet + * accepted. */ req = server->pipe.serv.pending_accepts; if (!req) { @@ -908,7 +925,7 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) { req->next_pending = NULL; req->pipeHandle = INVALID_HANDLE_VALUE; - if (!(server->flags & UV__HANDLE_CLOSING)) { + if (!(server->flags & UV_HANDLE_CLOSING)) { uv_pipe_queue_accept(loop, server, req, FALSE); } } @@ -953,74 +970,75 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { } -static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* parameter) { - int result; - DWORD bytes; - uv_read_t* req = (uv_read_t*) parameter; +static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* arg) { + uv_read_t* req = (uv_read_t*) arg; uv_pipe_t* handle = (uv_pipe_t*) req->data; uv_loop_t* loop = handle->loop; - HANDLE hThread = NULL; + volatile HANDLE* thread_ptr = &handle->pipe.conn.readfile_thread_handle; + CRITICAL_SECTION* lock = &handle->pipe.conn.readfile_thread_lock; + HANDLE thread; + DWORD bytes; DWORD err; - uv_mutex_t *m = &handle->pipe.conn.readfile_mutex; - assert(req != NULL); assert(req->type == UV_READ); assert(handle->type == UV_NAMED_PIPE); - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - uv_mutex_lock(m); /* mutex controls *setting* of readfile_thread */ - if (DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), - GetCurrentProcess(), &hThread, - 0, FALSE, DUPLICATE_SAME_ACCESS)) { - handle->pipe.conn.readfile_thread = hThread; - } else { - hThread = NULL; - } - uv_mutex_unlock(m); + err = 0; + + /* Create a handle to the current thread. */ + if (!DuplicateHandle(GetCurrentProcess(), + GetCurrentThread(), + GetCurrentProcess(), + &thread, + 0, + FALSE, + DUPLICATE_SAME_ACCESS)) { + err = GetLastError(); + goto out1; } -restart_readfile: - if (handle->flags & UV_HANDLE_READING) { - result = ReadFile(handle->handle, - &uv_zero_, - 0, - &bytes, - NULL); - if (!result) { - err = GetLastError(); - if (err == ERROR_OPERATION_ABORTED && - handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - if (handle->flags & UV_HANDLE_READING) { - /* just a brief break to do something else */ - handle->pipe.conn.readfile_thread = NULL; - /* resume after it is finished */ - uv_mutex_lock(m); - handle->pipe.conn.readfile_thread = hThread; - uv_mutex_unlock(m); - goto restart_readfile; - } else { - result = 1; /* successfully stopped reading */ - } - } - } + + /* The lock needs to be held when thread handle is modified. */ + EnterCriticalSection(lock); + if (*thread_ptr == INVALID_HANDLE_VALUE) { + /* uv__pipe_interrupt_read() cancelled reading before we got here. */ + err = ERROR_OPERATION_ABORTED; } else { - result = 1; /* successfully aborted read before it even started */ - } - if (hThread) { - assert(hThread == handle->pipe.conn.readfile_thread); - /* mutex does not control clearing readfile_thread */ - handle->pipe.conn.readfile_thread = NULL; - uv_mutex_lock(m); - /* only when we hold the mutex lock is it safe to - open or close the handle */ - CloseHandle(hThread); - uv_mutex_unlock(m); + /* Let main thread know which worker thread is doing the blocking read. */ + assert(*thread_ptr == NULL); + *thread_ptr = thread; } + LeaveCriticalSection(lock); - if (!result) { - SET_REQ_ERROR(req, err); - } + if (err) + goto out2; + + /* Block the thread until data is available on the pipe, or the read is + * cancelled. */ + if (!ReadFile(handle->handle, &uv_zero_, 0, &bytes, NULL)) + err = GetLastError(); + + /* Let the main thread know the worker is past the point of blocking. */ + assert(thread == *thread_ptr); + *thread_ptr = INVALID_HANDLE_VALUE; + + /* Briefly acquire the mutex. Since the main thread holds the lock while it + * is spinning trying to cancel this thread's I/O, we will block here until + * it stops doing that. */ + EnterCriticalSection(lock); + LeaveCriticalSection(lock); +out2: + /* Close the handle to the current thread. */ + CloseHandle(thread); + +out1: + /* Set request status and post a completion record to the IOCP. */ + if (err) + SET_REQ_ERROR(req, err); + else + SET_REQ_SUCCESS(req); POST_COMPLETION_FOR_REQ(loop, req); + return 0; } @@ -1102,6 +1120,7 @@ static void uv_pipe_queue_read(uv_loop_t* loop, uv_pipe_t* handle) { req = &handle->read_req; if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { + handle->pipe.conn.readfile_thread_handle = NULL; /* Reset cancellation. */ if (!QueueUserWorkItem(&uv_pipe_zero_readfile_thread_proc, req, WT_EXECUTELONGFUNCTION)) { @@ -1169,8 +1188,8 @@ int uv_pipe_read_start(uv_pipe_t* handle, handle->read_cb = read_cb; handle->alloc_cb = alloc_cb; - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ + /* If reading was stopped and then started again, there could still be a read + * request pending. */ if (!(handle->flags & UV_HANDLE_READ_PENDING)) uv_pipe_queue_read(loop, handle); @@ -1226,154 +1245,110 @@ static void uv_queue_non_overlapped_write(uv_pipe_t* handle) { } -static int uv_pipe_write_impl(uv_loop_t* loop, - uv_write_t* req, - uv_pipe_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - int err; - int result; - uv_tcp_t* tcp_send_handle; - uv_write_t* ipc_header_req = NULL; - uv_ipc_frame_uv_stream ipc_frame; +static int uv__build_coalesced_write_req(uv_write_t* user_req, + const uv_buf_t bufs[], + size_t nbufs, + uv_write_t** req_out, + uv_buf_t* write_buf_out) { + /* Pack into a single heap-allocated buffer: + * (a) a uv_write_t structure where libuv stores the actual state. + * (b) a pointer to the original uv_write_t. + * (c) data from all `bufs` entries. + */ + char* heap_buffer; + size_t heap_buffer_length, heap_buffer_offset; + uv__coalesced_write_t* coalesced_write_req; /* (a) + (b) */ + char* data_start; /* (c) */ + size_t data_length; + unsigned int i; + + /* Compute combined size of all combined buffers from `bufs`. */ + data_length = 0; + for (i = 0; i < nbufs; i++) + data_length += bufs[i].len; + + /* The total combined size of data buffers should not exceed UINT32_MAX, + * because WriteFile() won't accept buffers larger than that. */ + if (data_length > UINT32_MAX) + return WSAENOBUFS; /* Maps to UV_ENOBUFS. */ + + /* Compute heap buffer size. */ + heap_buffer_length = sizeof *coalesced_write_req + /* (a) + (b) */ + data_length; /* (c) */ + + /* Allocate buffer. */ + heap_buffer = uv__malloc(heap_buffer_length); + if (heap_buffer == NULL) + return ERROR_NOT_ENOUGH_MEMORY; /* Maps to UV_ENOMEM. */ + + /* Copy uv_write_t information to the buffer. */ + coalesced_write_req = (uv__coalesced_write_t*) heap_buffer; + coalesced_write_req->req = *user_req; /* copy (a) */ + coalesced_write_req->req.coalesced = 1; + coalesced_write_req->user_req = user_req; /* copy (b) */ + heap_buffer_offset = sizeof *coalesced_write_req; /* offset (a) + (b) */ + + /* Copy data buffers to the heap buffer. */ + data_start = &heap_buffer[heap_buffer_offset]; + for (i = 0; i < nbufs; i++) { + memcpy(&heap_buffer[heap_buffer_offset], + bufs[i].base, + bufs[i].len); /* copy (c) */ + heap_buffer_offset += bufs[i].len; /* offset (c) */ + } + assert(heap_buffer_offset == heap_buffer_length); + + /* Set out arguments and return. */ + *req_out = &coalesced_write_req->req; + *write_buf_out = uv_buf_init(data_start, (unsigned int) data_length); + return 0; +} - if (nbufs != 1 && (nbufs != 0 || !send_handle)) { - return ERROR_NOT_SUPPORTED; - } - /* Only TCP handles are supported for sharing. */ - if (send_handle && ((send_handle->type != UV_TCP) || - (!(send_handle->flags & UV_HANDLE_BOUND) && - !(send_handle->flags & UV_HANDLE_CONNECTION)))) { - return ERROR_NOT_SUPPORTED; - } +static int uv__pipe_write_data(uv_loop_t* loop, + uv_write_t* req, + uv_pipe_t* handle, + const uv_buf_t bufs[], + size_t nbufs, + uv_write_cb cb, + int copy_always) { + int err; + int result; + uv_buf_t write_buf; assert(handle->handle != INVALID_HANDLE_VALUE); UV_REQ_INIT(req, UV_WRITE); req->handle = (uv_stream_t*) handle; + req->send_handle = NULL; req->cb = cb; - req->ipc_header = 0; + /* Private fields. */ + req->coalesced = 0; req->event_handle = NULL; req->wait_handle = INVALID_HANDLE_VALUE; memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - if (handle->ipc) { - assert(!(handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)); - ipc_frame.header.flags = 0; - - /* Use the IPC framing protocol. */ - if (send_handle) { - tcp_send_handle = (uv_tcp_t*)send_handle; - - if (handle->pipe.conn.ipc_pid == 0) { - handle->pipe.conn.ipc_pid = uv_current_pid(); - } - - err = uv_tcp_duplicate_socket(tcp_send_handle, handle->pipe.conn.ipc_pid, - &ipc_frame.socket_info_ex.socket_info); - if (err) { - return err; - } - - ipc_frame.socket_info_ex.delayed_error = tcp_send_handle->delayed_error; - - ipc_frame.header.flags |= UV_IPC_TCP_SERVER; - - if (tcp_send_handle->flags & UV_HANDLE_CONNECTION) { - ipc_frame.header.flags |= UV_IPC_TCP_CONNECTION; - } - } - - if (nbufs == 1) { - ipc_frame.header.flags |= UV_IPC_RAW_DATA; - ipc_frame.header.raw_data_length = bufs[0].len; - } - - /* - * Use the provided req if we're only doing a single write. - * If we're doing multiple writes, use ipc_header_write_req to do - * the first write, and then use the provided req for the second write. - */ - if (!(ipc_frame.header.flags & UV_IPC_RAW_DATA)) { - ipc_header_req = req; - } else { - /* - * Try to use the preallocated write req if it's available. - * Otherwise allocate a new one. - */ - if (handle->pipe.conn.ipc_header_write_req.type != UV_WRITE) { - ipc_header_req = (uv_write_t*)&handle->pipe.conn.ipc_header_write_req; - } else { - ipc_header_req = (uv_write_t*)uv__malloc(sizeof(uv_write_t)); - if (!ipc_header_req) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - } - - UV_REQ_INIT(ipc_header_req, UV_WRITE); - ipc_header_req->handle = (uv_stream_t*) handle; - ipc_header_req->cb = NULL; - ipc_header_req->ipc_header = 1; - } - - /* Write the header or the whole frame. */ - memset(&ipc_header_req->u.io.overlapped, 0, - sizeof(ipc_header_req->u.io.overlapped)); - - /* Using overlapped IO, but wait for completion before returning. - This write is blocking because ipc_frame is on stack. */ - ipc_header_req->u.io.overlapped.hEvent = CreateEvent(NULL, 1, 0, NULL); - if (!ipc_header_req->u.io.overlapped.hEvent) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - - result = WriteFile(handle->handle, - &ipc_frame, - ipc_frame.header.flags & UV_IPC_TCP_SERVER ? - sizeof(ipc_frame) : sizeof(ipc_frame.header), - NULL, - &ipc_header_req->u.io.overlapped); - if (!result && GetLastError() != ERROR_IO_PENDING) { - err = GetLastError(); - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); + req->write_buffer = uv_null_buf_; + + if (nbufs == 0) { + /* Write empty buffer. */ + write_buf = uv_null_buf_; + } else if (nbufs == 1 && !copy_always) { + /* Write directly from bufs[0]. */ + write_buf = bufs[0]; + } else { + /* Coalesce all `bufs` into one big buffer. This also creates a new + * write-request structure that replaces the old one. */ + err = uv__build_coalesced_write_req(req, bufs, nbufs, &req, &write_buf); + if (err != 0) return err; - } - - if (!result) { - /* Request not completed immediately. Wait for it.*/ - if (WaitForSingleObject(ipc_header_req->u.io.overlapped.hEvent, INFINITE) != - WAIT_OBJECT_0) { - err = GetLastError(); - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); - return err; - } - } - ipc_header_req->u.io.queued_bytes = 0; - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); - ipc_header_req->u.io.overlapped.hEvent = NULL; - - REGISTER_HANDLE_REQ(loop, handle, ipc_header_req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - - /* If we don't have any raw data to write - we're done. */ - if (!(ipc_frame.header.flags & UV_IPC_RAW_DATA)) { - return 0; - } } if ((handle->flags & (UV_HANDLE_BLOCKING_WRITES | UV_HANDLE_NON_OVERLAPPED_PIPE)) == (UV_HANDLE_BLOCKING_WRITES | UV_HANDLE_NON_OVERLAPPED_PIPE)) { DWORD bytes; - result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, - &bytes, - NULL); + result = + WriteFile(handle->handle, write_buf.base, write_buf.len, &bytes, NULL); if (!result) { err = GetLastError(); @@ -1389,14 +1364,14 @@ static int uv_pipe_write_impl(uv_loop_t* loop, POST_COMPLETION_FOR_REQ(loop, req); return 0; } else if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - req->write_buffer = bufs[0]; + req->write_buffer = write_buf; uv_insert_non_overlapped_write_req(handle, req); if (handle->stream.conn.write_reqs_pending == 0) { uv_queue_non_overlapped_write(handle); } /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; + req->u.io.queued_bytes = write_buf.len; handle->write_queue_size += req->u.io.queued_bytes; } else if (handle->flags & UV_HANDLE_BLOCKING_WRITES) { /* Using overlapped IO, but wait for completion before returning */ @@ -1406,8 +1381,8 @@ static int uv_pipe_write_impl(uv_loop_t* loop, } result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, + write_buf.base, + write_buf.len, NULL, &req->u.io.overlapped); @@ -1422,13 +1397,13 @@ static int uv_pipe_write_impl(uv_loop_t* loop, req->u.io.queued_bytes = 0; } else { /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; + req->u.io.queued_bytes = write_buf.len; handle->write_queue_size += req->u.io.queued_bytes; if (WaitForSingleObject(req->u.io.overlapped.hEvent, INFINITE) != WAIT_OBJECT_0) { err = GetLastError(); CloseHandle(req->u.io.overlapped.hEvent); - return uv_translate_sys_error(err); + return err; } } CloseHandle(req->u.io.overlapped.hEvent); @@ -1439,8 +1414,8 @@ static int uv_pipe_write_impl(uv_loop_t* loop, return 0; } else { result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, + write_buf.base, + write_buf.len, NULL, &req->u.io.overlapped); @@ -1453,7 +1428,7 @@ static int uv_pipe_write_impl(uv_loop_t* loop, req->u.io.queued_bytes = 0; } else { /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; + req->u.io.queued_bytes = write_buf.len; handle->write_queue_size += req->u.io.queued_bytes; } @@ -1478,35 +1453,143 @@ static int uv_pipe_write_impl(uv_loop_t* loop, } -int uv_pipe_write(uv_loop_t* loop, - uv_write_t* req, - uv_pipe_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - return uv_pipe_write_impl(loop, req, handle, bufs, nbufs, NULL, cb); +static DWORD uv__pipe_get_ipc_remote_pid(uv_pipe_t* handle) { + DWORD* pid = &handle->pipe.conn.ipc_remote_pid; + + /* If the both ends of the IPC pipe are owned by the same process, + * the remote end pid may not yet be set. If so, do it here. + * TODO: this is weird; it'd probably better to use a handshake. */ + if (*pid == 0) + *pid = GetCurrentProcessId(); + + return *pid; +} + + +int uv__pipe_write_ipc(uv_loop_t* loop, + uv_write_t* req, + uv_pipe_t* handle, + const uv_buf_t data_bufs[], + size_t data_buf_count, + uv_stream_t* send_handle, + uv_write_cb cb) { + uv_buf_t stack_bufs[6]; + uv_buf_t* bufs; + size_t buf_count, buf_index; + uv__ipc_frame_header_t frame_header; + uv__ipc_socket_xfer_type_t xfer_type = UV__IPC_SOCKET_XFER_NONE; + uv__ipc_socket_xfer_info_t xfer_info; + uint64_t data_length; + size_t i; + int err; + + /* Compute the combined size of data buffers. */ + data_length = 0; + for (i = 0; i < data_buf_count; i++) + data_length += data_bufs[i].len; + if (data_length > UINT32_MAX) + return WSAENOBUFS; /* Maps to UV_ENOBUFS. */ + + /* Prepare the frame's socket xfer payload. */ + if (send_handle != NULL) { + uv_tcp_t* send_tcp_handle = (uv_tcp_t*) send_handle; + + /* Verify that `send_handle` it is indeed a tcp handle. */ + if (send_tcp_handle->type != UV_TCP) + return ERROR_NOT_SUPPORTED; + + /* Export the tcp handle. */ + err = uv__tcp_xfer_export(send_tcp_handle, + uv__pipe_get_ipc_remote_pid(handle), + &xfer_type, + &xfer_info); + if (err != 0) + return err; + } + + /* Compute the number of uv_buf_t's required. */ + buf_count = 1 + data_buf_count; /* Frame header and data buffers. */ + if (send_handle != NULL) + buf_count += 1; /* One extra for the socket xfer information. */ + + /* Use the on-stack buffer array if it is big enough; otherwise allocate + * space for it on the heap. */ + if (buf_count < ARRAY_SIZE(stack_bufs)) { + /* Use on-stack buffer array. */ + bufs = stack_bufs; + } else { + /* Use heap-allocated buffer array. */ + bufs = uv__calloc(buf_count, sizeof(uv_buf_t)); + if (bufs == NULL) + return ERROR_NOT_ENOUGH_MEMORY; /* Maps to UV_ENOMEM. */ + } + buf_index = 0; + + /* Initialize frame header and add it to the buffers list. */ + memset(&frame_header, 0, sizeof frame_header); + bufs[buf_index++] = uv_buf_init((char*) &frame_header, sizeof frame_header); + + if (send_handle != NULL) { + /* Add frame header flags. */ + switch (xfer_type) { + case UV__IPC_SOCKET_XFER_TCP_CONNECTION: + frame_header.flags |= UV__IPC_FRAME_HAS_SOCKET_XFER | + UV__IPC_FRAME_XFER_IS_TCP_CONNECTION; + break; + case UV__IPC_SOCKET_XFER_TCP_SERVER: + frame_header.flags |= UV__IPC_FRAME_HAS_SOCKET_XFER; + break; + default: + assert(0); /* Unreachable. */ + } + /* Add xfer info buffer. */ + bufs[buf_index++] = uv_buf_init((char*) &xfer_info, sizeof xfer_info); + } + + if (data_length > 0) { + /* Update frame header. */ + frame_header.flags |= UV__IPC_FRAME_HAS_DATA; + frame_header.data_length = (uint32_t) data_length; + /* Add data buffers to buffers list. */ + for (i = 0; i < data_buf_count; i++) + bufs[buf_index++] = data_bufs[i]; + } + + /* Write buffers. We set the `always_copy` flag, so it is not a problem that + * some of the written data lives on the stack. */ + err = uv__pipe_write_data(loop, req, handle, bufs, buf_count, cb, 1); + + /* If we had to heap-allocate the bufs array, free it now. */ + if (bufs != stack_bufs) { + uv__free(bufs); + } + + return err; } -int uv_pipe_write2(uv_loop_t* loop, +int uv__pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, const uv_buf_t bufs[], - unsigned int nbufs, + size_t nbufs, uv_stream_t* send_handle, uv_write_cb cb) { - if (!handle->ipc) { - return WSAEINVAL; + if (handle->ipc) { + /* IPC pipe write: use framing protocol. */ + return uv__pipe_write_ipc(loop, req, handle, bufs, nbufs, send_handle, cb); + } else { + /* Non-IPC pipe write: put data on the wire directly. */ + assert(send_handle == NULL); + return uv__pipe_write_data(loop, req, handle, bufs, nbufs, cb, 0); } - - return uv_pipe_write_impl(loop, req, handle, bufs, nbufs, send_handle, cb); } static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle, uv_buf_t buf) { - /* If there is an eof timer running, we don't need it any more, */ - /* so discard it. */ + /* If there is an eof timer running, we don't need it any more, so discard + * it. */ eof_timer_destroy(handle); handle->flags &= ~UV_HANDLE_READABLE; @@ -1518,8 +1601,8 @@ static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle, static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error, uv_buf_t buf) { - /* If there is an eof timer running, we don't need it any more, */ - /* so discard it. */ + /* If there is an eof timer running, we don't need it any more, so discard + * it. */ eof_timer_destroy(handle); uv_read_stop((uv_stream_t*) handle); @@ -1530,10 +1613,7 @@ static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error, static void uv_pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle, int error, uv_buf_t buf) { - if (error == ERROR_OPERATION_ABORTED) { - /* do nothing (equivalent to EINTR) */ - } - else if (error == ERROR_BROKEN_PIPE) { + if (error == ERROR_BROKEN_PIPE) { uv_pipe_read_eof(loop, handle, buf); } else { uv_pipe_read_error(loop, handle, error, buf); @@ -1541,152 +1621,228 @@ static void uv_pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle, } -void uv__pipe_insert_pending_socket(uv_pipe_t* handle, - uv__ipc_socket_info_ex* info, - int tcp_connection) { - uv__ipc_queue_item_t* item; +static void uv__pipe_queue_ipc_xfer_info( + uv_pipe_t* handle, + uv__ipc_socket_xfer_type_t xfer_type, + uv__ipc_socket_xfer_info_t* xfer_info) { + uv__ipc_xfer_queue_item_t* item; - item = (uv__ipc_queue_item_t*) uv__malloc(sizeof(*item)); + item = (uv__ipc_xfer_queue_item_t*) uv__malloc(sizeof(*item)); if (item == NULL) uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - memcpy(&item->socket_info_ex, info, sizeof(item->socket_info_ex)); - item->tcp_connection = tcp_connection; - QUEUE_INSERT_TAIL(&handle->pipe.conn.pending_ipc_info.queue, &item->member); - handle->pipe.conn.pending_ipc_info.queue_len++; + item->xfer_type = xfer_type; + item->xfer_info = *xfer_info; + + QUEUE_INSERT_TAIL(&handle->pipe.conn.ipc_xfer_queue, &item->member); + handle->pipe.conn.ipc_xfer_queue_length++; +} + + +/* Read an exact number of bytes from a pipe. If an error or end-of-file is + * encountered before the requested number of bytes are read, an error is + * returned. */ +static int uv__pipe_read_exactly(HANDLE h, void* buffer, DWORD count) { + DWORD bytes_read, bytes_read_now; + + bytes_read = 0; + while (bytes_read < count) { + if (!ReadFile(h, + (char*) buffer + bytes_read, + count - bytes_read, + &bytes_read_now, + NULL)) { + return GetLastError(); + } + + bytes_read += bytes_read_now; + } + + assert(bytes_read == count); + return 0; } -void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* req) { - DWORD bytes, avail; +static DWORD uv__pipe_read_data(uv_loop_t* loop, + uv_pipe_t* handle, + DWORD suggested_bytes, + DWORD max_bytes) { + DWORD bytes_read; uv_buf_t buf; - uv_ipc_frame_uv_stream ipc_frame; + /* Ask the user for a buffer to read data into. */ + buf = uv_buf_init(NULL, 0); + handle->alloc_cb((uv_handle_t*) handle, suggested_bytes, &buf); + if (buf.base == NULL || buf.len == 0) { + handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); + return 0; /* Break out of read loop. */ + } + + /* Ensure we read at most the smaller of: + * (a) the length of the user-allocated buffer. + * (b) the maximum data length as specified by the `max_bytes` argument. + */ + if (max_bytes > buf.len) + max_bytes = buf.len; + + /* Read into the user buffer. */ + if (!ReadFile(handle->handle, buf.base, max_bytes, &bytes_read, NULL)) { + uv_pipe_read_error_or_eof(loop, handle, GetLastError(), buf); + return 0; /* Break out of read loop. */ + } + + /* Call the read callback. */ + handle->read_cb((uv_stream_t*) handle, bytes_read, &buf); + + return bytes_read; +} + + +static DWORD uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) { + uint32_t* data_remaining = &handle->pipe.conn.ipc_data_frame.payload_remaining; + int err; + + if (*data_remaining > 0) { + /* Read frame data payload. */ + DWORD bytes_read = + uv__pipe_read_data(loop, handle, *data_remaining, *data_remaining); + *data_remaining -= bytes_read; + return bytes_read; + + } else { + /* Start of a new IPC frame. */ + uv__ipc_frame_header_t frame_header; + uint32_t xfer_flags; + uv__ipc_socket_xfer_type_t xfer_type; + uv__ipc_socket_xfer_info_t xfer_info; + + /* Read the IPC frame header. */ + err = uv__pipe_read_exactly( + handle->handle, &frame_header, sizeof frame_header); + if (err) + goto error; + + /* Validate that flags are valid. */ + if ((frame_header.flags & ~UV__IPC_FRAME_VALID_FLAGS) != 0) + goto invalid; + /* Validate that reserved2 is zero. */ + if (frame_header.reserved2 != 0) + goto invalid; + + /* Parse xfer flags. */ + xfer_flags = frame_header.flags & UV__IPC_FRAME_XFER_FLAGS; + if (xfer_flags & UV__IPC_FRAME_HAS_SOCKET_XFER) { + /* Socket coming -- determine the type. */ + xfer_type = xfer_flags & UV__IPC_FRAME_XFER_IS_TCP_CONNECTION + ? UV__IPC_SOCKET_XFER_TCP_CONNECTION + : UV__IPC_SOCKET_XFER_TCP_SERVER; + } else if (xfer_flags == 0) { + /* No socket. */ + xfer_type = UV__IPC_SOCKET_XFER_NONE; + } else { + /* Invalid flags. */ + goto invalid; + } + + /* Parse data frame information. */ + if (frame_header.flags & UV__IPC_FRAME_HAS_DATA) { + *data_remaining = frame_header.data_length; + } else if (frame_header.data_length != 0) { + /* Data length greater than zero but data flag not set -- invalid. */ + goto invalid; + } + + /* If no socket xfer info follows, return here. Data will be read in a + * subsequent invocation of uv__pipe_read_ipc(). */ + if (xfer_type == UV__IPC_SOCKET_XFER_NONE) + return sizeof frame_header; /* Number of bytes read. */ + + /* Read transferred socket information. */ + err = uv__pipe_read_exactly(handle->handle, &xfer_info, sizeof xfer_info); + if (err) + goto error; + + /* Store the pending socket info. */ + uv__pipe_queue_ipc_xfer_info(handle, xfer_type, &xfer_info); + + /* Return number of bytes read. */ + return sizeof frame_header + sizeof xfer_info; + } + +invalid: + /* Invalid frame. */ + err = WSAECONNABORTED; /* Maps to UV_ECONNABORTED. */ + +error: + uv_pipe_read_error_or_eof(loop, handle, err, uv_null_buf_); + return 0; /* Break out of read loop. */ +} + + +void uv_process_pipe_read_req(uv_loop_t* loop, + uv_pipe_t* handle, + uv_req_t* req) { assert(handle->type == UV_NAMED_PIPE); - handle->flags &= ~UV_HANDLE_READ_PENDING; + handle->flags &= ~(UV_HANDLE_READ_PENDING | UV_HANDLE_CANCELLATION_PENDING); + DECREASE_PENDING_REQ_COUNT(handle); eof_timer_stop(handle); - if (!REQ_SUCCESS(req)) { - /* An error occurred doing the 0-read. */ - if (handle->flags & UV_HANDLE_READING) { - uv_pipe_read_error_or_eof(loop, - handle, - GET_REQ_ERROR(req), - uv_null_buf_); - } - } else { - /* Do non-blocking reads until the buffer is empty */ - while (handle->flags & UV_HANDLE_READING) { - if (!PeekNamedPipe(handle->handle, - NULL, - 0, - NULL, - &avail, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_); - break; - } + /* At this point, we're done with bookkeeping. If the user has stopped + * reading the pipe in the meantime, there is nothing left to do, since there + * is no callback that we can call. */ + if (!(handle->flags & UV_HANDLE_READING)) + return; - if (avail == 0) { - /* There is nothing to read after all. */ - break; - } + if (!REQ_SUCCESS(req)) { + /* An error occurred doing the zero-read. */ + DWORD err = GET_REQ_ERROR(req); - if (handle->ipc) { - /* Use the IPC framing protocol to read the incoming data. */ - if (handle->pipe.conn.remaining_ipc_rawdata_bytes == 0) { - /* We're reading a new frame. First, read the header. */ - assert(avail >= sizeof(ipc_frame.header)); - - if (!ReadFile(handle->handle, - &ipc_frame.header, - sizeof(ipc_frame.header), - &bytes, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), - uv_null_buf_); - break; - } - - assert(bytes == sizeof(ipc_frame.header)); - assert(ipc_frame.header.flags <= (UV_IPC_TCP_SERVER | UV_IPC_RAW_DATA | - UV_IPC_TCP_CONNECTION)); - - if (ipc_frame.header.flags & UV_IPC_TCP_SERVER) { - assert(avail - sizeof(ipc_frame.header) >= - sizeof(ipc_frame.socket_info_ex)); - - /* Read the TCP socket info. */ - if (!ReadFile(handle->handle, - &ipc_frame.socket_info_ex, - sizeof(ipc_frame) - sizeof(ipc_frame.header), - &bytes, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), - uv_null_buf_); - break; - } - - assert(bytes == sizeof(ipc_frame) - sizeof(ipc_frame.header)); - - /* Store the pending socket info. */ - uv__pipe_insert_pending_socket( - handle, - &ipc_frame.socket_info_ex, - ipc_frame.header.flags & UV_IPC_TCP_CONNECTION); - } - - if (ipc_frame.header.flags & UV_IPC_RAW_DATA) { - handle->pipe.conn.remaining_ipc_rawdata_bytes = - ipc_frame.header.raw_data_length; - continue; - } - } else { - avail = min(avail, (DWORD)handle->pipe.conn.remaining_ipc_rawdata_bytes); - } - } + /* If the read was cancelled by uv__pipe_interrupt_read(), the request may + * indicate an ERROR_OPERATION_ABORTED error. This error isn't relevant to + * the user; we'll start a new zero-read at the end of this function. */ + if (err != ERROR_OPERATION_ABORTED) + uv_pipe_read_error_or_eof(loop, handle, err, uv_null_buf_); - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, avail, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); + } else { + /* The zero-read completed without error, indicating there is data + * available in the kernel buffer. */ + DWORD avail; + + /* Get the number of bytes available. */ + avail = 0; + if (!PeekNamedPipe(handle->handle, NULL, 0, NULL, &avail, NULL)) + uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_); + + /* Read until we've either read all the bytes available, or the 'reading' + * flag is cleared. */ + while (avail > 0 && handle->flags & UV_HANDLE_READING) { + /* Depending on the type of pipe, read either IPC frames or raw data. */ + DWORD bytes_read = + handle->ipc ? uv__pipe_read_ipc(loop, handle) + : uv__pipe_read_data(loop, handle, avail, (DWORD) -1); + + /* If no bytes were read, treat this as an indication that an error + * occurred, and break out of the read loop. */ + if (bytes_read == 0) break; - } - assert(buf.base != NULL); - - if (ReadFile(handle->handle, - buf.base, - min(buf.len, avail), - &bytes, - NULL)) { - /* Successful read */ - if (handle->ipc) { - assert(handle->pipe.conn.remaining_ipc_rawdata_bytes >= bytes); - handle->pipe.conn.remaining_ipc_rawdata_bytes = - handle->pipe.conn.remaining_ipc_rawdata_bytes - bytes; - } - handle->read_cb((uv_stream_t*)handle, bytes, &buf); - /* Read again only if bytes == buf.len */ - if (bytes <= buf.len) { - break; - } - } else { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), buf); + /* It is possible that more bytes were read than we thought were + * available. To prevent `avail` from underflowing, break out of the loop + * if this is the case. */ + if (bytes_read > avail) break; - } - } - /* Post another 0-read if still reading and not closing. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_pipe_queue_read(loop, handle); + /* Recompute the number of bytes available. */ + avail -= bytes_read; } } - DECREASE_PENDING_REQ_COUNT(handle); + /* Start another zero-read request if necessary. */ + if ((handle->flags & UV_HANDLE_READING) && + !(handle->flags & UV_HANDLE_READ_PENDING)) { + uv_pipe_queue_read(loop, handle); + } } @@ -1712,17 +1868,19 @@ void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, } } - if (req->ipc_header) { - if (req == &handle->pipe.conn.ipc_header_write_req) { - req->type = UV_UNKNOWN_REQ; - } else { - uv__free(req); - } - } else { - if (req->cb) { - err = GET_REQ_ERROR(req); - req->cb(req, uv_translate_sys_error(err)); - } + err = GET_REQ_ERROR(req); + + /* If this was a coalesced write, extract pointer to the user_provided + * uv_write_t structure so we can pass the expected pointer to the callback, + * then free the heap-allocated write req. */ + if (req->coalesced) { + uv__coalesced_write_t* coalesced_write = + container_of(req, uv__coalesced_write_t, req); + req = coalesced_write->user_req; + uv__free(coalesced_write); + } + if (req->cb) { + req->cb(req, uv_translate_sys_error(err)); } handle->stream.conn.write_reqs_pending--; @@ -1748,7 +1906,7 @@ void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle, assert(handle->type == UV_NAMED_PIPE); - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { /* The req->pipeHandle should be freed already in uv_pipe_cleanup(). */ assert(req->pipeHandle == INVALID_HANDLE_VALUE); DECREASE_PENDING_REQ_COUNT(handle); @@ -1768,7 +1926,7 @@ void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle, CloseHandle(req->pipeHandle); req->pipeHandle = INVALID_HANDLE_VALUE; } - if (!(handle->flags & UV__HANDLE_CLOSING)) { + if (!(handle->flags & UV_HANDLE_CLOSING)) { uv_pipe_queue_accept(loop, handle, req, FALSE); } } @@ -1806,19 +1964,19 @@ void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle, UNREGISTER_HANDLE_REQ(loop, handle, req); if (handle->flags & UV_HANDLE_READABLE) { - /* Initialize and optionally start the eof timer. Only do this if the */ - /* pipe is readable and we haven't seen EOF come in ourselves. */ + /* Initialize and optionally start the eof timer. Only do this if the pipe + * is readable and we haven't seen EOF come in ourselves. */ eof_timer_init(handle); - /* If reading start the timer right now. */ - /* Otherwise uv_pipe_queue_read will start it. */ + /* If reading start the timer right now. Otherwise uv_pipe_queue_read will + * start it. */ if (handle->flags & UV_HANDLE_READ_PENDING) { eof_timer_start(handle); } } else { - /* This pipe is not readable. We can just close it to let the other end */ - /* know that we're done writing. */ + /* This pipe is not readable. We can just close it to let the other end + * know that we're done writing. */ close_pipe(handle); } @@ -1869,17 +2027,16 @@ static void eof_timer_cb(uv_timer_t* timer) { assert(pipe->type == UV_NAMED_PIPE); - /* This should always be true, since we start the timer only */ - /* in uv_pipe_queue_read after successfully calling ReadFile, */ - /* or in uv_process_pipe_shutdown_req if a read is pending, */ - /* and we always immediately stop the timer in */ - /* uv_process_pipe_read_req. */ + /* This should always be true, since we start the timer only in + * uv_pipe_queue_read after successfully calling ReadFile, or in + * uv_process_pipe_shutdown_req if a read is pending, and we always + * immediately stop the timer in uv_process_pipe_read_req. */ assert(pipe->flags & UV_HANDLE_READ_PENDING); - /* If there are many packets coming off the iocp then the timer callback */ - /* may be called before the read request is coming off the queue. */ - /* Therefore we check here if the read request has completed but will */ - /* be processed later. */ + /* If there are many packets coming off the iocp then the timer callback may + * be called before the read request is coming off the queue. Therefore we + * check here if the read request has completed but will be processed later. + */ if ((pipe->flags & UV_HANDLE_READ_PENDING) && HasOverlappedIoCompleted(&pipe->read_req.u.io.overlapped)) { return; @@ -1888,12 +2045,12 @@ static void eof_timer_cb(uv_timer_t* timer) { /* Force both ends off the pipe. */ close_pipe(pipe); - /* Stop reading, so the pending read that is going to fail will */ - /* not be reported to the user. */ + /* Stop reading, so the pending read that is going to fail will not be + * reported to the user. */ uv_read_stop((uv_stream_t*) pipe); - /* Report the eof and update flags. This will get reported even if the */ - /* user stopped reading in the meantime. TODO: is that okay? */ + /* Report the eof and update flags. This will get reported even if the user + * stopped reading in the meantime. TODO: is that okay? */ uv_pipe_read_eof(loop, pipe, uv_null_buf_); } @@ -1980,8 +2137,8 @@ int uv_pipe_open(uv_pipe_t* pipe, uv_file file) { if (pipe->ipc) { assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)); - pipe->pipe.conn.ipc_pid = uv_os_getppid(); - assert(pipe->pipe.conn.ipc_pid != -1); + pipe->pipe.conn.ipc_remote_pid = uv_os_getppid(); + assert(pipe->pipe.conn.ipc_remote_pid != (DWORD) -1); } return 0; } @@ -2006,7 +2163,15 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) return UV_EINVAL; } - uv__pipe_pause_read((uv_pipe_t*)handle); /* cast away const warning */ + /* NtQueryInformationFile will block if another thread is performing a + * blocking operation on the queried handle. If the pipe handle is + * synchronous, there may be a worker thread currently calling ReadFile() on + * the pipe handle, which could cause a deadlock. To avoid this, interrupt + * the read. */ + if (handle->flags & UV_HANDLE_CONNECTION && + handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { + uv__pipe_interrupt_read((uv_pipe_t*) handle); /* cast away const warning */ + } nt_status = pNtQueryInformationFile(handle->handle, &io_status, @@ -2097,7 +2262,6 @@ error: uv__free(name_info); cleanup: - uv__pipe_unpause_read((uv_pipe_t*)handle); /* cast away const warning */ return err; } @@ -2105,7 +2269,7 @@ cleanup: int uv_pipe_pending_count(uv_pipe_t* handle) { if (!handle->ipc) return 0; - return handle->pipe.conn.pending_ipc_info.queue_len; + return handle->pipe.conn.ipc_xfer_queue_length; } @@ -2138,14 +2302,14 @@ int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) { uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) { if (!handle->ipc) return UV_UNKNOWN_HANDLE; - if (handle->pipe.conn.pending_ipc_info.queue_len == 0) + if (handle->pipe.conn.ipc_xfer_queue_length == 0) return UV_UNKNOWN_HANDLE; else return UV_TCP; } int uv_pipe_chmod(uv_pipe_t* handle, int mode) { - SID_IDENTIFIER_AUTHORITY sid_world = SECURITY_WORLD_SID_AUTHORITY; + SID_IDENTIFIER_AUTHORITY sid_world = { SECURITY_WORLD_SID_AUTHORITY }; PACL old_dacl, new_dacl; PSECURITY_DESCRIPTOR sd; EXPLICIT_ACCESS ea; @@ -2180,7 +2344,7 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { error = GetLastError(); goto clean_sid; } - + memset(&ea, 0, sizeof(EXPLICIT_ACCESS)); if (mode & UV_READABLE) ea.grfAccessPermissions |= GENERIC_READ | FILE_WRITE_ATTRIBUTES; diff --git a/Utilities/cmlibuv/src/win/poll.c b/Utilities/cmlibuv/src/win/poll.c index a648ba711d..3c6678600e 100644 --- a/Utilities/cmlibuv/src/win/poll.c +++ b/Utilities/cmlibuv/src/win/poll.c @@ -75,7 +75,7 @@ static AFD_POLL_INFO* uv__get_afd_poll_info_dummy(void) { static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { uv_req_t* req; AFD_POLL_INFO* afd_poll_info; - DWORD result; + int result; /* Find a yet unsubmitted req to submit. */ if (handle->submitted_events_1 == 0) { @@ -91,16 +91,16 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { handle->mask_events_1 = handle->events; handle->mask_events_2 = 0; } else { - /* Just wait until there's an unsubmitted req. */ - /* This will happen almost immediately as one of the 2 outstanding */ - /* requests is about to return. When this happens, */ - /* uv__fast_poll_process_poll_req will be called, and the pending */ - /* events, if needed, will be processed in a subsequent request. */ + /* Just wait until there's an unsubmitted req. This will happen almost + * immediately as one of the 2 outstanding requests is about to return. + * When this happens, uv__fast_poll_process_poll_req will be called, and + * the pending events, if needed, will be processed in a subsequent + * request. */ return; } - /* Setting Exclusive to TRUE makes the other poll request return if there */ - /* is any. */ + /* Setting Exclusive to TRUE makes the other poll request return if there is + * any. */ afd_poll_info->Exclusive = TRUE; afd_poll_info->NumberOfHandles = 1; afd_poll_info->Timeout.QuadPart = INT64_MAX; @@ -136,7 +136,7 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { static int uv__fast_poll_cancel_poll_req(uv_loop_t* loop, uv_poll_t* handle) { AFD_POLL_INFO afd_poll_info; - DWORD result; + int result; afd_poll_info.Exclusive = TRUE; afd_poll_info.NumberOfHandles = 1; @@ -218,7 +218,7 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, if ((handle->events & ~(handle->submitted_events_1 | handle->submitted_events_2)) != 0) { uv__fast_poll_submit_poll_req(loop, handle); - } else if ((handle->flags & UV__HANDLE_CLOSING) && + } else if ((handle->flags & UV_HANDLE_CLOSING) && handle->submitted_events_1 == 0 && handle->submitted_events_2 == 0) { uv_want_endgame(loop, (uv_handle_t*) handle); @@ -228,7 +228,7 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, static int uv__fast_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) { assert(handle->type == UV_POLL); - assert(!(handle->flags & UV__HANDLE_CLOSING)); + assert(!(handle->flags & UV_HANDLE_CLOSING)); assert((events & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0); handle->events = events; @@ -257,8 +257,8 @@ static int uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) { uv_want_endgame(loop, (uv_handle_t*) handle); return 0; } else { - /* Cancel outstanding poll requests by executing another, unique poll */ - /* request that forces the outstanding ones to return. */ + /* Cancel outstanding poll requests by executing another, unique poll + * request that forces the outstanding ones to return. */ return uv__fast_poll_cancel_poll_req(loop, handle); } } @@ -316,9 +316,8 @@ static SOCKET uv__fast_poll_get_peer_socket(uv_loop_t* loop, return INVALID_SOCKET; } - /* If we didn't (try) to create a peer socket yet, try to make one. Don't */ - /* try again if the peer socket creation failed earlier for the same */ - /* protocol. */ + /* If we didn't (try) to create a peer socket yet, try to make one. Don't try + * again if the peer socket creation failed earlier for the same protocol. */ peer_socket = loop->poll_peer_sockets[index]; if (peer_socket == 0) { peer_socket = uv__fast_poll_create_peer_socket(loop->iocp, protocol_info); @@ -357,8 +356,8 @@ static DWORD WINAPI uv__slow_poll_thread_proc(void* arg) { efds.fd_count = 0; } - /* Make the select() time out after 3 minutes. If select() hangs because */ - /* the user closed the socket, we will at least not hang indefinitely. */ + /* Make the select() time out after 3 minutes. If select() hangs because the + * user closed the socket, we will at least not hang indefinitely. */ timeout.tv_sec = 3 * 60; timeout.tv_usec = 0; @@ -462,7 +461,7 @@ static void uv__slow_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, if ((handle->events & ~(handle->submitted_events_1 | handle->submitted_events_2)) != 0) { uv__slow_poll_submit_poll_req(loop, handle); - } else if ((handle->flags & UV__HANDLE_CLOSING) && + } else if ((handle->flags & UV_HANDLE_CLOSING) && handle->submitted_events_1 == 0 && handle->submitted_events_2 == 0) { uv_want_endgame(loop, (uv_handle_t*) handle); @@ -472,7 +471,7 @@ static void uv__slow_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, static int uv__slow_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) { assert(handle->type == UV_POLL); - assert(!(handle->flags & UV__HANDLE_CLOSING)); + assert(!(handle->flags & UV_HANDLE_CLOSING)); assert((events & ~(UV_READABLE | UV_WRITABLE)) == 0); handle->events = events; @@ -522,10 +521,10 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) return uv_translate_sys_error(WSAGetLastError()); - /* Try to obtain a base handle for the socket. This increases this chances */ - /* that we find an AFD handle and are able to use the fast poll mechanism. */ - /* This will always fail on windows XP/2k3, since they don't support the */ - /* SIO_BASE_HANDLE ioctl. */ +/* Try to obtain a base handle for the socket. This increases this chances that + * we find an AFD handle and are able to use the fast poll mechanism. This will + * always fail on windows XP/2k3, since they don't support the. SIO_BASE_HANDLE + * ioctl. */ #ifndef NDEBUG base_socket = INVALID_SOCKET; #endif @@ -557,9 +556,9 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, return uv_translate_sys_error(WSAGetLastError()); } - /* Get the peer socket that is needed to enable fast poll. If the returned */ - /* value is NULL, the protocol is not implemented by MSAFD and we'll have */ - /* to use slow mode. */ + /* Get the peer socket that is needed to enable fast poll. If the returned + * value is NULL, the protocol is not implemented by MSAFD and we'll have to + * use slow mode. */ peer_socket = uv__fast_poll_get_peer_socket(loop, &protocol_info); if (peer_socket != INVALID_SOCKET) { @@ -634,7 +633,7 @@ int uv_poll_close(uv_loop_t* loop, uv_poll_t* handle) { void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); + assert(handle->flags & UV_HANDLE_CLOSING); assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(handle->submitted_events_1 == 0); diff --git a/Utilities/cmlibuv/src/win/process-stdio.c b/Utilities/cmlibuv/src/win/process-stdio.c index 032e30935c..355d618808 100644 --- a/Utilities/cmlibuv/src/win/process-stdio.c +++ b/Utilities/cmlibuv/src/win/process-stdio.c @@ -103,12 +103,12 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop, DWORD client_access = 0; HANDLE child_pipe = INVALID_HANDLE_VALUE; int err; + int overlap; if (flags & UV_READABLE_PIPE) { - /* The server needs inbound access too, otherwise CreateNamedPipe() */ - /* won't give us the FILE_READ_ATTRIBUTES permission. We need that to */ - /* probe the state of the write buffer when we're trying to shutdown */ - /* the pipe. */ + /* The server needs inbound access too, otherwise CreateNamedPipe() won't + * give us the FILE_READ_ATTRIBUTES permission. We need that to probe the + * state of the write buffer when we're trying to shutdown the pipe. */ server_access |= PIPE_ACCESS_OUTBOUND | PIPE_ACCESS_INBOUND; client_access |= GENERIC_READ | FILE_WRITE_ATTRIBUTES; } @@ -131,12 +131,13 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop, sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; + overlap = server_pipe->ipc || (flags & UV_OVERLAPPED_PIPE); child_pipe = CreateFileA(pipe_name, client_access, 0, &sa, OPEN_EXISTING, - server_pipe->ipc ? FILE_FLAG_OVERLAPPED : 0, + overlap ? FILE_FLAG_OVERLAPPED : 0, NULL); if (child_pipe == INVALID_HANDLE_VALUE) { err = GetLastError(); @@ -159,8 +160,8 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop, } #endif - /* Do a blocking ConnectNamedPipe. This should not block because we have */ - /* both ends of the pipe created. */ + /* Do a blocking ConnectNamedPipe. This should not block because we have both + * ends of the pipe created. */ if (!ConnectNamedPipe(server_pipe->handle, NULL)) { if (GetLastError() != ERROR_PIPE_CONNECTED) { err = GetLastError(); @@ -194,11 +195,11 @@ static int uv__duplicate_handle(uv_loop_t* loop, HANDLE handle, HANDLE* dup) { HANDLE current_process; - /* _get_osfhandle will sometimes return -2 in case of an error. This seems */ - /* to happen when fd <= 2 and the process' corresponding stdio handle is */ - /* set to NULL. Unfortunately DuplicateHandle will happily duplicate */ - /* (HANDLE) -2, so this situation goes unnoticed until someone tries to */ - /* use the duplicate. Therefore we filter out known-invalid handles here. */ + /* _get_osfhandle will sometimes return -2 in case of an error. This seems to + * happen when fd <= 2 and the process' corresponding stdio handle is set to + * NULL. Unfortunately DuplicateHandle will happily duplicate (HANDLE) -2, so + * this situation goes unnoticed until someone tries to use the duplicate. + * Therefore we filter out known-invalid handles here. */ if (handle == INVALID_HANDLE_VALUE || handle == NULL || handle == (HANDLE) -2) { @@ -284,8 +285,8 @@ int uv__stdio_create(uv_loop_t* loop, return ERROR_OUTOFMEMORY; } - /* Prepopulate the buffer with INVALID_HANDLE_VALUE handles so we can */ - /* clean up on failure. */ + /* Prepopulate the buffer with INVALID_HANDLE_VALUE handles so we can clean + * up on failure. */ CHILD_STDIO_COUNT(buffer) = count; for (i = 0; i < count; i++) { CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; @@ -303,12 +304,12 @@ int uv__stdio_create(uv_loop_t* loop, switch (fdopt.flags & (UV_IGNORE | UV_CREATE_PIPE | UV_INHERIT_FD | UV_INHERIT_STREAM)) { case UV_IGNORE: - /* Starting a process with no stdin/stout/stderr can confuse it. */ - /* So no matter what the user specified, we make sure the first */ - /* three FDs are always open in their typical modes, e.g. stdin */ - /* be readable and stdout/err should be writable. For FDs > 2, don't */ - /* do anything - all handles in the stdio buffer are initialized with */ - /* INVALID_HANDLE_VALUE, which should be okay. */ + /* Starting a process with no stdin/stout/stderr can confuse it. So no + * matter what the user specified, we make sure the first three FDs are + * always open in their typical modes, e. g. stdin be readable and + * stdout/err should be writable. For FDs > 2, don't do anything - all + * handles in the stdio buffer are initialized with. + * INVALID_HANDLE_VALUE, which should be okay. */ if (i <= 2) { DWORD access = (i == 0) ? FILE_GENERIC_READ : FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES; @@ -323,14 +324,14 @@ int uv__stdio_create(uv_loop_t* loop, break; case UV_CREATE_PIPE: { - /* Create a pair of two connected pipe ends; one end is turned into */ - /* an uv_pipe_t for use by the parent. The other one is given to */ - /* the child. */ + /* Create a pair of two connected pipe ends; one end is turned into an + * uv_pipe_t for use by the parent. The other one is given to the + * child. */ uv_pipe_t* parent_pipe = (uv_pipe_t*) fdopt.data.stream; HANDLE child_pipe = INVALID_HANDLE_VALUE; - /* Create a new, connected pipe pair. stdio[i].stream should point */ - /* to an uninitialized, but not connected pipe handle. */ + /* Create a new, connected pipe pair. stdio[i]. stream should point to + * an uninitialized, but not connected pipe handle. */ assert(fdopt.data.stream->type == UV_NAMED_PIPE); assert(!(fdopt.data.stream->flags & UV_HANDLE_CONNECTION)); assert(!(fdopt.data.stream->flags & UV_HANDLE_PIPESERVER)); @@ -354,8 +355,8 @@ int uv__stdio_create(uv_loop_t* loop, /* Make an inheritable duplicate of the handle. */ err = uv__duplicate_fd(loop, fdopt.data.fd, &child_handle); if (err) { - /* If fdopt.data.fd is not valid and fd fd <= 2, then ignore the */ - /* error. */ + /* If fdopt. data. fd is not valid and fd <= 2, then ignore the + * error. */ if (fdopt.data.fd <= 2 && err == ERROR_INVALID_HANDLE) { CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE; @@ -418,8 +419,8 @@ int uv__stdio_create(uv_loop_t* loop, if (stream_handle == NULL || stream_handle == INVALID_HANDLE_VALUE) { - /* The handle is already closed, or not yet created, or the */ - /* stream type is not supported. */ + /* The handle is already closed, or not yet created, or the stream + * type is not supported. */ err = ERROR_NOT_SUPPORTED; goto error; } diff --git a/Utilities/cmlibuv/src/win/process.c b/Utilities/cmlibuv/src/win/process.c index 25cfe87c44..24037b302c 100644 --- a/Utilities/cmlibuv/src/win/process.c +++ b/Utilities/cmlibuv/src/win/process.c @@ -360,8 +360,8 @@ static WCHAR* search_path(const WCHAR *file, return NULL; } - /* Find the start of the filename so we can split the directory from the */ - /* name. */ + /* Find the start of the filename so we can split the directory from the + * name. */ for (file_name_start = (WCHAR*)file + file_len; file_name_start > file && file_name_start[-1] != L'\\' @@ -556,8 +556,8 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { arg_count++; } - /* Adjust for potential quotes. Also assume the worst-case scenario */ - /* that every character needs escaping, so we need twice as much space. */ + /* Adjust for potential quotes. Also assume the worst-case scenario that + * every character needs escaping, so we need twice as much space. */ dst_len = dst_len * 2 + arg_count * 2; /* Allocate buffer for the final command line. */ @@ -739,7 +739,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { } } *ptr_copy = NULL; - assert(env_len == ptr - dst_copy); + assert(env_len == (size_t) (ptr - dst_copy)); /* sort our (UTF-16) copy */ qsort(env_copy, env_block_count-1, sizeof(wchar_t*), qsort_wcscmp); @@ -799,7 +799,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { var_size = GetEnvironmentVariableW(required_vars[i].wide, ptr, (int) (env_len - (ptr - dst))); - if (var_size != len-1) { /* race condition? */ + if (var_size != (DWORD) (len - 1)) { /* TODO: handle race condition? */ uv_fatal_error(GetLastError(), "GetEnvironmentVariableW"); } } @@ -815,7 +815,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { } /* Terminate with an extra NULL. */ - assert(env_len == (ptr - dst)); + assert(env_len == (size_t) (ptr - dst)); *ptr = L'\0'; uv__free(dst_copy); @@ -831,8 +831,13 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { */ static WCHAR* find_path(WCHAR *env) { for (; env != NULL && *env != 0; env += wcslen(env) + 1) { - if (wcsncmp(env, L"PATH=", 5) == 0) + if ((env[0] == L'P' || env[0] == L'p') && + (env[1] == L'A' || env[1] == L'a') && + (env[2] == L'T' || env[2] == L't') && + (env[3] == L'H' || env[3] == L'h') && + (env[4] == L'=')) { return &env[5]; + } } return NULL; @@ -865,9 +870,9 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) { assert(handle->exit_cb_pending); handle->exit_cb_pending = 0; - /* If we're closing, don't call the exit callback. Just schedule a close */ - /* callback now. */ - if (handle->flags & UV__HANDLE_CLOSING) { + /* If we're closing, don't call the exit callback. Just schedule a close + * callback now. */ + if (handle->flags & UV_HANDLE_CLOSING) { uv_want_endgame(loop, (uv_handle_t*) handle); return; } @@ -878,14 +883,14 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) { handle->wait_handle = INVALID_HANDLE_VALUE; } - /* Set the handle to inactive: no callbacks will be made after the exit */ - /* callback.*/ + /* Set the handle to inactive: no callbacks will be made after the exit + * callback. */ uv__handle_stop(handle); if (GetExitCodeProcess(handle->process_handle, &status)) { exit_code = status; } else { - /* Unable to to obtain the exit code. This should never happen. */ + /* Unable to obtain the exit code. This should never happen. */ exit_code = uv_translate_sys_error(GetLastError()); } @@ -900,8 +905,8 @@ void uv_process_close(uv_loop_t* loop, uv_process_t* handle) { uv__handle_closing(handle); if (handle->wait_handle != INVALID_HANDLE_VALUE) { - /* This blocks until either the wait was cancelled, or the callback has */ - /* completed. */ + /* This blocks until either the wait was cancelled, or the callback has + * completed. */ BOOL r = UnregisterWaitEx(handle->wait_handle, INVALID_HANDLE_VALUE); if (!r) { /* This should never happen, and if it happens, we can't recover... */ @@ -919,7 +924,7 @@ void uv_process_close(uv_loop_t* loop, uv_process_t* handle) { void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle) { assert(!handle->exit_cb_pending); - assert(handle->flags & UV__HANDLE_CLOSING); + assert(handle->flags & UV_HANDLE_CLOSING); assert(!(handle->flags & UV_HANDLE_CLOSED)); /* Clean-up the process handle. */ @@ -965,6 +970,8 @@ int uv_spawn(uv_loop_t* loop, UV_PROCESS_SETGID | UV_PROCESS_SETUID | UV_PROCESS_WINDOWS_HIDE | + UV_PROCESS_WINDOWS_HIDE_CONSOLE | + UV_PROCESS_WINDOWS_HIDE_GUI | UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS))); err = uv_utf8_to_utf16_alloc(options->file, &application); @@ -1066,7 +1073,8 @@ int uv_spawn(uv_loop_t* loop, process_flags = CREATE_UNICODE_ENVIRONMENT; - if (options->flags & UV_PROCESS_WINDOWS_HIDE) { + if ((options->flags & UV_PROCESS_WINDOWS_HIDE_CONSOLE) || + (options->flags & UV_PROCESS_WINDOWS_HIDE)) { /* Avoid creating console window if stdio is not inherited. */ for (i = 0; i < options->stdio_count; i++) { if (options->stdio[i].flags & UV_INHERIT_FD) @@ -1074,7 +1082,9 @@ int uv_spawn(uv_loop_t* loop, if (i == options->stdio_count - 1) process_flags |= CREATE_NO_WINDOW; } - + } + if ((options->flags & UV_PROCESS_WINDOWS_HIDE_GUI) || + (options->flags & UV_PROCESS_WINDOWS_HIDE)) { /* Use SW_HIDE to avoid any potential process window. */ startup.wShowWindow = SW_HIDE; } else { @@ -1160,14 +1170,13 @@ int uv_spawn(uv_loop_t* loop, } } - /* Spawn succeeded */ - /* Beyond this point, failure is reported asynchronously. */ + /* Spawn succeeded. Beyond this point, failure is reported asynchronously. */ process->process_handle = info.hProcess; process->pid = info.dwProcessId; - /* If the process isn't spawned as detached, assign to the global job */ - /* object so windows will kill it when the parent process dies. */ + /* If the process isn't spawned as detached, assign to the global job object + * so windows will kill it when the parent process dies. */ if (!(options->flags & UV_PROCESS_DETACHED)) { uv_once(&uv_global_job_handle_init_guard_, uv__init_global_job_handle); @@ -1194,7 +1203,8 @@ int uv_spawn(uv_loop_t* loop, if (fdopt->flags & UV_CREATE_PIPE && fdopt->data.stream->type == UV_NAMED_PIPE && ((uv_pipe_t*) fdopt->data.stream)->ipc) { - ((uv_pipe_t*) fdopt->data.stream)->pipe.conn.ipc_pid = info.dwProcessId; + ((uv_pipe_t*) fdopt->data.stream)->pipe.conn.ipc_remote_pid = + info.dwProcessId; } } @@ -1210,8 +1220,8 @@ int uv_spawn(uv_loop_t* loop, assert(!err); - /* Make the handle active. It will remain active until the exit callback */ - /* is made or the handle is closed, whichever happens first. */ + /* Make the handle active. It will remain active until the exit callback is + * made or the handle is closed, whichever happens first. */ uv__handle_start(process); /* Cleanup, whether we succeeded or failed. */ @@ -1242,16 +1252,16 @@ static int uv__kill(HANDLE process_handle, int signum) { case SIGTERM: case SIGKILL: case SIGINT: { - /* Unconditionally terminate the process. On Windows, killed processes */ - /* normally return 1. */ + /* Unconditionally terminate the process. On Windows, killed processes + * normally return 1. */ DWORD status; int err; if (TerminateProcess(process_handle, 1)) return 0; - /* If the process already exited before TerminateProcess was called, */ - /* TerminateProcess will fail with ERROR_ACCESS_DENIED. */ + /* If the process already exited before TerminateProcess was called,. + * TerminateProcess will fail with ERROR_ACCESS_DENIED. */ err = GetLastError(); if (err == ERROR_ACCESS_DENIED && GetExitCodeProcess(process_handle, &status) && diff --git a/Utilities/cmlibuv/src/win/req.c b/Utilities/cmlibuv/src/win/req.c deleted file mode 100644 index 111cc5e289..0000000000 --- a/Utilities/cmlibuv/src/win/req.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include <assert.h> - -#include "uv.h" -#include "internal.h" diff --git a/Utilities/cmlibuv/src/win/signal.c b/Utilities/cmlibuv/src/win/signal.c index a174da1f76..276dc60973 100644 --- a/Utilities/cmlibuv/src/win/signal.c +++ b/Utilities/cmlibuv/src/win/signal.c @@ -47,13 +47,13 @@ void uv_signals_init(void) { static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) { - /* Compare signums first so all watchers with the same signnum end up */ - /* adjacent. */ + /* Compare signums first so all watchers with the same signnum end up + * adjacent. */ if (w1->signum < w2->signum) return -1; if (w1->signum > w2->signum) return 1; - /* Sort by loop pointer, so we can easily look up the first item after */ - /* { .signum = x, .loop = NULL } */ + /* Sort by loop pointer, so we can easily look up the first item after + * { .signum = x, .loop = NULL }. */ if ((uintptr_t) w1->loop < (uintptr_t) w2->loop) return -1; if ((uintptr_t) w1->loop > (uintptr_t) w2->loop) return 1; @@ -90,7 +90,7 @@ int uv__signal_dispatch(int signum) { unsigned long previous = InterlockedExchange( (volatile LONG*) &handle->pending_signum, signum); - if (handle->flags & UV__SIGNAL_ONE_SHOT_DISPATCHED) + if (handle->flags & UV_SIGNAL_ONE_SHOT_DISPATCHED) continue; if (!previous) { @@ -98,8 +98,8 @@ int uv__signal_dispatch(int signum) { } dispatched = 1; - if (handle->flags & UV__SIGNAL_ONE_SHOT) - handle->flags |= UV__SIGNAL_ONE_SHOT_DISPATCHED; + if (handle->flags & UV_SIGNAL_ONE_SHOT) + handle->flags |= UV_SIGNAL_ONE_SHOT_DISPATCHED; } LeaveCriticalSection(&uv__signal_lock); @@ -118,10 +118,10 @@ static BOOL WINAPI uv__signal_control_handler(DWORD type) { case CTRL_CLOSE_EVENT: if (uv__signal_dispatch(SIGHUP)) { - /* Windows will terminate the process after the control handler */ - /* returns. After that it will just terminate our process. Therefore */ - /* block the signal handler so the main loop has some time to pick */ - /* up the signal and do something for a few seconds. */ + /* Windows will terminate the process after the control handler + * returns. After that it will just terminate our process. Therefore + * block the signal handler so the main loop has some time to pick up + * the signal and do something for a few seconds. */ Sleep(INFINITE); return TRUE; } @@ -129,8 +129,8 @@ static BOOL WINAPI uv__signal_control_handler(DWORD type) { case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: - /* These signals are only sent to services. Services have their own */ - /* notification mechanism, so there's no point in handling these. */ + /* These signals are only sent to services. Services have their own + * notification mechanism, so there's no point in handling these. */ default: /* We don't handle these. */ @@ -190,13 +190,13 @@ int uv__signal_start(uv_signal_t* handle, int signum, int oneshot) { /* Test for invalid signal values. */ - if (signum != SIGWINCH && (signum <= 0 || signum >= NSIG)) + if (signum <= 0 || signum >= NSIG) return UV_EINVAL; - /* Short circuit: if the signal watcher is already watching {signum} don't */ - /* go through the process of deregistering and registering the handler. */ - /* Additionally, this avoids pending signals getting lost in the (small) */ - /* time frame that handle->signum == 0. */ + /* Short circuit: if the signal watcher is already watching {signum} don't go + * through the process of deregistering and registering the handler. + * Additionally, this avoids pending signals getting lost in the (small) time + * frame that handle->signum == 0. */ if (signum == handle->signum) { handle->signal_cb = signal_cb; return 0; @@ -213,7 +213,7 @@ int uv__signal_start(uv_signal_t* handle, handle->signum = signum; if (oneshot) - handle->flags |= UV__SIGNAL_ONE_SHOT; + handle->flags |= UV_SIGNAL_ONE_SHOT; RB_INSERT(uv_signal_tree_s, &uv__signal_tree, handle); @@ -237,16 +237,16 @@ void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle, (volatile LONG*) &handle->pending_signum, 0); assert(dispatched_signum != 0); - /* Check if the pending signal equals the signum that we are watching for. */ - /* These can get out of sync when the handler is stopped and restarted */ - /* while the signal_req is pending. */ + /* Check if the pending signal equals the signum that we are watching for. + * These can get out of sync when the handler is stopped and restarted while + * the signal_req is pending. */ if (dispatched_signum == handle->signum) handle->signal_cb(handle, dispatched_signum); - if (handle->flags & UV__SIGNAL_ONE_SHOT) + if (handle->flags & UV_SIGNAL_ONE_SHOT) uv_signal_stop(handle); - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { /* When it is closing, it must be stopped at this point. */ assert(handle->signum == 0); uv_want_endgame(loop, (uv_handle_t*) handle); @@ -265,7 +265,7 @@ void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle) { void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); + assert(handle->flags & UV_HANDLE_CLOSING); assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(handle->signum == 0); diff --git a/Utilities/cmlibuv/src/win/stream.c b/Utilities/cmlibuv/src/win/stream.c index 13cbfdcb9e..7656627e90 100644 --- a/Utilities/cmlibuv/src/win/stream.c +++ b/Utilities/cmlibuv/src/win/stream.c @@ -105,12 +105,10 @@ int uv_read_stop(uv_stream_t* handle) { err = 0; if (handle->type == UV_TTY) { err = uv_tty_read_stop((uv_tty_t*) handle); + } else if (handle->type == UV_NAMED_PIPE) { + uv__pipe_read_stop((uv_pipe_t*) handle); } else { - if (handle->type == UV_NAMED_PIPE) { - uv__pipe_stop_read((uv_pipe_t*) handle); - } else { - handle->flags &= ~UV_HANDLE_READING; - } + handle->flags &= ~UV_HANDLE_READING; DECREASE_ACTIVE_COUNT(handle->loop, handle); } @@ -136,7 +134,8 @@ int uv_write(uv_write_t* req, err = uv_tcp_write(loop, req, (uv_tcp_t*) handle, bufs, nbufs, cb); break; case UV_NAMED_PIPE: - err = uv_pipe_write(loop, req, (uv_pipe_t*) handle, bufs, nbufs, cb); + err = uv__pipe_write( + loop, req, (uv_pipe_t*) handle, bufs, nbufs, NULL, cb); break; case UV_TTY: err = uv_tty_write(loop, req, (uv_tty_t*) handle, bufs, nbufs, cb); @@ -158,25 +157,18 @@ int uv_write2(uv_write_t* req, uv_loop_t* loop = handle->loop; int err; - if (!(handle->flags & UV_HANDLE_WRITABLE)) { - return UV_EPIPE; + if (send_handle == NULL) { + return uv_write(req, handle, bufs, nbufs, cb); } - err = ERROR_INVALID_PARAMETER; - switch (handle->type) { - case UV_NAMED_PIPE: - err = uv_pipe_write2(loop, - req, - (uv_pipe_t*) handle, - bufs, - nbufs, - send_handle, - cb); - break; - default: - assert(0); + if (handle->type != UV_NAMED_PIPE || !((uv_pipe_t*) handle)->ipc) { + return UV_EINVAL; + } else if (!(handle->flags & UV_HANDLE_WRITABLE)) { + return UV_EPIPE; } + err = uv__pipe_write( + loop, req, (uv_pipe_t*) handle, bufs, nbufs, send_handle, cb); return uv_translate_sys_error(err); } @@ -184,7 +176,7 @@ int uv_write2(uv_write_t* req, int uv_try_write(uv_stream_t* stream, const uv_buf_t bufs[], unsigned int nbufs) { - if (stream->flags & UV__HANDLE_CLOSING) + if (stream->flags & UV_HANDLE_CLOSING) return UV_EBADF; if (!(stream->flags & UV_HANDLE_WRITABLE)) return UV_EPIPE; diff --git a/Utilities/cmlibuv/src/win/tcp.c b/Utilities/cmlibuv/src/win/tcp.c index 39c1ff0565..3ce5548c0a 100644 --- a/Utilities/cmlibuv/src/win/tcp.c +++ b/Utilities/cmlibuv/src/win/tcp.c @@ -99,8 +99,8 @@ static int uv_tcp_set_socket(uv_loop_t* loop, if (!SetHandleInformation((HANDLE) socket, HANDLE_FLAG_INHERIT, 0)) return GetLastError(); - /* Associate it with the I/O completion port. */ - /* Use uv_handle_t pointer as completion key. */ + /* Associate it with the I/O completion port. Use uv_handle_t pointer as + * completion key. */ if (CreateIoCompletionPort((HANDLE)socket, loop->iocp, (ULONG_PTR)socket, @@ -118,15 +118,12 @@ static int uv_tcp_set_socket(uv_loop_t* loop, non_ifs_lsp = uv_tcp_non_ifs_lsp_ipv4; } - if (pSetFileCompletionNotificationModes && - !(handle->flags & UV_HANDLE_EMULATE_IOCP) && !non_ifs_lsp) { - if (pSetFileCompletionNotificationModes((HANDLE) socket, - FILE_SKIP_SET_EVENT_ON_HANDLE | - FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { - handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; - } else if (GetLastError() != ERROR_INVALID_FUNCTION) { + if (!(handle->flags & UV_HANDLE_EMULATE_IOCP) && !non_ifs_lsp) { + UCHAR sfcnm_flags = + FILE_SKIP_SET_EVENT_ON_HANDLE | FILE_SKIP_COMPLETION_PORT_ON_SUCCESS; + if (!SetFileCompletionNotificationModes((HANDLE) socket, sfcnm_flags)) return GetLastError(); - } + handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; } if (handle->flags & UV_HANDLE_TCP_NODELAY) { @@ -220,7 +217,7 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) { UNREGISTER_HANDLE_REQ(loop, handle, handle->stream.conn.shutdown_req); err = 0; - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { err = ERROR_OPERATION_ABORTED; } else if (shutdown(handle->socket, SD_SEND) == SOCKET_ERROR) { err = WSAGetLastError(); @@ -236,7 +233,7 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) { return; } - if (handle->flags & UV__HANDLE_CLOSING && + if (handle->flags & UV_HANDLE_CLOSING && handle->reqs_pending == 0) { assert(!(handle->flags & UV_HANDLE_CLOSED)); @@ -326,9 +323,9 @@ static int uv_tcp_try_bind(uv_tcp_t* handle, on = (flags & UV_TCP_IPV6ONLY) != 0; - /* TODO: how to handle errors? This may fail if there is no ipv4 stack */ - /* available, or when run on XP/2003 which have no support for dualstack */ - /* sockets. For now we're silently ignoring the error. */ + /* TODO: how to handle errors? This may fail if there is no ipv4 stack + * available, or when run on XP/2003 which have no support for dualstack + * sockets. For now we're silently ignoring the error. */ setsockopt(handle->socket, IPPROTO_IPV6, IPV6_V6ONLY, @@ -626,9 +623,9 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { uv_tcp_queue_accept(handle, req); } - /* Initialize other unused requests too, because uv_tcp_endgame */ - /* doesn't know how how many requests were initialized, so it will */ - /* try to clean up {uv_simultaneous_server_accepts} requests. */ + /* Initialize other unused requests too, because uv_tcp_endgame doesn't + * know how many requests were initialized, so it will try to clean up + * {uv_simultaneous_server_accepts} requests. */ for (i = simultaneous_accepts; i < uv_simultaneous_server_accepts; i++) { req = &handle->tcp.serv.accept_reqs[i]; UV_REQ_INIT(req, UV_ACCEPT); @@ -683,7 +680,7 @@ int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client) { req->next_pending = NULL; req->accept_socket = INVALID_SOCKET; - if (!(server->flags & UV__HANDLE_CLOSING)) { + if (!(server->flags & UV_HANDLE_CLOSING)) { /* Check if we're in a middle of changing the number of pending accepts. */ if (!(server->flags & UV_HANDLE_TCP_ACCEPT_STATE_CHANGING)) { uv_tcp_queue_accept(server, req); @@ -721,8 +718,8 @@ int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb, handle->alloc_cb = alloc_cb; INCREASE_ACTIVE_COUNT(loop, handle); - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ + /* If reading was stopped and then started again, there could still be a read + * request pending. */ if (!(handle->flags & UV_HANDLE_READ_PENDING)) { if (handle->flags & UV_HANDLE_EMULATE_IOCP && !handle->read_req.event_handle) { @@ -948,6 +945,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, uv_req_t* req) { DWORD bytes, flags, err; uv_buf_t buf; + int count; assert(handle->type == UV_TCP); @@ -965,8 +963,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, err = GET_REQ_SOCK_ERROR(req); if (err == WSAECONNABORTED) { - /* - * Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix. + /* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix. */ err = WSAECONNRESET; } @@ -1003,7 +1000,8 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, } /* Do nonblocking reads until the buffer is empty */ - while (handle->flags & UV_HANDLE_READING) { + count = 32; + while ((handle->flags & UV_HANDLE_READING) && (count-- > 0)) { buf = uv_buf_init(NULL, 0); handle->alloc_cb((uv_handle_t*) handle, 65536, &buf); if (buf.base == NULL || buf.len == 0) { @@ -1046,8 +1044,8 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, DECREASE_ACTIVE_COUNT(loop, handle); if (err == WSAECONNABORTED) { - /* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with */ - /* Unix. */ + /* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with + * Unix. */ err = WSAECONNRESET; } @@ -1119,10 +1117,9 @@ void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle, assert(handle->type == UV_TCP); - /* If handle->accepted_socket is not a valid socket, then */ - /* uv_queue_accept must have failed. This is a serious error. We stop */ - /* accepting connections and report this error to the connection */ - /* callback. */ + /* If handle->accepted_socket is not a valid socket, then uv_queue_accept + * must have failed. This is a serious error. We stop accepting connections + * and report this error to the connection callback. */ if (req->accept_socket == INVALID_SOCKET) { if (handle->flags & UV_HANDLE_LISTENING) { handle->flags &= ~UV_HANDLE_LISTENING; @@ -1147,9 +1144,9 @@ void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle, handle->stream.serv.connection_cb((uv_stream_t*)handle, 0); } } else { - /* Error related to accepted socket is ignored because the server */ - /* socket may still be healthy. If the server socket is broken */ - /* uv_queue_accept will detect it. */ + /* Error related to accepted socket is ignored because the server socket + * may still be healthy. If the server socket is broken uv_queue_accept + * will detect it. */ closesocket(req->accept_socket); req->accept_socket = INVALID_SOCKET; if (handle->flags & UV_HANDLE_LISTENING) { @@ -1171,7 +1168,7 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, err = 0; if (REQ_SUCCESS(req)) { - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { /* use UV_ECANCELED for consistency with Unix */ err = ERROR_OPERATION_ABORTED; } else if (setsockopt(handle->socket, @@ -1194,40 +1191,76 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, } -int uv_tcp_import(uv_tcp_t* tcp, uv__ipc_socket_info_ex* socket_info_ex, - int tcp_connection) { +int uv__tcp_xfer_export(uv_tcp_t* handle, + int target_pid, + uv__ipc_socket_xfer_type_t* xfer_type, + uv__ipc_socket_xfer_info_t* xfer_info) { + if (handle->flags & UV_HANDLE_CONNECTION) { + *xfer_type = UV__IPC_SOCKET_XFER_TCP_CONNECTION; + } else { + *xfer_type = UV__IPC_SOCKET_XFER_TCP_SERVER; + /* We're about to share the socket with another process. Because this is a + * listening socket, we assume that the other process will be accepting + * connections on it. Thus, before sharing the socket with another process, + * we call listen here in the parent process. */ + if (!(handle->flags & UV_HANDLE_LISTENING)) { + if (!(handle->flags & UV_HANDLE_BOUND)) { + return ERROR_NOT_SUPPORTED; + } + if (handle->delayed_error == 0 && + listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) { + handle->delayed_error = WSAGetLastError(); + } + } + } + + if (WSADuplicateSocketW(handle->socket, target_pid, &xfer_info->socket_info)) + return WSAGetLastError(); + xfer_info->delayed_error = handle->delayed_error; + + /* Mark the local copy of the handle as 'shared' so we behave in a way that's + * friendly to the process(es) that we share the socket with. */ + handle->flags |= UV_HANDLE_SHARED_TCP_SOCKET; + + return 0; +} + + +int uv__tcp_xfer_import(uv_tcp_t* tcp, + uv__ipc_socket_xfer_type_t xfer_type, + uv__ipc_socket_xfer_info_t* xfer_info) { int err; - SOCKET socket = WSASocketW(FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - &socket_info_ex->socket_info, - 0, - WSA_FLAG_OVERLAPPED); + SOCKET socket; + + assert(xfer_type == UV__IPC_SOCKET_XFER_TCP_SERVER || + xfer_type == UV__IPC_SOCKET_XFER_TCP_CONNECTION); + + socket = WSASocketW(FROM_PROTOCOL_INFO, + FROM_PROTOCOL_INFO, + FROM_PROTOCOL_INFO, + &xfer_info->socket_info, + 0, + WSA_FLAG_OVERLAPPED); if (socket == INVALID_SOCKET) { return WSAGetLastError(); } - err = uv_tcp_set_socket(tcp->loop, - tcp, - socket, - socket_info_ex->socket_info.iAddressFamily, - 1); + err = uv_tcp_set_socket( + tcp->loop, tcp, socket, xfer_info->socket_info.iAddressFamily, 1); if (err) { closesocket(socket); return err; } - if (tcp_connection) { + tcp->delayed_error = xfer_info->delayed_error; + tcp->flags |= UV_HANDLE_BOUND | UV_HANDLE_SHARED_TCP_SOCKET; + + if (xfer_type == UV__IPC_SOCKET_XFER_TCP_CONNECTION) { uv_connection_init((uv_stream_t*)tcp); tcp->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; } - tcp->flags |= UV_HANDLE_BOUND; - tcp->flags |= UV_HANDLE_SHARED_TCP_SOCKET; - - tcp->delayed_error = socket_info_ex->delayed_error; - tcp->loop->active_tcp_streams++; return 0; } @@ -1273,39 +1306,6 @@ int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { } -int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, - LPWSAPROTOCOL_INFOW protocol_info) { - if (!(handle->flags & UV_HANDLE_CONNECTION)) { - /* - * We're about to share the socket with another process. Because - * this is a listening socket, we assume that the other process will - * be accepting connections on it. So, before sharing the socket - * with another process, we call listen here in the parent process. - */ - - if (!(handle->flags & UV_HANDLE_LISTENING)) { - if (!(handle->flags & UV_HANDLE_BOUND)) { - return ERROR_INVALID_PARAMETER; - } - - if (!(handle->delayed_error)) { - if (listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) { - handle->delayed_error = WSAGetLastError(); - } - } - } - } - - if (WSADuplicateSocketW(handle->socket, pid, protocol_info)) { - return WSAGetLastError(); - } - - handle->flags |= UV_HANDLE_SHARED_TCP_SOCKET; - - return 0; -} - - int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) { if (handle->flags & UV_HANDLE_CONNECTION) { return UV_EINVAL; @@ -1346,8 +1346,8 @@ static int uv_tcp_try_cancel_io(uv_tcp_t* tcp) { non_ifs_lsp = (tcp->flags & UV_HANDLE_IPV6) ? uv_tcp_non_ifs_lsp_ipv6 : uv_tcp_non_ifs_lsp_ipv4; - /* If there are non-ifs LSPs then try to obtain a base handle for the */ - /* socket. This will always fail on Windows XP/3k. */ + /* If there are non-ifs LSPs then try to obtain a base handle for the socket. + * This will always fail on Windows XP/3k. */ if (non_ifs_lsp) { DWORD bytes; if (WSAIoctl(socket, @@ -1379,38 +1379,37 @@ void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) { int close_socket = 1; if (tcp->flags & UV_HANDLE_READ_PENDING) { - /* In order for winsock to do a graceful close there must not be any */ - /* any pending reads, or the socket must be shut down for writing */ + /* In order for winsock to do a graceful close there must not be any any + * pending reads, or the socket must be shut down for writing */ if (!(tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET)) { /* Just do shutdown on non-shared sockets, which ensures graceful close. */ shutdown(tcp->socket, SD_SEND); } else if (uv_tcp_try_cancel_io(tcp) == 0) { - /* In case of a shared socket, we try to cancel all outstanding I/O, */ - /* If that works, don't close the socket yet - wait for the read req to */ - /* return and close the socket in uv_tcp_endgame. */ + /* In case of a shared socket, we try to cancel all outstanding I/O,. If + * that works, don't close the socket yet - wait for the read req to + * return and close the socket in uv_tcp_endgame. */ close_socket = 0; } else { - /* When cancelling isn't possible - which could happen when an LSP is */ - /* present on an old Windows version, we will have to close the socket */ - /* with a read pending. That is not nice because trailing sent bytes */ - /* may not make it to the other side. */ + /* When cancelling isn't possible - which could happen when an LSP is + * present on an old Windows version, we will have to close the socket + * with a read pending. That is not nice because trailing sent bytes may + * not make it to the other side. */ } } else if ((tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET) && tcp->tcp.serv.accept_reqs != NULL) { - /* Under normal circumstances closesocket() will ensure that all pending */ - /* accept reqs are canceled. However, when the socket is shared the */ - /* presence of another reference to the socket in another process will */ - /* keep the accept reqs going, so we have to ensure that these are */ - /* canceled. */ + /* Under normal circumstances closesocket() will ensure that all pending + * accept reqs are canceled. However, when the socket is shared the + * presence of another reference to the socket in another process will keep + * the accept reqs going, so we have to ensure that these are canceled. */ if (uv_tcp_try_cancel_io(tcp) != 0) { - /* When cancellation is not possible, there is another option: we can */ - /* close the incoming sockets, which will also cancel the accept */ - /* operations. However this is not cool because we might inadvertently */ - /* close a socket that just accepted a new connection, which will */ - /* cause the connection to be aborted. */ + /* When cancellation is not possible, there is another option: we can + * close the incoming sockets, which will also cancel the accept + * operations. However this is not cool because we might inadvertently + * close a socket that just accepted a new connection, which will cause + * the connection to be aborted. */ unsigned int i; for (i = 0; i < uv_simultaneous_server_accepts; i++) { uv_tcp_accept_t* req = &tcp->tcp.serv.accept_reqs[i]; diff --git a/Utilities/cmlibuv/src/win/thread.c b/Utilities/cmlibuv/src/win/thread.c index 9eaad77cd0..fd4b7c9868 100644 --- a/Utilities/cmlibuv/src/win/thread.c +++ b/Utilities/cmlibuv/src/win/thread.c @@ -23,29 +23,15 @@ #include <limits.h> #include <stdlib.h> +#if defined(__MINGW64_VERSION_MAJOR) +/* MemoryBarrier expands to __mm_mfence in some cases (x86+sse2), which may + * require this header in some versions of mingw64. */ +#include <intrin.h> +#endif + #include "uv.h" #include "internal.h" - -#define HAVE_CONDVAR_API() (pInitializeConditionVariable != NULL) - -static int uv_cond_fallback_init(uv_cond_t* cond); -static void uv_cond_fallback_destroy(uv_cond_t* cond); -static void uv_cond_fallback_signal(uv_cond_t* cond); -static void uv_cond_fallback_broadcast(uv_cond_t* cond); -static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex); -static int uv_cond_fallback_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout); - -static int uv_cond_condvar_init(uv_cond_t* cond); -static void uv_cond_condvar_destroy(uv_cond_t* cond); -static void uv_cond_condvar_signal(uv_cond_t* cond); -static void uv_cond_condvar_broadcast(uv_cond_t* cond); -static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex); -static int uv_cond_condvar_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout); - - static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) { DWORD result; HANDLE existing_event, created_event; @@ -69,8 +55,8 @@ static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) { guard->ran = 1; } else { - /* We lost the race. Destroy the event we created and wait for the */ - /* existing one to become signaled. */ + /* We lost the race. Destroy the event we created and wait for the existing + * one to become signaled. */ CloseHandle(created_event); result = WaitForSingleObject(existing_event, INFINITE); assert(result == WAIT_OBJECT_0); @@ -138,7 +124,7 @@ int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { ctx->arg = arg; /* Create the thread in suspended state so we have a chance to pass - * its own creation handle to it */ + * its own creation handle to it */ thread = (HANDLE) _beginthreadex(NULL, 0, uv__thread_start, @@ -377,220 +363,35 @@ int uv_sem_trywait(uv_sem_t* sem) { } -/* This condition variable implementation is based on the SetEvent solution - * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - * We could not use the SignalObjectAndWait solution (section 3.4) because - * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and - * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. - */ - -static int uv_cond_fallback_init(uv_cond_t* cond) { - int err; - - /* Initialize the count to 0. */ - cond->fallback.waiters_count = 0; - - InitializeCriticalSection(&cond->fallback.waiters_count_lock); - - /* Create an auto-reset event. */ - cond->fallback.signal_event = CreateEvent(NULL, /* no security */ - FALSE, /* auto-reset event */ - FALSE, /* non-signaled initially */ - NULL); /* unnamed */ - if (!cond->fallback.signal_event) { - err = GetLastError(); - goto error2; - } - - /* Create a manual-reset event. */ - cond->fallback.broadcast_event = CreateEvent(NULL, /* no security */ - TRUE, /* manual-reset */ - FALSE, /* non-signaled */ - NULL); /* unnamed */ - if (!cond->fallback.broadcast_event) { - err = GetLastError(); - goto error; - } - - return 0; - -error: - CloseHandle(cond->fallback.signal_event); -error2: - DeleteCriticalSection(&cond->fallback.waiters_count_lock); - return uv_translate_sys_error(err); -} - - -static int uv_cond_condvar_init(uv_cond_t* cond) { - pInitializeConditionVariable(&cond->cond_var); - return 0; -} - - int uv_cond_init(uv_cond_t* cond) { - uv__once_init(); - - if (HAVE_CONDVAR_API()) - return uv_cond_condvar_init(cond); - else - return uv_cond_fallback_init(cond); -} - - -static void uv_cond_fallback_destroy(uv_cond_t* cond) { - if (!CloseHandle(cond->fallback.broadcast_event)) - abort(); - if (!CloseHandle(cond->fallback.signal_event)) - abort(); - DeleteCriticalSection(&cond->fallback.waiters_count_lock); -} - - -static void uv_cond_condvar_destroy(uv_cond_t* cond) { - /* nothing to do */ + InitializeConditionVariable(&cond->cond_var); + return 0; } void uv_cond_destroy(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_destroy(cond); - else - uv_cond_fallback_destroy(cond); -} - - -static void uv_cond_fallback_signal(uv_cond_t* cond) { - int have_waiters; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - have_waiters = cond->fallback.waiters_count > 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - if (have_waiters) - SetEvent(cond->fallback.signal_event); -} - - -static void uv_cond_condvar_signal(uv_cond_t* cond) { - pWakeConditionVariable(&cond->cond_var); + /* nothing to do */ + (void) &cond; } void uv_cond_signal(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_signal(cond); - else - uv_cond_fallback_signal(cond); -} - - -static void uv_cond_fallback_broadcast(uv_cond_t* cond) { - int have_waiters; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - have_waiters = cond->fallback.waiters_count > 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - if (have_waiters) - SetEvent(cond->fallback.broadcast_event); -} - - -static void uv_cond_condvar_broadcast(uv_cond_t* cond) { - pWakeAllConditionVariable(&cond->cond_var); + WakeConditionVariable(&cond->cond_var); } void uv_cond_broadcast(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_broadcast(cond); - else - uv_cond_fallback_broadcast(cond); -} - - -static int uv_cond_wait_helper(uv_cond_t* cond, uv_mutex_t* mutex, - DWORD dwMilliseconds) { - DWORD result; - int last_waiter; - HANDLE handles[2] = { - cond->fallback.signal_event, - cond->fallback.broadcast_event - }; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - cond->fallback.waiters_count++; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - /* It's ok to release the <mutex> here since Win32 manual-reset events */ - /* maintain state when used with <SetEvent>. This avoids the "lost wakeup" */ - /* bug. */ - uv_mutex_unlock(mutex); - - /* Wait for either event to become signaled due to <uv_cond_signal> being */ - /* called or <uv_cond_broadcast> being called. */ - result = WaitForMultipleObjects(2, handles, FALSE, dwMilliseconds); - - EnterCriticalSection(&cond->fallback.waiters_count_lock); - cond->fallback.waiters_count--; - last_waiter = result == WAIT_OBJECT_0 + 1 - && cond->fallback.waiters_count == 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - /* Some thread called <pthread_cond_broadcast>. */ - if (last_waiter) { - /* We're the last waiter to be notified or to stop waiting, so reset the */ - /* the manual-reset event. */ - ResetEvent(cond->fallback.broadcast_event); - } - - /* Reacquire the <mutex>. */ - uv_mutex_lock(mutex); - - if (result == WAIT_OBJECT_0 || result == WAIT_OBJECT_0 + 1) - return 0; - - if (result == WAIT_TIMEOUT) - return UV_ETIMEDOUT; - - abort(); - return -1; /* Satisfy the compiler. */ -} - - -static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (uv_cond_wait_helper(cond, mutex, INFINITE)) - abort(); -} - - -static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (!pSleepConditionVariableCS(&cond->cond_var, mutex, INFINITE)) - abort(); + WakeAllConditionVariable(&cond->cond_var); } void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_wait(cond, mutex); - else - uv_cond_fallback_wait(cond, mutex); -} - - -static int uv_cond_fallback_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout) { - return uv_cond_wait_helper(cond, mutex, (DWORD)(timeout / 1e6)); + if (!SleepConditionVariableCS(&cond->cond_var, mutex, INFINITE)) + abort(); } - -static int uv_cond_condvar_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout) { - if (pSleepConditionVariableCS(&cond->cond_var, mutex, (DWORD)(timeout / 1e6))) +int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { + if (SleepConditionVariableCS(&cond->cond_var, mutex, (DWORD)(timeout / 1e6))) return 0; if (GetLastError() != ERROR_TIMEOUT) abort(); @@ -598,15 +399,6 @@ static int uv_cond_condvar_timedwait(uv_cond_t* cond, } -int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, - uint64_t timeout) { - if (HAVE_CONDVAR_API()) - return uv_cond_condvar_timedwait(cond, mutex, timeout); - else - return uv_cond_fallback_timedwait(cond, mutex, timeout); -} - - int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { int err; diff --git a/Utilities/cmlibuv/src/win/timer.c b/Utilities/cmlibuv/src/win/timer.c deleted file mode 100644 index 7e006fedfa..0000000000 --- a/Utilities/cmlibuv/src/win/timer.c +++ /dev/null @@ -1,195 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include <assert.h> -#include <limits.h> - -#include "uv.h" -#include "internal.h" -#include "tree.h" -#include "handle-inl.h" - - -/* The number of milliseconds in one second. */ -#define UV__MILLISEC 1000 - - -void uv_update_time(uv_loop_t* loop) { - uint64_t new_time = uv__hrtime(UV__MILLISEC); - assert(new_time >= loop->time); - loop->time = new_time; -} - - -static int uv_timer_compare(uv_timer_t* a, uv_timer_t* b) { - if (a->due < b->due) - return -1; - if (a->due > b->due) - return 1; - /* - * compare start_id when both has the same due. start_id is - * allocated with loop->timer_counter in uv_timer_start(). - */ - if (a->start_id < b->start_id) - return -1; - if (a->start_id > b->start_id) - return 1; - return 0; -} - - -RB_GENERATE_STATIC(uv_timer_tree_s, uv_timer_s, tree_entry, uv_timer_compare) - - -int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_TIMER); - handle->timer_cb = NULL; - handle->repeat = 0; - - return 0; -} - - -void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -static uint64_t get_clamped_due_time(uint64_t loop_time, uint64_t timeout) { - uint64_t clamped_timeout; - - clamped_timeout = loop_time + timeout; - if (clamped_timeout < timeout) - clamped_timeout = (uint64_t) -1; - - return clamped_timeout; -} - - -int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout, - uint64_t repeat) { - uv_loop_t* loop = handle->loop; - uv_timer_t* old; - - if (timer_cb == NULL) - return UV_EINVAL; - - if (uv__is_active(handle)) - uv_timer_stop(handle); - - handle->timer_cb = timer_cb; - handle->due = get_clamped_due_time(loop->time, timeout); - handle->repeat = repeat; - uv__handle_start(handle); - - /* start_id is the second index to be compared in uv__timer_cmp() */ - handle->start_id = handle->loop->timer_counter++; - - old = RB_INSERT(uv_timer_tree_s, &loop->timers, handle); - assert(old == NULL); - - return 0; -} - - -int uv_timer_stop(uv_timer_t* handle) { - uv_loop_t* loop = handle->loop; - - if (!uv__is_active(handle)) - return 0; - - RB_REMOVE(uv_timer_tree_s, &loop->timers, handle); - uv__handle_stop(handle); - - return 0; -} - - -int uv_timer_again(uv_timer_t* handle) { - /* If timer_cb is NULL that means that the timer was never started. */ - if (!handle->timer_cb) { - return UV_EINVAL; - } - - if (handle->repeat) { - uv_timer_stop(handle); - uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat); - } - - return 0; -} - - -void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) { - assert(handle->type == UV_TIMER); - handle->repeat = repeat; -} - - -uint64_t uv_timer_get_repeat(const uv_timer_t* handle) { - assert(handle->type == UV_TIMER); - return handle->repeat; -} - - -DWORD uv__next_timeout(const uv_loop_t* loop) { - uv_timer_t* timer; - int64_t delta; - - /* Check if there are any running timers - * Need to cast away const first, since RB_MIN doesn't know what we are - * going to do with this return value, it can't be marked const - */ - timer = RB_MIN(uv_timer_tree_s, &((uv_loop_t*)loop)->timers); - if (timer) { - delta = timer->due - loop->time; - if (delta >= UINT_MAX - 1) { - /* A timeout value of UINT_MAX means infinite, so that's no good. */ - return UINT_MAX - 1; - } else if (delta < 0) { - /* Negative timeout values are not allowed */ - return 0; - } else { - return (DWORD)delta; - } - } else { - /* No timers */ - return INFINITE; - } -} - - -void uv_process_timers(uv_loop_t* loop) { - uv_timer_t* timer; - - /* Call timer callbacks */ - for (timer = RB_MIN(uv_timer_tree_s, &loop->timers); - timer != NULL && timer->due <= loop->time; - timer = RB_MIN(uv_timer_tree_s, &loop->timers)) { - - uv_timer_stop(timer); - uv_timer_again(timer); - timer->timer_cb((uv_timer_t*) timer); - } -} diff --git a/Utilities/cmlibuv/src/win/tty.c b/Utilities/cmlibuv/src/win/tty.c index ecf7bc9b5b..f38e9a8863 100644 --- a/Utilities/cmlibuv/src/win/tty.c +++ b/Utilities/cmlibuv/src/win/tty.c @@ -25,7 +25,7 @@ #include <stdlib.h> #if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" +# include "uv/stdint-msvc2008.h" #else # include <stdint.h> #endif @@ -164,7 +164,7 @@ void uv_console_init(void) { OPEN_EXISTING, 0, 0); - if (uv__tty_console_handle != NULL) { + if (uv__tty_console_handle != INVALID_HANDLE_VALUE) { QueueUserWorkItem(uv__tty_console_resize_message_loop_thread, NULL, WT_EXECUTELONGFUNCTION); @@ -172,9 +172,12 @@ void uv_console_init(void) { } -int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { +int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int unused) { + BOOL readable; + DWORD NumberOfEvents; HANDLE handle; CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info; + (void)unused; uv__once_init(); handle = (HANDLE) uv__get_osfhandle(fd); @@ -199,14 +202,15 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { fd = -1; } + readable = GetNumberOfConsoleInputEvents(handle, &NumberOfEvents); if (!readable) { /* Obtain the screen buffer info with the output handle. */ if (!GetConsoleScreenBufferInfo(handle, &screen_buffer_info)) { return uv_translate_sys_error(GetLastError()); } - /* Obtain the the tty_output_lock because the virtual window state is */ - /* shared between all uv_tty_t handles. */ + /* Obtain the tty_output_lock because the virtual window state is shared + * between all uv_tty_t handles. */ uv_sem_wait(&uv_tty_output_lock); if (uv__vterm_state == UV_UNCHECKED) @@ -356,6 +360,8 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { } } else { was_reading = 0; + alloc_cb = NULL; + read_cb = NULL; } uv_sem_wait(&uv_tty_output_lock); @@ -382,12 +388,6 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { } -int uv_is_tty(uv_file file) { - DWORD result; - return GetConsoleMode((HANDLE) _get_osfhandle(file), &result) != 0; -} - - int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { CONSOLE_SCREEN_BUFFER_INFO info; @@ -484,8 +484,8 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) { bytes = MAX_INPUT_BUFFER_LENGTH; } - /* At last, unicode! */ - /* One utf-16 codeunit never takes more than 3 utf-8 codeunits to encode */ + /* At last, unicode! One utf-16 codeunit never takes more than 3 utf-8 + * codeunits to encode. */ chars = bytes / 3; status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS); @@ -620,10 +620,10 @@ static const char* get_vt100_fn_key(DWORD code, char shift, char ctrl, } switch (code) { - /* These mappings are the same as Cygwin's. Unmodified and alt-modified */ - /* keypad keys comply with linux console, modifiers comply with xterm */ - /* modifier usage. F1..f12 and shift-f1..f10 comply with linux console, */ - /* f6..f12 with and without modifiers comply with rxvt. */ + /* These mappings are the same as Cygwin's. Unmodified and alt-modified + * keypad keys comply with linux console, modifiers comply with xterm + * modifier usage. F1. f12 and shift-f1. f10 comply with linux console, f6. + * f12 with and without modifiers comply with rxvt. */ VK_CASE(VK_INSERT, "[2~", "[2;2~", "[2;5~", "[2;6~") VK_CASE(VK_END, "[4~", "[4;2~", "[4;5~", "[4;6~") VK_CASE(VK_DOWN, "[B", "[1;2B", "[1;5B", "[1;6B") @@ -706,8 +706,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, goto out; } - /* Windows sends a lot of events that we're not interested in, so buf */ - /* will be allocated on demand, when there's actually something to emit. */ + /* Windows sends a lot of events that we're not interested in, so buf will be + * allocated on demand, when there's actually something to emit. */ buf = uv_null_buf_; buf_used = 0; @@ -733,16 +733,17 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, continue; } - /* Ignore keyup events, unless the left alt key was held and a valid */ - /* unicode character was emitted. */ - if (!KEV.bKeyDown && !(((KEV.dwControlKeyState & LEFT_ALT_PRESSED) || - KEV.wVirtualKeyCode==VK_MENU) && KEV.uChar.UnicodeChar != 0)) { + /* Ignore keyup events, unless the left alt key was held and a valid + * unicode character was emitted. */ + if (!KEV.bKeyDown && + KEV.wVirtualKeyCode != VK_MENU && + KEV.uChar.UnicodeChar != 0) { continue; } - /* Ignore keypresses to numpad number keys if the left alt is held */ - /* because the user is composing a character, or windows simulating */ - /* this. */ + /* Ignore keypresses to numpad number keys if the left alt is held + * because the user is composing a character, or windows simulating this. + */ if ((KEV.dwControlKeyState & LEFT_ALT_PRESSED) && !(KEV.dwControlKeyState & ENHANCED_KEY) && (KEV.wVirtualKeyCode == VK_INSERT || @@ -779,8 +780,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, continue; } - /* Prefix with \u033 if alt was held, but alt was not used as part */ - /* a compose sequence. */ + /* Prefix with \u033 if alt was held, but alt was not used as part a + * compose sequence. */ if ((KEV.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) && !(KEV.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) && KEV.bKeyDown) { @@ -793,8 +794,9 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, if (KEV.uChar.UnicodeChar >= 0xDC00 && KEV.uChar.UnicodeChar < 0xE000) { /* UTF-16 surrogate pair */ - WCHAR utf16_buffer[2] = { handle->tty.rd.last_utf16_high_surrogate, - KEV.uChar.UnicodeChar}; + WCHAR utf16_buffer[2]; + utf16_buffer[0] = handle->tty.rd.last_utf16_high_surrogate; + utf16_buffer[1] = KEV.uChar.UnicodeChar; char_len = WideCharToMultiByte(CP_UTF8, 0, utf16_buffer, @@ -818,8 +820,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, /* Whatever happened, the last character wasn't a high surrogate. */ handle->tty.rd.last_utf16_high_surrogate = 0; - /* If the utf16 character(s) couldn't be converted something must */ - /* be wrong. */ + /* If the utf16 character(s) couldn't be converted something must be + * wrong. */ if (!char_len) { handle->flags &= ~UV_HANDLE_READING; DECREASE_ACTIVE_COUNT(loop, handle); @@ -943,21 +945,15 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle, handle->read_cb((uv_stream_t*) handle, uv_translate_sys_error(GET_REQ_ERROR(req)), &buf); - } else { - /* The read was cancelled, or whatever we don't care */ - handle->read_cb((uv_stream_t*) handle, 0, &buf); } - } else { - if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { - /* Read successful */ - /* TODO: read unicode, convert to utf-8 */ + if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING) && + req->u.io.overlapped.InternalHigh != 0) { + /* Read successful. TODO: read unicode, convert to utf-8 */ DWORD bytes = req->u.io.overlapped.InternalHigh; handle->read_cb((uv_stream_t*) handle, bytes, &buf); - } else { - handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING; - handle->read_cb((uv_stream_t*) handle, 0, &buf); } + handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING; } /* Wait for more input events. */ @@ -975,9 +971,9 @@ void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle, assert(handle->type == UV_TTY); assert(handle->flags & UV_HANDLE_TTY_READABLE); - /* If the read_line_buffer member is zero, it must have been an raw read. */ - /* Otherwise it was a line-buffered read. */ - /* FIXME: This is quite obscure. Use a flag or something. */ + /* If the read_line_buffer member is zero, it must have been an raw read. + * Otherwise it was a line-buffered read. FIXME: This is quite obscure. Use a + * flag or something. */ if (handle->tty.rd.read_line_buffer.len == 0) { uv_process_tty_read_raw_req(loop, handle, req); } else { @@ -999,14 +995,14 @@ int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb, handle->read_cb = read_cb; handle->alloc_cb = alloc_cb; - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ + /* If reading was stopped and then started again, there could still be a read + * request pending. */ if (handle->flags & UV_HANDLE_READ_PENDING) { return 0; } - /* Maybe the user stopped reading half-way while processing key events. */ - /* Short-circuit if this could be the case. */ + /* Maybe the user stopped reading half-way while processing key events. + * Short-circuit if this could be the case. */ if (handle->tty.rd.last_key_len > 0) { SET_REQ_SUCCESS(&handle->read_req); uv_insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req); @@ -1033,9 +1029,10 @@ int uv_tty_read_stop(uv_tty_t* handle) { return 0; if (handle->flags & UV_HANDLE_TTY_RAW) { - /* Cancel raw read */ - /* Write some bullshit event to force the console wait to return. */ + /* Cancel raw read. Write some bullshit event to force the console wait to + * return. */ memset(&record, 0, sizeof record); + record.EventType = FOCUS_EVENT; if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) { return GetLastError(); } @@ -1116,8 +1113,8 @@ static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) { uv_tty_virtual_offset = info->dwCursorPosition.Y; } else if (uv_tty_virtual_offset < info->dwCursorPosition.Y - uv_tty_virtual_height + 1) { - /* If suddenly find the cursor outside of the virtual window, it must */ - /* have somehow scrolled. Update the virtual window offset. */ + /* If suddenly find the cursor outside of the virtual window, it must have + * somehow scrolled. Update the virtual window offset. */ uv_tty_virtual_offset = info->dwCursorPosition.Y - uv_tty_virtual_height + 1; } @@ -1304,8 +1301,8 @@ static int uv_tty_clear(uv_tty_t* handle, int dir, char entire_screen, x2 = 0; x2r = 1; } else { - /* Clear to end of row. We pretend the console is 65536 characters wide, */ - /* uv_tty_make_real_coord will clip it to the actual console width. */ + /* Clear to end of row. We pretend the console is 65536 characters wide, + * uv_tty_make_real_coord will clip it to the actual console width. */ x2 = 0xffff; x2r = 0; } @@ -1613,8 +1610,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle, const uv_buf_t bufs[], unsigned int nbufs, DWORD* error) { - /* We can only write 8k characters at a time. Windows can't handle */ - /* much more characters in a single console write anyway. */ + /* We can only write 8k characters at a time. Windows can't handle much more + * characters in a single console write anyway. */ WCHAR utf16_buf[MAX_CONSOLE_CHAR]; WCHAR* utf16_buffer; DWORD utf16_buf_used = 0; @@ -1650,9 +1647,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle, unsigned char previous_eol = handle->tty.wr.previous_eol; unsigned char ansi_parser_state = handle->tty.wr.ansi_parser_state; - /* Store the error here. If we encounter an error, stop trying to do i/o */ - /* but keep parsing the buffer so we leave the parser in a consistent */ - /* state. */ + /* Store the error here. If we encounter an error, stop trying to do i/o but + * keep parsing the buffer so we leave the parser in a consistent state. */ *error = ERROR_SUCCESS; utf16_buffer = utf16_buf; @@ -1700,9 +1696,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle, for (j = 0; j < buf.len; j++) { unsigned char c = buf.base[j]; - /* Run the character through the utf8 decoder We happily accept non */ - /* shortest form encodings and invalid code points - there's no real */ - /* harm that can be done. */ + /* Run the character through the utf8 decoder We happily accept non + * shortest form encodings and invalid code points - there's no real harm + * that can be done. */ if (utf8_bytes_left == 0) { /* Read utf-8 start byte */ DWORD first_zero_bit; @@ -1742,8 +1738,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle, /* Start byte where continuation was expected. */ utf8_bytes_left = 0; utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - /* Patch buf offset so this character will be parsed again as a */ - /* start byte. */ + /* Patch buf offset so this character will be parsed again as a start + * byte. */ j--; } @@ -1776,8 +1772,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle, case '_': case 'P': case ']': - /* Not supported, but we'll have to parse until we see a stop */ - /* code, e.g. ESC \ or BEL. */ + /* Not supported, but we'll have to parse until we see a stop code, + * e. g. ESC \ or BEL. */ ansi_parser_state = ANSI_ST_CONTROL; continue; @@ -1859,8 +1855,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle, continue; } else { - /* If ANSI_IN_ARG is not set, add another argument and */ - /* default it to 0. */ + /* If ANSI_IN_ARG is not set, add another argument and default it + * to 0. */ + /* Check for too many arguments */ if (handle->tty.wr.ansi_csi_argc >= ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) { ansi_parser_state |= ANSI_IGNORE; @@ -1874,9 +1871,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle, } else if (utf8_codepoint == '?' && !(ansi_parser_state & ANSI_IN_ARG) && handle->tty.wr.ansi_csi_argc == 0) { - /* Ignores '?' if it is the first character after CSI[ */ - /* This is an extension character from the VT100 codeset */ - /* that is supported and used by most ANSI terminals today. */ + /* Ignores '?' if it is the first character after CSI[. This is an + * extension character from the VT100 codeset that is supported and + * used by most ANSI terminals today. */ continue; } else if (utf8_codepoint >= '@' && utf8_codepoint <= '~' && @@ -2006,8 +2003,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle, continue; } else { - /* We don't support commands that use private mode characters or */ - /* intermediaries. Ignore the rest of the sequence. */ + /* We don't support commands that use private mode characters or + * intermediaries. Ignore the rest of the sequence. */ ansi_parser_state |= ANSI_IGNORE; continue; } @@ -2020,8 +2017,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle, } } else if (ansi_parser_state & ANSI_ST_CONTROL) { - /* Unsupported control code */ - /* Ignore everything until we see BEL or ESC \ */ + /* Unsupported control code. + * Ignore everything until we see `BEL` or `ESC \`. */ if (ansi_parser_state & ANSI_IN_STRING) { if (!(ansi_parser_state & ANSI_BACKSLASH_SEEN)) { if (utf8_codepoint == '"') { @@ -2055,9 +2052,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle, abort(); } - /* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the */ - /* windows console doesn't really support UTF-16, so just emit the */ - /* replacement character. */ + /* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the windows + * console doesn't really support UTF-16, so just emit the replacement + * character. */ if (utf8_codepoint > 0xffff) { utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; } @@ -2071,10 +2068,10 @@ static int uv_tty_write_bufs(uv_tty_t* handle, utf16_buf[utf16_buf_used++] = L'\r'; utf16_buf[utf16_buf_used++] = L'\n'; } else if (utf8_codepoint == 0x0d && previous_eol == 0x0a) { - /* \n was followed by \r; do not print the \r, since */ - /* the source was either \r\n\r (so the second \r is */ - /* redundant) or was \n\r (so the \n was processed */ - /* by the last case and an \r automatically inserted). */ + /* \n was followed by \r; do not print the \r, since the source was + * either \r\n\r (so the second \r is redundant) or was \n\r (so the + * \n was processed by the last case and an \r automatically + * inserted). */ } else { /* \r without \n; print \r as-is. */ ENSURE_BUFFER_SPACE(1); @@ -2182,14 +2179,14 @@ void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, void uv_tty_close(uv_tty_t* handle) { assert(handle->u.fd == -1 || handle->u.fd > 2); + if (handle->flags & UV_HANDLE_READING) + uv_tty_read_stop(handle); + if (handle->u.fd == -1) CloseHandle(handle->handle); else close(handle->u.fd); - if (handle->flags & UV_HANDLE_READING) - uv_tty_read_stop(handle); - handle->u.fd = -1; handle->handle = INVALID_HANDLE_VALUE; handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); @@ -2209,7 +2206,7 @@ void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) { /* TTY shutdown is really just a no-op */ if (handle->stream.conn.shutdown_req->cb) { - if (handle->flags & UV__HANDLE_CLOSING) { + if (handle->flags & UV_HANDLE_CLOSING) { handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, UV_ECANCELED); } else { handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, 0); @@ -2222,10 +2219,10 @@ void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) { return; } - if (handle->flags & UV__HANDLE_CLOSING && + if (handle->flags & UV_HANDLE_CLOSING && handle->reqs_pending == 0) { - /* The wait handle used for raw reading should be unregistered when the */ - /* wait callback runs. */ + /* The wait handle used for raw reading should be unregistered when the + * wait callback runs. */ assert(!(handle->flags & UV_HANDLE_TTY_READABLE) || handle->tty.rd.read_raw_wait == NULL); diff --git a/Utilities/cmlibuv/src/win/udp.c b/Utilities/cmlibuv/src/win/udp.c index cd1d0e07b2..37df849f8f 100644 --- a/Utilities/cmlibuv/src/win/udp.c +++ b/Utilities/cmlibuv/src/win/udp.c @@ -74,8 +74,8 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket, return GetLastError(); } - /* Associate it with the I/O completion port. */ - /* Use uv_handle_t pointer as completion key. */ + /* Associate it with the I/O completion port. Use uv_handle_t pointer as + * completion key. */ if (CreateIoCompletionPort((HANDLE)socket, loop->iocp, (ULONG_PTR)socket, @@ -83,31 +83,28 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket, return GetLastError(); } - if (pSetFileCompletionNotificationModes) { - /* All known Windows that support SetFileCompletionNotificationModes */ - /* have a bug that makes it impossible to use this function in */ - /* conjunction with datagram sockets. We can work around that but only */ - /* if the user is using the default UDP driver (AFD) and has no other */ - /* LSPs stacked on top. Here we check whether that is the case. */ - opt_len = (int) sizeof info; - if (getsockopt(socket, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &info, - &opt_len) == SOCKET_ERROR) { - return GetLastError(); - } + /* All known Windows that support SetFileCompletionNotificationModes have a + * bug that makes it impossible to use this function in conjunction with + * datagram sockets. We can work around that but only if the user is using + * the default UDP driver (AFD) and has no other. LSPs stacked on top. Here + * we check whether that is the case. */ + opt_len = (int) sizeof info; + if (getsockopt( + socket, SOL_SOCKET, SO_PROTOCOL_INFOW, (char*) &info, &opt_len) == + SOCKET_ERROR) { + return GetLastError(); + } - if (info.ProtocolChain.ChainLen == 1) { - if (pSetFileCompletionNotificationModes((HANDLE)socket, - FILE_SKIP_SET_EVENT_ON_HANDLE | - FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { - handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; - handle->func_wsarecv = uv_wsarecv_workaround; - handle->func_wsarecvfrom = uv_wsarecvfrom_workaround; - } else if (GetLastError() != ERROR_INVALID_FUNCTION) { - return GetLastError(); - } + if (info.ProtocolChain.ChainLen == 1) { + if (SetFileCompletionNotificationModes( + (HANDLE) socket, + FILE_SKIP_SET_EVENT_ON_HANDLE | + FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { + handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; + handle->func_wsarecv = uv_wsarecv_workaround; + handle->func_wsarecvfrom = uv_wsarecvfrom_workaround; + } else if (GetLastError() != ERROR_INVALID_FUNCTION) { + return GetLastError(); } } @@ -191,7 +188,7 @@ void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) { void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING && + if (handle->flags & UV_HANDLE_CLOSING && handle->reqs_pending == 0) { assert(!(handle->flags & UV_HANDLE_CLOSED)); uv__handle_close(handle); @@ -245,12 +242,12 @@ static int uv_udp_maybe_bind(uv_udp_t* handle, handle->flags |= UV_HANDLE_IPV6; if (addr->sa_family == AF_INET6 && !(flags & UV_UDP_IPV6ONLY)) { - /* On windows IPV6ONLY is on by default. */ - /* If the user doesn't specify it libuv turns it off. */ + /* On windows IPV6ONLY is on by default. If the user doesn't specify it + * libuv turns it off. */ - /* TODO: how to handle errors? This may fail if there is no ipv4 stack */ - /* available, or when run on XP/2003 which have no support for dualstack */ - /* sockets. For now we're silently ignoring the error. */ + /* TODO: how to handle errors? This may fail if there is no ipv4 stack + * available, or when run on XP/2003 which have no support for dualstack + * sockets. For now we're silently ignoring the error. */ setsockopt(handle->socket, IPPROTO_IPV6, IPV6_V6ONLY, @@ -369,7 +366,7 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, int err; if (handle->flags & UV_HANDLE_READING) { - return WSAEALREADY; + return UV_EALREADY; } err = uv_udp_maybe_bind(handle, @@ -377,7 +374,7 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, sizeof(uv_addr_ip4_any_), 0); if (err) - return err; + return uv_translate_sys_error(err); handle->flags |= UV_HANDLE_READING; INCREASE_ACTIVE_COUNT(loop, handle); @@ -386,8 +383,8 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, handle->recv_cb = recv_cb; handle->alloc_cb = alloc_cb; - /* If reading was stopped and then started again, there could still be a */ - /* recv request pending. */ + /* If reading was stopped and then started again, there could still be a recv + * request pending. */ if (!(handle->flags & UV_HANDLE_READ_PENDING)) uv_udp_queue_recv(loop, handle); @@ -467,19 +464,19 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, if (!REQ_SUCCESS(req)) { DWORD err = GET_REQ_SOCK_ERROR(req); if (err == WSAEMSGSIZE) { - /* Not a real error, it just indicates that the received packet */ - /* was bigger than the receive buffer. */ + /* Not a real error, it just indicates that the received packet was + * bigger than the receive buffer. */ } else if (err == WSAECONNRESET || err == WSAENETRESET) { - /* A previous sendto operation failed; ignore this error. If */ - /* zero-reading we need to call WSARecv/WSARecvFrom _without_ the */ - /* MSG_PEEK flag to clear out the error queue. For nonzero reads, */ - /* immediately queue a new receive. */ + /* A previous sendto operation failed; ignore this error. If zero-reading + * we need to call WSARecv/WSARecvFrom _without_ the. MSG_PEEK flag to + * clear out the error queue. For nonzero reads, immediately queue a new + * receive. */ if (!(handle->flags & UV_HANDLE_ZERO_READ)) { goto done; } } else { - /* A real error occurred. Report the error to the user only if we're */ - /* currently reading. */ + /* A real error occurred. Report the error to the user only if we're + * currently reading. */ if (handle->flags & UV_HANDLE_READING) { uv_udp_recv_stop(handle); buf = (handle->flags & UV_HANDLE_ZERO_READ) ? @@ -503,8 +500,8 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, struct sockaddr_storage from; int from_len; - /* Do a nonblocking receive */ - /* TODO: try to read multiple datagrams at once. FIONREAD maybe? */ + /* Do a nonblocking receive. + * TODO: try to read multiple datagrams at once. FIONREAD maybe? */ buf = uv_buf_init(NULL, 0); handle->alloc_cb((uv_handle_t*) handle, 65536, &buf); if (buf.base == NULL || buf.len == 0) { @@ -741,7 +738,7 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) return UV_EINVAL; } - if (!(handle->flags & UV_HANDLE_BOUND)) + if (handle->socket == INVALID_SOCKET) return UV_EBADF; if (addr_st.ss_family == AF_INET) { @@ -772,7 +769,7 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) int uv_udp_set_broadcast(uv_udp_t* handle, int value) { BOOL optval = (BOOL) value; - if (!(handle->flags & UV_HANDLE_BOUND)) + if (handle->socket == INVALID_SOCKET) return UV_EBADF; if (setsockopt(handle->socket, @@ -818,7 +815,7 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { return UV_EINVAL; \ } \ \ - if (!(handle->flags & UV_HANDLE_BOUND)) \ + if (handle->socket == INVALID_SOCKET) \ return UV_EBADF; \ \ if (!(handle->flags & UV_HANDLE_IPV6)) { \ diff --git a/Utilities/cmlibuv/src/win/util.c b/Utilities/cmlibuv/src/win/util.c index 49b5bc7206..923789129e 100644 --- a/Utilities/cmlibuv/src/win/util.c +++ b/Utilities/cmlibuv/src/win/util.c @@ -74,10 +74,6 @@ static char *process_title; static CRITICAL_SECTION process_title_lock; -/* Cached copy of the process id, written once. */ -static DWORD current_pid = 0; - - /* Interval (in seconds) of the high-resolution clock. */ static double hrtime_interval_ = 0; @@ -149,8 +145,8 @@ int uv_exepath(char* buffer, size_t* size_ptr) { uv__free(utf16_buffer); - /* utf8_len *does* include the terminating null at this point, but the */ - /* returned size shouldn't. */ + /* utf8_len *does* include the terminating null at this point, but the + * returned size shouldn't. */ *size_ptr = utf8_len - 1; return 0; @@ -173,16 +169,16 @@ int uv_cwd(char* buffer, size_t* size) { if (utf16_len == 0) { return uv_translate_sys_error(GetLastError()); } else if (utf16_len > MAX_PATH) { - /* This should be impossible; however the CRT has a code path to deal */ - /* with this scenario, so I added a check anyway. */ + /* This should be impossible; however the CRT has a code path to deal with + * this scenario, so I added a check anyway. */ return UV_EIO; } /* utf16_len contains the length, *not* including the terminating null. */ utf16_buffer[utf16_len] = L'\0'; - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed.*/ + /* The returned directory should not have a trailing slash, unless it points + * at a drive root, like c:\. Remove it if needed. */ if (utf16_buffer[utf16_len - 1] == L'\\' && !(utf16_len == 3 && utf16_buffer[1] == L':')) { utf16_len--; @@ -239,9 +235,9 @@ int uv_chdir(const char* dir) { utf16_buffer, MAX_PATH) == 0) { DWORD error = GetLastError(); - /* The maximum length of the current working directory is 260 chars, */ - /* including terminating null. If it doesn't fit, the path name must be */ - /* too long. */ + /* The maximum length of the current working directory is 260 chars, + * including terminating null. If it doesn't fit, the path name must be too + * long. */ if (error == ERROR_INSUFFICIENT_BUFFER) { return UV_ENAMETOOLONG; } else { @@ -253,9 +249,9 @@ int uv_chdir(const char* dir) { return uv_translate_sys_error(GetLastError()); } - /* Windows stores the drive-local path in an "hidden" environment variable, */ - /* which has the form "=C:=C:\Windows". SetCurrentDirectory does not */ - /* update this, so we'll have to do it. */ + /* Windows stores the drive-local path in an "hidden" environment variable, + * which has the form "=C:=C:\Windows". SetCurrentDirectory does not update + * this, so we'll have to do it. */ utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer); if (utf16_len == 0) { return uv_translate_sys_error(GetLastError()); @@ -263,8 +259,8 @@ int uv_chdir(const char* dir) { return UV_EIO; } - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed. */ + /* The returned directory should not have a trailing slash, unless it points + * at a drive root, like c:\. Remove it if needed. */ if (utf16_buffer[utf16_len - 1] == L'\\' && !(utf16_len == 3 && utf16_buffer[1] == L':')) { utf16_len--; @@ -272,8 +268,8 @@ int uv_chdir(const char* dir) { } if (utf16_len < 2 || utf16_buffer[1] != L':') { - /* Doesn't look like a drive letter could be there - probably an UNC */ - /* path. TODO: Need to handle win32 namespaces like \\?\C:\ ? */ + /* Doesn't look like a drive letter could be there - probably an UNC path. + * TODO: Need to handle win32 namespaces like \\?\C:\ ? */ drive_letter = 0; } else if (utf16_buffer[0] >= L'A' && utf16_buffer[0] <= L'Z') { drive_letter = utf16_buffer[0]; @@ -359,14 +355,6 @@ uv_pid_t uv_os_getppid(void) { } -int uv_current_pid(void) { - if (current_pid == 0) { - current_pid = GetCurrentProcessId(); - } - return current_pid; -} - - char** uv_setup_args(int argc, char** argv) { return argv; } @@ -828,6 +816,9 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, int is_vista_or_greater; ULONG flags; + *addresses_ptr = NULL; + *count_ptr = 0; + is_vista_or_greater = is_windows_version_or_greater(6, 0, 0, 0); if (is_vista_or_greater) { flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | @@ -842,17 +833,17 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, } - /* Fetch the size of the adapters reported by windows, and then get the */ - /* list itself. */ + /* Fetch the size of the adapters reported by windows, and then get the list + * itself. */ win_address_buf_size = 0; win_address_buf = NULL; for (;;) { ULONG r; - /* If win_address_buf is 0, then GetAdaptersAddresses will fail with */ - /* ERROR_BUFFER_OVERFLOW, and the required buffer size will be stored in */ - /* win_address_buf_size. */ + /* If win_address_buf is 0, then GetAdaptersAddresses will fail with. + * ERROR_BUFFER_OVERFLOW, and the required buffer size will be stored in + * win_address_buf_size. */ r = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, @@ -866,8 +857,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, switch (r) { case ERROR_BUFFER_OVERFLOW: - /* This happens when win_address_buf is NULL or too small to hold */ - /* all adapters. */ + /* This happens when win_address_buf is NULL or too small to hold all + * adapters. */ win_address_buf = uv__malloc(win_address_buf_size); if (win_address_buf == NULL) return UV_ENOMEM; @@ -901,15 +892,15 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, return UV_ENOBUFS; default: - /* Other (unspecified) errors can happen, but we don't have any */ - /* special meaning for them. */ + /* Other (unspecified) errors can happen, but we don't have any special + * meaning for them. */ assert(r != ERROR_SUCCESS); return uv_translate_sys_error(r); } } - /* Count the number of enabled interfaces and compute how much space is */ - /* needed to store their info. */ + /* Count the number of enabled interfaces and compute how much space is + * needed to store their info. */ count = 0; uv_address_buf_size = 0; @@ -919,9 +910,9 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, IP_ADAPTER_UNICAST_ADDRESS* unicast_address; int name_size; - /* Interfaces that are not 'up' should not be reported. Also skip */ - /* interfaces that have no associated unicast address, as to avoid */ - /* allocating space for the name for this interface. */ + /* Interfaces that are not 'up' should not be reported. Also skip + * interfaces that have no associated unicast address, as to avoid + * allocating space for the name for this interface. */ if (adapter->OperStatus != IfOperStatusUp || adapter->FirstUnicastAddress == NULL) continue; @@ -941,8 +932,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, } uv_address_buf_size += name_size; - /* Count the number of addresses associated with this interface, and */ - /* compute the size. */ + /* Count the number of addresses associated with this interface, and + * compute the size. */ for (unicast_address = (IP_ADAPTER_UNICAST_ADDRESS*) adapter->FirstUnicastAddress; unicast_address != NULL; @@ -959,8 +950,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, return UV_ENOMEM; } - /* Compute the start of the uv_interface_address_t array, and the place in */ - /* the buffer where the interface names will be stored. */ + /* Compute the start of the uv_interface_address_t array, and the place in + * the buffer where the interface names will be stored. */ uv_address = uv_address_buf; name_buf = (char*) (uv_address_buf + count); @@ -1199,8 +1190,8 @@ int uv_os_tmpdir(char* buffer, size_t* size) { return UV_EIO; } - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed.*/ + /* The returned directory should not have a trailing slash, unless it points + * at a drive root, like c:\. Remove it if needed. */ if (path[len - 1] == L'\\' && !(len == 3 && path[1] == L':')) { len--; @@ -1542,3 +1533,214 @@ int uv_os_gethostname(char* buffer, size_t* size) { *size = len; return 0; } + + +static int uv__get_handle(uv_pid_t pid, int access, HANDLE* handle) { + int r; + + if (pid == 0) + *handle = GetCurrentProcess(); + else + *handle = OpenProcess(access, FALSE, pid); + + if (*handle == NULL) { + r = GetLastError(); + + if (r == ERROR_INVALID_PARAMETER) + return UV_ESRCH; + else + return uv_translate_sys_error(r); + } + + return 0; +} + + +int uv_os_getpriority(uv_pid_t pid, int* priority) { + HANDLE handle; + int r; + + if (priority == NULL) + return UV_EINVAL; + + r = uv__get_handle(pid, PROCESS_QUERY_LIMITED_INFORMATION, &handle); + + if (r != 0) + return r; + + r = GetPriorityClass(handle); + + if (r == 0) { + r = uv_translate_sys_error(GetLastError()); + } else { + /* Map Windows priority classes to Unix nice values. */ + if (r == REALTIME_PRIORITY_CLASS) + *priority = UV_PRIORITY_HIGHEST; + else if (r == HIGH_PRIORITY_CLASS) + *priority = UV_PRIORITY_HIGH; + else if (r == ABOVE_NORMAL_PRIORITY_CLASS) + *priority = UV_PRIORITY_ABOVE_NORMAL; + else if (r == NORMAL_PRIORITY_CLASS) + *priority = UV_PRIORITY_NORMAL; + else if (r == BELOW_NORMAL_PRIORITY_CLASS) + *priority = UV_PRIORITY_BELOW_NORMAL; + else /* IDLE_PRIORITY_CLASS */ + *priority = UV_PRIORITY_LOW; + + r = 0; + } + + CloseHandle(handle); + return r; +} + + +int uv_os_setpriority(uv_pid_t pid, int priority) { + HANDLE handle; + int priority_class; + int r; + + /* Map Unix nice values to Windows priority classes. */ + if (priority < UV_PRIORITY_HIGHEST || priority > UV_PRIORITY_LOW) + return UV_EINVAL; + else if (priority < UV_PRIORITY_HIGH) + priority_class = REALTIME_PRIORITY_CLASS; + else if (priority < UV_PRIORITY_ABOVE_NORMAL) + priority_class = HIGH_PRIORITY_CLASS; + else if (priority < UV_PRIORITY_NORMAL) + priority_class = ABOVE_NORMAL_PRIORITY_CLASS; + else if (priority < UV_PRIORITY_BELOW_NORMAL) + priority_class = NORMAL_PRIORITY_CLASS; + else if (priority < UV_PRIORITY_LOW) + priority_class = BELOW_NORMAL_PRIORITY_CLASS; + else + priority_class = IDLE_PRIORITY_CLASS; + + r = uv__get_handle(pid, PROCESS_SET_INFORMATION, &handle); + + if (r != 0) + return r; + + if (SetPriorityClass(handle, priority_class) == 0) + r = uv_translate_sys_error(GetLastError()); + + CloseHandle(handle); + return r; +} + + +int uv_os_uname(uv_utsname_t* buffer) { + /* Implementation loosely based on + https://github.com/gagern/gnulib/blob/master/lib/uname.c */ + OSVERSIONINFOW os_info; + SYSTEM_INFO system_info; + int processor_level; + int r; + + if (buffer == NULL) + return UV_EINVAL; + + uv__once_init(); + os_info.dwOSVersionInfoSize = sizeof(os_info); + os_info.szCSDVersion[0] = L'\0'; + + /* Try calling RtlGetVersion(), and fall back to the deprecated GetVersionEx() + if RtlGetVersion() is not available. */ + if (pRtlGetVersion) { + pRtlGetVersion(&os_info); + } else { + /* Silence GetVersionEx() deprecation warning. */ + #pragma warning(suppress : 4996) + if (GetVersionExW(&os_info) == 0) { + r = uv_translate_sys_error(GetLastError()); + goto error; + } + } + + /* Populate the version field. */ + if (WideCharToMultiByte(CP_UTF8, + 0, + os_info.szCSDVersion, + -1, + buffer->version, + sizeof(buffer->version), + NULL, + NULL) == 0) { + r = uv_translate_sys_error(GetLastError()); + goto error; + } + + /* Populate the sysname field. */ +#ifdef __MINGW32__ + r = snprintf(buffer->sysname, + sizeof(buffer->sysname), + "MINGW32_NT-%u.%u", + (unsigned int) os_info.dwMajorVersion, + (unsigned int) os_info.dwMinorVersion); + assert(r < sizeof(buffer->sysname)); +#else + uv__strscpy(buffer->sysname, "Windows_NT", sizeof(buffer->sysname)); +#endif + + /* Populate the release field. */ + r = snprintf(buffer->release, + sizeof(buffer->release), + "%d.%d.%d", + (unsigned int) os_info.dwMajorVersion, + (unsigned int) os_info.dwMinorVersion, + (unsigned int) os_info.dwBuildNumber); + assert(r < sizeof(buffer->release)); + + /* Populate the machine field. */ + GetSystemInfo(&system_info); + + switch (system_info.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_AMD64: + uv__strscpy(buffer->machine, "x86_64", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_IA64: + uv__strscpy(buffer->machine, "ia64", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_INTEL: + uv__strscpy(buffer->machine, "i386", sizeof(buffer->machine)); + + if (system_info.wProcessorLevel > 3) { + processor_level = system_info.wProcessorLevel < 6 ? + system_info.wProcessorLevel : 6; + buffer->machine[1] = '0' + processor_level; + } + + break; + case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: + uv__strscpy(buffer->machine, "i686", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_MIPS: + uv__strscpy(buffer->machine, "mips", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_ALPHA: + case PROCESSOR_ARCHITECTURE_ALPHA64: + uv__strscpy(buffer->machine, "alpha", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_PPC: + uv__strscpy(buffer->machine, "powerpc", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_SHX: + uv__strscpy(buffer->machine, "sh", sizeof(buffer->machine)); + break; + case PROCESSOR_ARCHITECTURE_ARM: + uv__strscpy(buffer->machine, "arm", sizeof(buffer->machine)); + break; + default: + uv__strscpy(buffer->machine, "unknown", sizeof(buffer->machine)); + break; + } + + return 0; + +error: + buffer->sysname[0] = '\0'; + buffer->release[0] = '\0'; + buffer->version[0] = '\0'; + buffer->machine[0] = '\0'; + return r; +} diff --git a/Utilities/cmlibuv/src/win/winapi.c b/Utilities/cmlibuv/src/win/winapi.c index c330786142..fbbbceed95 100644 --- a/Utilities/cmlibuv/src/win/winapi.c +++ b/Utilities/cmlibuv/src/win/winapi.c @@ -26,6 +26,7 @@ /* Ntdll function pointers */ +sRtlGetVersion pRtlGetVersion; sRtlNtStatusToDosError pRtlNtStatusToDosError; sNtDeviceIoControlFile pNtDeviceIoControlFile; sNtQueryInformationFile pNtQueryInformationFile; @@ -34,20 +35,8 @@ sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile; sNtQueryDirectoryFile pNtQueryDirectoryFile; sNtQuerySystemInformation pNtQuerySystemInformation; - /* Kernel32 function pointers */ sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; -sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; -sCreateSymbolicLinkW pCreateSymbolicLinkW; -sCancelIoEx pCancelIoEx; -sInitializeConditionVariable pInitializeConditionVariable; -sSleepConditionVariableCS pSleepConditionVariableCS; -sSleepConditionVariableSRW pSleepConditionVariableSRW; -sWakeAllConditionVariable pWakeAllConditionVariable; -sWakeConditionVariable pWakeConditionVariable; -sCancelSynchronousIo pCancelSynchronousIo; -sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW; - /* Powrprof.dll function pointer */ sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; @@ -55,22 +44,21 @@ sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; /* User32.dll function pointer */ sSetWinEventHook pSetWinEventHook; -/* iphlpapi.dll function pointer */ -sConvertInterfaceIndexToLuid pConvertInterfaceIndexToLuid = NULL; -sConvertInterfaceLuidToNameW pConvertInterfaceLuidToNameW = NULL; void uv_winapi_init(void) { HMODULE ntdll_module; - HMODULE kernel32_module; HMODULE powrprof_module; HMODULE user32_module; - HMODULE iphlpapi_module; + HMODULE kernel32_module; ntdll_module = GetModuleHandleA("ntdll.dll"); if (ntdll_module == NULL) { uv_fatal_error(GetLastError(), "GetModuleHandleA"); } + pRtlGetVersion = (sRtlGetVersion) GetProcAddress(ntdll_module, + "RtlGetVersion"); + pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress( ntdll_module, "RtlNtStatusToDosError"); @@ -127,37 +115,6 @@ void uv_winapi_init(void) { kernel32_module, "GetQueuedCompletionStatusEx"); - pSetFileCompletionNotificationModes = (sSetFileCompletionNotificationModes) - GetProcAddress(kernel32_module, "SetFileCompletionNotificationModes"); - - pCreateSymbolicLinkW = (sCreateSymbolicLinkW) - GetProcAddress(kernel32_module, "CreateSymbolicLinkW"); - - pCancelIoEx = (sCancelIoEx) - GetProcAddress(kernel32_module, "CancelIoEx"); - - pInitializeConditionVariable = (sInitializeConditionVariable) - GetProcAddress(kernel32_module, "InitializeConditionVariable"); - - pSleepConditionVariableCS = (sSleepConditionVariableCS) - GetProcAddress(kernel32_module, "SleepConditionVariableCS"); - - pSleepConditionVariableSRW = (sSleepConditionVariableSRW) - GetProcAddress(kernel32_module, "SleepConditionVariableSRW"); - - pWakeAllConditionVariable = (sWakeAllConditionVariable) - GetProcAddress(kernel32_module, "WakeAllConditionVariable"); - - pWakeConditionVariable = (sWakeConditionVariable) - GetProcAddress(kernel32_module, "WakeConditionVariable"); - - pCancelSynchronousIo = (sCancelSynchronousIo) - GetProcAddress(kernel32_module, "CancelSynchronousIo"); - - pGetFinalPathNameByHandleW = (sGetFinalPathNameByHandleW) - GetProcAddress(kernel32_module, "GetFinalPathNameByHandleW"); - - powrprof_module = LoadLibraryA("powrprof.dll"); if (powrprof_module != NULL) { pPowerRegisterSuspendResumeNotification = (sPowerRegisterSuspendResumeNotification) @@ -170,11 +127,4 @@ void uv_winapi_init(void) { GetProcAddress(user32_module, "SetWinEventHook"); } - iphlpapi_module = LoadLibraryA("iphlpapi.dll"); - if (iphlpapi_module != NULL) { - pConvertInterfaceIndexToLuid = (sConvertInterfaceIndexToLuid) - GetProcAddress(iphlpapi_module, "ConvertInterfaceIndexToLuid"); - pConvertInterfaceLuidToNameW = (sConvertInterfaceLuidToNameW) - GetProcAddress(iphlpapi_module, "ConvertInterfaceLuidToNameW"); - } } diff --git a/Utilities/cmlibuv/src/win/winapi.h b/Utilities/cmlibuv/src/win/winapi.h index ae384b71ab..1e49b57873 100644 --- a/Utilities/cmlibuv/src/win/winapi.h +++ b/Utilities/cmlibuv/src/win/winapi.h @@ -4076,8 +4076,8 @@ # define STATUS_HASH_NOT_PRESENT ((NTSTATUS) 0xC000A101L) #endif -/* This is not the NTSTATUS_FROM_WIN32 that the DDK provides, because the */ -/* DDK got it wrong! */ +/* This is not the NTSTATUS_FROM_WIN32 that the DDK provides, because the DDK + * got it wrong! */ #ifdef NTSTATUS_FROM_WIN32 # undef NTSTATUS_FROM_WIN32 #endif @@ -4109,6 +4109,9 @@ #endif /* from winternl.h */ +#if !defined(__UNICODE_STRING_DEFINED) && defined(__MINGW32_) +#define __UNICODE_STRING_DEFINED +#endif typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; @@ -4524,6 +4527,9 @@ typedef VOID (NTAPI *PIO_APC_ROUTINE) PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved); +typedef NTSTATUS (NTAPI *sRtlGetVersion) + (PRTL_OSVERSIONINFOW lpVersionInformation); + typedef ULONG (NTAPI *sRtlNtStatusToDosError) (NTSTATUS Status); @@ -4659,48 +4665,6 @@ typedef BOOL (WINAPI *sGetQueuedCompletionStatusEx) DWORD dwMilliseconds, BOOL fAlertable); -typedef BOOL (WINAPI* sSetFileCompletionNotificationModes) - (HANDLE FileHandle, - UCHAR Flags); - -typedef BOOLEAN (WINAPI* sCreateSymbolicLinkW) - (LPCWSTR lpSymlinkFileName, - LPCWSTR lpTargetFileName, - DWORD dwFlags); - -typedef BOOL (WINAPI* sCancelIoEx) - (HANDLE hFile, - LPOVERLAPPED lpOverlapped); - -typedef VOID (WINAPI* sInitializeConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef BOOL (WINAPI* sSleepConditionVariableCS) - (PCONDITION_VARIABLE ConditionVariable, - PCRITICAL_SECTION CriticalSection, - DWORD dwMilliseconds); - -typedef BOOL (WINAPI* sSleepConditionVariableSRW) - (PCONDITION_VARIABLE ConditionVariable, - PSRWLOCK SRWLock, - DWORD dwMilliseconds, - ULONG Flags); - -typedef VOID (WINAPI* sWakeAllConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef VOID (WINAPI* sWakeConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef BOOL (WINAPI* sCancelSynchronousIo) - (HANDLE hThread); - -typedef DWORD (WINAPI* sGetFinalPathNameByHandleW) - (HANDLE hFile, - LPWSTR lpszFilePath, - DWORD cchFilePath, - DWORD dwFlags); - /* from powerbase.h */ #ifndef DEVICE_NOTIFY_CALLBACK # define DEVICE_NOTIFY_CALLBACK 2 @@ -4755,6 +4719,7 @@ typedef HWINEVENTHOOK (WINAPI *sSetWinEventHook) /* Ntdll function pointers */ +extern sRtlGetVersion pRtlGetVersion; extern sRtlNtStatusToDosError pRtlNtStatusToDosError; extern sNtDeviceIoControlFile pNtDeviceIoControlFile; extern sNtQueryInformationFile pNtQueryInformationFile; @@ -4763,20 +4728,8 @@ extern sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile; extern sNtQueryDirectoryFile pNtQueryDirectoryFile; extern sNtQuerySystemInformation pNtQuerySystemInformation; - /* Kernel32 function pointers */ extern sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; -extern sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; -extern sCreateSymbolicLinkW pCreateSymbolicLinkW; -extern sCancelIoEx pCancelIoEx; -extern sInitializeConditionVariable pInitializeConditionVariable; -extern sSleepConditionVariableCS pSleepConditionVariableCS; -extern sSleepConditionVariableSRW pSleepConditionVariableSRW; -extern sWakeAllConditionVariable pWakeAllConditionVariable; -extern sWakeConditionVariable pWakeConditionVariable; -extern sCancelSynchronousIo pCancelSynchronousIo; -extern sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW; - /* Powrprof.dll function pointer */ extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; @@ -4784,19 +4737,4 @@ extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotifi /* User32.dll function pointer */ extern sSetWinEventHook pSetWinEventHook; -/* iphlpapi.dll function pointer */ -union _NET_LUID_LH; -typedef DWORD (WINAPI *sConvertInterfaceIndexToLuid)( - ULONG InterfaceIndex, - union _NET_LUID_LH *InterfaceLuid); - -typedef DWORD (WINAPI *sConvertInterfaceLuidToNameW)( - const union _NET_LUID_LH *InterfaceLuid, - PWSTR InterfaceName, - size_t Length); - -extern sConvertInterfaceIndexToLuid pConvertInterfaceIndexToLuid; -extern sConvertInterfaceLuidToNameW pConvertInterfaceLuidToNameW; - - #endif /* UV_WIN_WINAPI_H_ */ diff --git a/Utilities/cmlibuv/src/win/winsock.c b/Utilities/cmlibuv/src/win/winsock.c index 84188954d8..5e7da2a8f2 100644 --- a/Utilities/cmlibuv/src/win/winsock.c +++ b/Utilities/cmlibuv/src/win/winsock.c @@ -256,8 +256,8 @@ int uv_ntstatus_to_winsock_error(NTSTATUS status) { default: if ((status & (FACILITY_NTWIN32 << 16)) == (FACILITY_NTWIN32 << 16) && (status & (ERROR_SEVERITY_ERROR | ERROR_SEVERITY_WARNING))) { - /* It's a windows error that has been previously mapped to an */ - /* ntstatus code. */ + /* It's a windows error that has been previously mapped to an ntstatus + * code. */ return (DWORD) (status & 0xffff); } else { /* The default fallback for unmappable ntstatus codes. */ @@ -519,8 +519,8 @@ int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in, sizeof *info_out); if (overlapped == NULL) { - /* If this is a blocking operation, wait for the event to become */ - /* signaled, and then grab the real status from the io status block. */ + /* If this is a blocking operation, wait for the event to become signaled, + * and then grab the real status from the io status block. */ if (status == STATUS_PENDING) { DWORD r = WaitForSingleObject(event, INFINITE); @@ -491,8 +491,11 @@ KWSYS_FILES="\ if ${cmake_system_mingw}; then LIBUV_C_SOURCES="\ src/fs-poll.c \ + src/idna.c src/inet.c \ src/threadpool.c \ + src/strscpy.c \ + src/timer.c \ src/uv-common.c \ src/win/async.c \ src/win/core.c \ @@ -509,12 +512,10 @@ if ${cmake_system_mingw}; then src/win/poll.c \ src/win/process-stdio.c \ src/win/process.c \ - src/win/req.c \ src/win/signal.c \ src/win/stream.c \ src/win/tcp.c \ src/win/thread.c \ - src/win/timer.c \ src/win/tty.c \ src/win/udp.c \ src/win/util.c \ @@ -523,6 +524,8 @@ if ${cmake_system_mingw}; then " else LIBUV_C_SOURCES="\ + src/strscpy.c \ + src/timer.c \ src/uv-common.c \ src/unix/cmake-bootstrap.c \ src/unix/core.c \ @@ -537,7 +540,6 @@ else src/unix/process.c \ src/unix/signal.c \ src/unix/stream.c \ - src/unix/timer.c \ " fi @@ -1310,6 +1312,7 @@ cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_versi cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\"" +cmake_report cmConfigure.h${_tmp} "#define CMake_DEFAULT_RECURSION_LIMIT 400" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP" |