forked from Mq-b/Loser-HomeWork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
32 lines (29 loc) · 1.25 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
cmake_minimum_required(VERSION 3.17)
project(loser_homework)
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(LoserHomeWork)
set(homework_src "${CMAKE_CURRENT_SOURCE_DIR}/src/群友提交")
file(GLOB homework_src_childs RELATIVE ${homework_src} "${homework_src}/*")
set(homework_src_subdirs "")
foreach(child ${homework_src_childs})
if(IS_DIRECTORY ${homework_src}/${child})
list(APPEND homework_src_subdirs ${child})
endif()
endforeach()
enable_msvc_build_stl_modules()
set(all_run_target_list "")
foreach(subdir ${homework_src_subdirs})
string(REGEX MATCH "[0-9]+" index ${subdir})
if(NOT index)
continue()
endif ()
get_cpp_files(${homework_src}/${subdir} cpp_file_list)
set(hw_prefix "hw_${index}")
generate_cpp_files_targets_name("${cpp_file_list}" target_list "${hw_prefix}")
add_cpp_executable_targets("${cpp_file_list}" "${target_list}")
add_run_cpp_executable_targets("${cpp_file_list}" "${target_list}" run_target_list)
add_run_all_targets("run_all_${hw_prefix}" "${run_target_list}")
list(APPEND all_run_target_list "${run_target_list}")
endforeach()
add_run_all_targets("run_all" "${all_run_target_list}")