From ed4fbb92d015dac03ecc47b3a377da1f54a1ec7c Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Sat, 18 Apr 2015 00:31:12 +0300 Subject: [PATCH] cmake: add LIBGIT2_FROM_PKGCONFIG and LIBDC_FROM_PKGCONFIG These two new options allow usage of pkg-config to retrieve libdivecomputer and libgit2. For some reason the variables *_LIBRARIES have to be set to blank strings in the process, otherwise "-l" is passed to the linker. LIBGIT2_FROM_PKGCONFIG is a rename from PREFER_GIT_FROMSOURCE for consistency. The IF() check is also fixed. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d766caec1..21a9616ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,8 @@ cmake_minimum_required(VERSION 2.8.11) SET(CMAKE_AUTOMOC ON) SET(CMAKE_AUTOUIC ON) -OPTION(PREFER_GIT_FROMSOURCE "Turn off if you wanna use system's libgit 0.21.5" ON) +OPTION(LIBGIT2_FROM_PKGCONFIG "use pkg-config to retrieve libgit2" OFF) +OPTION(LIBDC_FROM_PKGCONFIG "use pkg-config to retrieve libdivecomputer" OFF) OPTION(NO_MARBLE "disable the marble widget" OFF) OPTION(NO_TESTS "disable the tests" OFF) OPTION(NO_DOCS "disable the docs" OFF) @@ -33,15 +34,21 @@ pkg_config_library(LIBUSB libusb-1.0 QUIET) # more libraries with special handling in case we build them ourselves -if(NOT ${PREFER_GIT_FROMSOURCE}) +IF(LIBGIT2_FROM_PKGCONFIG) pkg_config_library(LIBGIT2 libgit2 REQUIRED) + SET(LIBGIT2_LIBRARIES "") ELSE() FIND_PACKAGE(LIBGIT2 REQUIRED) INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDE_DIR}) ENDIF() -FIND_PACKAGE(Libdivecomputer REQUIRED) -INCLUDE_DIRECTORIES(${LIBDIVECOMPUTER_INCLUDE_DIR}) +IF(LIBDC_FROM_PKGCONFIG) + pkg_config_library(LIBDC libdivecomputer REQUIRED) + SET(LIBDIVECOMPUTER_LIBRARIES "") +ELSE() + FIND_PACKAGE(Libdivecomputer REQUIRED) + INCLUDE_DIRECTORIES(${LIBDIVECOMPUTER_INCLUDE_DIR}) +ENDIF() # optional marble