add version and find_package() module

This commit is contained in:
Lephenixnoir 2021-01-28 22:47:45 +01:00
parent c9ceb18681
commit 9ae8136471
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 31 additions and 7 deletions

View File

@ -2,11 +2,9 @@
cmake_minimum_required(VERSION 3.18)
project(libimg VERSION 2.2.1 LANGUAGES C)
find_package(Gint 2.2.1 REQUIRED)
add_compile_options(-Wall -Wextra -std=c11 -Os)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
configure_file(libimg.h libimg.h)
set(SOURCES
src/alloc.c
@ -20,8 +18,15 @@ set(SOURCES
)
set(NAME "img-${FXSDK_PLATFORM}")
add_library("${NAME}" STATIC ${SOURCES})
target_link_libraries("${NAME}" Gint::Gint)
add_library(${NAME} STATIC ${SOURCES})
install(TARGETS "${NAME}" DESTINATION "${FXSDK_COMPILER_INSTALL}")
install(FILES libimg.h DESTINATION "${FXSDK_COMPILER_INSTALL}/include")
target_compile_options(${NAME} PUBLIC -Wall -Wextra -std=c11 -Os)
target_include_directories(${NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(${NAME} Gint::Gint)
install(TARGETS ${NAME}
DESTINATION "${FXSDK_COMPILER_INSTALL}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libimg.h"
DESTINATION "${FXSDK_COMPILER_INSTALL}/include")
install(FILES cmake/FindLibImg.cmake
DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")

16
cmake/FindLibImg.cmake Normal file
View File

@ -0,0 +1,16 @@
include(FindSimpleLibrary)
include(FindPackageHandleStandardArgs)
find_simple_library("libimg-${FXSDK_PLATFORM}.a" include/libimg.h
"IMG_VERSION" PATH_VAR IMG_PATH VERSION_VAR IMG_VERSION)
find_package_handle_standard_args(LibImg
REQUIRED_VARS IMG_PATH IMG_VERSION
VERSION_VAR IMG_VERSION)
if(LibImg_FOUND)
add_library(LibImg::LibImg UNKNOWN IMPORTED)
set_target_properties(LibImg::LibImg PROPERTIES
IMPORTED_LOCATION "${IMG_PATH}"
INTERFACE_LINK_OPTIONS -limg-${FXSDK_PLATFORM})
endif()

View File

@ -4,6 +4,9 @@
#include <gint/display.h>
#include <stdint.h>
/* This is substituted by CMake at compile-time */
#define IMG_VERSION "@libimg_VERSION@"
#ifdef FX9860G
/* On fx-9860G, the format is 8-bit per color. Although there are much less
than 256 colors (you could find 9 at best including partially-transparent