summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/IAR/RunCMakeTest.cmake
blob: 2049740b2f658cccae9fd0bd9d55a2029cfb624d (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
include(RunCMake)

if(RunCMake_GENERATOR MATCHES "Makefile|Ninja")
  file(GLOB _iar_toolchains
    "${CMake_TEST_IAR_TOOLCHAINS}/bx*-*/*/bin/icc*" )
  if(_iar_toolchains STREQUAL "")
    message(FATAL_ERROR "Could not find any IAR toolchains at: ${CMake_TEST_IAR_TOOLCHAINS}.")
  endif()
endif()

foreach(_iar_toolchain IN LISTS _iar_toolchains)
  message(STATUS "Found IAR toolchain: ${_iar_toolchain}")
  cmake_path(GET _iar_toolchain PARENT_PATH BIN_DIR)
  cmake_path(GET BIN_DIR PARENT_PATH TOOLKIT_DIR)
  cmake_path(GET TOOLKIT_DIR FILENAME ARCH)

  # Sets the minimal requirements for linking each target architecture
  if(ARCH STREQUAL rl78)
    set(LINK_OPTS
"--config_def _STACK_SIZE=256 \
--config_def _NEAR_HEAP_SIZE=0x400 \
--config_def _FAR_HEAP_SIZE=4096 \
--config_def _HUGE_HEAP_SIZE=0 \
--config_def _NEAR_CONST_LOCATION_START=0x2000 \
--config_def _NEAR_CONST_LOCATION_SIZE=0x6F00 \
--define_symbol _NEAR_CONST_LOCATION=0 \
--config ${TOOLKIT_DIR}/config/lnkrl78_s3.icf" )
  else()
    set(LINK_OPTS "")
  endif()

  # Set IAR Assembler (ILINK || XLINK)
  find_program(IAR_ASSEMBLER
    NAMES iasm${ARCH} a${ARCH}
    PATHS ${BIN_DIR}
    REQUIRED )

  set(RunCMake_TEST_OPTIONS
    -DCMAKE_SYSTEM_NAME=Generic
    -DCMAKE_C_COMPILER=${_iar_toolchain}
    -DCMAKE_EXE_LINKER_FLAGS=${LINK_OPTS}
  )
  run_cmake(iar-c)

  set(RunCMake_TEST_OPTIONS
    -DCMAKE_SYSTEM_NAME=Generic
    -DCMAKE_CXX_COMPILER=${_iar_toolchain}
    -DCMAKE_EXE_LINKER_FLAGS=${LINK_OPTS}
  )
  run_cmake(iar-cxx)

  set(RunCMake_TEST_OPTIONS
    -DCMAKE_SYSTEM_NAME=Generic
    -DCMAKE_ASM_COMPILER=${IAR_ASSEMBLER}
    )
  run_cmake(iar-asm)

  set(RunCMake_TEST_OPTIONS
    -DCMAKE_SYSTEM_NAME=Generic
    -DCMAKE_C_COMPILER=${_iar_toolchain}
    -DCMAKE_EXE_LINKER_FLAGS=${LINK_OPTS}
    )
  run_cmake(iar-lib)
endforeach()