makefile: add version definitions to makefile & CMakeLists
[lwext4.git] / CMakeLists.txt
1 project(lwext4 C)
2 cmake_minimum_required(VERSION 2.8)
3
4
5 include_directories(lwext4)
6 include_directories(blockdev/filedev)
7 include_directories(blockdev/filedev_win)
8
9 set(BLOCKDEV_TYPE  none)
10
11 add_definitions(-DVERSION="${VERSION}")
12
13 #Examples
14 if    (CMAKE_SYSTEM_PROCESSOR STREQUAL  cortex-m0)
15     #...
16 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL  cortex-m3)
17     #...
18 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL  arm-sim)
19     #...
20 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL  cortex-m4)
21     #...
22 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL  bf518)
23     #...
24 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL  avrxmega7)
25     #...
26 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL  msp430g2210)
27     add_definitions(-DCONFIG_DEBUG_PRINTF=0)
28     add_definitions(-DCONFIG_DEBUG_ASSERT=0)
29     #...
30 else()
31     #Generic example target
32     set(BLOCKDEV_TYPE  linux)
33     add_definitions(-DCONFIG_HAVE_OWN_OFLAGS=0)
34     add_definitions(-DCONFIG_HAVE_OWN_ERRNO=0)
35     add_definitions(-DCONFIG_HAVE_OWN_ASSERT=0)
36     add_definitions(-DCONFIG_BLOCK_DEV_CACHE_SIZE=16)
37     add_subdirectory(fs_test)
38 endif()
39
40 add_subdirectory(blockdev)
41
42 #Library build
43 add_subdirectory(lwext4)
44 #Detect all possible warnings for lwext4 target
45 set_target_properties(lwext4 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic")
46
47
48 #DISTRIBUTION
49 set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
50 set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
51 set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
52 set(CPACK_SOURCE_GENERATOR "TBZ2")
53 set(CPACK_SOURCE_PACKAGE_FILE_NAME
54   "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
55 set(CPACK_SOURCE_IGNORE_FILES
56 "/build" ".git")
57 include(CPack)
58
59
60 add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)