# This file was automagically generated by mbed.org.
# If you would like to add your own targets, create a
# project.cmake file locally in your project directory.

CMAKE_MINIMUM_REQUIRED(VERSION 3.9)
SET(CMAKE_SYSTEM_NAME Generic)
#SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_CROSSCOMPILING TRUE)

# force compiler settings
SET(CMAKE_C_COMPILER_WORKS TRUE)
SET(CMAKE_CXX_COMPILER_WORKS TRUE)

# force cmake compilers
SET(CMAKE_ASM_COMPILER    "arm-none-eabi-gcc")
SET(CMAKE_C_COMPILER      "arm-none-eabi-gcc")
SET(CMAKE_CXX_COMPILER    "arm-none-eabi-g++")
SET(ELF2BIN               "arm-none-eabi-objcopy")


# if the environment does not specify build type, set to Debug
IF(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Debug"
        CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
        FORCE)
ENDIF()

# here starts the project
PROJECT(OpPanel_Offline C CXX ASM)

# uncomment below to have a verbose build process
#SET(CMAKE_VERBOSE_MAKEFILE ON)

SET(LD_SYS_LIBS "-Wl,--start-group -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys  -Wl,--end-group")

SET(CMAKE_C_FLAGS "-std=gnu99 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -g1 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DMBED_ROM_START=0x8000000 -DMBED_ROM_SIZE=0x80000 -DMBED_RAM_START=0x20000000 -DMBED_RAM_SIZE=0x10000 -include mbed_config.h")
SET(CMAKE_CXX_FLAGS "-std=gnu++98 -fno-rtti -Wvla -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -g1 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DMBED_ROM_START=0x8000000 -DMBED_ROM_SIZE=0x80000 -DMBED_RAM_START=0x20000000 -DMBED_RAM_SIZE=0x10000  -include mbed_config.h")
SET(CMAKE_ASM_FLAGS "-x assembler-with-cpp -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -g1 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp  -include mbed_config.h")
SET(CMAKE_CXX_LINK_FLAGS "-Wl,--gc-sections -Wl,--wrap,main -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DMBED_ROM_START=0x8000000 -DMBED_ROM_SIZE=0x80000 -DMBED_RAM_START=0x20000000 -DMBED_RAM_SIZE=0x10000 -DMBED_BOOT_STACK_SIZE=4096 ")
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} ${LD_SYS_LIBS} -T ${CMAKE_BINARY_DIR}/OpPanel_Offline_pp.link_script.ld")

ADD_DEFINITIONS(
  -DARM_MATH_CM4
  -DCOMPONENT_NSPE=1
  -DCOMPONENT_PSA_SRV_EMUL=1
  -DCOMPONENT_PSA_SRV_IMPL=1
  -DDEVICE_ANALOGIN=1
  -DDEVICE_ANALOGOUT=1
  -DDEVICE_CAN=1
  -DDEVICE_CRC=1
  -DDEVICE_FLASH=1
  -DDEVICE_I2C=1
  -DDEVICE_I2CSLAVE=1
  -DDEVICE_I2C_ASYNCH=1
  -DDEVICE_INTERRUPTIN=1
  -DDEVICE_LPTICKER=1
  -DDEVICE_MPU=1
  -DDEVICE_PORTIN=1
  -DDEVICE_PORTINOUT=1
  -DDEVICE_PORTOUT=1
  -DDEVICE_PWMOUT=1
  -DDEVICE_RTC=1
  -DDEVICE_SERIAL=1
  -DDEVICE_SERIAL_ASYNCH=1
  -DDEVICE_SERIAL_FC=1
  -DDEVICE_SLEEP=1
  -DDEVICE_SPI=1
  -DDEVICE_SPISLAVE=1
  -DDEVICE_SPI_ASYNCH=1
  -DDEVICE_STDIO_MESSAGES=1
  -DDEVICE_USTICKER=1
  -DMBED_BUILD_TIMESTAMP=1552877423.47
  -DTARGET_CORTEX
  -DTARGET_CORTEX_M
  -DTARGET_FAMILY_STM32
  -DTARGET_FF_ARDUINO
  -DTARGET_FF_MORPHO
  -DTARGET_LIKE_CORTEX_M4
  -DTARGET_LIKE_MBED
  -DTARGET_M4
  -DTARGET_NUCLEO_F303RE
  -DTARGET_RELEASE
  -DTARGET_RTOS_M4_M7
  -DTARGET_STM
  -DTARGET_STM32F3
  -DTARGET_STM32F303RE
  -DTARGET_STM32F303xE
  -DTOOLCHAIN_GCC
  -DTOOLCHAIN_GCC_ARM
  -DTRANSACTION_QUEUE_SIZE_SPI=2
  -D__CMSIS_RTOS
  -D__CORTEX_M4
  -D__FPU_PRESENT=1
  -D__MBED_CMSIS_RTOS_CM
  -D__MBED__=1
  )
