summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2017-03-24 16:18:32 -0700
committerStefan Agner <stefan.agner@toradex.com>2017-03-24 17:15:45 -0700
commitec57ed4d8fbbe4285b9105c8e5cd4670f7ee4e80 (patch)
tree3575d6502ba482a14142757d00fa4786d3a20b2b
parent06661975a63c21058e65d54ce1bd5d37fdc52afd (diff)
simplify CMake makefile
Deduplicate debug/release variables by moving shared settings into common variables. Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
-rw-r--r--examples/imx7_colibri_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/CMakeLists.txt60
1 files changed, 25 insertions, 35 deletions
diff --git a/examples/imx7_colibri_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/CMakeLists.txt b/examples/imx7_colibri_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/CMakeLists.txt
index 4249705..dc68cc1 100644
--- a/examples/imx7_colibri_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/CMakeLists.txt
+++ b/examples/imx7_colibri_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/CMakeLists.txt
@@ -21,62 +21,53 @@ SET(CMAKE_SKIP_INSTALL_RULES TRUE)
SET(ProjDirPath ${CMAKE_CURRENT_SOURCE_DIR})
SET(BspRootDirPath ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../..)
-# DEBUG LINK FILE
-set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${BspRootDirPath}/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_tcm.ld -static")
+# RELEASE/DEBUG LINK FILE
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T${BspRootDirPath}/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_tcm.ld -static")
-# RELEASE LINK FILE
-set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -T${BspRootDirPath}/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_tcm.ld -static")
+# DEFAULT ASM FLAGS
+SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99")
+
+# DEFAULT C FLAGS
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -MMD -MP -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99")
+
+# DEFAULT LD FLAGS
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs")
# DEBUG ASM FLAGS
-SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -g -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99")
+SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -g")
# DEBUG C FLAGS
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0 -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -MMD -MP -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0")
# DEBUG LD FLAGS
-SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -lm -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs")
-
-# RELEASE ASM FLAGS
-SET(CMAKE_ASM_FLAGS_RELEASE "${CMAKE_ASM_FLAGS_RELEASE} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99")
+SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g")
# RELEASE C FLAGS
-SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -MMD -MP -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99")
-
-# RELEASE LD FLAGS
-SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -lm -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs")
+SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os")
# ASM MACRO
SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -D__DEBUG")
# C MACRO
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__DEBUG")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCPU_MCIMX7D_M4")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D__NDEBUG")
-SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DCPU_MCIMX7D_M4")
-# CXX MACRO
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCPU_MCIMX7D_M4")
# INCLUDE_DIRECTORIES
IF(CMAKE_BUILD_TYPE MATCHES Debug)
- INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../..)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/CMSIS/Include)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices/MCIMX7D/include)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices/MCIMX7D/startup)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/drivers/inc)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/utilities/inc)
- INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../..)
ELSEIF(CMAKE_BUILD_TYPE MATCHES Release)
- INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../..)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/CMSIS/Include)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices/MCIMX7D/include)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices/MCIMX7D/startup)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/drivers/inc)
- INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/utilities/inc)
- INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../..)
ENDIF()
+INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../..)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/CMSIS/Include)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices/MCIMX7D/include)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices/MCIMX7D/startup)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/drivers/inc)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/utilities/inc)
+INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../..)
+
# ADD_EXECUTABLE
ADD_EXECUTABLE(ecspi_interrupt_master_example
"${BspRootDirPath}/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S"
@@ -126,8 +117,7 @@ TARGET_LINK_LIBRARIES(ecspi_interrupt_master_example nosys)
TARGET_LINK_LIBRARIES(ecspi_interrupt_master_example -Wl,--end-group)
# MAP FILE
-SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/ecspi_interrupt_master_example.map")
-SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/ecspi_interrupt_master_example.map")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -Map=${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_master_example.map")
# BIN AND HEX
ADD_CUSTOM_COMMAND(TARGET ecspi_interrupt_master_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_master_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_master_example.hex)