Skip to content

Commit

Permalink
Add CMake config version for allowing versioning on find_package.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Jan 4, 2019
1 parent 09f697e commit 46244e7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
16 changes: 10 additions & 6 deletions CMakeLists.txt
Expand Up @@ -159,9 +159,9 @@ else()
endif()

# Set runtime path
set(CMAKE_SKIP_BUILD_RPATH FALSE) # Add absolute path to all dependencies for BUILD
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use CMAKE_INSTALL_RPATH for INSTALL
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # Do NOT add path to dependencies for INSTALL
set(CMAKE_SKIP_BUILD_RPATH FALSE) # Add absolute path to all dependencies for BUILD
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use CMAKE_INSTALL_RPATH for INSTALL
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # Do NOT add path to dependencies for INSTALL

if(NOT SYSTEM_DIR_INSTALL)
# Find libraries relative to binary
Expand Down Expand Up @@ -214,10 +214,13 @@ add_subdirectory(deploy)
#

set(PROJECT_CONFIGURATION "metacall-config.cmake")
set(PROJECT_CONFIGURATION_VERSION "metacall-config-version.cmake")

set(PROJECT_CONFIGURATION_PATH "${PROJECT_BINARY_DIR}/${PROJECT_CONFIGURATION}")
set(PROJECT_CONFIGURATION_VERSION_PATH "${PROJECT_BINARY_DIR}/${PROJECT_CONFIGURATION_VERSION}")

configure_file("${PROJECT_CONFIGURATION}.in" "${PROJECT_CONFIGURATION_PATH}" @ONLY)
configure_file("${PROJECT_CONFIGURATION_VERSION}.in" "${PROJECT_CONFIGURATION_VERSION_PATH}" @ONLY)

#
# Deployment (global project files)
Expand All @@ -228,11 +231,12 @@ install(FILES "${PROJECT_BINARY_DIR}/VERSION" DESTINATION ${INSTALL_ROOT} COMPON

# Install cmake find script for the project
install(FILES ${PROJECT_CONFIGURATION_PATH} DESTINATION ${INSTALL_ROOT} COMPONENT dev)
install(FILES ${PROJECT_CONFIGURATION_VERSION_PATH} DESTINATION ${INSTALL_ROOT} COMPONENT dev)

# Install the project meta files
install(FILES AUTHORS DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
install(FILES LICENSE DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
install(FILES AUTHORS DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
install(FILES LICENSE DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime)

# Install runtime data
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA} COMPONENT runtime)
32 changes: 32 additions & 0 deletions metacall-config-version.cmake.in
@@ -0,0 +1,32 @@
#
# MetaCall Library by Parra Studios
# A library for providing a foreing function interface calls.
#
# Copyright (C) 2016 - 2019 Vicente Eduardo Ferrer Garcia <vic798@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set(PACKAGE_VERSION @META_VERSION@)

if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "@META_VERSION_MAJOR@")
if ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL "@META_VERSION_MINOR@")
set(PACKAGE_VERSION_EXACT TRUE)
elseif("${PACKAGE_FIND_VERSION_MINOR}" LESS "@META_VERSION_MINOR@")
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else()
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
else()
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

0 comments on commit 46244e7

Please sign in to comment.