Browse Source

Merge topic 'ghs_initial_setup'

aa59eaac4f GHS: Allow setting GHS variables from toolchain file
ab6f0b51b1 GHS: Add note about -T and path style
a55b5c4e18 GHS: Update BSP selection logic
0427f22539 GHS: Update RTOS selection logic
e006b87cc6 GHS: GHSMULTI - Update documentation to match implementation
83eb5695e9 GHS: Update toolset selection logic
8114ddcad1 GHS: Continue splitting variables used by generator
831607889f GHS: Update selection of primaryTarget in MULTI project file
...

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !6715
Brad King 4 years ago
parent
commit
3519c19091

+ 1 - 1
Auxiliary/vim/syntax/cmake.vim

@@ -1903,7 +1903,7 @@ syn keyword cmakeVariable contained
             \ DOXYGEN_XML_PROGRAMLISTING
             \ ENV
             \ EXECUTABLE_OUTPUT_PATH
-            \ GHS-MULTI
+            \ GHSMULTI
             \ IOS
             \ LIBRARY_OUTPUT_PATH
             \ MINGW

+ 95 - 29
Help/generator/Green Hills MULTI.rst

@@ -8,70 +8,125 @@ Green Hills MULTI
 
 Generates Green Hills MULTI project files (experimental, work-in-progress).
 
-Customizations are available through the following cache variables:
-
-* ``GHS_CUSTOMIZATION``
-* ``GHS_GPJ_MACROS``
-
-.. versionadded:: 3.14
   The buildsystem has predetermined build-configuration settings that can be controlled
   via the :variable:`CMAKE_BUILD_TYPE` variable.
 
-Toolset and Platform Selection
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Platform Selection
+^^^^^^^^^^^^^^^^^^
 
 .. versionadded:: 3.13
 
-Customizations that are used to pick toolset and target system:
+The variable ``GHS_PRIMARY_TARGET`` can be used to select the target platform.
+
+  | Sets ``primaryTarget`` entry in project file.
+
+For example:
 
-* 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.
+* ``cmake -G "Green Hills MULTI" -D GHS_PRIMARY_TARGET=ppc_integrity.tgt``
 
-* 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.
+Otherwise the ``primaryTarget`` will be composed from the values of :variable:`CMAKE_GENERATOR_PLATFORM`
+and ``GHS_TARGET_PLATFORM``. Defaulting to the value of ``arm_integrity.tgt``
 
-Cache variables that are used for toolset and target system customization:
+* The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+  via the :manual:`cmake(1)` ``-A`` option.
 
-* ``GHS_TARGET_PLATFORM``
+  | Typical values of ``arm``, ``ppc``, ``86``, etcetera, are used.
+
+* The variable ``GHS_TARGET_PLATFORM`` may be set, perhaps via the :manual:`cmake(1)`
+  ``-D`` option.
 
   | Defaults to ``integrity``.
   | Usual values are ``integrity``, ``threadx``, ``uvelosity``, ``velosity``,
     ``vxworks``, ``standalone``.
 
-* ``GHS_PRIMARY_TARGET``
+For example:
 
-  | Sets ``primaryTarget`` entry in project file.
-  | Defaults to ``<arch>_<GHS_TARGET_PLATFORM>.tgt``.
+* ``cmake -G "Green Hills MULTI"`` for ``arm_integrity.tgt``.
+* ``cmake -G "Green Hills MULTI" -A 86`` for ``86_integrity.tgt``.
+* ``cmake -G "Green Hills MULTI" -D GHS_TARGET_PLATFORM=standalone`` for ``arm_standalone.tgt``.
+* ``cmake -G "Green Hills MULTI" -A ppc -D GHS_TARGET_PLATFORM=standalone`` for ``ppc_standalone.tgt``.
 
-* ``GHS_TOOLSET_ROOT``
+Toolset Selection
+^^^^^^^^^^^^^^^^^
 
