build: add support for generic source sub-directories in modules

This commit is contained in:
2025-04-11 13:48:18 +01:00
parent bf83831cee
commit c630321bf6

View File

@@ -1,12 +1,18 @@
function(add_bluelib_module) function(add_bluelib_module)
set(options) set(options)
set(one_value_args NAME) set(one_value_args NAME)
set(multi_value_args DEPENDENCIES) set(multi_value_args DEPENDENCIES SUBDIRS)
cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${one_value_args}" "${multi_value_args}") cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${one_value_args}" "${multi_value_args}")
set(module_name ${arg_NAME}) set(module_name ${arg_NAME})
file(GLOB sources *.c *.h) file(GLOB sources *.c *.h)
foreach (dir ${arg_SUBDIRS})
file(GLOB dir_sources ${dir}/*.c ${dir}/*.h)
set(sources ${sources} ${dir_sources})
endforeach (dir)
file(GLOB sys_sources sys/${b_system_name}/*.c sys/${b_system_name}/*.h) file(GLOB sys_sources sys/${b_system_name}/*.c sys/${b_system_name}/*.h)
set(root_header include/blue/${module_name}.h) set(root_header include/blue/${module_name}.h)
file(GLOB headers include/blue/${module_name}/*.h) file(GLOB headers include/blue/${module_name}/*.h)
@@ -36,7 +42,7 @@ function(add_bluelib_module)
set_target_properties(blue-${module_name} PROPERTIES FOLDER "Shared/${module_name}") set_target_properties(blue-${module_name} PROPERTIES FOLDER "Shared/${module_name}")
set_target_properties(blue-${module_name}-s PROPERTIES FOLDER "Static/${module_name}") set_target_properties(blue-${module_name}-s PROPERTIES FOLDER "Static/${module_name}")
TEST_BIG_ENDIAN(IS_BIG_ENDIAN) TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN) if(IS_BIG_ENDIAN)
target_compile_definitions(blue-${module_name} PRIVATE BIG_ENDIAN) target_compile_definitions(blue-${module_name} PRIVATE BIG_ENDIAN)