mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
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.
This commit is contained in:
@@ -2,54 +2,72 @@
|
|||||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
# Setup variables used for Green Hills MULTI generator
|
# Setup variables used for Green Hills MULTI generator
|
||||||
|
# -- Allow users to override these values.
|
||||||
|
|
||||||
if(CMAKE_GENERATOR MATCHES "Green Hills MULTI")
|
if(CMAKE_GENERATOR MATCHES "Green Hills MULTI")
|
||||||
|
|
||||||
# Set the project primaryTarget value
|
# Set the project primaryTarget value
|
||||||
# If not set then primaryTarget will be determined by the generator
|
# If not set then primaryTarget will be determined by the generator
|
||||||
set(GHS_PRIMARY_TARGET "IGNORE" CACHE STRING "GHS MULTI primaryTarget")
|
if((NOT DEFINED GHS_PRIMARY_TARGET) OR (DEFINED CACHE{GHS_PRIMARY_TARGET}))
|
||||||
mark_as_advanced(GHS_PRIMARY_TARGET)
|
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()
|
||||||
|
|
||||||
# Setup MULTI toolset selection variables
|
# Setup MULTI toolset selection variables
|
||||||
if(CMAKE_HOST_UNIX)
|
if((NOT DEFINED GHS_TOOLSET_ROOT) OR (DEFINED CACHE{GHS_TOOLSET_ROOT}))
|
||||||
set(_ts_root "/usr/ghs")
|
if(CMAKE_HOST_UNIX)
|
||||||
else()
|
set(_ts_root "/usr/ghs")
|
||||||
set(_ts_root "C:/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()
|
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
|
# Setup MULTI project variables
|
||||||
set(GHS_CUSTOMIZATION "" CACHE FILEPATH "optional GHS customization")
|
if((NOT DEFINED GHS_CUSTOMIZATION) OR (DEFINED CACHE{GHS_CUSTOMIZATION}))
|
||||||
mark_as_advanced(GHS_CUSTOMIZATION)
|
set(GHS_CUSTOMIZATION "" CACHE FILEPATH "optional GHS customization")
|
||||||
set(GHS_GPJ_MACROS "" CACHE STRING "optional GHS macros generated in the .gpjs for legacy reasons")
|
mark_as_advanced(GHS_CUSTOMIZATION)
|
||||||
mark_as_advanced(GHS_GPJ_MACROS)
|
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()
|
endif()
|
||||||
|
|
||||||
# Settings for OS selection
|
# Settings for OS selection
|
||||||
if(CMAKE_HOST_UNIX)
|
if((NOT DEFINED GHS_OS_ROOT) OR (DEFINED CACHE{GHS_OS_ROOT}))
|
||||||
set(_os_root "/usr/ghs")
|
if(CMAKE_HOST_UNIX)
|
||||||
else()
|
set(_os_root "/usr/ghs")
|
||||||
set(_os_root "C:/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()
|
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
|
# 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")
|
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")
|
set(_ghs_os_dir "GHS_OS_DIR-NOT-SPECIFIED")
|
||||||
else()
|
else()
|
||||||
|
# Not needed for this target
|
||||||
set(_ghs_os_dir "IGNORE")
|
set(_ghs_os_dir "IGNORE")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(_ghs_os_dir AND NOT DEFINED GHS_OS_DIR)
|
if(_ghs_os_dir AND NOT DEFINED GHS_OS_DIR)
|
||||||
if(EXISTS ${GHS_OS_ROOT})
|
if(EXISTS ${GHS_OS_ROOT})
|
||||||
|
|
||||||
@@ -77,11 +95,16 @@ if(_ghs_os_dir AND NOT DEFINED GHS_OS_DIR)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
#Used for targets requiring RTOS
|
#Used for targets requiring RTOS
|
||||||
set(GHS_OS_DIR "${_ghs_os_dir}" CACHE PATH "GHS platform OS directory")
|
if((NOT DEFINED GHS_OS_DIR) OR (DEFINED CACHE{GHS_OS_DIR}))
|
||||||
mark_as_advanced(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")
|
if((NOT DEFINED GHS_OS_DIR_OPTION) OR (DEFINED CACHE{GHS_OS_DIR_OPTION}))
|
||||||
mark_as_advanced(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
|
# 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")
|
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()
|
||||||
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)
|
||||||
|
|||||||
@@ -113,24 +113,18 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
|
|||||||
cmMakefile* mf)
|
cmMakefile* mf)
|
||||||
{
|
{
|
||||||
/* set primary target */
|
/* set primary target */
|
||||||
cmValue t =
|
cmValue t = mf->GetDefinition("GHS_PRIMARY_TARGET");
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_PRIMARY_TARGET");
|
if (cmIsOff(t)) {
|
||||||
if (!cmIsOff(t)) {
|
|
||||||
this->GetCMakeInstance()->MarkCliAsUsed("GHS_PRIMARY_TARGET");
|
|
||||||
} else {
|
|
||||||
/* Use the value from `-A` or use `arm` */
|
/* Use the value from `-A` or use `arm` */
|
||||||
std::string arch = "arm";
|
std::string arch = "arm";
|
||||||
if (!cmIsOff(p)) {
|
if (!cmIsOff(p)) {
|
||||||
arch = p;
|
arch = p;
|
||||||
}
|
}
|
||||||
cmValue platform =
|
cmValue platform = mf->GetDefinition("GHS_TARGET_PLATFORM");
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_TARGET_PLATFORM");
|
|
||||||
std::string tgt = cmStrCat(arch, '_', platform, ".tgt");
|
std::string tgt = cmStrCat(arch, '_', platform, ".tgt");
|
||||||
|
|
||||||
/* update the primary target name*/
|
/* update the primary target name*/
|
||||||
mf->AddCacheDefinition("GHS_PRIMARY_TARGET", tgt,
|
mf->AddDefinition("GHS_PRIMARY_TARGET", tgt);
|
||||||
"Generator selected GHS MULTI primaryTarget.",
|
|
||||||
cmStateEnums::STRING, true);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -292,18 +286,17 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout,
|
|||||||
|
|
||||||
// Specify BSP option if supplied by user
|
// Specify BSP option if supplied by user
|
||||||
// -- not all platforms require this entry in the project file
|
// -- not all platforms require this entry in the project file
|
||||||
cmValue bspName =
|
cmValue bspName = root->GetMakefile()->GetDefinition("GHS_BSP_NAME");
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME");
|
|
||||||
if (!cmIsOff(bspName)) {
|
if (!cmIsOff(bspName)) {
|
||||||
fout << " -bsp " << *bspName << '\n';
|
fout << " -bsp " << *bspName << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specify OS DIR if supplied by user
|
// Specify OS DIR if supplied by user
|
||||||
// -- not all platforms require this entry in the project file
|
// -- 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)) {
|
if (!cmIsOff(osDir)) {
|
||||||
cmValue osDirOption =
|
cmValue osDirOption =
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION");
|
root->GetMakefile()->GetDefinition("GHS_OS_DIR_OPTION");
|
||||||
fout << " ";
|
fout << " ";
|
||||||
if (cmIsOff(osDirOption)) {
|
if (cmIsOff(osDirOption)) {
|
||||||
fout << "";
|
fout << "";
|
||||||
@@ -575,8 +568,7 @@ void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout,
|
|||||||
cmLocalGenerator* root)
|
cmLocalGenerator* root)
|
||||||
{
|
{
|
||||||
fout << "macro PROJ_NAME=" << root->GetProjectName() << '\n';
|
fout << "macro PROJ_NAME=" << root->GetProjectName() << '\n';
|
||||||
cmValue ghsGpjMacros =
|
cmValue ghsGpjMacros = root->GetMakefile()->GetDefinition("GHS_GPJ_MACROS");
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS");
|
|
||||||
if (ghsGpjMacros) {
|
if (ghsGpjMacros) {
|
||||||
std::vector<std::string> expandedList = cmExpandedList(*ghsGpjMacros);
|
std::vector<std::string> expandedList = cmExpandedList(*ghsGpjMacros);
|
||||||
for (std::string const& arg : expandedList) {
|
for (std::string const& arg : expandedList) {
|
||||||
@@ -589,8 +581,7 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(
|
|||||||
cmLocalGenerator* root, std::ostream& fout)
|
cmLocalGenerator* root, std::ostream& fout)
|
||||||
{
|
{
|
||||||
/* put primary target and customization files into project file */
|
/* put primary target and customization files into project file */
|
||||||
cmValue const tgt =
|
cmValue const tgt = root->GetMakefile()->GetDefinition("GHS_PRIMARY_TARGET");
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_PRIMARY_TARGET");
|
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
fout << "primaryTarget=" << tgt << "\n"
|
fout << "primaryTarget=" << tgt << "\n"
|
||||||
@@ -601,7 +592,7 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(
|
|||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
cmValue const customization =
|
cmValue const customization =
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION");
|
root->GetMakefile()->GetDefinition("GHS_CUSTOMIZATION");
|
||||||
if (cmNonempty(customization)) {
|
if (cmNonempty(customization)) {
|
||||||
fout << "customization="
|
fout << "customization="
|
||||||
<< cmGlobalGhsMultiGenerator::TrimQuotes(*customization) << '\n';
|
<< cmGlobalGhsMultiGenerator::TrimQuotes(*customization) << '\n';
|
||||||
|
|||||||
Reference in New Issue
Block a user