-  | Root path for ``toolset`` searches.
-  | Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux.
+.. versionadded:: 3.13
 
-* ``GHS_OS_ROOT``
+The generator searches for the latest compiler or can be given a location to use.
+``GHS_TOOLSET_ROOT`` is the directory that is checked for the latest compiler.
 
-  | Root path for RTOS searches.
+* The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
+  via the :manual:`cmake(1)` ``-T`` option, to specify the location of the toolset.
+  Both absolute and relative paths are valid. Paths are relative to ``GHS_TOOLSET_ROOT``.
+
+* The variable ``GHS_TOOLSET_ROOT`` may be set, perhaps via the :manual:`cmake(1)`
+  ``-D`` option.
+
+  | Root path for toolset searches and relative paths.
   | Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux.
 
+For example, setting a specific compiler:
+
+* ``cmake -G "Green Hills MULTI" -T comp_201754`` for ``/usr/ghs/comp_201754``.
+* ``cmake -G "Green Hills MULTI" -T comp_201754 -D GHS_TOOLSET_ROOT=/opt/ghs`` for ``/opt/ghs/comp_201754``.
+* ``cmake -G "Green Hills MULTI" -T /usr/ghs/comp_201554``
+* ``cmake -G "Green Hills MULTI" -T C:/ghs/comp_201754``
+
+For example, searching for latest compiler:
+
+* ``cmake -G "Green Hills MULTI"`` for searching ``/usr/ghs``.
+* ``cmake -G "Green Hills MULTI -D GHS_TOOLSET_ROOT=/opt/ghs"`` for searching ``/opt/ghs``.
+
+.. note::
+  The :variable:`CMAKE_GENERATOR_TOOLSET` should use CMake style paths.
+
+OS and BSP Selection
+^^^^^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.3
+
+Certain target platforms, like Integrity, require an OS.  The RTOS directory path
+can be explicitly set using ``GHS_OS_DIR``.  Otherwise ``GHS_OS_ROOT`` will be
+searched for the latest Integrity RTOS.
+
+If the target platform, like Integrity, requires a BSP name then it can be set via
+the ``GHS_BSP_NAME`` variable.
+
 * ``GHS_OS_DIR`` and ``GHS_OS_DIR_OPTION``
 
   | 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_OS_DIR_OPTION`` default value is ``-os_dir``.
 
   .. versionadded:: 3.15
     The ``GHS_OS_DIR_OPTION`` variable.
 
+  For example:
+
+  * ``cmake -G "Green Hills MULTI" -D GHS_OS_DIR=/usr/ghs/int1144``
+
+* ``GHS_OS_ROOT``
+
+  | Root path for RTOS searches.
+  | Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux.
+
+  For example:
+
+  * ``cmake -G "Green Hills MULTI" -D GHS_OS_ROOT=/opt/ghs``
+
 * ``GHS_BSP_NAME``
 
   | Sets ``-bsp`` entry in project file.
   | Defaults to ``sim<arch>`` for ``integrity`` platforms.
 
+  For example:
+
+  * ``cmake -G "Green Hills MULTI"`` for ``simarm`` on ``arm_integrity.tgt``.
+  * ``cmake -G "Green Hills MULTI" -A 86`` for ``sim86`` on ``86_integrity.tgt``.
+  * ``cmake -G "Green Hills MULTI" -A ppc -D GHS_BSP_NAME=sim800`` for ``sim800``
+    on ``ppc_integrity.tgt``.
+  * ``cmake -G "Green Hills MULTI" -D GHS_PRIMARY_TARGET=ppc_integrity.tgt -D GHS_BSP_NAME=fsl-t1040``
+    for ``fsl-t1040`` on ``ppc_integrity.tgt``.
+
 Target Properties
 ^^^^^^^^^^^^^^^^^
 
@@ -82,6 +137,17 @@ The following properties are available:
 * :prop_tgt:`GHS_INTEGRITY_APP`
 * :prop_tgt:`GHS_NO_SOURCE_GROUP_FILE`
 
