Browse Source

Build system refactoring.

pull/1/head
gkostka 11 years ago
parent
commit
6f2630560d
  1. 36
      CMakeLists.txt
  2. 2
      Makefile
  3. 5
      blockdev/CMakeLists.txt
  4. 4
      demos/generic/CMakeLists.txt
  5. 9
      demos/generic/generic.cmake
  6. 1
      demos/generic/main.c
  7. 37
      demos/stm32f429_disco/CMakeLists.txt
  8. 38
      demos/stm32f429_disco/stm32f429_demo.cmake
  9. 10
      fs_test.mk
  10. 12
      fs_test/CMakeLists.txt
  11. 17
      fs_test/fs_test.cmake
  12. 1
      fs_test/lwext4_server.c
  13. 8
      lwext4/CMakeLists.txt
  14. 0
      lwext4/ext4.h
  15. 6
      toolchain/bf518.cmake
  16. 4
      toolchain/cortex-m3.cmake
  17. 5
      toolchain/cortex-m4.cmake
  18. 25
      toolchain/generic.cmake

36
CMakeLists.txt

@ -2,34 +2,34 @@ project(lwext4 C)
cmake_minimum_required(VERSION 2.8)
include_directories(lwext4)
include_directories(blockdev/filedev)
include_directories(blockdev/filedev_win)
#LIBRARY
include_directories(. lwext4)
aux_source_directory(lwext4 LWEXT4_SRC)
add_library(lwext4 ${LWEXT4_SRC})
#Library build
add_subdirectory(lwext4)
#Detect all possible warnings for lwext4 target
set_target_properties(lwext4 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic")
#Examples
if (CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m3)
#Library size print
add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a)
#cortex-m3 demos
#...
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m4)
#Library size print
add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a)
#Discoery disco demo
include(demos/stm32f429_disco/stm32f429_demo.cmake)
#cortex-m4 demos
add_subdirectory(demos/stm32f429_disco)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL bf518)
#Library size print
add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a)
#bf518 demos
#...
else()
#Warning setup
set_target_properties(lwext4 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic -std=gnu99")
#Library size print
add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND size -B liblwext4.a)
#Generic example target
include(demos/generic/generic.cmake)
include(fs_test/fs_test.cmake)
add_subdirectory(blockdev)
add_subdirectory(fs_test)
add_subdirectory(demos/generic)
endif()
#DISTRIBUTION
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "4")

2
Makefile

@ -11,7 +11,7 @@ PROJECT_SETUP = "Eclipse CDT4 - Unix Makefiles"
generic:
rm -R -f build_generic
mkdir build_generic
cd build_generic && cmake -G$(PROJECT_SETUP) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) ..
cd build_generic && cmake -G$(PROJECT_SETUP) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=../toolchain/generic.cmake ..
bf518:
rm -R -f build_bf518

5
blockdev/CMakeLists.txt

@ -0,0 +1,5 @@
#Blockdev library
aux_source_directory(filedev BLOCKDEV_SRC)
aux_source_directory(filedev_win BLOCKDEV_SRC)
add_library(blockdev ${BLOCKDEV_SRC})

4
demos/generic/CMakeLists.txt

@ -0,0 +1,4 @@
#Generic demo
add_executable(fileimage_demo main.c)
target_link_libraries(fileimage_demo lwext4)
target_link_libraries(fileimage_demo blockdev)

9
demos/generic/generic.cmake

@ -1,9 +0,0 @@
include_directories(blockdev/filedev)
include_directories(blockdev/filedev_win)
aux_source_directory(blockdev/filedev GENERIC_SRC)
aux_source_directory(blockdev/filedev_win GENERIC_SRC)
aux_source_directory(demos/generic GENERIC_SRC)
add_executable(fileimage_demo ${GENERIC_SRC})
target_link_libraries(fileimage_demo lwext4)

1
demos/generic/main.c

@ -34,6 +34,7 @@
#include <stdbool.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#include <ext4_filedev.h>
#include <io_raw.h>

37
demos/stm32f429_disco/CMakeLists.txt

