diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f07d3ada..a257cceab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,20 @@ else(${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 7) set( NO_GENERATOR_EXPRESSIONS ON ) endif(${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 7) +# Function to get a recursive list of files, but also get the directory names +# as well unlike GLOB_RECURSE +function( glob_recurse_with_directories OUTVAR DIR ) + file( GLOB CHILDREN ${DIR}/* ) + foreach( CHILD ${CHILDREN} ) + if( IS_DIRECTORY ${CHILD} ) + set( TEMP_LIST "" ) + glob_recurse_with_directories( TEMP_LIST ${CHILD} ) + set( ${OUTVAR} ${${OUTVAR}} ${TEMP_LIST} ) + endif( IS_DIRECTORY ${CHILD} ) + endforeach( CHILD ${CHILDREN} ) + set( ${OUTVAR} ${${OUTVAR}} ${CHILDREN} PARENT_SCOPE ) +endfunction( glob_recurse_with_directories ) + # Simplify pk3 building, add_pk3(filename srcdirectory) function( add_pk3 PK3_NAME PK3_DIR ) get_target_property(ZIPDIR_EXE zipdir LOCATION) @@ -23,15 +37,18 @@ function( add_pk3 PK3_NAME PK3_DIR ) set( PK3_TARGET "pk3" ) endif( ${PK3_TARGET} STREQUAL "zdoom_pk3" ) + # Get as many files as we can to depend on. + glob_recurse_with_directories( PK3_DEPENDS ${PK3_DIR} ) + if( NOT NO_GENERATOR_EXPRESSIONS AND NOT ZDOOM_OUTPUT_OLDSTYLE ) add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} COMMAND ${ZIPDIR_EXE} -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} $/${PK3_NAME} - DEPENDS zipdir ${PK3_DIR} ) + DEPENDS zipdir ${PK3_DIR} ${PK3_DEPENDS} ) else( NOT NO_GENERATOR_EXPRESSIONS AND NOT ZDOOM_OUTPUT_OLDSTYLE ) add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} COMMAND ${ZIPDIR_EXE} -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR} - DEPENDS zipdir ${PK3_DIR} ) + DEPENDS zipdir ${PK3_DIR} ${PK3_DEPENDS} ) endif( NOT NO_GENERATOR_EXPRESSIONS AND NOT ZDOOM_OUTPUT_OLDSTYLE ) add_custom_target( ${PK3_TARGET} ALL