aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-08-16 18:33:46 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-08-16 18:47:52 +0200
commit9c71a765f0e4f53a6bbae5f550515b93eb9d7c53 (patch)
tree72dcc4a1048369f428d9c0e1b87cbb2dbb13408d /cmake
parent0013593d4289e0be2e6651980185e3e95fcb8726 (diff)
Personal files inclusion now by projects.
Depending on file name you can include some files from your home or system by project or globally Change-Id: I1fef678073977633576a21893065e681b286646c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/cmake.d/03-macros.cmake48
-rw-r--r--cmake/common.cmake4
2 files changed, 39 insertions, 13 deletions
diff --git a/cmake/cmake.d/03-macros.cmake b/cmake/cmake.d/03-macros.cmake
index 62e5790..7abbf08 100644
--- a/cmake/cmake.d/03-macros.cmake
+++ b/cmake/cmake.d/03-macros.cmake
@@ -50,21 +50,41 @@ endmacro(configure_files_in_dir)
# Create custom target dedicated for HTML5 and DATA AGL target type
macro(add_input_files INPUT_FILES)
+ set(XML_LIST ${INPUT_FILES})
+ set(LUA_LIST ${INPUT_FILES})
+ set(JSON_LIST ${INPUT_FILES})
+ list(FILTER XML_LIST INCLUDE REGEX "xml$")
+ list(FILTER LUA_LIST INCLUDE REGEX "lua$")
+ list(FILTER JSON_LIST INCLUDE REGEX "json$")
+
add_custom_target(${TARGET_NAME}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
)
+ foreach(file ${XML_LIST})
+ add_custom_command(TARGET ${TARGET_NAME}
+ PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${XML_CHECKER} ${file}
+ )
+ endforeach()
+ foreach(file ${LUA_LIST})
add_custom_command(TARGET ${TARGET_NAME}
- PRE_BUILD
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND [ -f *xml ] && ${XML_CHECKER} ${INPUT_FILES}
- COMMAND [ -f *lua ] && ${LUA_CHECKER} ${INPUT_FILES}
- COMMAND [ -f *json ] && for f in ${INPUT_FILES}; do cat ${INPUT_FILES} | ${JSON_CHECKER}; done
+ PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${LUA_CHECKER} ${file}
)
+ endforeach()
+ foreach(file ${JSON_LIST})
+ add_custom_command(TARGET ${TARGET_NAME}
+ PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND cat ${file} | ${JSON_CHECKER}
+ )
+ endforeach()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
- DEPENDS ${INPUT_FILES}
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
+ DEPENDS ${INPUT_FILES}
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
COMMAND cp -r ${INPUT_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
@@ -163,13 +183,19 @@ macro(project_targets_populate)
add_dependencies(populate ${POPULE_PACKAGE_TARGET})
add_dependencies(${POPULE_PACKAGE_TARGET} ${TARGET})
elseif(${T} STREQUAL "DATA")
- add_custom_command(OUTPUT ${PACKAGE_DATADIR}-xx
- DEPENDS ${BD}/${P}${OUT}
+ # Generate list of output files instead of just one output directory
+ get_target_property(SF ${TARGET} SOURCES)
+ foreach(file ${SF})
+ get_filename_component(JUST_FILENAME ${file} NAME)
+ list(APPEND OUTPUT_FILES ${PACKAGE_DATADIR}/${JUST_FILENAME})
+ endforeach()
+ add_custom_target(${POPULE_PACKAGE_TARGET})
+ add_custom_command(TARGET ${POPULE_PACKAGE_TARGET}
+ POST_BUILD
COMMAND mkdir -p ${PACKAGE_DATADIR}
COMMAND touch ${PACKAGE_DATADIR}
- COMMAND cp -r ${BD}/${P}${OUT}/* ${PACKAGE_DATADIR}
+ COMMAND cp -r ${BD}/${TARGET} ${PACKAGE_DATADIR}
)
- add_custom_target(${POPULE_PACKAGE_TARGET} DEPENDS ${PACKAGE_DATADIR}-xx)
add_dependencies(populate ${POPULE_PACKAGE_TARGET})
add_dependencies(${POPULE_PACKAGE_TARGET} ${TARGET})
endif(${T} STREQUAL "BINDING")
diff --git a/cmake/common.cmake b/cmake/common.cmake
index 4e34fcd..1cec2a7 100644
--- a/cmake/common.cmake
+++ b/cmake/common.cmake
@@ -26,9 +26,9 @@
file(GLOB project_cmakefiles ${PROJECT_APP_TEMPLATES_DIR}/cmake/cmake.d/[0-9][0-9]-*.cmake)
list(SORT project_cmakefiles)
-file(GLOB home_cmakefiles $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-*.cmake)
+file(GLOB home_cmakefiles $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-common-*.cmake $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-${PROJECT_NAME}-*.cmake)
list(SORT home_cmakefiles)
-file(GLOB system_cmakefiles /etc/app-templates/cmake.d/[0-9][0-9]-*.cmake)
+file(GLOB system_cmakefiles /etc/app-templates/cmake.d/[0-9][0-9]-common-*.cmake /etc/app-templates/cmake.d/[0-9][0-9]-${PROJECT_NAME}-*.cmake)
list(SORT system_cmakefiles)
foreach(file ${system_cmakefiles} ${home_cmakefiles} ${project_cmakefiles})