@ -0,0 +1,37 @@
#Discoery disco demo
enable_language(ASM)
set (STM32F429_DEMO_ASM
startup.S
)
include_directories(.)
include_directories(cmsis)
include_directories(stm/lcd_utils)
include_directories(stm/stm32f4_spl/inc)
include_directories(stm/stm32f429)
include_directories(stm/usb_dev/Core/inc)
include_directories(stm/usb_host/Core/inc)
include_directories(stm/usb_host/Class/MSC/inc)
include_directories(stm/usb_otg/inc)
include_directories(stm/usb_user)
aux_source_directory(. STM32F429_DEMO)
aux_source_directory(cmsis STM32F429_DEMO)
aux_source_directory(stm/lcd_utils STM32F429_DEMO)
aux_source_directory(stm/stm32f4_spl/src STM32F429_DEMO)
aux_source_directory(stm/stm32f429 STM32F429_DEMO)
aux_source_directory(stm/usb_host/Core/src STM32F429_DEMO)
aux_source_directory(stm/usb_host/Class/MSC/src STM32F429_DEMO)
aux_source_directory(stm/usb_otg/src STM32F429_DEMO)
aux_source_directory(stm/usb_user STM32F429_DEMO)
add_executable(stm324f29_demo ${STM32F429_DEMO} ${STM32F429_DEMO_ASM})
set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter")
set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-format")
set_target_properties(stm324f29_demo PROPERTIES COMPILE_DEFINITIONS "STM32F429_439xx")
set_target_properties(stm324f29_demo PROPERTIES LINK_FLAGS "-T${CMAKE_SOURCE_DIR}/demos/stm32f429_disco/stm32f429.ld")
target_link_libraries(stm324f29_demo lwext4)
add_custom_target(stm32f429_size ALL DEPENDS stm324f29_demo COMMAND ${SIZE} -B stm324f29_demo)

38
demos/stm32f429_disco/stm32f429_demo.cmake

@ -1,38 +0,0 @@
#Discoery disco demo
enable_language(ASM)
set (STM32F429_DEMO_ASM
demos/stm32f429_disco/startup.S
)
include_directories(demos/stm32f429_disco)
include_directories(demos/stm32f429_disco/cmsis)
include_directories(demos/stm32f429_disco/stm/lcd_utils)
include_directories(demos/stm32f429_disco/stm/stm32f4_spl/inc)
include_directories(demos/stm32f429_disco/stm/stm32f429)
include_directories(demos/stm32f429_disco/stm/usb_dev/Core/inc)
include_directories(demos/stm32f429_disco/stm/usb_host/Core/inc)
include_directories(demos/stm32f429_disco/stm/usb_host/Class/MSC/inc)
include_directories(demos/stm32f429_disco/stm/usb_otg/inc)
include_directories(demos/stm32f429_disco/stm/usb_user)
aux_source_directory(demos/stm32f429_disco STM32F429_DEMO)
aux_source_directory(demos/stm32f429_disco/cmsis STM32F429_DEMO)
aux_source_directory(demos/stm32f429_disco/stm/lcd_utils STM32F429_DEMO)
aux_source_directory(demos/stm32f429_disco/stm/stm32f4_spl/src STM32F429_DEMO)
aux_source_directory(demos/stm32f429_disco/stm/stm32f429 STM32F429_DEMO)
aux_source_directory(demos/stm32f429_disco/stm/usb_host/Core/src STM32F429_DEMO)
aux_source_directory(demos/stm32f429_disco/stm/usb_host/Class/MSC/src STM32F429_DEMO)
aux_source_directory(demos/stm32f429_disco/stm/usb_otg/src STM32F429_DEMO)
aux_source_directory(demos/stm32f429_disco/stm/usb_user STM32F429_DEMO)
add_executable(stm324f29_demo ${STM32F429_DEMO} ${STM32F429_DEMO_ASM})
set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter")
set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-format")
set_target_properties(stm324f29_demo PROPERTIES COMPILE_DEFINITIONS "STM32F429_439xx")
set_target_properties(stm324f29_demo PROPERTIES LINK_FLAGS "-T${CMAKE_SOURCE_DIR}/demos/stm32f429_disco/stm32f429.ld")
target_link_libraries(stm324f29_demo lwext4)
add_custom_target(stm32f429_size ALL DEPENDS stm324f29_demo COMMAND ${SIZE} -B stm324f29_demo)

10
fs_test.mk

@ -1,10 +1,10 @@
ifeq ($(OS),Windows_NT)
LWEXT4_CLIENT = @build_generic\\lwext4_client
LWEXT4_SERVER = @build_generic\\lwext4_server
LWEXT4_CLIENT = @build_generic\\fs_test\\lwext4_client
LWEXT4_SERVER = @build_generic\\fs_test\\lwext4_server
else
LWEXT4_CLIENT = @build_generic/lwext4_client
LWEXT4_SERVER = @build_generic/lwext4_server
LWEXT4_CLIENT = @build_generic/fs_test/lwext4_client
LWEXT4_SERVER = @build_generic/fs_test/lwext4_server
endif
TEST_DIR = /test
@ -504,4 +504,4 @@ server_ext3:
server_ext4:
$(LWEXT4_SERVER) -i ext_images/ext4
all_tests: t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20
tests: t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20

12
fs_test/CMakeLists.txt

