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})
|
add_executable(NXST ${NXST_SOURCES})
|
||||||
|
|
||||||
# ── Include paths ─────────────────────────────────────────────────────────────
|
# ── Include paths ─────────────────────────────────────────────────────────────
|
||||||
target_include_directories(NXST PRIVATE
|
target_include_directories(NXST PRIVATE include)
|
||||||
include
|
|
||||||
lib/Plutonium/include
|
|
||||||
)
|
|
||||||
|
|
||||||
# ── pkg-config (uses aarch64-none-elf-pkg-config set by Switch.cmake) ─────────
|
# ── pkg-config (uses aarch64-none-elf-pkg-config set by Switch.cmake) ─────────
|
||||||
find_package(PkgConfig REQUIRED)
|
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})
|
target_include_directories(NXST PRIVATE ${PORTLIBS_INCLUDE_DIRS})
|
||||||
|
|
||||||
# ── Link libraries ────────────────────────────────────────────────────────────
|
# ── Plutonium ─────────────────────────────────────────────────────────────────
|
||||||
# ── Plutonium static library ──────────────────────────────────────────────────
|
include(ExternalProject)
|
||||||
|
|
||||||
set(LIBPU_A ${CMAKE_SOURCE_DIR}/lib/Plutonium/lib/libpu.a)
|
set(LIBPU_A ${CMAKE_SOURCE_DIR}/lib/Plutonium/lib/libpu.a)
|
||||||
|
|
||||||
add_custom_command(
|
ExternalProject_Add(plutonium_ep
|
||||||
OUTPUT ${LIBPU_A}
|
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/Plutonium
|
||||||
COMMAND make -C ${CMAKE_SOURCE_DIR}/lib/Plutonium -j
|
CONFIGURE_COMMAND ""
|
||||||
COMMENT "Building Plutonium (libpu.a)"
|
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 ────────────────────────────────────────────────────────────
|
# ── Link libraries ────────────────────────────────────────────────────────────
|
||||||
# Order matters for static linking: put most dependent libs first.
|
# 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
|
# 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).
|
# to fix the freetype→harfbuzz static link order (see build notes from libnx update).
|
||||||
target_link_libraries(NXST PRIVATE
|
target_link_libraries(NXST PRIVATE
|
||||||
${LIBPU_A}
|
plutonium
|
||||||
PkgConfig::PORTLIBS
|
PkgConfig::PORTLIBS
|
||||||
drm_nouveau
|
drm_nouveau
|
||||||
harfbuzz
|
harfbuzz
|
||||||
|
|||||||
Reference in New Issue
Block a user