aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-09-07 11:34:33 +0200
committerTor Egge <Tor.Egge@online.no>2023-09-07 11:34:33 +0200
commita980fb4526bad013e3f5498b57377dcc78eb2dc6 (patch)
treec8a308365d2d2604d9386b0318ad4d456e780dfe
parentdaba552c567f1fcb9e300ae65825c1d97cedbb5e (diff)
Export vespa cmake config.
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt32
-rw-r--r--build_settings.cmake4
-rw-r--r--cmake/vespaConfig.cmake.in13
-rw-r--r--cmake/vespaTargets.cmake7
5 files changed, 57 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index c5ebe0aef49..c1d500c3c4f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,5 +49,7 @@ Testing
.preprocessed/
.DS_Store
install_manifest.txt
+/vespaConfig.cmake
+/vespaConfigVersion.cmake
*.cbp
!/.copr/Makefile
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ee96529c32..a09c08951b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,6 +61,38 @@ include(build_settings.cmake)
# Enable CTest unit testing
enable_testing()
+# Export vespa cmake config, to be used by other cmake project depending on vespa
+set(VESPA_CMAKECONFIG_INSTALL_DIR ${CMAKE_INSTALL_DATAROOTDIR}/cmake/vespa)
+string(REGEX REPLACE "-DV_TAG_COMPONENT=\\\\\"(.*)\\\\\"" "\\1" VESPA_VERSION ${V_TAG_COMPONENT})
+message("-- VESPA_VERSION is ${VESPA_VERSION}")
+
+include(CMakePackageConfigHelpers)
+function(vespa_configure_exported_config)
+ set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
+ set(INSTALL_PREFIX_DIR ${CMAKE_INSTALL_PREFIX})
+ set(CMAKECONFIG_DIR ${VESPA_CMAKECONFIG_INSTALL_DIR})
+ configure_package_config_file(cmake/vespaConfig.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/vespaConfig.cmake
+ INSTALL_DESTINATION ${VESPA_CMAKECONFIG_INSTALL_DIR}
+ PATH_VARS INCLUDE_INSTALL_DIR INSTALL_PREFIX_DIR CMAKECONFIG_DIR)
+endfunction()
+function(vespa_configure_exported_configversion)
+ write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/vespaConfigVersion.cmake
+ VERSION ${VESPA_VERSION}
+ COMPATIBILITY AnyNewerVersion)
+endfunction()
+vespa_configure_exported_config()
+vespa_configure_exported_configversion()
+install(FILES
+ functions.cmake
+ build_settings.cmake
+ default_build_settings.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/vespaConfig.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/vespaConfigVersion.cmake
+ cmake/vespaTargets.cmake
+ DESTINATION ${VESPA_CMAKECONFIG_INSTALL_DIR})
+# End of exporting vespa cmake config
+
vespa_install_data(valgrind-suppressions.txt etc/vespa)
vespa_install_data(tsan-suppressions.txt etc/vespa)
diff --git a/build_settings.cmake b/build_settings.cmake
index d0bb50360da..fc4ba131969 100644
--- a/build_settings.cmake
+++ b/build_settings.cmake
@@ -1,7 +1,9 @@
# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
# @author Vegard Sjonfjell
-include(${CMAKE_CURRENT_LIST_DIR}/vtag.cmake)
+if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/vtag.cmake)
+ include(${CMAKE_CURRENT_LIST_DIR}/vtag.cmake)
+endif()
if (VESPA_USE_SANITIZER)
if (VESPA_USE_SANITIZER STREQUAL "address" OR VESPA_USE_SANITIZER STREQUAL "thread" OR VESPA_USE_SANITIZER STREQUAL "undefined")
diff --git a/cmake/vespaConfig.cmake.in b/cmake/vespaConfig.cmake.in
new file mode 100644
index 00000000000..0c38820de21
--- /dev/null
+++ b/cmake/vespaConfig.cmake.in
@@ -0,0 +1,13 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+# This file contains some of the vespa cmake config needed for other
+# cmake projects depending on vespa.
+
+set(VESPA_VERSION @VESPA_VERSION@)
+@PACKAGE_INIT@
+set_and_check(VESPA_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
+set_and_check(VESPA_HOME "@PACKAGE_INSTALL_PREFIX_DIR@")
+set_and_check(VESPA_CMAKECONFIG_DIR "@PACKAGE_CMAKECONFIG_DIR@")
+include("${CMAKE_CURRENT_LIST_DIR}/vespaTargets.cmake")
+check_required_components(vespa)
+message(STATUS "Found vespa ${VESPA_VERSION} at ${VESPA_HOME}")
diff --git a/cmake/vespaTargets.cmake b/cmake/vespaTargets.cmake
new file mode 100644
index 00000000000..f2e3a3f5a03
--- /dev/null
+++ b/cmake/vespaTargets.cmake
@@ -0,0 +1,7 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+# This file is included from vespaConfig.cmake and contains a list of
+# targets that are imported from vespa.
+
+add_library(searchlib SHARED IMPORTED)
+set_target_properties(searchlib PROPERTIES IMPORTED_LOCATION ${VESPA_HOME}/lib64/libsearchlib.so INTERFACE_INCLUDE_DIRECTORIES ${VESPA_INCLUDE_DIR})