35 lines
1.6 KiB
Plaintext
35 lines
1.6 KiB
Plaintext
set(LIB_NAME CMSIS)
|
|
if(NOT DEFINED ENV{MCU_SERIES})
|
|
message(FATAL_ERROR "MCU_SERIES NOT DEFINED. Please define it like stm32fxx")
|
|
else()
|
|
string(TOUPPER $ENV{MCU_SERIES} MCU_SERIES_UPPERCASE)
|
|
endif()
|
|
|
|
project(${LIB_NAME}
|
|
LANGUAGES C ASM
|
|
)
|
|
if (NOT DEFINED ENV{MCU})
|
|
message(FATAL_ERROR "PLEASE DEFINE ENV{MCU} i.e STM32F427xx")
|
|
endif ()
|
|
|
|
if (NOT GTEST)
|
|
if (NOT $ENV{CORTEX-M} STREQUAL "3" AND NOT $ENV{CORTEX-M} STREQUAL "1" AND NOT $ENV{CORTEX-M} STREQUAL "0" AND NOT $ENV{CORTEX-M} STREQUAL "4" AND NOT $ENV{CORTEX-M} STREQUAL "3" AND NOT $ENV{CORTEX-M} STREQUAL "55")
|
|
message(FATAL_ERROR "Error: please set CORTEX-M")
|
|
endif ()
|
|
|
|
if (NOT DEFINED ENV{COMPILE_OPTIONS})
|
|
set(COMPILE_OPTIONS -ffunction-sections -fdata-sections -fno-common -fmessage-length=0 $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti> -mcpu=cortex-m$ENV{CORTEX-M} -mthumb -mthumb-interwork)
|
|
message(WARNING "${LIB_NAME} compile with default options")
|
|
else ()
|
|
set(COMPILE_OPTIONS $ENV{COMPILE_OPTIONS})
|
|
endif()
|
|
endif()
|
|
|
|
add_library(${LIB_NAME} INTERFACE)
|
|
target_include_directories(${LIB_NAME} INTERFACE Include Device/ST/${MCU_SERIES_UPPERCASE}/Include)
|
|
target_compile_definitions(${LIB_NAME} INTERFACE "$ENV{MCU}")
|
|
if (NOT $ENV{CORTEX-M} STREQUAL "3" AND NOT $ENV{CORTEX-M} STREQUAL "1" AND NOT $ENV{CORTEX-M} STREQUAL "0" AND NOT $ENV{CORTEX-M} STREQUAL "4" AND NOT $ENV{CORTEX-M} STREQUAL "3" AND NOT $ENV{CORTEX-M} STREQUAL "55")
|
|
message(FATAL_ERROR "Error: please set CORTEX-M")
|
|
else ()
|
|
target_compile_options(${LIB_NAME} BEFORE INTERFACE ${COMPILE_OPTIONS})
|
|
endif () |