now compatible with gint 2.9.0

This commit is contained in:
Sylvain PILLOT 2022-08-22 20:49:35 +02:00
parent 86635a4944
commit 8e0d4a3ddb
2 changed files with 44 additions and 53 deletions

View File

@ -1,53 +1,44 @@
# SDL_prizm: build system
cmake_minimum_required(VERSION 3.16)
project(Libczlib VERSION 1.2.5 LANGUAGES C)
# Libraries that libexample depends on
find_package(Gint 2.7.1 REQUIRED)
project(Libcpng VERSION 1.5.30 LANGUAGES C)
find_package(Gint 2.9.0 REQUIRED)
set(SOURCES
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
infback.c
inffast.c
inflate.c
inftrees.c
trees.c
uncompr.c
zutil.c
png.c
pngerror.c
pngget.c
pngmem.c
pngpread.c
pngread.c
pngrio.c
pngrtran.c
pngrutil.c
pngset.c
pngtrans.c
pngwio.c
pngwrite.c
pngwtran.c
pngwutil.c
)
include_directories(
"${PROJECT_SOURCE_DIR}"
"${PROJECT_BINARY_DIR}/include"
"${FXSDK_COMPILER_INSTALL}/include"
"${FXSDK_COMPILER_INSTALL}/include/openlibm")
add_compile_options(-Os -lm -m4-nofpu -mb -std=c11 -ffreestanding -nostdlib -Wa,--dsp)
# Target name is "czlib", output file is "libczlib.a" (by default)
add_library(czlib STATIC ${SOURCES})
# After building, install the target (that is, czlib.a) in the compiler
install(TARGETS czlib
DESTINATION "${FXSDK_COMPILER_INSTALL}")
# Install zlib.h from the build dir
install(FILES "${PROJECT_SOURCE_DIR}/zlib.h"
DESTINATION "${FXSDK_COMPILER_INSTALL}/include")
# Install zlib.h from the build dir
install(FILES "${PROJECT_SOURCE_DIR}/zconf.h"
DESTINATION "${FXSDK_COMPILER_INSTALL}/include")
# Install FindSDL_prizm.cmake so that users can do find_package(LibSDL_prizm)
install(FILES cmake/Findczlib.cmake
"${FXSDK_INCLUDE}")
add_compile_options(-Os -lm -m4-nofpu -mb -std=c11 -lczlib -ffreestanding -nostdlib -Wa,--dsp)
# Target name is "czlib", output file is "libcPNG.a" (by default)
add_library(cPNG STATIC ${SOURCES})
# After building, install the target (that is, cPNG.a) in the compiler
install(TARGETS cPNG
DESTINATION "${FXSDK_LIB}")
# Install png.h from the build dir
install(FILES "${PROJECT_SOURCE_DIR}/png.h"
DESTINATION "${FXSDK_INCLUDE}")
# Install pngconf.h from the build dir
install(FILES "${PROJECT_SOURCE_DIR}/pngconf.h"
DESTINATION "${FXSDK_INCLUDE}")
# Install pnglibconf.h from the build dir
install(FILES "${PROJECT_SOURCE_DIR}/pnglibconf.h"
DESTINATION "${FXSDK_INCLUDE}")
# Install FindcPNG.cmake so that users can do find_package(LibcPNG)
install(FILES cmake/FindcPNG.cmake
DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")

View File

@ -2,13 +2,13 @@ find_package(Gint 2.7 REQUIRED)
# Find libexample.a; if we had platform-specific versions we could look for
# libexample-${FXSDK_PLATFORM}.a instead.
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libczlib.a
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libcPNG.a
OUTPUT_VARIABLE EX_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
# EX_PATH is now the full path if libustl.a exists, "libustl.a" otherwise
if(NOT "${EX_PATH}" STREQUAL "libczlib.a")
if(NOT "${EX_PATH}" STREQUAL "libcPNG.a")
# Find the version.h header
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=include/zconf.h
COMMAND ${CMAKE_C_COMPILER} -print-file-name=include/pngconf.h
OUTPUT_VARIABLE EX_CONFIG OUTPUT_STRIP_TRAILING_WHITESPACE)
# Extract version information from the config.h header. This command prints
# the version on the line matching the regex and deletes every other line.
@ -28,22 +28,22 @@ endif()
# they're undefined, CMake will conclude libexample was not found)
# -> The version, so CMake can compare with the user's requested one
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libczlib
find_package_handle_standard_args(libcPNG
REQUIRED_VARS EX_CONFIG EX_VERSION
VERSION_VAR EX_VERSION)
# We now have a LibExample_FOUND variable, let's create the target that users
# can link against with target_link_libraries()
if(Libczlib_FOUND)
if(LibcPNG_FOUND)
# This is an imported target, we don't build it, we just claim it's here
add_library(libczlib::libczlib UNKNOWN IMPORTED)
add_library(libcPNG::libcPNG UNKNOWN IMPORTED)
# Here we declare the compiler and linker flags that every user of LibExample
# needs to use.
set_target_properties(libczlib::libczlib PROPERTIES
set_target_properties(libcPNG::libcPNG PROPERTIES
# If we specify where the library comes from, CMake will watch that file
# and relink any user application when the library is updated!
IMPORTED_LOCATION "${EX_PATH}"
# Linking options
INTERFACE_LINK_OPTIONS -lczlib
INTERFACE_LINK_OPTIONS -lcPNG
# Dependencies (for order on the command-line)
IMPORTED_LINK_INTERFACE_LIBRARIES Gint::Gint)
IMPORTED_LINK_INTERFACE_LIBRARIES Gint::Gint -lczlib)
endif()