diff --git a/CMakeLists.txt b/CMakeLists.txt index d23959d..2c690db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,11 @@ cmake_minimum_required(VERSION 3.5) -project(Irrlicht CXX) +project(Irrlicht + VERSION 1.9.0 + LANGUAGES CXX +) -set(IRRLICHT_VERSION_MAJOR 1) -set(IRRLICHT_VERSION_MINOR 9) -set(IRRLICHT_VERSION_RELEASE 0) - -set(VERSION "${IRRLICHT_VERSION_MAJOR}.${IRRLICHT_VERSION_MINOR}.${IRRLICHT_VERSION_RELEASE}") -message(STATUS "*** Building IrrlichtMt ${VERSION} ***") +message(STATUS "*** Building IrrlichtMt ${PROJECT_VERSION} ***") if(ANDROID) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/Android) @@ -28,3 +26,39 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") add_subdirectory(source/Irrlicht) + +# Installation of library and headers. +include(GNUInstallDirs) +install(TARGETS IrrlichtMt + EXPORT IrrlichtMt-export + DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/IrrlichtMt" +) + +# Installation of CMake target and configuration files. +install(EXPORT IrrlichtMt-export + FILE IrrlichtMtTargets.cmake + NAMESPACE IrrlichtMt:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt" +) + +include(CMakePackageConfigHelpers) +configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/IrrlichtMtConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/IrrlichtMtConfigVersion.cmake" + COMPATIBILITY AnyNewerVersion +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/IrrlichtMtConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/IrrlichtMtConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt" +) diff --git a/Config.cmake.in b/Config.cmake.in new file mode 100644 index 0000000..96194f3 --- /dev/null +++ b/Config.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +if(NOT TARGET IrrlichtMt::IrrlichtMt) + include("${CMAKE_CURRENT_LIST_DIR}/IrrlichtMtTargets.cmake") +endif() diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index 621f7bd..f8bf819 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -394,16 +394,10 @@ add_library(IrrlichtMt ) set_target_properties(IrrlichtMt PROPERTIES - VERSION ${VERSION} - SOVERSION ${IRRLICHT_VERSION_MAJOR}.${IRRLICHT_VERSION_MINOR} + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} ) if(WIN32) set_target_properties(IrrlichtMt PROPERTIES PREFIX "") # for DLL name endif() - -# Installation - -include(GNUInstallDirs) -install(TARGETS IrrlichtMt DESTINATION "${CMAKE_INSTALL_LIBDIR}") -install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt")