summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2017-05-08 14:41:54 -0700
committerStefan Agner <stefan.agner@toradex.com>2017-05-12 13:54:18 -0700
commit6fcd37817cbea037bd1194b50382c7d8ca4b74ee (patch)
tree831d8933037194c97345cc0fce0301d52dd76a6f
parent74e83463973d77b16449e7b9206f4f75b94296d1 (diff)
examples: convert CMake structure to allow multiple builds
Convert CMake build files structure such that we can build debug and release configuration simultaneously. This is useful when using Eclipse's Makefile integration. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Suggested-by: Raul Munoz <raul.munoz@toradex.com>
-rw-r--r--.gitignore6
-rw-r--r--examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt3
-rw-r--r--examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.bat10
-rwxr-xr-xexamples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.sh10
-rw-r--r--examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.bat10
-rwxr-xr-xexamples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.sh8
-rw-r--r--examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.bat (renamed from examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.bat)2
-rwxr-xr-xexamples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.sh (renamed from examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.sh)2
-rw-r--r--examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.bat (renamed from examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.bat)2
-rwxr-xr-xexamples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.sh (renamed from examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.sh)2
-rw-r--r--tools/cmake_toolchain_files/armgcc.cmake9
11 files changed, 37 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore
index f40c56e..94ac416 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,7 @@ CMakeCache.txt
CMakeFiles/
Makefile
cmake_install.cmake
-release/
-debug/
+*.bin
+*.elf
+*.hex
+*.map
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt
index 7b23972..4fa749b 100644
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt
@@ -154,8 +154,7 @@ TARGET_LINK_LIBRARIES(hello_world nosys)
TARGET_LINK_LIBRARIES(hello_world -Wl,--end-group)
# MAP FILE
-SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/hello_world.map")
-SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/hello_world.map")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -Map=hello_world.map")
# BIN AND HEX
ADD_CUSTOM_COMMAND(TARGET hello_world POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/hello_world.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world.hex)
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.bat b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.bat
index 6d41d86..426a29f 100644
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.bat
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.bat
@@ -1,5 +1,7 @@
-cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug .
-mingw32-make -j4
-cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release .
-mingw32-make -j4
+cd release
+call build_release.bat
+cd ..
+cd debug
+call build_debug.bat
+cd ..
pause
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.sh b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.sh
index ebb0c25..99e6267 100755
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.sh
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.sh
@@ -1,5 +1,7 @@
#!/bin/sh
-cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug .
-make -j4
-cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .
-make -j4
+cd debug/
+./build_debug.sh
+cd ..
+cd release/
+./build_release.sh
+cd ..
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.bat b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.bat
index ffea088..fc53949 100644
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.bat
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.bat
@@ -1,3 +1,9 @@
-RD /s /Q Debug Release CMakeFiles
-DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt
+cd debug
+rd /s /Q CMakeFiles/
+del /s /Q /F Makefile cmake_install.cmake CMakeCache.txt *.elf *.bin *.map *.hex
+cd ..
+cd release
+rd /s /Q CMakeFiles/
+del /s /Q /F Makefile cmake_install.cmake CMakeCache.txt *.elf *.bin *.map *.hex
+cd ..
pause
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.sh b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.sh
index 795ad87..7120907 100755
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.sh
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.sh
@@ -1,3 +1,7 @@
#!/bin/sh
-rm -rf debug release CMakeFiles
-rm -rf Makefile cmake_install.cmake CMakeCache.txt
+cd debug
+rm -rf Makefile cmake_install.cmake CMakeCache.txt CMakeFiles *.elf *.bin *.map *.hex
+cd ..
+cd release
+rm -rf Makefile cmake_install.cmake CMakeCache.txt CMakeFiles *.elf *.bin *.map *.hex
+cd ..
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.bat b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.bat
index bf3b902..434e91e 100644
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.bat
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.bat
@@ -1,3 +1,3 @@
-cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug .
+cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
mingw32-make -j4
pause
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.sh b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.sh
index 571868b..5526f5d 100755
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.sh
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug .
+cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
make -j4
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.bat b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.bat
index e229a83..17f773a 100644
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.bat
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.bat
@@ -1,3 +1,3 @@
-cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release .
+cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..
mingw32-make -j4
pause
diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.sh b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.sh
index 035ce4e..1ad7338 100755
--- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.sh
+++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .
+cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
make -j4
diff --git a/tools/cmake_toolchain_files/armgcc.cmake b/tools/cmake_toolchain_files/armgcc.cmake
index 3d7f729..c161aa0 100644
--- a/tools/cmake_toolchain_files/armgcc.cmake
+++ b/tools/cmake_toolchain_files/armgcc.cmake
@@ -59,12 +59,7 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-IF(CMAKE_BUILD_TYPE MATCHES Release)
- SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/release)
- SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/release)
-ELSEIF(CMAKE_BUILD_TYPE MATCHES Debug)
- SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/debug)
- SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/debug)
-ENDIF()
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
+SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "BUILD_TYPE: " ${CMAKE_BUILD_TYPE})