summaryrefslogtreecommitdiffstats
path: root/Modules/Platform/GHS-MULTI-Determine.cmake
blob: ba1bebb99b30810cecec4ce6d0d432111888eec3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

# 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()

  # 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)
  set(GHS_GPJ_MACROS "" CACHE STRING "optional GHS macros generated in the .gpjs for legacy reasons")
  mark_as_advanced(GHS_GPJ_MACROS)
endif()

# Settings for OS selection
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)

# 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
    FILE(GLOB GHS_CANDIDATE_OS_DIRS
      LIST_DIRECTORIES true RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
    FILE(GLOB GHS_CANDIDATE_OS_FILES
      LIST_DIRECTORIES false RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
    if(GHS_CANDIDATE_OS_FILES)
      list(REMOVE_ITEM GHS_CANDIDATE_OS_DIRS ${GHS_CANDIDATE_OS_FILES})
    endif ()

    # 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]")
    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})
    endif()
  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")