build: build fx and fx.collections assemblies

This commit is contained in:
2026-05-02 21:02:10 +01:00
parent c78ea4bfa6
commit 604ddfcebf
+9 -49
View File
@@ -9,8 +9,12 @@ set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (NOT DEFINED fx_modules)
set(fx_modules core ds serial term cmd io compress)
set(fx_all_assemblies
fx
fx.collections)
if (NOT DEFINED fx_assemblies)
set(fx_assemblies ${fx_all_assemblies})
endif ()
if (NOT DEFINED fx_enable_floating_point)
@@ -32,50 +36,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
foreach (module ${fx_modules})
add_subdirectory(${module})
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/${module})
message(STATUS "Building unit tests for module ${module}")
if (fx_enable_tests AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/${module}/${module}-units.c)
add_executable(fx-${module}-units
test/${module}/${module}-units.c
misc/AllTests.c
misc/CuTest.c
misc/CuTest.h)
target_link_libraries(fx-${module}-units fx-${module})
target_include_directories(fx-${module}-units PRIVATE misc/)
set_target_properties(fx-${module}-units PROPERTIES FOLDER "Tests/${module}")
endif ()
file(GLOB test_sources test/${module}/*.c)
list(REMOVE_ITEM test_sources "${CMAKE_CURRENT_SOURCE_DIR}/test/${module}/${module}-units.c")
if (fx_enable_tests)
foreach (test_file ${test_sources})
get_filename_component(test_name ${test_file} NAME_WE)
add_executable(fx-${module}-${test_name} ${test_file})
set_target_properties(fx-${module}-${test_name} PROPERTIES FOLDER "Tests/${module}")
target_link_libraries(fx-${module}-${test_name} fx-${module})
endforeach (test_file)
endif ()
endif ()
endforeach (module)
if (fx_enable_tests)
file(GLOB test_sources test/*.c)
list(REMOVE_ITEM test_sources "${CMAKE_CURRENT_SOURCE_DIR}/test/units.c")
foreach (test_file ${test_sources})
get_filename_component(test_name ${test_file} NAME_WE)
add_executable(fx-${test_name} ${test_file})
set_target_properties(fx-${test_name} PROPERTIES FOLDER "Tests")
foreach (module ${fx_modules})
target_link_libraries(fx-${test_name} fx-${module})
endforeach (module)
endforeach (test_file)
endif ()
foreach (assembly ${fx_assemblies})
add_subdirectory(${assembly})
endforeach (assembly)