Update palaldium / add cmake install targets

This commit is contained in:
2026-02-27 20:13:11 +01:00
parent 7bc7c60a15
commit 61061277f6
6 changed files with 61 additions and 16 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
build/ build*/
.cache .cache
.zed

View File

@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.22) cmake_minimum_required(VERSION 3.22)
project(ctrff) project(ctrff VERSION 0.2.0)
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true) set(CMAKE_CXX_STANDARD_REQUIRED true)
@@ -9,7 +11,7 @@ option(CTRFF_DESKTOP OFF "Buid for Desktop Platform")
option(CTRFF_3DS OFF "Build lib for 3ds") option(CTRFF_3DS OFF "Build lib for 3ds")
option(CTRFF_SHARED OFF) option(CTRFF_SHARED OFF)
if(${CTRFF_3DS}) if(CTRFF_3DS)
set(CTRFF_DESKTOP OFF CACHE BOOL) set(CTRFF_DESKTOP OFF CACHE BOOL)
set(CTRFF_BUILD_GUI OFF CACHE BOOL) set(CTRFF_BUILD_GUI OFF CACHE BOOL)
set(CTRFF_SHARED OFF CACHE BOOL) set(CTRFF_SHARED OFF CACHE BOOL)
@@ -35,18 +37,54 @@ set(CTRFF_SOURCE
source/smdh.cpp source/smdh.cpp
) )
if(${CTRFF_SHARED}) if(CTRFF_SHARED)
add_library(ctrff SHARED ${CTRFF_SOURCE}) add_library(ctrff SHARED ${CTRFF_SOURCE})
target_compile_definitions(ctrff PUBLIC CTRFF_SHARED) target_compile_definitions(ctrff PUBLIC CTRFF_SHARED)
target_compile_definitions(ctrff PRIVATE CTRFF_BUILD_SHARED) target_compile_definitions(ctrff PRIVATE CTRFF_BUILD_SHARED)
else() else()
add_library(ctrff STATIC ${CTRFF_SOURCE}) add_library(ctrff STATIC ${CTRFF_SOURCE})
endif() endif()
target_include_directories(ctrff PUBLIC include)
if(${CTRFF_DESKTOP}) target_include_directories(ctrff
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if(CTRFF_DESKTOP)
add_subdirectory(tools) add_subdirectory(tools)
endif() endif()
install(TARGETS ctrff) install(TARGETS ctrff
install(DIRECTORY include DESTINATION ".") EXPORT ctrffTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT ctrffTargets
FILE ctrffTargets.cmake
NAMESPACE ctrff::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ctrff
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
cmake/ctrffConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ctrffConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ctrff
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ctrffConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/ctrffConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ctrffConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ctrff
)

View File

@@ -0,0 +1,3 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/ctrffTargets.cmake")

View File

@@ -18,5 +18,8 @@ target_include_directories(test PUBLIC include
${CMAKE_CURRENT_SOURCE_DIR}/../../vendor/cli-fancy/include ${CMAKE_CURRENT_SOURCE_DIR}/../../vendor/cli-fancy/include
) )
target_link_libraries(test PUBLIC ctrff) target_link_libraries(test PUBLIC ctrff)
set_target_properties(ctrff-cli PROPERTIES
OUTPUT_NAME ctrff
)
install(TARGETS ctrff-cli) install(TARGETS ctrff-cli)

View File

@@ -10,7 +10,7 @@
#include <utility> #include <utility>
/** Import palladium stb image */ /** Import palladium stb image */
#include <pd/external/stb_image.h> #include <pd/external/stb_image.hpp>
#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h> #include <stb_image_write.h>
/** Could not use the palladium func due to only using headers */ /** Could not use the palladium func due to only using headers */
@@ -121,7 +121,7 @@ void MakeSMDH(const cf7::command::ArgumentList &data) {
smdh.SetAuthor(a); smdh.SetAuthor(a);
std::vector<unsigned char> img; std::vector<unsigned char> img;
int w, h, c; int w, h, c;
ctrff::u8 *buf = stbi_load(i.c_str(), &w, &h, &c, 4); ctrff::u8 *buf = pdi_load(i.c_str(), &w, &h, &c, 4);
if (buf == nullptr) { if (buf == nullptr) {
cf7::PrintFancy({ cf7::PrintFancy({
std::make_pair("Error", cf7::col(190, 0, 0)), std::make_pair("Error", cf7::col(190, 0, 0)),