Initial Course
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user