From 6fcd37817cbea037bd1194b50382c7d8ca4b74ee Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 8 May 2017 14:41:54 -0700 Subject: 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 Suggested-by: Raul Munoz --- .gitignore | 6 ++++-- .../demo_apps/hello_world/armgcc/CMakeLists.txt | 3 +-- .../imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.bat | 10 ++++++---- .../imx7_colibri_m4/demo_apps/hello_world/armgcc/build_all.sh | 10 ++++++---- .../demo_apps/hello_world/armgcc/build_debug.bat | 3 --- .../demo_apps/hello_world/armgcc/build_debug.sh | 3 --- .../demo_apps/hello_world/armgcc/build_release.bat | 3 --- .../demo_apps/hello_world/armgcc/build_release.sh | 3 --- .../imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.bat | 10 ++++++++-- examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/clean.sh | 8 ++++++-- .../demo_apps/hello_world/armgcc/debug/build_debug.bat | 3 +++ .../demo_apps/hello_world/armgcc/debug/build_debug.sh | 3 +++ .../demo_apps/hello_world/armgcc/release/build_release.bat | 3 +++ .../demo_apps/hello_world/armgcc/release/build_release.sh | 3 +++ tools/cmake_toolchain_files/armgcc.cmake | 9 ++------- 15 files changed, 45 insertions(+), 35 deletions(-) delete mode 100644 examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.bat delete mode 100755 examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.sh delete mode 100644 examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.bat delete mode 100755 examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.sh create mode 100644 examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.bat create mode 100755 examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.sh create mode 100644 examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.bat create mode 100755 examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.sh 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/build_debug.bat b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.bat deleted file mode 100644 index bf3b902..0000000 --- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.bat +++ /dev/null @@ -1,3 +0,0 @@ -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/build_debug.sh deleted file mode 100755 index 571868b..0000000 --- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_debug.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -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/build_release.bat deleted file mode 100644 index e229a83..0000000 --- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.bat +++ /dev/null @@ -1,3 +0,0 @@ -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/build_release.sh deleted file mode 100755 index 035ce4e..0000000 --- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/build_release.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . -make -j4 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/debug/build_debug.bat b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.bat new file mode 100644 index 0000000..434e91e --- /dev/null +++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.bat @@ -0,0 +1,3 @@ +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/debug/build_debug.sh b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.sh new file mode 100755 index 0000000..5526f5d --- /dev/null +++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/debug/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +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/release/build_release.bat b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.bat new file mode 100644 index 0000000..17f773a --- /dev/null +++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.bat @@ -0,0 +1,3 @@ +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/release/build_release.sh b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.sh new file mode 100755 index 0000000..1ad7338 --- /dev/null +++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/release/build_release.sh @@ -0,0 +1,3 @@ +#!/bin/sh +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}) -- cgit v1.2.3