add version and a find_package() module

This commit is contained in:
Lephenixnoir 2021-01-28 22:23:33 +01:00
parent 91bb658d6c
commit 6b5685a35e
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
3 changed files with 30 additions and 7 deletions

View file

@ -2,16 +2,20 @@
cmake_minimum_required(VERSION 3.18)
project(libprof 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(libprof.h libprof.h)
set(NAME "prof-${FXSDK_PLATFORM}")
add_library("${NAME}" STATIC libprof.c)
target_link_libraries("${NAME}" Gint::Gint)
add_library(${NAME} STATIC libprof.c)
install(TARGETS "${NAME}" DESTINATION "${FXSDK_COMPILER_INSTALL}")
install(FILES libprof.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}/libprof.h"
DESTINATION "${FXSDK_COMPILER_INSTALL}/include")
install(FILES cmake/FindLibProf.cmake
DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")

16
cmake/FindLibProf.cmake Normal file
View file

@ -0,0 +1,16 @@
include(FindSimpleLibrary)
include(FindPackageHandleStandardArgs)
find_simple_library("libprof-${FXSDK_PLATFORM}.a" include/libprof.h
"PROF_VERSION" PATH_VAR PROF_PATH VERSION_VAR PROF_VERSION)
find_package_handle_standard_args(LibProf
REQUIRED_VARS PROF_PATH PROF_VERSION
VERSION_VAR PROF_VERSION)
if(LibProf_FOUND)
add_library(LibProf::LibProf UNKNOWN IMPORTED)
set_target_properties(LibProf::LibProf PROPERTIES
IMPORTED_LOCATION "${PROF_PATH}"
INTERFACE_LINK_OPTIONS -lprof-${FXSDK_PLATFORM})
endif()

View file

@ -8,6 +8,9 @@
#include <stdint.h>
#include <gint/defs/attributes.h>
/* This is substituted by CMake at compile-time */
#define PROF_VERSION "@libprof_VERSION@"
//---
// Initialization
//---