INCLUDE_DIRECTORIES(
  mbed/TARGET_NUCLEO_F303RE/TARGET_STM/TARGET_NUCLEO_F303RE
  mbed/TARGET_NUCLEO_F303RE
  mbed
  )

# executable OpPanel_Offline
ADD_EXECUTABLE(OpPanel_Offline
  main.cpp
  mbed/AnalogIn.h
  mbed/AnalogOut.h
  mbed/BusIn.h
  mbed/BusInOut.h
  mbed/BusOut.h
  mbed/CAN.h
  mbed/CallChain.h
  mbed/DigitalIn.h
  mbed/DigitalInOut.h
  mbed/DigitalOut.h
  mbed/DirHandle.h
  mbed/Ethernet.h
  mbed/FileBase.h
  mbed/FileHandle.h
  mbed/FileLike.h
  mbed/FilePath.h
  mbed/FileSystemLike.h
  mbed/FunctionPointer.h
  mbed/I2C.h
  mbed/I2CSlave.h
  mbed/InterruptIn.h
  mbed/InterruptManager.h
  mbed/LocalFileSystem.h
  mbed/PortIn.h
  mbed/PortInOut.h
  mbed/PortOut.h
  mbed/PwmOut.h
  mbed/RawSerial.h
  mbed/SPI.h
  mbed/SPISlave.h
  mbed/Serial.h
  mbed/SerialBase.h
  mbed/Stream.h
  mbed/TARGET_NUCLEO_F303RE/TARGET_STM/TARGET_NUCLEO_F303RE/PeripheralNames.h
  mbed/TARGET_NUCLEO_F303RE/TARGET_STM/TARGET_NUCLEO_F303RE/PeripheralPins.h
  mbed/TARGET_NUCLEO_F303RE/TARGET_STM/TARGET_NUCLEO_F303RE/PinNames.h
  mbed/TARGET_NUCLEO_F303RE/TARGET_STM/TARGET_NUCLEO_F303RE/PortNames.h
  mbed/TARGET_NUCLEO_F303RE/TARGET_STM/TARGET_NUCLEO_F303RE/device.h
  mbed/TARGET_NUCLEO_F303RE/TARGET_STM/TARGET_NUCLEO_F303RE/gpio_object.h
  mbed/TARGET_NUCLEO_F303RE/TARGET_STM/TARGET_NUCLEO_F303RE/objects.h
  mbed/TARGET_NUCLEO_F303RE/cmsis.h
  mbed/TARGET_NUCLEO_F303RE/cmsis_nvic.h
  mbed/TARGET_NUCLEO_F303RE/core_ca9.h
  mbed/TARGET_NUCLEO_F303RE/core_caFunc.h
  mbed/TARGET_NUCLEO_F303RE/core_caInstr.h
  mbed/TARGET_NUCLEO_F303RE/core_ca_mmu.h
  mbed/TARGET_NUCLEO_F303RE/core_cm0.h
  mbed/TARGET_NUCLEO_F303RE/core_cm0plus.h
  mbed/TARGET_NUCLEO_F303RE/core_cm3.h
  mbed/TARGET_NUCLEO_F303RE/core_cm4.h
  mbed/TARGET_NUCLEO_F303RE/core_cm4_simd.h
  mbed/TARGET_NUCLEO_F303RE/core_cmFunc.h
  mbed/TARGET_NUCLEO_F303RE/core_cmInstr.h
  mbed/TARGET_NUCLEO_F303RE/hal_tick.h
  mbed/TARGET_NUCLEO_F303RE/stm32f303xe.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_adc.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_adc_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_can.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_cec.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_comp.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_comp_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_conf.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_cortex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_crc.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_crc_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_dac.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_dac_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_def.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_dma.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_dma_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_flash.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_flash_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_gpio.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_gpio_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_hrtim.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_i2c.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_i2c_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_i2s.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_i2s_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_irda.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_irda_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_iwdg.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_nand.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_nor.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_opamp.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_opamp_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_pccard.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_pcd.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_pcd_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_pwr.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_pwr_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_rcc.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_rcc_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_rtc.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_rtc_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_sdadc.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_smartcard.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_smartcard_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_smbus.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_spi.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_sram.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_tim.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_tim_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_tsc.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_uart.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_uart_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_usart.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_usart_ex.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_hal_wwdg.h
  mbed/TARGET_NUCLEO_F303RE/stm32f3xx_ll_fmc.h
  mbed/TARGET_NUCLEO_F303RE/system_stm32f3xx.h
  mbed/Ticker.h
  mbed/Timeout.h
  mbed/Timer.h
  mbed/TimerEvent.h
  mbed/analogin_api.h
  mbed/analogout_api.h
  mbed/can_api.h
  mbed/can_helper.h
  mbed/ethernet_api.h
  mbed/gpio_api.h
  mbed/gpio_irq_api.h
  mbed/i2c_api.h
  mbed/mbed.h
  mbed/mbed_assert.h
  mbed/mbed_debug.h
  mbed/mbed_error.h
  mbed/mbed_interface.h
  mbed/pinmap.h
  mbed/platform.h
  mbed/port_api.h
  mbed/pwmout_api.h
  mbed/rtc_api.h
  mbed/rtc_time.h
  mbed/semihost_api.h
  mbed/serial_api.h
  mbed/sleep_api.h
  mbed/spi_api.h
  mbed/toolchain.h
  mbed/us_ticker_api.h
  mbed/wait_api.h
  mbed_config.h
  )
