Skip to content

Commit

Permalink
fix cmake failing with empty modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragingram2 authored and GlynLeine committed Dec 29, 2022
1 parent 6b35a08 commit 0c553cf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
34 changes: 19 additions & 15 deletions cmake/configure_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ macro(rythe_configure_module module)
get_target_property(MODULE_SOURCES ${module} SOURCES)
set(MODULE_INFO_SOURCES ${MODULE_SOURCES} PARENT_SCOPE)

foreach(src ${MODULE_SOURCES})
get_filename_component(SRC_EXT ${src} EXT)
if(MODULE_SOURCES)
foreach(src ${MODULE_SOURCES})
get_filename_component(SRC_EXT ${src} EXT)

if (SRC_EXT STREQUAL ".hpp" OR
SRC_EXT STREQUAL ".h" OR
SRC_EXT STREQUAL ".inl")
set(MODULE_INFO_HAS_HEADERS ON PARENT_SCOPE)
endif()
if (SRC_EXT STREQUAL ".hpp" OR
SRC_EXT STREQUAL ".h" OR
SRC_EXT STREQUAL ".inl")
set(MODULE_INFO_HAS_HEADERS ON PARENT_SCOPE)
endif()

if (SRC_EXT STREQUAL ".cpp" OR
SRC_EXT STREQUAL ".c")
set(MODULE_INFO_HAS_SOURCES ON PARENT_SCOPE)
endif()
if (SRC_EXT STREQUAL ".cpp" OR
SRC_EXT STREQUAL ".c")
set(MODULE_INFO_HAS_SOURCES ON PARENT_SCOPE)
endif()

get_filename_component(dir ${src} DIRECTORY)
file(RELATIVE_PATH rel_path ${RYTHE_DIR_ENGINE}/${module}/src/${module} ${dir})
source_group("${rel_path}" FILES "${src}")
endforeach()
get_filename_component(dir ${src} DIRECTORY)
file(RELATIVE_PATH rel_path ${RYTHE_DIR_ENGINE}/${module}/src/${module} ${dir})
source_group("${rel_path}" FILES "${src}")
endforeach()
else()
message(WARNING "Module: \"${module}\" is empty.")
endif()
endmacro()
5 changes: 5 additions & 0 deletions cmake/find_sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
macro(rythe_find_sources sources directory)
file(GLOB_RECURSE sources ${RYTHE_FILE_TYPES})
list(FILTER sources INCLUDE REGEX ${directory})
if(NOT sources)
file(WRITE ${directory}/delete_me.cpp)
file(GLOB_RECURSE sources ${RYTHE_FILE_TYPES})
list(FILTER sources INCLUDE REGEX ${directory})
endif()
endmacro()
2 changes: 1 addition & 1 deletion rythe/engine/core

0 comments on commit 0c553cf

Please sign in to comment.