build: libavr rides as the pinned submodule
The submodule replaces FetchContent and the unpinned forge fallback; LIBAVR_ROOT stays as the tandem-development override, the presets take the toolchain file from the submodule, and the Studio project's include path anchors there — correct by construction. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,18 +2,19 @@ cmake_minimum_required(VERSION 3.28)
|
||||
|
||||
project(fantemp LANGUAGES CXX)
|
||||
|
||||
# libavr from a local checkout (LIBAVR_ROOT) or the forge; the toolchain
|
||||
# file comes from the same checkout via CMakePresets.json.
|
||||
include(FetchContent)
|
||||
# libavr rides as the pinned submodule; LIBAVR_ROOT (cache or environment)
|
||||
# overrides it for tandem development against a working tree. The toolchain
|
||||
# file comes from the submodule via CMakePresets.json either way.
|
||||
if(NOT LIBAVR_ROOT AND DEFINED ENV{LIBAVR_ROOT})
|
||||
set(LIBAVR_ROOT $ENV{LIBAVR_ROOT})
|
||||
endif()
|
||||
if(LIBAVR_ROOT)
|
||||
FetchContent_Declare(libavr SOURCE_DIR ${LIBAVR_ROOT})
|
||||
else()
|
||||
FetchContent_Declare(libavr GIT_REPOSITORY git@git.blackmark.me:avr/libavr.git GIT_TAG main)
|
||||
if(NOT LIBAVR_ROOT)
|
||||
set(LIBAVR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/libavr)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(libavr)
|
||||
if(NOT EXISTS ${LIBAVR_ROOT}/CMakeLists.txt)
|
||||
message(FATAL_ERROR "libavr not found at ${LIBAVR_ROOT} — run: git submodule update --init libavr")
|
||||
endif()
|
||||
add_subdirectory(${LIBAVR_ROOT} libavr-build)
|
||||
|
||||
add_executable(fantemp src/main.cpp)
|
||||
target_link_libraries(fantemp PRIVATE libavr)
|
||||
|
||||
Reference in New Issue
Block a user