+MULTI Project Variables
+^^^^^^^^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.3
+
+Adding a Customization file and macros are available through the use of the following
+variables:
+
+* ``GHS_CUSTOMIZATION`` - CMake path name to Customization File.
+* ``GHS_GPJ_MACROS`` - CMake list of Macros.
+
 .. note::
   This generator is deemed experimental as of CMake |release|
   and is still a work in progress.  Future versions of CMake

+ 1 - 1
Help/manual/cmake-variables.7.rst

@@ -308,7 +308,7 @@ Variables that Describe the System
    /variable/CMAKE_SYSTEM_PROCESSOR
    /variable/CMAKE_SYSTEM_VERSION
    /variable/CYGWIN
-   /variable/GHS-MULTI
+   /variable/GHSMULTI
    /variable/IOS
    /variable/MINGW
    /variable/MSVC

+ 0 - 6
Help/variable/GHS-MULTI.rst

@@ -1,6 +0,0 @@
-GHS-MULTI
----------
-
-.. versionadded:: 3.3
-
-``True`` when using :generator:`Green Hills MULTI` generator.

+ 9 - 0
Help/variable/GHSMULTI.rst

@@ -0,0 +1,9 @@
+GHSMULTI
+--------
+
+.. versionadded:: 3.3
+
+``1`` when using :generator:`Green Hills MULTI` generator.
+
+Also, Set to ``1`` when the target system is a Green Hills platform
+(i.e. When CMAKE_SYSTEM_NAME is ``GHS-MULTI``).

+ 2 - 6
Modules/CMakeDetermineCompilerId.cmake

@@ -662,12 +662,8 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
   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(ghs_primary_target "${GHS_PRIMARY_TARGET}")
+    if ("${ghs_primary_target}" MATCHES "integrity")
         set(bsp_name "macro GHS_BSP=${GHS_BSP_NAME}")
         set(os_dir "macro GHS_OS=${GHS_OS_DIR}")
     endif()

+ 100 - 27
Modules/Platform/GHS-MULTI-Determine.cmake

@@ -1,26 +1,77 @@
 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
 # file Copyright.txt or https://cmake.org/licensing for details.
 
-#Setup Green Hills MULTI specific compilation information
+# Setup variables used for Green Hills MULTI generator
+# -- Allow users to override these values.
+
+if(CMAKE_GENERATOR MATCHES "Green Hills MULTI")
+
+  # Set the project primaryTarget value
+  # If not set then primaryTarget will be determined by the generator
+  if((NOT DEFINED GHS_PRIMARY_TARGET) OR (DEFINED CACHE{GHS_PRIMARY_TARGET}))
+    set(GHS_PRIMARY_TARGET "IGNORE" CACHE STRING "GHS MULTI primaryTarget")
+    mark_as_advanced(GHS_PRIMARY_TARGET)
+  endif()
+
+  # Setup MULTI toolset selection variables
+  if((NOT DEFINED GHS_TOOLSET_ROOT) OR (DEFINED CACHE{GHS_TOOLSET_ROOT}))
+    if(CMAKE_HOST_UNIX)
+      set(_ts_root "/usr/ghs")
+    else()
+      set(_ts_root "C:/ghs")
+    endif()
+    set(GHS_TOOLSET_ROOT "${_ts_root}" CACHE PATH "GHS platform toolset root directory")
+    mark_as_advanced(GHS_TOOLSET_ROOT)
+    unset(_ts_root)
+  endif()
+
+  # Setup MULTI project variables
+  if((NOT DEFINED GHS_CUSTOMIZATION) OR (DEFINED CACHE{GHS_CUSTOMIZATION}))
+    set(GHS_CUSTOMIZATION "" CACHE FILEPATH "optional GHS customization")
+    mark_as_advanced(GHS_CUSTOMIZATION)
+  endif()
+
+  if((NOT DEFINED GHS_GPJ_MACROS) OR (DEFINED CACHE{GHS_GPJ_MACROS}))
+    set(GHS_GPJ_MACROS "" CACHE STRING "optional GHS macros generated in the .gpjs for legacy reasons")
+    mark_as_advanced(GHS_GPJ_MACROS)
+  endif()
 
