summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake8
-rw-r--r--Modules/Platform/GHS-MULTI-Determine.cmake19
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx58
3 files changed, 40 insertions, 45 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index edfa01621a..b7119a805d 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 349d906571..3f094db69b 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 b1c0488d43..ffa2c4ceb8 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 <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);
+ /* 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"