build: migrate Plutonium to ExternalProject_Add + IMPORTED target
Replaces add_custom_command/add_custom_target with ExternalProject_Add, which correctly declares BUILD_BYPRODUCTS for Ninja and propagates include paths via INTERFACE_INCLUDE_DIRECTORIES on the IMPORTED STATIC target. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+19
-14
@@ -35,10 +35,7 @@ file(GLOB_RECURSE NXST_SOURCES
|
||||
add_executable(NXST ${NXST_SOURCES})
|
||||
|
||||
# ── Include paths ─────────────────────────────────────────────────────────────
|
||||
target_include_directories(NXST PRIVATE
|
||||
include
|
||||
lib/Plutonium/include
|
||||
)
|
||||
target_include_directories(NXST PRIVATE include)
|
||||
|
||||
# ── pkg-config (uses aarch64-none-elf-pkg-config set by Switch.cmake) ─────────
|
||||
find_package(PkgConfig REQUIRED)
|
||||
@@ -52,25 +49,33 @@ pkg_check_modules(PORTLIBS REQUIRED IMPORTED_TARGET ${NXST_PKG_MODULES})
|
||||
|
||||
target_include_directories(NXST PRIVATE ${PORTLIBS_INCLUDE_DIRS})
|
||||
|
||||
# ── Link libraries ────────────────────────────────────────────────────────────
|
||||
# ── Plutonium static library ──────────────────────────────────────────────────
|
||||
# ── Plutonium ─────────────────────────────────────────────────────────────────
|
||||
include(ExternalProject)
|
||||
|
||||
set(LIBPU_A ${CMAKE_SOURCE_DIR}/lib/Plutonium/lib/libpu.a)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${LIBPU_A}
|
||||
COMMAND make -C ${CMAKE_SOURCE_DIR}/lib/Plutonium -j
|
||||
COMMENT "Building Plutonium (libpu.a)"
|
||||
ExternalProject_Add(plutonium_ep
|
||||
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/Plutonium
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND make -j -C ${CMAKE_SOURCE_DIR}/lib/Plutonium
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_BYPRODUCTS ${LIBPU_A}
|
||||
)
|
||||
|
||||
add_library(plutonium STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(plutonium plutonium_ep)
|
||||
set_target_properties(plutonium PROPERTIES
|
||||
IMPORTED_LOCATION ${LIBPU_A}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/lib/Plutonium/include
|
||||
)
|
||||
add_custom_target(plutonium DEPENDS ${LIBPU_A})
|
||||
add_dependencies(NXST plutonium)
|
||||
|
||||
# ── Link libraries ────────────────────────────────────────────────────────────
|
||||
# Order matters for static linking: put most dependent libs first.
|
||||
# libpu.a first (contains C wrappers not in Plutonium source).
|
||||
# drm_nouveau, harfbuzz, freetype, z appended explicitly after pkg-config output
|
||||
# to fix the freetype→harfbuzz static link order (see build notes from libnx update).
|
||||
target_link_libraries(NXST PRIVATE
|
||||
${LIBPU_A}
|
||||
plutonium
|
||||
PkgConfig::PORTLIBS
|
||||
drm_nouveau
|
||||
harfbuzz
|
||||
|
||||
Reference in New Issue
Block a user