-if(CMAKE_HOST_UNIX)
-  set(GHS_OS_ROOT "/usr/ghs" CACHE PATH "GHS platform OS search root directory")
-else()
-  set(GHS_OS_ROOT "C:/ghs" CACHE PATH "GHS platform OS search root directory")
 endif()
-mark_as_advanced(GHS_OS_ROOT)
 
-set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory")
-mark_as_advanced(GHS_OS_DIR)
+# If project primaryTarget not set then set target platform name.
+# -- May be used by the generator when determining the primaryTarget.
+if(NOT GHS_PRIMARY_TARGET)
+  if((NOT DEFINED GHS_TARGET_PLATFORM) OR (DEFINED CACHE{GHS_TARGET_PLATFORM}))
+    set(GHS_TARGET_PLATFORM "integrity" CACHE STRING "GHS MULTI target platform")
+    mark_as_advanced(GHS_TARGET_PLATFORM)
+  endif()
+endif()
 
-set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler OS option")
-mark_as_advanced(GHS_OS_DIR_OPTION)
+# Settings for OS selection
+if((NOT DEFINED GHS_OS_ROOT) OR (DEFINED CACHE{GHS_OS_ROOT}))
+  if(CMAKE_HOST_UNIX)
+    set(_os_root "/usr/ghs")
+  else()
+    set(_os_root "C:/ghs")
+  endif()
+  set(GHS_OS_ROOT "${_os_root}" CACHE PATH "GHS platform OS search root directory")
+  unset(_os_root)
+  mark_as_advanced(GHS_OS_ROOT)
+endif()
 
-#set GHS_OS_DIR if not set by user
-if(NOT GHS_OS_DIR)
+# Search for GHS_OS_DIR if not set by user and is known to be required
+if(GHS_PRIMARY_TARGET MATCHES "integrity" OR GHS_TARGET_PLATFORM MATCHES "integrity")
+  # Needed - Use a value that will make it apparent RTOS selection failed
+  set(_ghs_os_dir "GHS_OS_DIR-NOT-SPECIFIED")
+else()
+  # Not needed for this target
+  set(_ghs_os_dir "IGNORE")
+endif()
+
+if(_ghs_os_dir AND NOT DEFINED GHS_OS_DIR)
   if(EXISTS ${GHS_OS_ROOT})
 
