Files
bluelib/CMakeLists.txt

43 lines
1.4 KiB
CMake
Raw Normal View History

2024-08-03 07:54:28 +01:00
cmake_minimum_required(VERSION 3.25)
project(bluelib C)
2024-11-14 16:56:12 +00:00
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
2024-10-24 21:32:28 +01:00
set(b_modules core object term cmd)
2024-08-03 07:54:28 +01:00
set(b_system_name ${CMAKE_SYSTEM_NAME})
string(TOLOWER ${b_system_name} b_system_name)
2024-10-24 21:33:19 +01:00
message(STATUS "System name: ${b_system_name}")
2024-08-03 07:54:28 +01:00
foreach (module ${b_modules})
add_subdirectory(${module})
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${module}-test)
message(STATUS "Building unit tests for module ${module}")
2024-10-24 21:33:19 +01:00
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${module}-test/${module}-units.c)
add_executable(blue-${module}-units
${module}-test/${module}-units.c
misc/AllTests.c
misc/CuTest.c
misc/CuTest.h)
target_link_libraries(blue-${module}-units blue-${module})
target_include_directories(blue-${module}-units PRIVATE misc/)
2024-11-14 16:56:12 +00:00
set_target_properties(blue-${module}-units PROPERTIES FOLDER "Tests/${module}")
2024-10-24 21:33:19 +01:00
endif ()
file(GLOB test_sources ${module}-test/*.c)
list(REMOVE_ITEM test_sources "${CMAKE_CURRENT_SOURCE_DIR}/${module}-test/${module}-units.c")
foreach (test_file ${test_sources})
get_filename_component(test_name ${test_file} NAME_WE)
add_executable(blue-${module}-${test_name} ${test_file})
2024-11-14 16:56:12 +00:00
set_target_properties(blue-${module}-${test_name} PROPERTIES FOLDER "Tests/${module}")
2024-10-24 21:33:19 +01:00
target_link_libraries(blue-${module}-${test_name} blue-${module})
endforeach (test_file)
2024-08-03 07:54:28 +01:00
endif ()
endforeach (module)