diff options
292 files changed, 3358 insertions, 1659 deletions
diff --git a/.clang-tidy b/.clang-tidy index 3ae249f..aef99dc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -15,7 +15,6 @@ modernize-*,\ -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,\ diff --git a/Help/command/ctest_submit.rst b/Help/command/ctest_submit.rst index 426475c..fba03fd 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 6e2a6dd..db4d6fc 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 cafef8c..54d5f68 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/qt_wrap_cpp.rst b/Help/command/qt_wrap_cpp.rst index c04c7a6..ce11c2d 100644 --- a/Help/command/qt_wrap_cpp.rst +++ b/Help/command/qt_wrap_cpp.rst @@ -1,7 +1,16 @@ qt_wrap_cpp ----------- -Create Qt Wrappers. +.. deprecated:: 3.14 + + This command was originally added to support Qt 3 before the + :command:`add_custom_command()` command was sufficiently mature. The + :module:`FindQt4` module provides the ``qt4_wrap_cpp()`` macro, which + should be used instead for Qt 4 projects. For projects using Qt 5 or + later, use the equivalent macro provided by Qt itself (e.g. Qt 5 provides + ``qt5_wrap_cpp()``). + +Manually create Qt Wrappers. .. code-block:: cmake @@ -9,3 +18,6 @@ Create Qt Wrappers. Produces moc files for all the .h files listed in the SourceLists. The moc files will be added to the library using the ``DestName`` source list. + +Consider updating the project to use the :prop_tgt:`AUTOMOC` target property +instead for a more automated way of invoking the ``moc`` tool. diff --git a/Help/command/qt_wrap_ui.rst b/Help/command/qt_wrap_ui.rst index 9a8863d..efbbc54 100644 --- a/Help/command/qt_wrap_ui.rst +++ b/Help/command/qt_wrap_ui.rst @@ -1,7 +1,16 @@ qt_wrap_ui ---------- -Create Qt user interfaces Wrappers. +.. deprecated:: 3.14 + + This command was originally added to support Qt 3 before the + :command:`add_custom_command()` command was sufficiently mature. The + :module:`FindQt4` module provides the ``qt4_wrap_ui()`` macro, which + should be used instead for Qt 4 projects. For projects using Qt 5 or + later, use the equivalent macro provided by Qt itself (e.g. Qt 5 provides + ``qt5_wrap_ui()``). + +Manually create Qt user interfaces Wrappers. .. code-block:: cmake @@ -12,3 +21,6 @@ Produces .h and .cxx files for all the .ui files listed in the ``SourceLists``. The .h files will be added to the library using the ``HeadersDestNamesource`` list. The .cxx files will be added to the library using the ``SourcesDestNamesource`` list. + +Consider updating the project to use the :prop_tgt:`AUTOUIC` target property +instead for a more automated way of invoking the ``uic`` tool. diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index cf9e06f..77f42a1 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/generator/Green Hills MULTI.rst b/Help/generator/Green Hills MULTI.rst index 1b4960d..bfe671f 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/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index ee13e40..a3bc465 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -100,8 +100,6 @@ These commands are available only in CMake projects. /command/link_libraries /command/load_cache /command/project - /command/qt_wrap_cpp - /command/qt_wrap_ui /command/remove_definitions /command/set_source_files_properties /command/set_target_properties @@ -145,9 +143,10 @@ These commands are available only in CTest scripts. Deprecated Commands =================== -These commands are deprecated since CMake version 3.0. -They are available only for backward compatibility. -Do not use them in new code. +These commands are deprecated and are only made available to maintain +backward compatibility. The documentation of each command states the +CMake version in which it was deprecated. Do not use these commands +in new code. .. toctree:: :maxdepth: 1 @@ -161,6 +160,8 @@ Do not use them in new code. /command/load_command /command/make_directory /command/output_required_files + /command/qt_wrap_cpp + /command/qt_wrap_ui /command/remove /command/subdir_depends /command/subdirs diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index df8f12c..e1de134 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -23,6 +23,7 @@ Properties of Global Scope /prop_gbl/AUTORCC_SOURCE_GROUP /prop_gbl/CMAKE_C_KNOWN_FEATURES /prop_gbl/CMAKE_CXX_KNOWN_FEATURES + /prop_gbl/CMAKE_ROLE /prop_gbl/DEBUG_CONFIGURATIONS /prop_gbl/DISABLED_FEATURES /prop_gbl/ENABLED_FEATURES @@ -193,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 @@ -204,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 e464b0c..bd6a58f 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 @@ -482,11 +483,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 +570,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/ctest.1.rst b/Help/manual/ctest.1.rst index 8490e3d..bcf75ac 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_gbl/CMAKE_ROLE.rst b/Help/prop_gbl/CMAKE_ROLE.rst new file mode 100644 index 0000000..27512fa --- /dev/null +++ b/Help/prop_gbl/CMAKE_ROLE.rst @@ -0,0 +1,20 @@ +CMAKE_ROLE +---------- + +Tells what mode the current running script is in. Could be one of several +values: + +``PROJECT`` + Running in project mode (processing a ``CMakeLists.txt`` file). + +``SCRIPT`` + Running in ``-P`` script mode. + +``FIND_PACKAGE`` + Running in ``--find-package`` mode. + +``CTEST`` + Running in CTest script mode. + +``CPACK`` + Running in CPack. diff --git a/Help/prop_tgt/GHS_INTEGRITY_APP.rst b/Help/prop_tgt/GHS_INTEGRITY_APP.rst new file mode 100644 index 0000000..7643038 --- /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/dev/cmake_role-global-property.rst b/Help/release/dev/cmake_role-global-property.rst new file mode 100644 index 0000000..7b1fa0b --- /dev/null +++ b/Help/release/dev/cmake_role-global-property.rst @@ -0,0 +1,6 @@ +cmake_role-global-property +-------------------------- + +* A new global property, :prop_gbl:`CMAKE_ROLE`, was added to allow scripts to + determine whether they're running in project mode, script mode, find-package + mode, CTest, or CPack. diff --git a/Help/release/dev/ctest-submit-url.rst b/Help/release/dev/ctest-submit-url.rst new file mode 100644 index 0000000..f848877 --- /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 0000000..7adb9fe --- /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/vs-debug-utility-targets.rst b/Help/release/dev/vs-debug-utility-targets.rst new file mode 100644 index 0000000..02e5262 --- /dev/null +++ b/Help/release/dev/vs-debug-utility-targets.rst @@ -0,0 +1,6 @@ +vs-debug-utility-targets +------------------------ + +* :ref:`Visual Studio Generators` for VS 2010 and above learned + to support the ``VS_DEBUGGER_*`` properties on targets created + via :command:`add_custom_target`. 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 0000000..dfbde20 --- /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_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 2264269..033e81c 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -19,6 +19,7 @@ include: Embarcadero, Borland = Embarcadero (embarcadero.com) 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) 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 8ed1c02..0000000 --- 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 4fea67a..0000000 --- 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 31f87f2..0000000 --- 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 1acd198..0000000 --- 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 ac1b6bc..0000000 --- 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/CTEST_SUBMIT_URL.rst b/Help/variable/CTEST_SUBMIT_URL.rst new file mode 100644 index 0000000..7d84da4 --- /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 0f91be8..fe3b17e 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/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 9b2a91f..4d0c681 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 1a0d8a6..4f355f3 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 0a0c37b..96b4209 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 604ac27..d88f2ed 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -7,6 +7,7 @@ # code. include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake) +include(CMakeTestCompilerCommon) function(CMAKE_DETERMINE_COMPILER_ABI lang src) if(NOT DEFINED CMAKE_${lang}_ABI_COMPILED) @@ -23,6 +24,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) # from which we might detect implicit link libraries. list(APPEND CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD_LIBRARIES=") endif() + __TestCompiler_setTryCompileTargetType() try_compile(CMAKE_${lang}_ABI_COMPILED ${CMAKE_BINARY_DIR} ${src} CMAKE_FLAGS ${CMAKE_FLAGS} diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index f987d9a..2a0dbd3 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/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index c2b5aa9..3cb7f24 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 e34ae75..f74a1c6 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 e4d49ae..fe6bd25 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 f76076f..6ee5175 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/CTest.cmake b/Modules/CTest.cmake index 8848bdd..d100704 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/Compiler/GHS-C.cmake b/Modules/Compiler/GHS-C.cmake index c30bdec..a825b0b 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 b3018a7..07b5044 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 56d24e2..368b375 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 e6a867d..b41c3eb 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/CompilerId/GHS_default.gpj.in b/Modules/CompilerId/GHS_default.gpj.in new file mode 100644 index 0000000..b5cea5c --- /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 0000000..149b981 --- /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 24e7b55..e4513b3 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/FindCURL.cmake b/Modules/FindCURL.cmake index d28dfea..b1989b1 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/Platform/GHS-MULTI-Initialize.cmake b/Modules/Platform/GHS-MULTI-Initialize.cmake index 9b384df..25004c6 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/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 1a300f2..62f5f70 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 20190116) +set(CMake_VERSION_PATCH 20190121) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 326d26c..be4a18e 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -71,8 +71,8 @@ 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); diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index acd6650..f7f3f24 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -18,6 +18,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmStateSnapshot.h" #include "cmVersion.h" #include "cmWorkingDirectory.h" @@ -690,7 +691,7 @@ int cmCPackGenerator::InstallCMakeProject( "- Install component: " << component << std::endl); } - cmake cm(cmake::RoleScript); + cmake cm(cmake::RoleScript, cmState::CPack); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); @@ -1035,7 +1036,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 diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index d02aa5a..4b865ca 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -610,7 +610,7 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories( } } } - dirs.push_back(topdir); + dirs.emplace_back(topdir); return true; } diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index a24dd30..28e0561 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -340,16 +340,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/cpack.cxx b/Source/CPack/cpack.cxx index 4e49727..db9a0e7 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -24,6 +24,7 @@ #include "cmDocumentationFormatter.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cmake.h" @@ -208,7 +209,7 @@ int main(int argc, char const* const* argv) cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack config file: " << cpackConfigFile << std::endl); - cmake cminst(cmake::RoleScript); + cmake cminst(cmake::RoleScript, cmState::CPack); cminst.SetHomeDirectory(""); cminst.SetHomeOutputDirectory(""); cminst.SetProgressCallback(cpackProgressCallback, nullptr); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 668a387..312d126 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -6,6 +6,7 @@ #include "cmCTestTestHandler.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" #include "cmake.h" @@ -163,7 +164,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) return 1; } - cmake cm(cmake::RoleProject); + cmake cm(cmake::RoleProject, cmState::Project); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); std::string cmakeOutString; @@ -231,7 +232,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 361883c..d07bd21 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) @@ -1034,7 +1034,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/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index fbd1038..6c68f46 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -56,12 +56,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; } @@ -316,8 +316,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 +1004,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 diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 6cd1c09..5218993 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -15,6 +15,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmProcessOutput.h" +#include "cmState.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" @@ -145,7 +146,7 @@ void cmCTestLaunch::HandleRealArg(const char* arg) return; } #endif - this->RealArgs.push_back(arg); + this->RealArgs.emplace_back(arg); } void cmCTestLaunch::ComputeFileNames() @@ -533,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); @@ -610,7 +611,7 @@ int cmCTestLaunch::Main(int argc, const char* const argv[]) void cmCTestLaunch::LoadConfig() { - cmake cm(cmake::RoleScript); + cmake cm(cmake::RoleScript, cmState::CTest); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 9c9532a..8ba59d3 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 8867323..320647a 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -1039,6 +1039,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 511dbd2..c0bdc17 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -307,20 +307,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/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 6c439e9..afde61c 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -521,7 +521,7 @@ private: } else { local_path = path; } - this->SVN->Repositories.emplace_back(local_path.c_str()); + this->SVN->Repositories.emplace_back(local_path); } }; @@ -532,7 +532,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 a467ede..5c8505d 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 30192c2..3eac903 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -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); } @@ -280,7 +280,7 @@ void cmCTestScriptHandler::CreateCMake() delete this->GlobalGenerator; delete this->Makefile; } - this->CMake = new cmake(cmake::RoleScript); + this->CMake = new cmake(cmake::RoleScript, cmState::CTest); this->CMake->SetHomeDirectory(""); this->CMake->SetHomeOutputDirectory(""); this->CMake->GetCurrentSnapshot().SetDefaultDefinitions(); @@ -450,7 +450,7 @@ int cmCTestScriptHandler::ExtractVariables() updateVar, " specified without specifying CTEST_CVS_COMMAND."); return 12; } - this->ExtraUpdates.push_back(updateVal); + this->ExtraUpdates.emplace_back(updateVal); } } diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 76a1830..00c0610 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 c4b84ce..0caccd6 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 3042480..5213bd3 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -162,7 +162,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 +494,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 +514,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 +838,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 +849,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 +859,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 393e826..58f4f97 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 9fd2299..f86a4cd 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -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"); } } @@ -1676,7 +1676,7 @@ void cmCTestTestHandler::GetListOfTests() } cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Constructing a list of tests" << std::endl, this->Quiet); - cmake cm(cmake::RoleScript); + cmake cm(cmake::RoleScript, cmState::CTest); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx index cc81979..d99de06 100644 --- a/Source/CTest/cmParseDelphiCoverage.cxx +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -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/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index a3e0717..856723a 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -6,6 +6,7 @@ #include "cmCursesStandardIncludes.h" #include "cmDocumentation.h" #include "cmDocumentationEntry.h" +#include "cmState.h" #include "cmSystemTools.h" #include "cmake.h" @@ -83,7 +84,7 @@ int main(int argc, char const* const* argv) cmDocumentation doc; doc.addCMakeStandardDocSections(); if (doc.CheckOptions(argc, argv)) { - cmake hcm(cmake::RoleInternal); + cmake hcm(cmake::RoleInternal, cmState::Unknown); hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); @@ -108,7 +109,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]); } } diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 931797a..55ef375 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -37,11 +37,11 @@ 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->CMakeInstance = new cmake(cmake::RoleProject); + this->HelpMessage.emplace_back(); + this->HelpMessage.emplace_back(s_ConstHelpMessage); + this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project); this->CMakeInstance->SetCMakeEditCommand( cmSystemTools::GetCMakeCursesCommand()); @@ -652,7 +652,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/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 98cf8b0..b4307bb 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -64,7 +64,7 @@ int main(int argc, char** argv) doc.addCMakeStandardDocSections(); if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) { // Construct and print requested documentation. - cmake hcm(cmake::RoleInternal); + cmake hcm(cmake::RoleInternal, cmState::Unknown); hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 0133b88..9a6784e 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -27,7 +27,7 @@ QCMake::QCMake(QObject* p) cmSystemTools::SetStdoutCallback(QCMake::stdoutCallback, this); cmSystemTools::SetStderrCallback(QCMake::stderrCallback, this); - this->CMakeInstance = new cmake(cmake::RoleProject); + this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project); this->CMakeInstance->SetCMakeEditCommand( cmSystemTools::GetCMakeGUICommand()); this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this); diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 264c63c..8ed43f9 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; @@ -627,7 +626,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 +646,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. diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 65c0d91..7966a0d 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -429,7 +429,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) } } - cmake cm(cmake::RoleScript); + cmake cm(cmake::RoleScript, cmState::CTest); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); @@ -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; } } @@ -2626,6 +2629,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 +2719,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) diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 2b40ca3..a82f400 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -176,6 +176,8 @@ public: bool suppress = false); void EmptyCTestConfiguration(); + std::string GetSubmitURL(); + /** * constructor and destructor */ diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 4274cb4..87bc150 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); } } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index a483fd1..fcb27b4 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) { @@ -869,6 +875,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 +1021,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/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 02db119..792db48 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/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 679a648..8de012a 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()) { @@ -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/cmFileCommand.cxx b/Source/cmFileCommand.cxx index db2fde8..999af54 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); @@ -3670,3 +3673,119 @@ 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.c_str(), newFileName.c_str()); + 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 fe05c98..12c5115 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/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 009f0e3..39051b9 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -178,13 +178,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/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8dc7ca2..9ae1cb9 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")) { @@ -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; } } @@ -1848,7 +1858,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 +1917,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); } } } @@ -2070,16 +2080,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 05bad49..83d8431 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 3047167..e359def 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/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx index 242915d..dd1e243 100644 --- a/Source/cmGeneratorExpressionLexer.cxx +++ b/Source/cmGeneratorExpressionLexer.cxx @@ -20,8 +20,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/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6515dfa..eb3d4af 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -319,7 +319,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 +355,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 +389,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 +988,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths( item.back() == '>') { continue; } - files.push_back(item); + files.emplace_back(item); } } return files; @@ -3260,7 +3260,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 +3838,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)) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index cfd1df0..d9221f0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -536,7 +536,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); /** @@ -694,7 +694,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; diff --git a/Source/cmGhsMultiGpj.cxx b/Source/cmGhsMultiGpj.cxx index f58cfc1..c1f0742 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 b1eead1..6d59225 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 1a25633..19605e4 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.c_str()); + 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.c_str()); + 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.c_str()); + 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,27 @@ 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->ConvertToRelativePath(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 +169,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 +214,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 +240,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 +254,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 +331,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 +345,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->ConvertToRelativePath(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 e936b08..a241cc6 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/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 85c2345..039f881 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -302,7 +302,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; } @@ -1761,7 +1762,7 @@ void cmGlobalGenerator::GenerateBuildCommand( bool /*unused*/, int /*unused*/, bool /*unused*/, std::vector<std::string> const& /*unused*/) { - makeCommand.push_back( + makeCommand.emplace_back( "cmGlobalGenerator::GenerateBuildCommand not implemented"); } @@ -2313,12 +2314,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 +2484,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") && diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 831c4a9..557efec 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()); - /* 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()); + 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,129 +170,208 @@ 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.c_str()); + 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.c_str()); + 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->ConvertToRelativePath(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*/, + 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) { @@ -313,16 +389,34 @@ void cmGlobalGhsMultiGenerator::GenerateBuildCommand( makeCommand.insert(makeCommand.end(), 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.push_back("-top"); + makeCommand.push_back(proj); if (!targetName.empty()) { if (targetName == "clean") { makeCommand.push_back("-clean"); } else { - makeCommand.push_back(targetName); + if (targetName.compare(targetName.size() - 4, 4, ".gpj") == 0) { + makeCommand.push_back(targetName); + } else { + makeCommand.push_back(targetName + ".gpj"); + } } } } -void cmGlobalGhsMultiGenerator::WriteMacros() +void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout) { char const* ghsGpjMacros = this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS"); @@ -332,12 +426,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 +451,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 a5aff73..9332567 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,29 +63,28 @@ 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; @@ -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/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 57d341a..23dbd76 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, @@ -681,12 +681,12 @@ void cmGlobalNinjaGenerator::GenerateBuildCommand( makeCommand.push_back(this->SelectMakeProgram(makeProgram)); if (verbose) { - makeCommand.push_back("-v"); + makeCommand.emplace_back("-v"); } if ((jobs != cmake::NO_BUILD_PARALLEL_LEVEL) && (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL)) { - makeCommand.push_back("-j"); + makeCommand.emplace_back("-j"); makeCommand.push_back(std::to_string(jobs)); } @@ -694,8 +694,8 @@ void cmGlobalNinjaGenerator::GenerateBuildCommand( makeOptions.end()); if (!targetName.empty()) { if (targetName == "clean") { - makeCommand.push_back("-t"); - makeCommand.push_back("clean"); + makeCommand.emplace_back("-t"); + makeCommand.emplace_back("clean"); } else { makeCommand.push_back(targetName); } @@ -1939,7 +1939,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg, } } - cmake cm(cmake::RoleInternal); + cmake cm(cmake::RoleInternal, cmState::Unknown); cm.SetHomeDirectory(dir_top_src); cm.SetHomeOutputDirectory(dir_top_bld); std::unique_ptr<cmGlobalNinjaGenerator> ggd( diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ceee500..52bb046 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -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, @@ -513,7 +513,7 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( makeCommand.push_back(this->SelectMakeProgram(makeProgram)); if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back("-j"); + makeCommand.emplace_back("-j"); if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { makeCommand.push_back(std::to_string(jobs)); } @@ -542,7 +542,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 @@ -577,7 +577,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), 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); @@ -631,7 +631,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. @@ -740,7 +740,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"; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6618351..80ccd73 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -329,14 +329,14 @@ void cmGlobalXCodeGenerator::GenerateBuildCommand( int jobs, bool /*verbose*/, std::vector<std::string> const& makeOptions) { // now build the test - makeCommand.push_back( + makeCommand.emplace_back( this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand())); - makeCommand.push_back("-project"); + makeCommand.emplace_back("-project"); std::string projectArg = projectName; projectArg += ".xcode"; projectArg += "proj"; - makeCommand.push_back(projectArg); + makeCommand.emplace_back(projectArg); bool clean = false; std::string realTarget = targetName; @@ -345,23 +345,23 @@ void cmGlobalXCodeGenerator::GenerateBuildCommand( realTarget = "ALL_BUILD"; } if (clean) { - makeCommand.push_back("clean"); + makeCommand.emplace_back("clean"); } else { - makeCommand.push_back("build"); + makeCommand.emplace_back("build"); } - makeCommand.push_back("-target"); + makeCommand.emplace_back("-target"); if (!realTarget.empty()) { - makeCommand.push_back(realTarget); + makeCommand.emplace_back(realTarget); } else { - makeCommand.push_back("ALL_BUILD"); + makeCommand.emplace_back("ALL_BUILD"); } - makeCommand.push_back("-configuration"); - makeCommand.push_back(!config.empty() ? config : "Debug"); + makeCommand.emplace_back("-configuration"); + makeCommand.emplace_back(!config.empty() ? config : "Debug"); if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back("-jobs"); + makeCommand.emplace_back("-jobs"); if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { - makeCommand.push_back(std::to_string(jobs)); + makeCommand.emplace_back(std::to_string(jobs)); } } @@ -1051,7 +1051,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(); } } diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 199c8e2..4b60279 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -13,6 +13,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -172,7 +173,7 @@ cmGraphVizWriter::cmGraphVizWriter(const cmGlobalGenerator* globalGenerator) void cmGraphVizWriter::ReadSettings(const char* settingsFileName, const char* fallbackSettingsFileName) { - cmake cm(cmake::RoleScript); + cmake cm(cmake::RoleScript, cmState::Unknown); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index bb56714..135fd25 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)); } } @@ -580,8 +580,8 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, std::vector<std::string> includePathList; lg->GetIncludeDirectories(includePathList, target, lang, config, true); 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/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 797add9..97e684b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1684,19 +1684,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["C"].push_back("11"); - langStdMap["C"].push_back("99"); - langStdMap["C"].push_back("90"); - - langStdMap["CUDA"].push_back("14"); - langStdMap["CUDA"].push_back("11"); - langStdMap["CUDA"].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"].emplace_back("11"); + langStdMap["C"].emplace_back("99"); + langStdMap["C"].emplace_back("90"); + + langStdMap["CUDA"].emplace_back("14"); + langStdMap["CUDA"].emplace_back("11"); + langStdMap["CUDA"].emplace_back("98"); } std::string standard(standardProp); diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index ab6774e..125e8b5 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 aa842d7..d5bec42 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/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 707a1b5..9f42a92 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -318,7 +318,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); @@ -685,7 +685,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()) { @@ -852,7 +852,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); } } @@ -1507,7 +1507,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 +1571,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,7 +1593,7 @@ 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(); @@ -1643,7 +1643,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( 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,10 +1656,10 @@ 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)); diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 23d93a3..411c0c3 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -94,7 +94,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/cmMakefile.cxx b/Source/cmMakefile.cxx index 274c631..9e9b6af 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2099,7 +2099,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 } @@ -3374,7 +3374,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, // make sure the same generator is used // use this program as the cmake to be run, it should not // be run that way but the cmake object requires a vailid path - cmake cm(cmake::RoleProject); + cmake cm(cmake::RoleProject, cmState::Project); cm.SetIsInTryCompile(true); cmGlobalGenerator* gg = cm.CreateGlobalGenerator(this->GetGlobalGenerator()->GetName()); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d1dcd81..1207646 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -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('.'); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b62da66..8f6a23a 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -377,7 +377,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 +405,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 +423,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", diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5013be5..c959a04 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,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( aux_sources += " " + this->GetSourceFilePath(src.Source.Value); } vars["SWIFT_AUXILIARY_SOURCES"] = aux_sources; + + vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName(); } if (!this->NeedDepTypeMSVC(language)) { diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index a2bf841..796974c 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/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 14e92c6..2fe9fe8 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/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 9fa8a89..47f7d73 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -963,7 +963,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); } @@ -1356,7 +1356,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 +1371,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 +1483,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; @@ -1546,9 +1547,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 47f157c..eefbaf0 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -102,7 +102,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 f2f4cad..c5d5d7c 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -8,6 +8,7 @@ #include "cmAlgorithms.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" @@ -686,7 +687,7 @@ bool cmQtAutoGenerator::Run(std::string const& infoFile, bool success = false; { - cmake cm(cmake::RoleScript); + cmake cm(cmake::RoleScript, cmState::Unknown); cm.SetHomeOutputDirectory(InfoDir()); cm.SetHomeDirectory(InfoDir()); cm.GetCurrentSnapshot().SetDefaultDefinitions(); diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 9658e97..56ce5b6 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); @@ -1288,7 +1288,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 +1506,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/cmQtAutoGeneratorRcc.cxx b/Source/cmQtAutoGeneratorRcc.cxx index 29dc7a0..f7af99e 100644 --- a/Source/cmQtAutoGeneratorRcc.cxx +++ b/Source/cmQtAutoGeneratorRcc.cxx @@ -603,7 +603,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 f0f92aa..2866a39 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -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/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 4b74ff0..c3e8ff5 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -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 a936747..7aa63db 100644 --- a/Source/cmRulePlaceholderExpander.h +++ b/Source/cmRulePlaceholderExpander.h @@ -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/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 6dbfd10..11a3f46 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -130,7 +130,8 @@ bool cmServerProtocol::Activate(cmServer* server, { assert(server); this->m_Server = server; - this->m_CMakeInstance = cm::make_unique<cmake>(cmake::RoleProject); + this->m_CMakeInstance = + cm::make_unique<cmake>(cmake::RoleProject, cmState::Project); const bool result = this->DoActivate(request, errorMessage); if (!result) { this->m_CMakeInstance = nullptr; diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 8445b02..9388e7c 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 7f33b7a..01758ee 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/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 08f4d1a..34ded38 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 f664000..d4d3df5 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -539,6 +539,9 @@ const char* cmState::GetGlobalProperty(const std::string& prop) std::string langs; langs = cmJoin(this->EnabledLanguages, ";"); this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str()); + } else if (prop == "CMAKE_ROLE") { + std::string mode = this->GetModeString(); + this->SetGlobalProperty("CMAKE_ROLE", mode.c_str()); } #define STRING_LIST_ELEMENT(F) ";" #F if (prop == "CMAKE_C_KNOWN_FEATURES") { @@ -593,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; @@ -643,6 +656,40 @@ unsigned int cmState::GetCacheMinorVersion() const return this->CacheManager->GetCacheMinorVersion(); } +cmState::Mode cmState::GetMode() const +{ + return this->CurrentMode; +} + +std::string cmState::GetModeString() const +{ + return ModeToString(this->CurrentMode); +} + +void cmState::SetMode(cmState::Mode mode) +{ + this->CurrentMode = mode; +} + +std::string cmState::ModeToString(cmState::Mode mode) +{ + switch (mode) { + case Project: + return "PROJECT"; + case Script: + return "SCRIPT"; + case FindPackage: + return "FIND_PACKAGE"; + case CTest: + return "CTEST"; + case CPack: + return "CPACK"; + case Unknown: + return "UNKNOWN"; + } + return "UNKNOWN"; +} + std::string const& cmState::GetBinaryDirectory() const { return this->BinaryDirectory; diff --git a/Source/cmState.h b/Source/cmState.h index abe93ed..e447485 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -35,6 +35,16 @@ public: cmState(); ~cmState(); + enum Mode + { + Unknown, + Project, + Script, + FindPackage, + CTest, + CPack, + }; + static const char* GetTargetTypeName(cmStateEnums::TargetType targetType); cmStateSnapshot CreateBaseSnapshot(); @@ -154,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); @@ -166,6 +178,12 @@ public: unsigned int GetCacheMajorVersion() const; unsigned int GetCacheMinorVersion() const; + Mode GetMode() const; + std::string GetModeString() const; + void SetMode(Mode mode); + + static std::string ModeToString(Mode mode); + private: friend class cmake; void AddCacheEntry(const std::string& key, const char* value, @@ -206,10 +224,12 @@ private: bool IsGeneratorMultiConfig = false; bool WindowsShell = false; bool WindowsVSIDE = false; + bool GhsMultiIDE = false; bool WatcomWMake = false; bool MinGWMake = false; bool NMake = false; bool MSYSShell = false; + Mode CurrentMode = Unknown; }; #endif diff --git a/Source/cmStringReplaceHelper.cxx b/Source/cmStringReplaceHelper.cxx index 69b7ced..f50cf58 100644 --- a/Source/cmStringReplaceHelper.cxx +++ b/Source/cmStringReplaceHelper.cxx @@ -85,10 +85,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 +99,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/cmSystemTools.cxx b/Source/cmSystemTools.cxx index be65853..71a9cb4 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -534,7 +534,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); } } }; @@ -1586,7 +1586,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; } @@ -3063,7 +3063,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 +3114,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 +3129,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.c_str()); + } + 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.c_str()); + } return false; } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index c0999e7..489811d 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -528,7 +528,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; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a94cf6a..fe48934 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -662,7 +662,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 +671,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 +737,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; } @@ -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 655cefd..24b3742 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/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index e224a27..10a6d9a 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()) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index dd90269..ac4a4f5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2283,6 +2283,58 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( e1.Element("_ProjectFileVersion", "10.0.20506.1"); for (std::string const& config : this->Configurations) { const std::string cond = this->CalcCondition(config); + + if (ttype <= cmStateEnums::UTILITY) { + if (const char* workingDir = this->GeneratorTarget->GetProperty( + "VS_DEBUGGER_WORKING_DIRECTORY")) { + cmGeneratorExpression ge; + std::unique_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(workingDir); + std::string genWorkingDir = + cge->Evaluate(this->LocalGenerator, config); + + e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond, + genWorkingDir); + } + + if (const char* environment = + this->GeneratorTarget->GetProperty("VS_DEBUGGER_ENVIRONMENT")) { + cmGeneratorExpression ge; + std::unique_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(environment); + std::string genEnvironment = + cge->Evaluate(this->LocalGenerator, config); + + e1.WritePlatformConfigTag("LocalDebuggerEnvironment", cond, + genEnvironment); + } + + if (const char* debuggerCommand = + this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) { + + cmGeneratorExpression ge; + std::unique_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(debuggerCommand); + std::string genDebuggerCommand = + cge->Evaluate(this->LocalGenerator, config); + + e1.WritePlatformConfigTag("LocalDebuggerCommand", cond, + genDebuggerCommand); + } + + if (const char* commandArguments = this->GeneratorTarget->GetProperty( + "VS_DEBUGGER_COMMAND_ARGUMENTS")) { + cmGeneratorExpression ge; + std::unique_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(commandArguments); + std::string genCommandArguments = + cge->Evaluate(this->LocalGenerator, config); + + e1.WritePlatformConfigTag("LocalDebuggerCommandArguments", cond, + genCommandArguments); + } + } + if (ttype >= cmStateEnums::UTILITY) { e1.WritePlatformConfigTag( "IntDir", cond, "$(Platform)\\$(Configuration)\\$(ProjectName)\\"); @@ -2347,55 +2399,6 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( e1.WritePlatformConfigTag("ExcludePath", cond, sdkExcludeDirectories); } - if (const char* workingDir = this->GeneratorTarget->GetProperty( - "VS_DEBUGGER_WORKING_DIRECTORY")) { - cmGeneratorExpression ge; - std::unique_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(workingDir); - std::string genWorkingDir = - cge->Evaluate(this->LocalGenerator, config); - - e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond, - genWorkingDir); - } - - if (const char* environment = - this->GeneratorTarget->GetProperty("VS_DEBUGGER_ENVIRONMENT")) { - cmGeneratorExpression ge; - std::unique_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(environment); - std::string genEnvironment = - cge->Evaluate(this->LocalGenerator, config); - - e1.WritePlatformConfigTag("LocalDebuggerEnvironment", cond, - genEnvironment); - } - - if (const char* debuggerCommand = - this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) { - - cmGeneratorExpression ge; - std::unique_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(debuggerCommand); - std::string genDebuggerCommand = - cge->Evaluate(this->LocalGenerator, config); - - e1.WritePlatformConfigTag("LocalDebuggerCommand", cond, - genDebuggerCommand); - } - - if (const char* commandArguments = this->GeneratorTarget->GetProperty( - "VS_DEBUGGER_COMMAND_ARGUMENTS")) { - cmGeneratorExpression ge; - std::unique_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(commandArguments); - std::string genCommandArguments = - cge->Evaluate(this->LocalGenerator, config); - - e1.WritePlatformConfigTag("LocalDebuggerCommandArguments", cond, - genCommandArguments); - } - std::string name = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); e1.WritePlatformConfigTag("TargetName", cond, name); @@ -2620,6 +2623,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } clOptions.AddDefines(targetDefines); + if (this->ProjectType == csproj) { + clOptions.AppendFlag("DefineConstants", targetDefines); + } + // Get includes for this target if (!this->LangForClCompile.empty()) { clOptions.AddIncludes( diff --git a/Source/cmake.cxx b/Source/cmake.cxx index c65bd2e..06edeba 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -126,7 +126,7 @@ void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/, cm->MarkCliAsUsed(variable); } -cmake::cmake(Role role) +cmake::cmake(Role role, cmState::Mode mode) { this->Trace = false; this->TraceExpand = false; @@ -140,6 +140,7 @@ cmake::cmake(Role role) this->FileComparison = new cmFileTimeComparison; this->State = new cmState; + this->State->SetMode(mode); this->CurrentSnapshot = this->State->CreateBaseSnapshot(); this->Messenger = new cmMessenger; @@ -178,31 +179,31 @@ cmake::cmake(Role role) // 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(), @@ -2023,7 +2024,8 @@ int cmake::CheckBuildSystem() // Read the rerun check file and use it to decide whether to do the // global generate. - cmake cm(RoleScript); // Actually, all we need is the `set` command. + // Actually, all we need is the `set` command. + cmake cm(RoleScript, cmState::Unknown); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); @@ -2483,7 +2485,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; } diff --git a/Source/cmake.h b/Source/cmake.h index 9891857..cd8c622 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -15,6 +15,7 @@ #include "cmInstalledFile.h" #include "cmListFileCache.h" #include "cmMessageType.h" +#include "cmState.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" @@ -29,7 +30,6 @@ class cmGlobalGenerator; class cmGlobalGeneratorFactory; class cmMakefile; class cmMessenger; -class cmState; class cmVariableWatch; struct cmDocumentationEntry; @@ -113,7 +113,7 @@ public: static const int DEFAULT_BUILD_PARALLEL_LEVEL = 0; /// Default constructor - cmake(Role role); + cmake(Role role, cmState::Mode mode); /// Destructor ~cmake(); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index e52f2b3..5a04eab 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -106,7 +106,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); } @@ -217,7 +217,7 @@ int do_cmake(int ac, char const* const* av) doc.addCMakeStandardDocSections(); if (doc.CheckOptions(ac, av)) { // Construct and print requested documentation. - cmake hcm(cmake::RoleInternal); + cmake hcm(cmake::RoleInternal, cmState::Unknown); hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); @@ -288,18 +288,18 @@ 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) { - cmake cm(cmake::RoleProject); + cmake cm(cmake::RoleProject, cmState::Project); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); int ret = cm.GetSystemInformation(args); @@ -307,7 +307,19 @@ int do_cmake(int ac, char const* const* av) } cmake::Role const role = workingMode == cmake::SCRIPT_MODE ? cmake::RoleScript : cmake::RoleProject; - cmake cm(role); + cmState::Mode mode = cmState::Unknown; + switch (workingMode) { + case cmake::NORMAL_MODE: + mode = cmState::Project; + break; + case cmake::SCRIPT_MODE: + mode = cmState::Script; + break; + case cmake::FIND_PACKAGE_MODE: + mode = cmState::FindPackage; + break; + } + cmake cm(role, mode); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); @@ -374,7 +386,7 @@ 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]); + nativeOptions.emplace_back(av[i]); } else if ((strcmp(av[i], "-j") == 0) || (strcmp(av[i], "--parallel") == 0)) { jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL; @@ -463,7 +475,7 @@ static int do_build(int ac, char const* const* av) return 1; } - cmake cm(cmake::RoleInternal); + cmake cm(cmake::RoleInternal, cmState::Unknown); cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); cm.SetProgressCallback(cmakemainProgressCallback, &cm); return cm.Build(jobs, dir, target, config, nativeOptions, clean); @@ -501,7 +513,7 @@ static int do_open(int ac, char const* const* av) return 1; } - cmake cm(cmake::RoleInternal); + cmake cm(cmake::RoleInternal, cmState::Unknown); cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); cm.SetProgressCallback(cmakemainProgressCallback, &cm); return cm.Open(dir, false) ? 0 : 1; diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index b645ef1..26f7509 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -9,6 +9,7 @@ #include "cmMakefile.h" #include "cmQtAutoGeneratorMocUic.h" #include "cmQtAutoGeneratorRcc.h" +#include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" @@ -200,7 +201,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. @@ -227,9 +228,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. @@ -721,7 +722,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::cerr << "-E capabilities accepts no additional arguments\n"; return 1; } - cmake cm(cmake::RoleInternal); + cmake cm(cmake::RoleInternal, cmState::Unknown); #if defined(CMAKE_BUILD_WITH_CMAKE) std::cout << cm.ReportCapabilities(true); #else @@ -898,7 +899,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) const bool verbose = isCMakeVerbose(); // Create a cmake object instance to process dependencies. - cmake cm(cmake::RoleScript); // All we need is the `set` command. + // All we need is the `set` command. + cmake cm(cmake::RoleScript, cmState::Unknown); std::string gen; std::string homeDir; std::string startDir; @@ -1731,7 +1733,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); } @@ -1879,8 +1881,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); } @@ -1890,7 +1892,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 8ba126f..4a2531a 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/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6b166d6..7338993 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1362,18 +1362,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" @@ -2260,32 +2260,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/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 6a80df5..f8b36c5 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 0000000..b2cf87c --- /dev/null +++ b/Tests/FindPackageTest/cmake/SetFoundResolvedConfig.cmake @@ -0,0 +1 @@ +set(SetFoundResolved_DIR "${CMAKE_CURRENT_LIST_DIR}") diff --git a/Tests/GhsMulti/CMakeLists.txt b/Tests/GhsMulti/CMakeLists.txt deleted file mode 100644 index 6e15ba9..0000000 --- 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 0000000..4a3f5c2 --- /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 0000000..fc24d90 --- /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 0000000..95f2e8e --- /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 0000000..d6d007d --- /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 0000000..5c657b5 --- /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 82a014b..a1f152f 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 d5b7914..d4ef7bb 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 e1e1759..5d857dd 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 0000000..66ee6f3 --- /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 c552e6a..83589ba 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 170b33d..82f9a52 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 5ffcbdf..feba80e 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 0000000..943c19d --- /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 0000000..0448cf2 --- /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 0000000..8488f4e --- /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 0000000..b35e9cc --- /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 0000000..0467b5a --- /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 0000000..d4cbf04 --- /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 0000000..29ad70a --- /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 0000000..b35e9cc --- /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 2adbd4e..e431217 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 db8d658..db8d658 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 7bcc5f9..92254e6 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 9e22b5e..5035d58 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 0000000..d173c01 --- /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 0000000..00e0f59 --- /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 61922bb..61922bb 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 00971b0..00971b0 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 0000000..c5db155 --- /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 0000000..29ad70a --- /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 0000000..c302418 --- /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 0000000..d1bce33 --- /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 0000000..361793a --- /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 0000000..fa0dce0 --- /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 0000000..da80b51 --- /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 0000000..58c2115 --- /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 0000000..f21c126 --- /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 0000000..e2b1725 --- /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 0000000..8f66fba --- /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 0000000..57c7a6f --- /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 0000000..109fd7b --- /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 0000000..f28a705 --- /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 0000000..bf77406 --- /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 0000000..6a4a9a1 --- /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 0000000..145dac0 --- /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 0000000..f49e33d --- /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 0000000..f21c126 --- /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 0000000..e2b1725 --- /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 0000000..9039730 --- /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 0000000..8f66fba --- /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 0000000..57c7a6f --- /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 0000000..109fd7b --- /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 0000000..f28a705 --- /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 0000000..bf77406 --- /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 0000000..6a4a9a1 --- /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 0000000..9e077a9 --- /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 0000000..b9cdd61 --- /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 0000000..5100945 --- /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 0000000..0d83bc3 --- /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 0000000..9238cf3 --- /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 0000000..b35e9cc --- /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 0000000..e42e7fb --- /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 0000000..9238cf3 --- /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 0000000..b35e9cc --- /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 0000000..3855215 --- /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 0000000..a025814 --- /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 0000000..c2c5a19 --- /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 0000000..5228ef2 --- /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 0000000..ec6f2c3 --- /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 0000000..9aef431 --- /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 0000000..b6a9b93 --- /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 0000000..b177887 --- /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 0000000..4132aa4 --- /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 0000000..f5792b4 --- /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 0000000..8488f4e --- /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 0000000..29ad70a --- /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 0000000..b35e9cc --- /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 0000000..9c9c1d9 --- /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 0000000..93a1afc --- /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 0000000..c6cac69 --- /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 0000000..c6cac69 --- /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 0000000..e69de29 --- /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 0000000..e2b1725 --- /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 0000000..e2b1725 --- /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 0000000..e2b1725 --- /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 0000000..2773a55 --- /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 0000000..90ea9b9 --- /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 0000000..e2b1725 --- /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 0000000..94f818a --- /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 0000000..e2b1725 --- /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 0000000..8f66fba --- /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 0000000..57c7a6f --- /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 0000000..2773a55 --- /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 0000000..109fd7b --- /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 0000000..f28a705 --- /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 0000000..bf77406 --- /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 0000000..6a4a9a1 --- /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 0000000..e86e2a4 --- /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 0000000..e2b1725 --- /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 0000000..48cdce8 --- /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 0000000..48cdce8 --- /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 0000000..ed3094b --- /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 0000000..6a4a9a1 --- /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 44c5de1..0000000 --- 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 224ec29..0000000 --- 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 9c822da..0000000 --- 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/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 358521b..c8653b4 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -155,6 +155,7 @@ add_RunCMake_test(BuildDepends) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(Byproducts) endif() +add_RunCMake_test(CMakeRoleGlobalProperty) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) endif() diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt b/Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt new file mode 100644 index 0000000..332b023 --- /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 b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt new file mode 100644 index 0000000..44025d3 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.12) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in new file mode 100644 index 0000000..bb8f9c1 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in @@ -0,0 +1,4 @@ +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/FindDummyPackage.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake new file mode 100644 index 0000000..8299042 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) + +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "FIND_PACKAGE") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"FIND_PACKAGE\"") +endif() + +set(DummyPackage_FOUND 1) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake new file mode 100644 index 0000000..c0b6a48 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake @@ -0,0 +1,6 @@ +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_subdirectory(sub) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake new file mode 100644 index 0000000..3cbd51d --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake @@ -0,0 +1,14 @@ +include(RunCMake) +include(RunCTest) + +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/CMakeRoleGlobalProperty/Script.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake new file mode 100644 index 0000000..371edbc --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.12) + +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "SCRIPT") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"SCRIPT\"") +endif() diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt b/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt new file mode 100644 index 0000000..8ecf671 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt @@ -0,0 +1,4 @@ +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "PROJECT") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"PROJECT\"") +endif() diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in b/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in new file mode 100644 index 0000000..4e2c085 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.12) +set(CTEST_RUN_CURRENT_SCRIPT 0) + +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "CTEST") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"CTEST\"") +endif() diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake index 2d7f993..6f7c4c2 100644 --- a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake @@ -1,5 +1,10 @@ message("This script could run an external packaging tool") +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "CPACK") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"CPACK\"") +endif() + function(expect_variable VAR) if(NOT ${VAR}) message(FATAL_ERROR "${VAR} is unexpectedly not set") diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index cae14b1..d524f41 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/CTestCommandLine/show-only_bad-result.txt b/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt @@ -0,0 +1 @@ +1 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 0000000..cc55ab3 --- /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 0000000..1332149 --- /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 0000000..f9234f8 --- /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 d794e7d..4dff90c 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 493c9e5..493c9e5 100644 --- a/Tests/RunCMake/CTestCommandLine/ShowAsJson_check.py +++ b/Tests/RunCMake/CTestCommandLine/show_only_json_check.py diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index c796840..7c1ed4e 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -14,5 +14,6 @@ run_cmake(VsCSharpCustomTags) run_cmake(VsCSharpReferenceProps) run_cmake(VsCSharpWithoutSources) run_cmake(VsCSharpDeployFiles) +run_cmake(VSCSharpDefines) run_cmake(VsSdkDirectories) run_cmake(VsGlobals) diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake new file mode 100644 index 0000000..152bf9c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake @@ -0,0 +1,64 @@ +# +# Check C# VS project for required elements. +# +set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj") +if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() +endif() + + +set(inDebug FALSE) +set(inRelease FALSE) +set(debugOK FALSE) +set(releaseOK FALSE) + + +file(STRINGS "${csProjectFile}" lines) +foreach(line IN LISTS lines) + #message(STATUS ${line}) + if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*") + set(inDebug TRUE) + elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*") + set(inRelease TRUE) + elseif(line MATCHES "^ *</PropertyGroup> *$") + set(inRelease FALSE) + set(inDebug FALSE) + elseif(inDebug AND + (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND + (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$") AND + (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$") AND + (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$")) + ) + set(debugOK TRUE) + elseif(inRelease AND + (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND + (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$") AND + (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$") AND + (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$")) + ) + set(releaseOK TRUE) + endif() +endforeach() + +function(print_csprojfile) + file(STRINGS "${csProjectFile}" lines) + foreach(line IN LISTS lines) + message(STATUS ${line}) + endforeach() +endfunction() + + +if(NOT debugOK) + message(STATUS "Failed to set Debug configuration defines correctly.") + set(RunCMake_TEST_FAILED "Failed to set Debug configuration defines correctly.") + print_csprojfile() + return() +endif() + +if(NOT releaseOK) + message(STATUS "Failed to set Release configuration defines correctly.") + set(RunCMake_TEST_FAILED "Failed to set Release configuration defines correctly.") + print_csprojfile() + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines.cmake new file mode 100644 index 0000000..62c19c5 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpDefines.cmake @@ -0,0 +1,18 @@ +enable_language(CSharp) + +add_library(foo SHARED + foo.cs) + +set_target_properties(foo PROPERTIES + LINKER_LANGUAGE CSharp) + + +# Issue 18698 +target_compile_definitions( + foo + PUBLIC + MY_FOO_DEFINE + "MY_BAR_ASSIGNMENT=bar" + $<$<CONFIG:Debug>:DEFINE_ONLY_FOR_DEBUG> + $<$<CONFIG:Release>:DEFINE_ONLY_FOR_RELEASE> +) diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake index 440f9f2..00288d4 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake @@ -1,22 +1,24 @@ -set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") -if(NOT EXISTS "${vcProjectFile}") - set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") - return() -endif() +foreach(target foo bar) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() + endif() -set(debuggerCommandSet FALSE) + set(debuggerCommandSet FALSE) -file(STRINGS "${vcProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "^ *<LocalDebuggerCommand[^>]*>([^<>]+)</LocalDebuggerCommand>$") - if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command foo") - message(STATUS "foo.vcxproj has debugger command set") - set(debuggerCommandSet TRUE) + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerCommand[^>]*>([^<>]+)</LocalDebuggerCommand>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command foo") + message(STATUS "${target}.vcxproj has debugger command set") + set(debuggerCommandSet TRUE) + endif() endif() + endforeach() + + if(NOT debuggerCommandSet) + set(RunCMake_TEST_FAILED "LocalDebuggerCommand not found or not set correctly.") + return() endif() endforeach() - -if(NOT debuggerCommandSet) - set(RunCMake_TEST_FAILED "LocalDebuggerCommand not found or not set correctly.") - return() -endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake index 5dcb6d1..54f9154 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake @@ -1,5 +1,6 @@ enable_language(CXX) add_library(foo foo.cpp) +add_custom_target(bar) -set_target_properties(foo PROPERTIES +set_target_properties(foo bar PROPERTIES VS_DEBUGGER_COMMAND "my-debugger-command $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake index b2e0a43..87555d1 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake @@ -1,22 +1,24 @@ -set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") -if(NOT EXISTS "${vcProjectFile}") - set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") - return() -endif() +foreach(target foo bar) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() + endif() -set(debuggerCommandArgumentsSet FALSE) + set(debuggerCommandArgumentsSet FALSE) -file(STRINGS "${vcProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "^ *<LocalDebuggerCommandArguments[^>]*>([^<>]+)</LocalDebuggerCommandArguments>$") - if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command-arguments foo") - message(STATUS "foo.vcxproj has debugger command arguments set") - set(debuggerCommandArgumentsSet TRUE) + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerCommandArguments[^>]*>([^<>]+)</LocalDebuggerCommandArguments>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command-arguments foo") + message(STATUS "${target}.vcxproj has debugger command arguments set") + set(debuggerCommandArgumentsSet TRUE) + endif() endif() + endforeach() + + if(NOT debuggerCommandArgumentsSet) + set(RunCMake_TEST_FAILED "LocalDebuggerCommandArguments not found or not set correctly.") + return() endif() endforeach() - -if(NOT debuggerCommandArgumentsSet) - set(RunCMake_TEST_FAILED "LocalDebuggerCommandArguments not found or not set correctly.") - return() -endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake index aa87cdc..1f7d0be 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake @@ -1,5 +1,6 @@ enable_language(CXX) add_library(foo foo.cpp) +add_custom_target(bar) -set_target_properties(foo PROPERTIES +set_target_properties(foo bar PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS "my-debugger-command-arguments $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake index 2427ad4..fee121a 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake @@ -1,22 +1,24 @@ -set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") -if(NOT EXISTS "${vcProjectFile}") - set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") - return() -endif() +foreach(target foo bar) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() + endif() -set(debuggerEnvironmentSet FALSE) + set(debuggerEnvironmentSet FALSE) -file(STRINGS "${vcProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "^ *<LocalDebuggerEnvironment[^>]*>([^<>]+)</LocalDebuggerEnvironment>$") - if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-environment foo") - message(STATUS "foo.vcxproj has debugger environment set") - set(debuggerEnvironmentSet TRUE) + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerEnvironment[^>]*>([^<>]+)</LocalDebuggerEnvironment>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-environment foo") + message(STATUS "${target}.vcxproj has debugger environment set") + set(debuggerEnvironmentSet TRUE) + endif() endif() + endforeach() + + if(NOT debuggerEnvironmentSet) + set(RunCMake_TEST_FAILED "LocalDebuggerEnvironment not found or not set correctly.") + return() endif() endforeach() - -if(NOT debuggerEnvironmentSet) - set(RunCMake_TEST_FAILED "LocalDebuggerEnvironment not found or not set correctly.") - return() -endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake index d5bec4c..c594f35 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake @@ -1,5 +1,6 @@ enable_language(CXX) add_library(foo foo.cpp) +add_custom_target(bar) -set_target_properties(foo PROPERTIES +set_target_properties(foo bar PROPERTIES VS_DEBUGGER_ENVIRONMENT "my-debugger-environment $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake index 6a142f8..9d3f2a8 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake @@ -1,22 +1,24 @@ -set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") -if(NOT EXISTS "${vcProjectFile}") - set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") - return() -endif() +foreach(target foo bar) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() + endif() -set(debuggerWorkDirSet FALSE) + set(debuggerWorkDirSet FALSE) -file(STRINGS "${vcProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$") - if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory foo") - message(STATUS "foo.vcxproj has debugger working dir set") - set(debuggerWorkDirSet TRUE) + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory foo") + message(STATUS "${target}.vcxproj has debugger working dir set") + set(debuggerWorkDirSet TRUE) + endif() endif() + endforeach() + + if(NOT debuggerWorkDirSet) + set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.") + return() endif() endforeach() - -if(NOT debuggerWorkDirSet) - set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.") - return() -endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake index 36daed0..69ed85c 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake @@ -1,5 +1,6 @@ enable_language(CXX) add_library(foo foo.cpp) +add_custom_target(bar) -set_target_properties(foo PROPERTIES +set_target_properties(foo bar PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt index c7f35c5..c9111b0 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 19f8234..2c67eb9 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 0000000..777ef4e --- /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 0000000..61aaf38 --- /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 0000000..77b899c --- /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 0000000..d00491f --- /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 0000000..12494f8 --- /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 0000000..65002fa --- /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 0000000..97eee4f --- /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 0000000..5ee2580 --- /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 0000000..ca61646 --- /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 b872824..128e8f3 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 0000000..4496a05 --- /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 e9f3558..066523e 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 0000000..ea94be5 --- /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 0000000..8d56513 --- /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") |