Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJoerg Steffens <joerg.steffens@bareos.com>2021-04-12 19:34:31 +0300
committerAndreas Rogge <andreas.rogge@bareos.com>2021-04-22 16:36:17 +0300
commitaaebe53a5af0e8fe10fcf764140ad9916f4b70ff (patch)
treece55ecfcfa2a64544dcf16d0d273c0efdf0d95a8 /cmake
parent8e7d6245d10f689ce64d02fcc31e93eeca719a9d (diff)
cmake: make the jansson library mandatory for build the Director
Without the library, the API 2 commands are not available. Implement find_package for Jansson, as otherwise Solaris would require special treatment.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindJansson.cmake99
1 files changed, 99 insertions, 0 deletions
diff --git a/cmake/FindJansson.cmake b/cmake/FindJansson.cmake
new file mode 100644
index 000000000..cd44d0307
--- /dev/null
+++ b/cmake/FindJansson.cmake
@@ -0,0 +1,99 @@
+# BAREOSĀ® - Backup Archiving REcovery Open Sourced
+#
+# Copyright (C) 2021-2021 Bareos GmbH & Co. KG
+#
+# This program is Free Software; you can redistribute it and/or modify it under
+# the terms of version three of the GNU Affero General Public License as
+# published by the Free Software Foundation and included in the file LICENSE.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+#[=======================================================================[.rst:
+FindJansson
+-----------
+
+Find Jansson headers and libraries.
+`
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+The following :prop_tgt:`IMPORTED` targets may be defined:
+
+``Jansson::Jansson``
+ Jansson library.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``JANSSON_FOUND``
+ True if Jansson found.
+``JANSSON_INCLUDE_DIRS``
+ Where to find jansson.h.
+``JANSSON_LIBRARIES``
+ List of libraries when using Jansson.
+``JANSSON_VERSION_STRING``
+ The version of Jansson found.
+``HAVE_JANSSON``
+ 1 if Jansson found.
+
+#]=======================================================================]
+
+find_package(PkgConfig QUIET)
+pkg_check_modules(PC_JANSSON QUIET jansson)
+
+find_path(
+ JANSSON_INCLUDE_DIR
+ NAMES jansson.h
+ HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS}
+)
+
+find_library(
+ JANSSON_LIBRARY
+ NAMES jansson libjansson
+ HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS}
+)
+
+if(PC_JANSSON_VERSION)
+ set(JANSSON_VERSION_STRING ${PC_JANSSON_VERSION})
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ Jansson
+ REQUIRED_VARS JANSSON_LIBRARY JANSSON_INCLUDE_DIR
+ VERSION_VAR JANSSON_VERSION_STRING
+)
+
+if(JANSSON_FOUND)
+ set(JANSSON_LIBRARIES ${JANSSON_LIBRARY})
+ set(JANSSON_INCLUDE_DIRS ${JANSSON_INCLUDE_DIR})
+ set(HAVE_JANSSON 1)
+endif()
+
+mark_as_advanced(JANSSON_INCLUDE_DIR JANSSON_LIBRARY)
+
+if(JANSSON_FOUND AND NOT TARGET Jansson::Jansson)
+ add_library(Jansson::Jansson UNKNOWN IMPORTED)
+ set_target_properties(
+ Jansson::Jansson PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+ "${JANSSON_INCLUDE_DIRS}"
+ )
+ set_target_properties(
+ Jansson::Jansson PROPERTIES INTERFACE_COMPILE_OPTIONS
+ "${JANSSON_DEFINITIONS}"
+ )
+ set_property(
+ TARGET Jansson::Jansson
+ APPEND
+ PROPERTY IMPORTED_LOCATION "${JANSSON_LIBRARY}"
+ )
+endif()