diff options
author | Brad King <brad.king@kitware.com> | 2021-11-19 14:05:22 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-11-19 14:05:35 (GMT) |
commit | 3519c19091b0f298aa29285388d15076b0754e19 (patch) | |
tree | 88a816de8f0c23b37c38379310aa67ce58bcff45 /Modules | |
parent | 7d1cb6496e5fbe5ed9668e95141ade3514b52c93 (diff) | |
parent | aa59eaac4faf04f1c195be4463795a7953de7fde (diff) | |
download | CMake-3519c19091b0f298aa29285388d15076b0754e19.zip CMake-3519c19091b0f298aa29285388d15076b0754e19.tar.gz CMake-3519c19091b0f298aa29285388d15076b0754e19.tar.bz2 |
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 <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6715
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 8 | ||||
-rw-r--r-- | Modules/Platform/GHS-MULTI-Determine.cmake | 127 |
2 files changed, 102 insertions, 33 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..96f0162 100644 --- a/Modules/Platform/GHS-MULTI-Determine.cmake +++ b/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) |