diff options
author | Fred Baksik <frodak17@gmail.com> | 2019-01-09 04:52:12 (GMT) |
---|---|---|
committer | Fred Baksik <frodak17@gmail.com> | 2019-01-16 15:42:00 (GMT) |
commit | 436cc5e991c7be07610d7902a5ce2a00221ca0a2 (patch) | |
tree | 912fdd8810121d1bc39520340b999c6c7c9ed7c0 | |
parent | 4a1ec0de3d2102918284eff13763f2aa3d20d119 (diff) | |
download | CMake-436cc5e991c7be07610d7902a5ce2a00221ca0a2.zip CMake-436cc5e991c7be07610d7902a5ce2a00221ca0a2.tar.gz CMake-436cc5e991c7be07610d7902a5ce2a00221ca0a2.tar.bz2 |
GHS: try_compile() now uses GHS platform variables
-- Forward GHS platform variables to try_compile()
CMAKE_TRY_COMPILE_PLATFORM_VARIABLES only worked for source signature try_compile()
-- Update tests to no longer add GHS platform variables to try_compile()
-- Avoid linker error in GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt by building library
-rw-r--r-- | Help/command/try_compile.rst | 3 | ||||
-rw-r--r-- | Help/generator/Green Hills MULTI.rst | 3 | ||||
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 16 | ||||
-rw-r--r-- | Source/cmGlobalGhsMultiGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmState.cxx | 10 | ||||
-rw-r--r-- | Source/cmState.h | 3 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt | 6 |
9 files changed, 39 insertions, 15 deletions
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 2794598..bfe671f 100644 --- a/Help/generator/Green Hills MULTI.rst +++ b/Help/generator/Green Hills MULTI.rst @@ -17,13 +17,14 @@ Both absolute and relative paths are valid. Relative paths use ``GHS_TOOLSET_ROO 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`` | Defaults to ``integrity``. | Usual values are ``integrity``, ``threadx``, ``uvelosity``, ``velosity``, ``vxworks``, ``standalone``. - * ``GHS_PRIMARY_TARGET`` | Sets ``primaryTarget`` entry in project file. diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index a483fd1..137b25f 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; diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 25a4d21..82543e7 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" @@ -21,6 +22,7 @@ const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "C:/ghs"; cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm) : cmGlobalGenerator(cm) { + cm->GetState()->SetGhsMultiIDE(true); } cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() diff --git a/Source/cmState.cxx b/Source/cmState.cxx index f664000..94a84e5 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -593,6 +593,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; diff --git a/Source/cmState.h b/Source/cmState.h index abe93ed..b60eece 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -154,6 +154,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); @@ -206,6 +208,7 @@ private: bool IsGeneratorMultiConfig = false; bool WindowsShell = false; bool WindowsVSIDE = false; + bool GhsMultiIDE = false; bool WatcomWMake = false; bool MinGWMake = false; bool NMake = false; diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt index 1436cbb..4a3f5c2 100644 --- a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt @@ -14,14 +14,12 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.c ) 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 -DGHS_BSP_NAME=${GHS_BSP_NAME} - -DGHS_OS_ROOT=${GHS_OS_ROOT} - -DGHS_TOOLSET_ROOT=${GHS_TOOLSET_ROOT} - -DGHS_TARGET_PLATFORM=${GHS_TARGET_PLATFORM} + CMAKE_FLAGS -DRUN_TEST=${RUN_TEST} -DCMAKE_BUILD_TYPE=${RUN_TEST_BUILD_TYPE} OUTPUT_VARIABLE OUTPUT) diff --git a/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt index 46d833b..d6d007d 100644 --- a/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt @@ -9,11 +9,6 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}/build ${CMAKE_CURRENT_SOURCE_DIR}/test.c - CMAKE_FLAGS -DGHS_BSP_NAME=${GHS_BSP_NAME} - -DGHS_OS_ROOT=${GHS_OS_ROOT} - -DGHS_OS_DIR=${GHS_OS_DIR} - -DGHS_TOOLSET_ROOT=${GHS_TOOLSET_ROOT} - -DGHS_TARGET_PLATFORM=${GHS_TARGET_PLATFORM} OUTPUT_VARIABLE OUTPUT COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/test_library" ) diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt index 9b23493..dfb72ce 100644 --- a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt @@ -25,11 +25,7 @@ try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}/link_build ${CMAKE_CURRENT_BINARY_DIR}/link_src test - CMAKE_FLAGS -DGHS_BSP_NAME=${GHS_BSP_NAME} - -DGHS_OS_ROOT=${GHS_OS_ROOT} - -DGHS_OS_DIR=${GHS_OS_DIR} - -DGHS_TOOLSET_ROOT=${GHS_TOOLSET_ROOT} - -DGHS_TARGET_PLATFORM=${GHS_TARGET_PLATFORM} + CMAKE_FLAGS -DRUN_TEST=${RUN_TEST} -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} OUTPUT_VARIABLE OUTPUT) |