@ -0,0 +1,12 @@
#fs_test executables
add_executable(lwext4_server lwext4_server.c)
target_link_libraries(lwext4_server lwext4)
target_link_libraries(lwext4_server blockdev)
if(WIN32)
target_link_libraries(lwext4_server ws2_32)
endif(WIN32)
add_executable(lwext4_client lwext4_client.c)
target_link_libraries(lwext4_client lwext4)
if(WIN32)
target_link_libraries(lwext4_client ws2_32)
endif(WIN32)

17
fs_test/fs_test.cmake

@ -1,17 +0,0 @@
include_directories(blockdev/filedev)
include_directories(blockdev/filedev_win)
aux_source_directory(blockdev/filedev BLOCKDEV_SRC)
aux_source_directory(blockdev/filedev_win BLOCKDEV_SRC)
add_executable(lwext4_server fs_test/lwext4_server.c ${BLOCKDEV_SRC})
target_link_libraries(lwext4_server lwext4)
if(WIN32)
target_link_libraries(lwext4_server ws2_32)
endif(WIN32)
add_executable(lwext4_client fs_test/lwext4_client.c ${BLOCKDEV_SRC})
target_link_libraries(lwext4_client lwext4)
if(WIN32)
target_link_libraries(lwext4_client ws2_32)
endif(WIN32)

1
fs_test/lwext4_server.c

@ -35,6 +35,7 @@
#include <stdbool.h>
#include <getopt.h>
#include <time.h>
#include <sys/time.h>
#ifdef WIN32
#include <winsock2.h>

8
lwext4/CMakeLists.txt

@ -0,0 +1,8 @@
#LIBRARY
include_directories(.)
aux_source_directory(. LWEXT4_SRC)
add_library(lwext4 ${LWEXT4_SRC})
add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a)

0
ext4.h → lwext4/ext4.h

6
toolchain/bf518.cmake

@ -1,5 +1,5 @@
# Name of the target
SET(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_NAME bfin-elf)
set(CMAKE_SYSTEM_PROCESSOR bf518)
# Toolchain settings
@ -12,9 +12,9 @@ set(OBJDUMP bfin-elf-objdump)
set(SIZE bfin-elf-size)
set(CMAKE_C_FLAGS "-mcpu=bf518 -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "-mcpu=bf518 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_CXX_FLAGS "-mcpu=bf518 -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_ASM_FLAGS "-mcpu=bf518 -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags")
set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mcpu=bf592" CACHE INTERNAL "exe link flags")
set(CMAKE_EXE_LINKER_FLAGS "-mcpu=bf592 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")

4
toolchain/cortex-m3.cmake

@ -1,5 +1,5 @@
# Name of the target
SET(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_NAME arm-none-eabi)
set(CMAKE_SYSTEM_PROCESSOR cortex-m3)
# Toolchain settings
@ -14,7 +14,7 @@ set(SIZE arm-none-eabi-size)
set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m3" CACHE INTERNAL "asm compiler flags")
set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m3" CACHE INTERNAL "exe link flags")
set(CMAKE_EXE_LINKER_FLAGS "-mthumb -mcpu=cortex-m3 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")

5
toolchain/cortex-m4.cmake

@ -1,5 +1,5 @@
# Name of the target
SET(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_NAME arm-none-eabi)
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
# Toolchain settings
@ -14,7 +14,7 @@ set(SIZE arm-none-eabi-size)
set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m4" CACHE INTERNAL "asm compiler flags")
set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m4" CACHE INTERNAL "exe link flags")
set(CMAKE_EXE_LINKER_FLAGS " -mthumb -mcpu=cortex-m4 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags")
@ -25,4 +25,3 @@ SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags")
SET(CMAKE_C_FLAGS_RELEASE "-Os" CACHE INTERNAL "c release compiler flags")
SET(CMAKE_CXX_FLAGS_RELEASE "-Os" CACHE INTERNAL "cxx release compiler flags")
SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags")

25
toolchain/generic.cmake

@ -0,0 +1,25 @@
# Name of the target
set(CMAKE_SYSTEM_PROCESSOR generic)
# Toolchain settings
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
set(AS as)
set(AR ar)
set(OBJCOPY objcopy)
set(OBJDUMP objdump)
set(SIZE size)
set(CMAKE_C_FLAGS "-std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "-fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_ASM_FLAGS "" CACHE INTERNAL "asm compiler flags")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections" CACHE INTERNAL "exe link flags")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")
SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags")
SET(CMAKE_C_FLAGS_RELEASE "-O2" CACHE INTERNAL "c release compiler flags")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE INTERNAL "cxx release compiler flags")
SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags")
Loading…
Cancel
Save