SET_TARGET_PROPERTIES(OpPanel_Offline PROPERTIES ENABLE_EXPORTS 1)
# add syslibs dependencies to create the correct linker order
TARGET_LINK_LIBRARIES(OpPanel_Offline -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys)

add_custom_command(TARGET OpPanel_Offline PRE_LINK
                   COMMAND "arm-none-eabi-cpp" -E -P -Wl,--gc-sections -Wl,--wrap,main -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DMBED_ROM_START=0x8000000 -DMBED_ROM_SIZE=0x80000 -DMBED_RAM_START=0x20000000 -DMBED_RAM_SIZE=0x10000 -DMBED_BOOT_STACK_SIZE=4096 None -o ${CMAKE_CURRENT_BINARY_DIR}/OpPanel_Offline_pp.link_script.ld
                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                   BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/OpPanel_Offline_pp.link_script.ld"
                   )

add_custom_command(TARGET OpPanel_Offline POST_BUILD
                   COMMAND ${ELF2BIN} -O ihex $<TARGET_FILE:OpPanel_Offline> $<TARGET_FILE:OpPanel_Offline>.hex
                   COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:OpPanel_Offline>.hex"
                  )




##########################################################################
# mbed-cli specific targets
##########################################################################

# detect the build type and select the corresponding cli profile
SET(MBED_BUILD_PROFILE "")
STRING(TOLOWER ${CMAKE_BUILD_TYPE} LOWERCASE_CMAKE_BUILD_TYPE)
IF(LOWERCASE_CMAKE_BUILD_TYPE MATCHES debug)
    SET(MBED_BUILD_PROFILE "mbed-os/tools/profiles/debug.json")
ELSEIF(LOWERCASE_CMAKE_BUILD_TYPE MATCHES relwithdebinfo)
    SET(MBED_BUILD_PROFILE "mbed-os/tools/profiles/develop.json")
ELSEIF(LOWERCASE_CMAKE_BUILD_TYPE MATCHES release)
    SET(MBED_BUILD_PROFILE "mbed-os/tools/profiles/release.json")
ELSEIF(LOWERCASE_CMAKE_BUILD_TYPE MATCHES minsizerel)
    SET(MBED_BUILD_PROFILE "mbed-os/tools/profiles/release.json")
ELSE()
  MESSAGE(WARNING "Build type '${CMAKE_BUILD_TYPE}' is unknown, using debug profile")
  SET(MBED_BUILD_PROFILE "mbed-os/tools/profiles/debug.json")
ENDIF()

# optional custom target to build via mbed-cli
ADD_CUSTOM_TARGET(mbed-cli-build
        COMMAND ${CMAKE_COMMAND} -E echo "mbed compile --build BUILD/${CMAKE_BUILD_TYPE} --profile ${MBED_BUILD_PROFILE}"
        COMMAND mbed compile --build BUILD/${CMAKE_BUILD_TYPE} --profile ${MBED_BUILD_PROFILE}
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
        SOURCES ${SOURCE_FILES} ${SYS_SOURCE_FILES})

IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/project.cmake)
  INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/project.cmake)
ELSE()
  MESSAGE(STATUS "Add a local project.cmake file to add your own targets.")
ENDIF()

# this will take care of binary directories generated by cmake/clion not to confuse the cli build
FILE(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/.mbedignore" CONTENT "*")