Initial Course

This commit is contained in:
David Gil de Gómez Pérez
2026-08-11 17:40:36 +03:00
commit 9aed1d1d86
202 changed files with 3420 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
function(add_course_exercise)
set(options "")
set(oneValueArgs NAME MODULE STANDARD)
set(multiValueArgs SOURCES)
cmake_parse_arguments(
EXERCISE
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
if(NOT EXERCISE_NAME)
message(FATAL_ERROR "add_course_exercise requires NAME")
endif()
if(NOT EXERCISE_MODULE)
message(FATAL_ERROR "add_course_exercise requires MODULE")
endif()
if(NOT EXERCISE_SOURCES)
message(FATAL_ERROR "add_course_exercise requires SOURCES")
endif()
if(NOT EXERCISE_STANDARD)
set(EXERCISE_STANDARD 23)
endif()
set(target_name "${EXERCISE_MODULE}_${EXERCISE_NAME}")
add_executable(${target_name} ${EXERCISE_SOURCES})
target_include_directories(
${target_name}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)
course_set_cxx_standard(${target_name} ${EXERCISE_STANDARD})
course_apply_warnings(${target_name})
if(COURSE_BUILD_TESTS)
target_link_libraries(${target_name} PRIVATE GTest::gtest_main)
gtest_discover_tests(
${target_name}
DISCOVERY_MODE PRE_TEST
PROPERTIES LABELS "${EXERCISE_MODULE};${EXERCISE_NAME}"
)
endif()
set_target_properties(
${target_name}
PROPERTIES
FOLDER "modules/${EXERCISE_MODULE}"
)
endfunction()
+25
View File
@@ -0,0 +1,25 @@
function(course_apply_warnings target_name)
if(MSVC)
target_compile_options(${target_name} PRIVATE /W4 /permissive-)
if(COURSE_WARNINGS_AS_ERRORS)
target_compile_options(${target_name} PRIVATE /WX)
endif()
else()
target_compile_options(
${target_name}
PRIVATE
-Wall
-Wextra
-Wpedantic
-Wconversion
-Wshadow
)
if(COURSE_WARNINGS_AS_ERRORS)
target_compile_options(${target_name} PRIVATE -Werror)
endif()
endif()
endfunction()
function(course_set_cxx_standard target_name standard)
target_compile_features(${target_name} PRIVATE cxx_std_${standard})
endfunction()