42 lines
1.2 KiB
CMake
42 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.10.0)
|
|
|
|
# Set compilers before project() to ensure they're used
|
|
set(CMAKE_C_COMPILER /usr/bin/clang-21)
|
|
set(CMAKE_CXX_COMPILER /usr/bin/clang++-21)
|
|
|
|
project(aoc25 VERSION 0.1.0 LANGUAGES C CXX)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
# 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)
|
|
|
|
target_compile_options(${name} PRIVATE -stdlib=libc++)
|
|
target_link_options(${name} PRIVATE -stdlib=libc++)
|
|
|
|
# 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)
|
|
add_subdirectory(day3)
|
|
add_subdirectory(day4)
|
|
add_subdirectory(day5)
|
|
|