Day2Part1

This commit is contained in:
Feiko Wielsma 2025-12-03 21:28:53 +00:00
parent 86dcbd3aaf
commit 5d1d878d78
7 changed files with 117 additions and 18 deletions

View file

@ -6,6 +6,33 @@ set(CMAKE_CXX_COMPILER /usr/bin/clang++-21)
project(aoc25 VERSION 0.1.0 LANGUAGES C CXX)
# Helper to add AoC day targets and auto-copy any input files
function(aoc_add_day name src_dir)
# remaining args are source files
set(sources ${ARGN})
add_executable(${name} ${sources})
set_target_properties(${name} PROPERTIES CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
# Use GCC toolchain compatibility for clang++-21
target_compile_options(${name} PRIVATE --gcc-toolchain=/usr)
# Gather common input files in the source directory
file(GLOB INPUT_FILES
"${src_dir}/*_input"
"${src_dir}/puzzle_input"
"${src_dir}/test_input"
)
foreach(f IN LISTS INPUT_FILES)
get_filename_component(fname ${f} NAME)
add_custom_command(TARGET ${name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${f} $<TARGET_FILE_DIR:${name}>/${fname}
COMMENT "Copying ${fname} to build directory for ${name}"
)
endforeach()
endfunction()
# Per-day subprojects (example: day1)
add_subdirectory(day1)
add_subdirectory(day2)