feat: add c++ file and remove mconfig file

This commit is contained in:
2025-08-11 23:38:45 +02:00
parent bc9c9b2a94
commit 78a6edf84b
11 changed files with 120 additions and 88 deletions

View File

@@ -1,12 +1,20 @@
cmake_minimum_required(VERSION 3.10)
project(t3dsr C)
project(t3dsr C CXX)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 17)
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.c)
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS src/*.h)
# ==== sources ====
file(GLOB_RECURSE C_SOURCES CONFIGURE_DEPENDS src/*.c)
file(GLOB_RECURSE CPP_SOURCES CONFIGURE_DEPENDS src/*.cpp)
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS src/*.h src/*.hpp)
add_executable(main ${SOURCES} ${HEADERS})
file(GLOB MAIN_SRC CONFIGURE_DEPENDS src/main.*)
set(ALL_SOURCES ${C_SOURCES} ${CPP_SOURCES})
list(REMOVE_ITEM ALL_SOURCES ${MAIN_SRC})
add_executable(main ${MAIN_SRC} ${ALL_SOURCES} ${HEADERS})
if(NOT MSVC)
target_link_libraries(main m)
endif()
@@ -14,13 +22,11 @@ endif()
# ==== tests ====
enable_testing()
file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS tests/*.c)
list(FILTER SOURCES EXCLUDE REGEX ".*src/main\\.c$")
foreach(test_src ${TEST_SOURCES})
get_filename_component(test_name ${test_src} NAME_WE)
add_executable(${test_name} ${test_src} ${SOURCES})
add_executable(${test_name} ${test_src} ${ALL_SOURCES})
if(NOT MSVC)
target_link_libraries(${test_name} m)
endif()