From bff48c59080784217383a270cc5e6af4f0d7e510 Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:09 -0500 Subject: GHS: Update generator documentation Break up into different sections and add examples --- Help/generator/Green Hills MULTI.rst | 119 ++++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 29 deletions(-) diff --git a/Help/generator/Green Hills MULTI.rst b/Help/generator/Green Hills MULTI.rst index 5d2b1cd..bae4980 100644 --- a/Help/generator/Green Hills MULTI.rst +++ b/Help/generator/Green Hills MULTI.rst @@ -8,70 +8,120 @@ 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 `` can be supplied for setting the target architecture. - ```` 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 `` 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 ``_.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``. + +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`` 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``. + Target Properties ^^^^^^^^^^^^^^^^^ @@ -82,6 +132,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 -- cgit v0.12 From 831607889f6d197bba260fc604cd5df992d248b0 Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:10 -0500 Subject: GHS: Update selection of primaryTarget in MULTI project file Changes to ``-A`` handling: * Don't force CMAKE_GENERATOR_PLATFORM into cache when using default value (breaks using CMake presets). * Don't print message when using default value (breaks CMake tests). Changes to ``GHS_PRIMARY_TARGET`` handling: * Add as a cache variable so its known to GUI * Don't always include``GHS_TARGET_PLATFORM``, it's only needed if ``GHS_PRIMARY_TARGET`` wasn't set by the user. * Set ``GHS_PRIMARY_TARGET`` during platform selection instead of when a language is enabled. By performing this sooner ``GHS_TARGET_PLATFORM`` is not always required to be set into cache. --- Modules/CMakeDetermineCompilerId.cmake | 8 ++--- Modules/Platform/GHS-MULTI-Determine.cmake | 19 ++++++++-- Source/cmGlobalGhsMultiGenerator.cxx | 58 +++++++++++------------------- 3 files changed, 40 insertions(+), 45 deletions(-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index edfa016..b7119a8 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/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() diff --git a/Modules/Platform/GHS-MULTI-Determine.cmake b/Modules/Platform/GHS-MULTI-Determine.cmake index 349d906..3f094db 100644 --- a/Modules/Platform/GHS-MULTI-Determine.cmake +++ b/Modules/Platform/GHS-MULTI-Determine.cmake @@ -1,7 +1,21 @@ # 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 +if(CMAKE_GENERATOR MATCHES "Green Hills MULTI") + + # Set the project primaryTarget value + # If not set then primaryTarget will be determined by the generator + set(GHS_PRIMARY_TARGET "IGNORE" CACHE STRING "GHS MULTI primaryTarget") + mark_as_advanced(GHS_PRIMARY_TARGET) + + if(NOT GHS_PRIMARY_TARGET) + # If project primaryTarget not set by user then set target platform name + # to be used by the generator when determining the primaryTarget. + set(GHS_TARGET_PLATFORM "integrity" CACHE STRING "GHS MULTI target platform") + mark_as_advanced(GHS_TARGET_PLATFORM) + endif() +endif() if(CMAKE_HOST_UNIX) set(GHS_OS_ROOT "/usr/ghs" CACHE PATH "GHS platform OS search root directory") @@ -30,7 +44,7 @@ if(NOT GHS_OS_DIR) endif () #filter based on platform name - if(GHS_TARGET_PLATFORM MATCHES "integrity") + 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) @@ -50,6 +64,7 @@ endif() set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name") +# Setup MULTI project variables 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") diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index b1c0488..ffa2c4c 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -124,20 +124,25 @@ 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 not specified; defaulting to \"arm\""); - arch = "arm"; - - /* store the platform name for later use - * -- already done if -A was specified - */ - mf->AddCacheDefinition("CMAKE_GENERATOR_PLATFORM", arch, - "Name of generator platform.", - cmStateEnums::INTERNAL); + /* set primary target */ + cmValue t = + this->GetCMakeInstance()->GetCacheDefinition("GHS_PRIMARY_TARGET"); + if (!cmIsOff(t)) { + this->GetCMakeInstance()->MarkCliAsUsed("GHS_PRIMARY_TARGET"); } else { - arch = p; + /* Use the value from `-A` or use `arm` */ + std::string arch = "arm"; + if (!cmIsOff(p)) { + arch = p; + } + cmValue platform = + this->GetCMakeInstance()->GetCacheDefinition("GHS_TARGET_PLATFORM"); + std::string tgt = cmStrCat(arch, '_', platform, ".tgt"); + + /* update the primary target name*/ + mf->AddCacheDefinition("GHS_PRIMARY_TARGET", tgt, + "Generator selected GHS MULTI primaryTarget.", + cmStateEnums::STRING, true); } /* check if OS location has been updated by platform scripts */ @@ -165,6 +170,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p, std::string bspName = mf->GetSafeDefinition("GHS_BSP_NAME"); if (cmIsOff(bspName) && platform.find("integrity") != std::string::npos) { + std::string arch = "arm"; /* FIXME - extract from GHS_PRIMARY_TARGET */ bspName = "sim" + arch; /* write back the calculate name for next time */ mf->AddCacheDefinition("GHS_BSP_NAME", bspName, @@ -186,17 +192,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"); @@ -629,20 +624,9 @@ void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout, void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives( cmLocalGenerator* root, std::ostream& fout) { - /* set primary target */ - std::string tgt; - cmValue t = + /* put primary target and customization files into project file */ + cmValue const tgt = 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"); - } /* clang-format off */ fout << "primaryTarget=" << tgt << "\n" -- cgit v0.12 From 8114ddcad1d274fd16ef6e1a74e5a0d083242018 Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:10 -0500 Subject: GHS: Continue splitting variables used by generator This makes it easier to use GHS-MULTI platform in other generators that want to use the GHS-MULTI platform and compilers. --- Modules/Platform/GHS-MULTI-Determine.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/Platform/GHS-MULTI-Determine.cmake b/Modules/Platform/GHS-MULTI-Determine.cmake index 3f094db..15a06e1 100644 --- a/Modules/Platform/GHS-MULTI-Determine.cmake +++ b/Modules/Platform/GHS-MULTI-Determine.cmake @@ -15,6 +15,12 @@ if(CMAKE_GENERATOR MATCHES "Green Hills MULTI") set(GHS_TARGET_PLATFORM "integrity" CACHE STRING "GHS MULTI target platform") mark_as_advanced(GHS_TARGET_PLATFORM) endif() + + # Setup MULTI project variables + 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) endif() if(CMAKE_HOST_UNIX) @@ -63,9 +69,3 @@ if(NOT GHS_OS_DIR) endif() set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name") - -# Setup MULTI project variables -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) -- cgit v0.12 From 83eb5695e9540d18d7ff40a369763036813da79b Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:10 -0500 Subject: GHS: Update toolset selection logic -- Ensure that GHS_TOOLSET_ROOT is used as a path * Converts directory path slashes to CMake style -- Use ComparePath() to properly check for path changes of build tool * Accounts for Windows file-system case insensitivity. -- Don't print message "defaulting" messages (this causes CMake test failures) -- Don't force update CMAKE_GENERATOR_TOOLSET back into cache when `-T` is not used on initial configure. This change avoids an unnessary error message when accidentally using `-T` in subsequent runs but the same tools are always used. -- Use IssueMessage() for error messages. --- Modules/Platform/GHS-MULTI-Determine.cmake | 10 ++++ Source/cmGlobalGhsMultiGenerator.cxx | 88 ++++++++++++++++-------------- Source/cmGlobalGhsMultiGenerator.h | 1 - 3 files changed, 56 insertions(+), 43 deletions(-) diff --git a/Modules/Platform/GHS-MULTI-Determine.cmake b/Modules/Platform/GHS-MULTI-Determine.cmake index 15a06e1..0a6a3b1 100644 --- a/Modules/Platform/GHS-MULTI-Determine.cmake +++ b/Modules/Platform/GHS-MULTI-Determine.cmake @@ -16,6 +16,16 @@ if(CMAKE_GENERATOR MATCHES "Green Hills MULTI") mark_as_advanced(GHS_TARGET_PLATFORM) endif() + # Setup MULTI toolset selection variables + 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) + # Setup MULTI project variables set(GHS_CUSTOMIZATION "" CACHE FILEPATH "optional GHS customization") mark_as_advanced(GHS_CUSTOMIZATION) diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index ffa2c4c..0727f67 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalGhsMultiGenerator.h" -#include #include #include #include @@ -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 not specified; defaulting to \"", tsp, - '"'); - cmSystemTools::Message(message); - - /* store the full toolset for later use - * -- already done if -T 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; } @@ -207,43 +195,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 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; } } } diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index bd08301..935a878 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -114,7 +114,6 @@ private: std::string OsDir; static const char* DEFAULT_BUILD_PROGRAM; - static const char* DEFAULT_TOOLSET_ROOT; bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt, std::vector& build); -- cgit v0.12 From e006b87cc635f847eebad567159d17db191dc1f0 Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:11 -0500 Subject: GHS: GHSMULTI - Update documentation to match implementation * The variable being set was named `GHSMULTI` not `GHS-MULTI`. --- Auxiliary/vim/syntax/cmake.vim | 2 +- Help/manual/cmake-variables.7.rst | 2 +- Help/variable/GHS-MULTI.rst | 6 ------ Help/variable/GHSMULTI.rst | 9 +++++++++ 4 files changed, 11 insertions(+), 8 deletions(-) delete mode 100644 Help/variable/GHS-MULTI.rst create mode 100644 Help/variable/GHSMULTI.rst diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 80bde99..52330f7 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/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 diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 628924f..3c50117 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/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 diff --git a/Help/variable/GHS-MULTI.rst b/Help/variable/GHS-MULTI.rst deleted file mode 100644 index bb139af..0000000 --- a/Help/variable/GHS-MULTI.rst +++ /dev/null @@ -1,6 +0,0 @@ -GHS-MULTI ---------- - -.. versionadded:: 3.3 - -``True`` when using :generator:`Green Hills MULTI` generator. diff --git a/Help/variable/GHSMULTI.rst b/Help/variable/GHSMULTI.rst new file mode 100644 index 0000000..3daef5d --- /dev/null +++ b/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``). -- cgit v0.12 From 0427f225395d3fbc5df273596cb7b9d150a369b7 Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:11 -0500 Subject: GHS: Update RTOS selection logic Selection of an RTOS only needs to be performed if not set by user. Avoid CMake developer warnings for setting GHS_OS_DIR multiple times. Instead only set it once after searching has been performed. Remove all the logic for printing error and status messages about RTOS selection. This was broken and reporting incorrect messages. These messages also breaks CMake tests. NOTE: If RTOS selection fails then the compiler checks will result in a build error. The build error will report that the RTOS "GHS_OS_DIR-NOT-SPECIFIED" does not exist. --- Modules/Platform/GHS-MULTI-Determine.cmake | 43 +++++++++++++++++------------- Source/cmGlobalGhsMultiGenerator.cxx | 30 +++------------------ Source/cmGlobalGhsMultiGenerator.h | 1 - 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/Modules/Platform/GHS-MULTI-Determine.cmake b/Modules/Platform/GHS-MULTI-Determine.cmake index 0a6a3b1..ba1bebb 100644 --- a/Modules/Platform/GHS-MULTI-Determine.cmake +++ b/Modules/Platform/GHS-MULTI-Determine.cmake @@ -33,24 +33,27 @@ if(CMAKE_GENERATOR MATCHES "Green Hills MULTI") mark_as_advanced(GHS_GPJ_MACROS) endif() +# Settings for OS selection if(CMAKE_HOST_UNIX) - set(GHS_OS_ROOT "/usr/ghs" CACHE PATH "GHS platform OS search root directory") + set(_os_root "/usr/ghs") else() - set(GHS_OS_ROOT "C:/ghs" CACHE PATH "GHS platform OS search root directory") + 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) -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_OPTION) - -#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") + # Use a value that will make it apparent RTOS selection failed + set(_ghs_os_dir "GHS_OS_DIR-NOT-SPECIFIED") +else() + 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 @@ -59,23 +62,25 @@ if(NOT GHS_OS_DIR) list(REMOVE_ITEM GHS_CANDIDATE_OS_DIRS ${GHS_CANDIDATE_OS_FILES}) endif () - #filter based on platform name + # 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() +#Used for targets requiring RTOS +set(GHS_OS_DIR "${_ghs_os_dir}" 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_OPTION) + set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name") diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 0727f67..e319242 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -133,27 +133,6 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p, cmStateEnums::STRING, true); } - /* 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); - } - 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"); @@ -180,9 +159,6 @@ void cmGlobalGhsMultiGenerator::EnableLanguage( mf->AddDefinition("GHSMULTI", "1"); // identifier for user CMake files - /* store original OS location */ - this->OsDir = mf->GetSafeDefinition("GHS_OS_DIR"); - this->cmGlobalGenerator::EnableLanguage(l, mf, optional); } @@ -340,17 +316,17 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout, // Specify OS DIR if supplied by user // -- not all platforms require this entry in the project file - if (!cmIsOff(this->OsDir)) { + cmValue osDir = this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR"); + if (!cmIsOff(osDir)) { cmValue osDirOption = this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION"); - std::replace(this->OsDir.begin(), this->OsDir.end(), '\\', '/'); fout << " "; if (cmIsOff(osDirOption)) { fout << ""; } else { fout << *osDirOption; } - fout << "\"" << this->OsDir << "\"\n"; + fout << "\"" << osDir << "\"\n"; } } diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 935a878..9076e0e 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -112,7 +112,6 @@ private: static std::string TrimQuotes(std::string str); - std::string OsDir; static const char* DEFAULT_BUILD_PROGRAM; bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt, -- cgit v0.12 From a55b5c4e188126cf73c3e0a25d39f10ed8fcbece Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:11 -0500 Subject: GHS: Update BSP selection logic Selection of a BSP only needs to be performed if not set by user. Remove all the logic for printing error and status messages about BSP selection. These messages also breaks CMake tests. NOTE: If BSP selection fails then the compiler checks will result in a build error. The build error will report that the BSP does not exist. --- Help/generator/Green Hills MULTI.rst | 2 ++ Modules/Platform/GHS-MULTI-Determine.cmake | 18 +++++++++++++++++- Source/cmGlobalGhsMultiGenerator.cxx | 18 +----------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Help/generator/Green Hills MULTI.rst b/Help/generator/Green Hills MULTI.rst index bae4980..472f725 100644 --- a/Help/generator/Green Hills MULTI.rst +++ b/Help/generator/Green Hills MULTI.rst @@ -121,6 +121,8 @@ the ``GHS_BSP_NAME`` variable. * ``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 ^^^^^^^^^^^^^^^^^ diff --git a/Modules/Platform/GHS-MULTI-Determine.cmake b/Modules/Platform/GHS-MULTI-Determine.cmake index ba1bebb..501acca 100644 --- a/Modules/Platform/GHS-MULTI-Determine.cmake +++ b/Modules/Platform/GHS-MULTI-Determine.cmake @@ -83,4 +83,20 @@ 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_OPTION) -set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name") +# 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() + +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() + +set(GHS_BSP_NAME "${_ghs_bsp_name}" CACHE STRING "BSP name") diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index e319242..a237689 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -132,23 +132,6 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p, "Generator selected GHS MULTI primaryTarget.", cmStateEnums::STRING, true); } - - // Determine GHS_BSP_NAME - std::string bspName = mf->GetSafeDefinition("GHS_BSP_NAME"); - - if (cmIsOff(bspName) && platform.find("integrity") != std::string::npos) { - std::string arch = "arm"; /* FIXME - extract from GHS_PRIMARY_TARGET */ - 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); - } - return true; } @@ -308,6 +291,7 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout, fout << "# Top Level Project File\n"; // Specify BSP option if supplied by user + // -- not all platforms require this entry in the project file cmValue bspName = this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME"); if (!cmIsOff(bspName)) { -- cgit v0.12 From ab6f0b51b110dabfeed231f9c5ed9e816f480335 Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:12 -0500 Subject: GHS: Add note about -T and path style If backslashes are used for CMAKE_GENERATOR_TOOLSET, then ctest processing will complain about COMP0010. For example: Syntax error in cmake code at C:/Users/XXX/test_bld/Tests/CTestTestfile.cmake:253 when parsing string C:\Users\XXX\bin_tools\XXX Invalid escape sequence \U Policy CMP0010 is not set: Bad variable reference syntax is an error. Run "cmake --help-policy CMP0010" for policy details. Use the cmake_policy command to set the policy and suppress this warning. --- Help/generator/Green Hills MULTI.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Help/generator/Green Hills MULTI.rst b/Help/generator/Green Hills MULTI.rst index 472f725..1b4739b 100644 --- a/Help/generator/Green Hills MULTI.rst +++ b/Help/generator/Green Hills MULTI.rst @@ -69,13 +69,16 @@ 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`` +* ``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 ^^^^^^^^^^^^^^^^^^^^ -- cgit v0.12 From aa59eaac4faf04f1c195be4463795a7953de7fde Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Mon, 15 Nov 2021 13:15:12 -0500 Subject: GHS: Allow setting GHS variables from toolchain file * Update generator to use the current variable definition, not the CACHE definition. * Avoid overwriting toolchain variables and avoid developer warnings when setting up the GHS variables. -- A cache entry is only required when: a) The toolchain uses set( CACHE ) to set the variable b) A -D or preset value was used to set the variable The cache entry is required so that the TYPE gets set properly. -- Avoid the Policy CMP0126 warnings: setting cache variable when normal variable exists * Move GHS_PRIMARY_TARGET back into area so non-GHS generator toolchain file can trigger the OS search. --- Modules/Platform/GHS-MULTI-Determine.cmake | 91 +++++++++++++++++++----------- Source/cmGlobalGhsMultiGenerator.cxx | 29 ++++------ 2 files changed, 69 insertions(+), 51 deletions(-) diff --git a/Modules/Platform/GHS-MULTI-Determine.cmake b/Modules/Platform/GHS-MULTI-Determine.cmake index 501acca..96f0162 100644 --- a/Modules/Platform/GHS-MULTI-Determine.cmake +++ b/Modules/Platform/GHS-MULTI-Determine.cmake @@ -2,54 +2,72 @@ # file Copyright.txt or https://cmake.org/licensing for details. # 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 - set(GHS_PRIMARY_TARGET "IGNORE" CACHE STRING "GHS MULTI primaryTarget") - mark_as_advanced(GHS_PRIMARY_TARGET) - - if(NOT GHS_PRIMARY_TARGET) - # If project primaryTarget not set by user then set target platform name - # to be used by the generator when determining the primaryTarget. - set(GHS_TARGET_PLATFORM "integrity" CACHE STRING "GHS MULTI target platform") - mark_as_advanced(GHS_TARGET_PLATFORM) + 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(CMAKE_HOST_UNIX) - set(_ts_root "/usr/ghs") - else() - set(_ts_root "C:/ghs") + 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() - set(GHS_TOOLSET_ROOT "${_ts_root}" CACHE PATH "GHS platform toolset root directory") - mark_as_advanced(GHS_TOOLSET_ROOT) - unset(_ts_root) # Setup MULTI project variables - 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((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() + +endif() + +# 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() # Settings for OS selection -if(CMAKE_HOST_UNIX) - set(_os_root "/usr/ghs") -else() - set(_os_root "C:/ghs") +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_ROOT "${_os_root}" CACHE PATH "GHS platform OS search root directory") -unset(_os_root) -mark_as_advanced(GHS_OS_ROOT) # 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") - # Use a value that will make it apparent RTOS selection failed + # 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}) @@ -77,11 +95,16 @@ if(_ghs_os_dir AND NOT DEFINED GHS_OS_DIR) endif() #Used for targets requiring RTOS -set(GHS_OS_DIR "${_ghs_os_dir}" CACHE PATH "GHS platform OS directory") -mark_as_advanced(GHS_OS_DIR) +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) -set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler OS option") -mark_as_advanced(GHS_OS_DIR_OPTION) +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") @@ -99,4 +122,8 @@ if(_ghs_bsp_name AND NOT DEFINED GHS_BSP_NAME) endif() endif() -set(GHS_BSP_NAME "${_ghs_bsp_name}" CACHE STRING "BSP name") +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) diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index a237689..bf537b7 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -113,24 +113,18 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p, cmMakefile* mf) { /* set primary target */ - cmValue t = - this->GetCMakeInstance()->GetCacheDefinition("GHS_PRIMARY_TARGET"); - if (!cmIsOff(t)) { - this->GetCMakeInstance()->MarkCliAsUsed("GHS_PRIMARY_TARGET"); - } else { + 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; } - cmValue platform = - this->GetCMakeInstance()->GetCacheDefinition("GHS_TARGET_PLATFORM"); + cmValue platform = mf->GetDefinition("GHS_TARGET_PLATFORM"); std::string tgt = cmStrCat(arch, '_', platform, ".tgt"); /* update the primary target name*/ - mf->AddCacheDefinition("GHS_PRIMARY_TARGET", tgt, - "Generator selected GHS MULTI primaryTarget.", - cmStateEnums::STRING, true); + mf->AddDefinition("GHS_PRIMARY_TARGET", tgt); } return true; } @@ -292,18 +286,17 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout, // Specify BSP option if supplied by user // -- not all platforms require this entry in the project file - cmValue bspName = - this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME"); + 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 - cmValue osDir = this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR"); + cmValue osDir = root->GetMakefile()->GetDefinition("GHS_OS_DIR"); if (!cmIsOff(osDir)) { cmValue osDirOption = - this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION"); + root->GetMakefile()->GetDefinition("GHS_OS_DIR_OPTION"); fout << " "; if (cmIsOff(osDirOption)) { fout << ""; @@ -575,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 expandedList = cmExpandedList(*ghsGpjMacros); for (std::string const& arg : expandedList) { @@ -589,8 +581,7 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives( cmLocalGenerator* root, std::ostream& fout) { /* put primary target and customization files into project file */ - cmValue const tgt = - this->GetCMakeInstance()->GetCacheDefinition("GHS_PRIMARY_TARGET"); + cmValue const tgt = root->GetMakefile()->GetDefinition("GHS_PRIMARY_TARGET"); /* clang-format off */ fout << "primaryTarget=" << tgt << "\n" @@ -601,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'; -- cgit v0.12