diff options
| -rw-r--r-- | CMakeLists.txt | 33 | ||||
| -rw-r--r-- | include/ext4_config.h | 4 |
2 files changed, 34 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 97fde99..1a5fcf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,13 @@ project(lwext4 C) cmake_minimum_required(VERSION 2.8) -include_directories(include) +include_directories(${PROJECT_BINARY_DIR}/include) include_directories(blockdev/filedev) include_directories(blockdev/filedev_win) set(BLOCKDEV_TYPE none) +add_definitions(-DCONFIG_USE_DEFAULT_CONFIG=0) add_definitions(-DVERSION="${VERSION}") #Examples @@ -43,6 +44,30 @@ else() add_subdirectory(fs_test) endif() +macro(output_configure) + get_property( + definitions + DIRECTORY + PROPERTY COMPILE_DEFINITIONS + ) + file(WRITE + ${PROJECT_BINARY_DIR}/include/generated/ext4_config.h + "") + foreach(item ${definitions}) + string(REGEX MATCH "^CONFIG_" match_res ${item}) + if(match_res) + string(REGEX REPLACE "=(.+)$" "" replace_res ${item}) + string(CONFIGURE + "#define ${replace_res} ${CMAKE_MATCH_1}" + output_str) + file(APPEND + ${PROJECT_BINARY_DIR}/include/generated/ext4_config.h + "${output_str}\n") + endif() + endforeach() +endmacro() +output_configure() + add_subdirectory(blockdev) #Library build @@ -54,6 +79,12 @@ else() set_target_properties(lwext4 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic") endif() +#Config file generation +file( + COPY include + DESTINATION . +) + #DISTRIBUTION set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") diff --git a/include/ext4_config.h b/include/ext4_config.h index 3d856eb..0fc06cd 100644 --- a/include/ext4_config.h +++ b/include/ext4_config.h @@ -41,8 +41,8 @@ extern "C" { #endif -#ifdef CONFIG_HAVE_OWN_CFG -#include <config.h> +#if !CONFIG_USE_DEFAULT_CFG +#include "generated/ext4_config.h" #endif /*****************************************************************************/ |
