CMake package exports

This commit is contained in:
Jack Andersen 2015-07-08 13:53:40 -10:00
parent 8ca702785c
commit c49ec5c13d
5 changed files with 112 additions and 12 deletions

View File

@ -36,9 +36,6 @@ ATHENA_PRO=true
include(Athena.pri) include(Athena.pri)
OTHER_FILES += \
.travis.yml
unix { unix {
isEmpty(PREFIX) { isEmpty(PREFIX) {
PREFIX = /usr/local PREFIX = /usr/local

22
AthenaConfig.cmake.in Normal file
View File

@ -0,0 +1,22 @@
# - Config file for the Athena package
# It defines the following variables
# ATHENA_INCLUDE_DIR - include directory for Athena
# ATHENA_LIBRARIES - libraries to link against
# ATHENA_ICON - path to Athena.ico
# Compute paths
get_filename_component(ATHENA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(ATHENA_INCLUDE_DIR "@CONF_INCLUDE_DIR@")
# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET AthenaCore AND NOT Athena_BINARY_DIR)
include("${ATHENA_CMAKE_DIR}/AthenaTargets.cmake")
endif()
# These are IMPORTED targets created by AthenaTargets.cmake
set(ATHENA_LIBRARIES AthenaCore AthenaSakura AthenaZelda AthenaWiiSave)
# Set icon location if on windows
if(WIN32 AND NOT CYGWIN)
set(ATHENA_ICON "@CONF_ICON_DIR@")
endif()

View File

@ -0,0 +1,11 @@
set(PACKAGE_VERSION "@ATHENA_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@ -1,6 +1,20 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(Athena) project(Athena)
##################
# Athena Version #
##################
set(ATHENA_MAJOR_VERSION 2)
set(ATHENA_MINOR_VERSION 0)
set(ATHENA_PATCH_VERSION 0)
set(ATHENA_VERSION
${ATHENA_MAJOR_VERSION}.${ATHENA_MINOR_VERSION}.${ATHENA_PATCH_VERSION})
################
# Athena Build #
################
add_subdirectory(extern) add_subdirectory(extern)
file(GLOB ATHENA_HEADERS include/Athena/*.hpp) file(GLOB ATHENA_HEADERS include/Athena/*.hpp)
@ -134,23 +148,79 @@ add_library(AthenaZelda
include/Athena/SkywardSwordQuest.hpp include/Athena/SkywardSwordQuest.hpp
) )
# Offer the user the choice of overriding the installation directories
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR cmake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/cmake/Athena)
endif()
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
install(DIRECTORY include/ DESTINATION include/Athena) # Make relative paths absolute (needed later on)
foreach(p LIB INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()
# Define installs
install(DIRECTORY include/ DESTINATION ${INSTALL_INCLUDE_DIR}/Athena)
install(TARGETS AthenaCore AthenaSakura AthenaWiiSave AthenaZelda install(TARGETS AthenaCore AthenaSakura AthenaWiiSave AthenaZelda
DESTINATION lib) DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets)
if(WIN32 AND NOT UNIX) if(WIN32 AND NOT CYGWIN)
install(FILES Athena.ico) install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR})
endif() endif()
# CPack settings ##################
# Package Export #
##################
# Add all targets to the build-tree export set
export(TARGETS AthenaCore AthenaSakura AthenaWiiSave AthenaZelda
FILE "${PROJECT_BINARY_DIR}/AthenaTargets.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE Athena)
# Create the AthenaConfig.cmake
# ... for the build tree
set(CONF_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
set(CONF_ICON_DIR "${PROJECT_SOURCE_DIR}/Athena.ico")
configure_file(AthenaConfig.cmake.in "${PROJECT_BINARY_DIR}/AthenaConfig.cmake" @ONLY)
# ... for the install tree
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")
file(RELATIVE_PATH REL_ICON_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_LIB_DIR}/Athena.ico")
set(CONF_INCLUDE_DIR "\${ATHENA_CMAKE_DIR}/${REL_INCLUDE_DIR}")
set(CONF_ICON_DIR "\${ATHENA_CMAKE_DIR}/${REL_ICON_DIR}")
configure_file(AthenaConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/AthenaConfig.cmake" @ONLY)
# ... for both
configure_file(AthenaConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/AthenaConfigVersion.cmake" @ONLY)
# Install AthenaConfig.cmake
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/AthenaConfig.cmake"
"${PROJECT_BINARY_DIR}/AthenaConfigVersion.cmake"
DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT dev)
# Install the export set for use with the install-tree
install(EXPORT AthenaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT dev)
#########
# CPack #
#########
include(InstallRequiredSystemLibraries) include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Athena") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Athena")
set(CPACK_PACKAGE_VENDOR "2015 Antidote / Jackoalan") set(CPACK_PACKAGE_VENDOR "2015 Antidote / Jackoalan")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "2") set(CPACK_PACKAGE_VERSION_MAJOR ${ATHENA_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR "0") set(CPACK_PACKAGE_VERSION_MINOR ${ATHENA_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH "0") set(CPACK_PACKAGE_VERSION_PATCH ${ATHENA_PATCH_VERSION})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Athena") set(CPACK_PACKAGE_INSTALL_DIRECTORY "Athena")
if(WIN32 AND NOT UNIX) if(WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make # There is a bug in NSI that does not handle full unix paths properly. Make

View File

@ -1,7 +1,7 @@
# PKGBUILD for libAthena # PKGBUILD for libAthena
_pkgname=libathena _pkgname=libathena
pkgname=$_pkgname-git pkgname=$_pkgname-git
pkgver=1.1.0.59.g582d2ce pkgver=1.1.0.60.g8ca7027
pkgrel=1 pkgrel=1
pkgdesc="Basic cross platform IO library" pkgdesc="Basic cross platform IO library"
arch=('i686' 'x86_64') arch=('i686' 'x86_64')