-    #get all directories in root directory
+    # Get all directories in root directory
     FILE(GLOB GHS_CANDIDATE_OS_DIRS
       LIST_DIRECTORIES true RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
     FILE(GLOB GHS_CANDIDATE_OS_FILES
@@ -29,28 +80,50 @@ if(NOT GHS_OS_DIR)
       list(REMOVE_ITEM GHS_CANDIDATE_OS_DIRS ${GHS_CANDIDATE_OS_FILES})
     endif ()
 
-    #filter based on platform name
-    if(GHS_TARGET_PLATFORM MATCHES "integrity")
+    # Filter based on platform name
+    if(GHS_PRIMARY_TARGET MATCHES "integrity" OR 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()
 
+    # Select latest? of matching candidates
     if(GHS_CANDIDATE_OS_DIRS)
       list(SORT GHS_CANDIDATE_OS_DIRS)
       list(GET GHS_CANDIDATE_OS_DIRS -1 GHS_OS_DIR)
-      string(CONCAT GHS_OS_DIR ${GHS_OS_ROOT} "/" ${GHS_OS_DIR})
+      string(CONCAT _ghs_os_dir ${GHS_OS_ROOT} "/" ${GHS_OS_DIR})
     endif()
-
-    #update cache with new value
-    set(GHS_OS_DIR "${GHS_OS_DIR}" CACHE PATH "GHS platform OS directory" FORCE)
   endif()
 endif()
 
-set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name")
+#Used for targets requiring RTOS
+if((NOT DEFINED GHS_OS_DIR) OR (DEFINED CACHE{GHS_OS_DIR}))
+  set(GHS_OS_DIR "${_ghs_os_dir}" CACHE PATH "GHS platform OS directory")
+  mark_as_advanced(GHS_OS_DIR)
+endif()
+unset(_ghs_os_dir)
+
+if((NOT DEFINED GHS_OS_DIR_OPTION) OR (DEFINED CACHE{GHS_OS_DIR_OPTION}))
+  set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler OS option")
+  mark_as_advanced(GHS_OS_DIR_OPTION)
+endif()
+
+# Select GHS_BSP_NAME if not set by user and is known to be required
+if(GHS_PRIMARY_TARGET MATCHES "integrity" OR GHS_TARGET_PLATFORM MATCHES "integrity")
+  set(_ghs_bsp_name "GHS_BSP_NAME-NOT-SPECIFIED")
+else()
+  set(_ghs_bsp_name "IGNORE")
+endif()
 
-set(GHS_CUSTOMIZATION "" CACHE FILEPATH "optional GHS customization")
-mark_as_advanced(GHS_CUSTOMIZATION)
-set(GHS_GPJ_MACROS "" CACHE STRING "optional GHS macros generated in the .gpjs for legacy reasons")
-mark_as_advanced(GHS_GPJ_MACROS)
+if(_ghs_bsp_name AND NOT DEFINED GHS_BSP_NAME)
+  # First try taking architecture from `-A` option
+  if(CMAKE_GENERATOR_PLATFORM)
+    set(_ghs_bsp_name "sim${CMAKE_GENERATOR_PLATFORM}")
+  else()
+    set(_ghs_bsp_name "simarm")
+  endif()
+endif()
+
+if((NOT DEFINED GHS_BSP_NAME) OR (DEFINED CACHE{GHS_BSP_NAME}))
+  set(GHS_BSP_NAME "${_ghs_bsp_name}" CACHE STRING "BSP name")
+  mark_as_advanced(GHS_BSP_NAME)
+endif()
+unset(_ghs_bsp_name)

+ 68 - 129
Source/cmGlobalGhsMultiGenerator.cxx

@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalGhsMultiGenerator.h"
 
-#include <algorithm>
 #include <map>
 #include <ostream>
 #include <utility>
@@ -18,6 +17,7 @@
 #include "cmLocalGenerator.h"
 #include "cmLocalGhsMultiGenerator.h"
 #include "cmMakefile.h"
+#include "cmMessageType.h"
 #include "cmState.h"
 #include "cmStateTypes.h"
 #include "cmStringAlgorithms.h"
@@ -29,10 +29,8 @@
 const char* cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj";
 #ifdef __linux__
 const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild";
-const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "/usr/ghs";
 #elif defined(_WIN32)
 const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild.exe";
-const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "C:/ghs";
 #endif
 
 cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm)
@@ -70,31 +68,21 @@ void cmGlobalGhsMultiGenerator::ComputeTargetObjectDirectory(
 bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
                                                     bool build, cmMakefile* mf)
 {
+  /* In build mode nothing to be done.
+   * Toolset already determined and build tool absolute path is cached.
+   */
   if (build) {
     return true;
   }
-  std::string tsp; /* toolset path */
 
+  /* Determine the absolute directory for the toolset */
+  std::string tsp;
   this->GetToolset(mf, tsp, ts);
 
   /* no toolset was found */
   if (tsp.empty()) {
     return false;
   }
-  if (ts.empty()) {
-    std::string message;
-    message = cmStrCat(
-      "Green Hills MULTI: -T <toolset> not specified; defaulting to \"", tsp,
-      '"');
-    cmSystemTools::Message(message);
-
-    /* store the full toolset for later use
-     * -- already done if -T<toolset> was specified
-     */
-    mf->AddCacheDefinition("CMAKE_GENERATOR_TOOLSET", tsp,
-                           "Location of generator toolset.",
-                           cmStateEnums::INTERNAL);
-  }
 
   /* set the build tool to use */
   std::string gbuild(tsp + ((tsp.back() == '/') ? "" : "/") +
@@ -102,13 +90,13 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
   cmValue prevTool = mf->GetDefinition("CMAKE_MAKE_PROGRAM");
 
   /* check if the toolset changed from last generate */
-  if (prevTool && (gbuild != *prevTool)) {
-    std::string message =
+  if (cmNonempty(prevTool) && !cmSystemTools::ComparePath(gbuild, prevTool)) {
+    std::string const& e =
       cmStrCat("toolset build tool: ", gbuild,
-               "\nDoes not match the previously used build tool: ", *prevTool,
+               "\nDoes not match the previously used build tool: ", prevTool,
                "\nEither remove the CMakeCache.txt file and CMakeFiles "
                "directory or choose a different binary directory.");
-    cmSystemTools::Error(message);
+    mf->IssueMessage(MessageType::FATAL_ERROR, e);
     return false;
   }
 
@@ -124,58 +112,20 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
 bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
                                                      cmMakefile* mf)
 {
-  std::string arch;
-  if (p.empty()) {
-    cmSystemTools::Message(
-      "Green Hills MULTI: -A <arch> not specified; defaulting to \"arm\"");
-    arch = "arm";
-
-    /* store the platform name for later use
-     * -- already done if -A<arch> was specified
-     */
-    mf->AddCacheDefinition("CMAKE_GENERATOR_PLATFORM", arch,
-                           "Name of generator platform.",
-                           cmStateEnums::INTERNAL);
-  } else {
-    arch = p;
-  }
-
-  /* check if OS location has been updated by platform scripts */
-  std::string platform = mf->GetSafeDefinition("GHS_TARGET_PLATFORM");
-  std::string osdir = mf->GetSafeDefinition("GHS_OS_DIR");
-  if (cmIsOff(osdir) && platform.find("integrity") != std::string::npos) {
-    if (!this->CMakeInstance->GetIsInTryCompile()) {
-      /* required OS location is not found */
-      std::string m = cmStrCat(
-        "Green Hills MULTI: GHS_OS_DIR not specified; No OS found in \"",
-        mf->GetSafeDefinition("GHS_OS_ROOT"), '"');
-      cmSystemTools::Message(m);
+  /* set primary target */
+  cmValue t = mf->GetDefinition("GHS_PRIMARY_TARGET");
+  if (cmIsOff(t)) {
+    /* Use the value from `-A` or use `arm` */
+    std::string arch = "arm";
+    if (!cmIsOff(p)) {
+      arch = p;
     }
-    osdir = "GHS_OS_DIR-NOT-SPECIFIED";
-  } else if (!this->CMakeInstance->GetIsInTryCompile() &&
-             cmIsOff(this->OsDir) && !cmIsOff(osdir)) {
-    /* OS location was updated by auto-selection */
-    std::string m = cmStrCat(
-      "Green Hills MULTI: GHS_OS_DIR not specified; found \"", osdir, '"');
-    cmSystemTools::Message(m);
-  }
-  this->OsDir = osdir;
-
-  // Determine GHS_BSP_NAME
-  std::string bspName = mf->GetSafeDefinition("GHS_BSP_NAME");
-
-  if (cmIsOff(bspName) && platform.find("integrity") != std::string::npos) {
-    bspName = "sim" + arch;
-    /* write back the calculate name for next time */
-    mf->AddCacheDefinition("GHS_BSP_NAME", bspName,
-                           "Name of GHS target platform.",
-                           cmStateEnums::STRING, true);
-    std::string m = cmStrCat(
-      "Green Hills MULTI: GHS_BSP_NAME not specified; defaulting to \"",
-      bspName, '"');
-    cmSystemTools::Message(m);
-  }
+    cmValue platform = mf->GetDefinition("GHS_TARGET_PLATFORM");
+    std::string tgt = cmStrCat(arch, '_', platform, ".tgt");
 
+    /* update the primary target name*/
+    mf->AddDefinition("GHS_PRIMARY_TARGET", tgt);
+  }
   return true;
 }
 
@@ -186,20 +136,6 @@ void cmGlobalGhsMultiGenerator::EnableLanguage(
 
   mf->AddDefinition("GHSMULTI", "1"); // identifier for user CMake files
 
-  const char* tgtPlatform = mf->GetDefinition("GHS_TARGET_PLATFORM")->c_str();
-  if (!tgtPlatform) {
-    cmSystemTools::Message("Green Hills MULTI: GHS_TARGET_PLATFORM not "
-                           "specified; defaulting to \"integrity\"");
-    tgtPlatform = "integrity";
-  }
-
-  /* store the platform name for later use */
-  mf->AddCacheDefinition("GHS_TARGET_PLATFORM", tgtPlatform,
-                         "Name of GHS target platform.", cmStateEnums::STRING);
-
-  /* store original OS location */
-  this->OsDir = mf->GetSafeDefinition("GHS_OS_DIR");
-
   this->cmGlobalGenerator::EnableLanguage(l, mf, optional);
 }
 
@@ -212,43 +148,59 @@ bool cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* /*mf*/)
   return true;
 }
 
-void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd,
+void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsp,
                                            const std::string& ts)
 {
-  cmValue ghsRoot = mf->GetDefinition("GHS_TOOLSET_ROOT");
+  /* Determine tsp - full path of the toolset from ts (toolset hint via -T) */
 
-  if (cmNonempty(ghsRoot)) {
-    tsd = *ghsRoot;
-  } else {
-    tsd = DEFAULT_TOOLSET_ROOT;
-  }
+  std::string root = mf->GetSafeDefinition("GHS_TOOLSET_ROOT");
 
+  // Check if `-T` was set by user
   if (ts.empty()) {
+    // Enter toolset search mode
     std::vector<std::string> output;
 
-    // Use latest? version
-    if (tsd.back() != '/') {
-      tsd += "/";
+    // Make sure root exists...
+    if (!cmSystemTools::PathExists(root)) {
+      std::string msg =
+        "GHS_TOOLSET_ROOT directory \"" + root + "\" does not exist.";
+      mf->IssueMessage(MessageType::FATAL_ERROR, msg);
+      tsp = "";
+      return;
+    }
+
+    // Add a directory separator
+    if (root.back() != '/') {
+      root += "/";
     }
-    cmSystemTools::Glob(tsd, "comp_[^;]+", output);
+
+    // Get all compiler directories in toolset root
+    cmSystemTools::Glob(root, "comp_[^;]+", output);
 
     if (output.empty()) {
+      // No compiler directories found
       std::string msg =
-        "No GHS toolsets found in GHS_TOOLSET_ROOT \"" + tsd + "\".";
-      cmSystemTools::Error(msg);
-      tsd = "";
+        "No GHS toolsets found in GHS_TOOLSET_ROOT \"" + root + "\".";
+      mf->IssueMessage(MessageType::FATAL_ERROR, msg);
+      tsp = "";
     } else {
-      tsd += output.back();
+      // Use latest? version
+      tsp = root + output.back();
     }
+
   } else {
+    // Toolset was provided by user
     std::string tryPath;
-    tryPath = cmSystemTools::CollapseFullPath(ts, tsd);
+
+    // NOTE: CollapseFullPath() will determine if user toolset was full path or
+    //       or relative path.
+    tryPath = cmSystemTools::CollapseFullPath(ts, root);
     if (!cmSystemTools::FileExists(tryPath)) {
-      std::string msg = "GHS toolset \"" + tryPath + "\" not found.";
-      cmSystemTools::Error(msg);
-      tsd = "";
+      std::string msg = "GHS toolset \"" + tryPath + "\" does not exist.";
+      mf->IssueMessage(MessageType::FATAL_ERROR, msg);
+      tsp = "";
     } else {
-      tsd = tryPath;
+      tsp = tryPath;
     }
   }
 }
@@ -333,25 +285,25 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout,
   fout << "# Top Level Project File\n";
 
   // Specify BSP option if supplied by user
-  cmValue bspName =
-    this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME");
+  // -- not all platforms require this entry in the project file
+  cmValue bspName = root->GetMakefile()->GetDefinition("GHS_BSP_NAME");
   if (!cmIsOff(bspName)) {
     fout << "    -bsp " << *bspName << '\n';
   }
 
   // Specify OS DIR if supplied by user
   // -- not all platforms require this entry in the project file
-  if (!cmIsOff(this->OsDir)) {
+  cmValue osDir = root->GetMakefile()->GetDefinition("GHS_OS_DIR");
+  if (!cmIsOff(osDir)) {
     cmValue osDirOption =
-      this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION");
-    std::replace(this->OsDir.begin(), this->OsDir.end(), '\\', '/');
+      root->GetMakefile()->GetDefinition("GHS_OS_DIR_OPTION");
     fout << "    ";
     if (cmIsOff(osDirOption)) {
       fout << "";
     } else {
       fout << *osDirOption;
     }
-    fout << "\"" << this->OsDir << "\"\n";
+    fout << "\"" << osDir << "\"\n";
   }
 }
 
@@ -616,8 +568,7 @@ void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout,
                                             cmLocalGenerator* root)
 {
   fout << "macro PROJ_NAME=" << root->GetProjectName() << '\n';
-  cmValue ghsGpjMacros =
-    this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS");
+  cmValue ghsGpjMacros = root->GetMakefile()->GetDefinition("GHS_GPJ_MACROS");
   if (ghsGpjMacros) {
     std::vector<std::string> expandedList = cmExpandedList(*ghsGpjMacros);
     for (std::string const& arg : expandedList) {
@@ -629,20 +580,8 @@ void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout,
 void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(
   cmLocalGenerator* root, std::ostream& fout)
 {
-  /* set primary target */
-  std::string tgt;
-  cmValue t =
-    this->GetCMakeInstance()->GetCacheDefinition("GHS_PRIMARY_TARGET");
-  if (cmNonempty(t)) {
-    tgt = *t;
-    this->GetCMakeInstance()->MarkCliAsUsed("GHS_PRIMARY_TARGET");
-  } else {
-    cmValue a =
-      this->GetCMakeInstance()->GetCacheDefinition("CMAKE_GENERATOR_PLATFORM");
-    cmValue p =
-      this->GetCMakeInstance()->GetCacheDefinition("GHS_TARGET_PLATFORM");
-    tgt = cmStrCat((a ? *a : ""), '_', (p ? *p : ""), ".tgt");
-  }
+  /* put primary target and customization files into project file */
+  cmValue const tgt = root->GetMakefile()->GetDefinition("GHS_PRIMARY_TARGET");
 
   /* clang-format off */
   fout << "primaryTarget=" << tgt << "\n"
@@ -653,7 +592,7 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(
   /* clang-format on */
 
   cmValue const customization =
-    this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION");
+    root->GetMakefile()->GetDefinition("GHS_CUSTOMIZATION");
   if (cmNonempty(customization)) {
     fout << "customization="
          << cmGlobalGhsMultiGenerator::TrimQuotes(*customization) << '\n';

+ 0 - 2
Source/cmGlobalGhsMultiGenerator.h

@@ -112,9 +112,7 @@ private:
 
   static std::string TrimQuotes(std::string str);
 
-  std::string OsDir;
   static const char* DEFAULT_BUILD_PROGRAM;
-  static const char* DEFAULT_TOOLSET_ROOT;
 
   bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt,
                                std::vector<cmGeneratorTarget const*>& build);