[ismrmrd] 111/177: add support for linking with system pugixml

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:02:09 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag v1.1.0.beta.1
in repository ismrmrd.

commit 141ea78e624220b287e8da6e40ff1c7a6db53766
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date:   Mon Sep 22 12:12:08 2014 +0100

    add support for linking with system pugixml
    
    - introduce option USE_SYSTEM_PUGIXML (sug. by Michael)
    - default is USE_SYSTEM_PUGIXML=OFF
    - USE_SYSTEM_PUGIXML=OFF: compile with provided pugixml.cpp
    - USE_SYSTEM_PUGIXML=ON: link with found libpugixml
    - Abort with helpful error msg if USE_SYSTEM_PUGIXML=ON
    but the library is not found by the FindPugiXML module
---
 CMakeLists.txt          | 35 ++++++++++++++++++++++++++++++-----
 cmake/FindPugiXML.cmake | 27 +++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 150a7e6..2461dc8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,9 @@
 cmake_minimum_required(VERSION 2.8)
 project(ISMRMRD)
 
+# command line options
+option(USE_SYSTEM_PUGIXML "Use pugixml installed on the system" OFF)
+
 # add project specific cmake find modules
 list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
 
@@ -85,26 +88,48 @@ set(ISMRMRD_SOVERSION ${ISMRMRD_VERSION_MAJOR}.${ISMRMRD_VERSION_MINOR})
 find_package(HDF5 1.8 COMPONENTS C REQUIRED)
 
 # include directories for main library
-include_directories(
+set(ISMRMRD_TARGET_INCLUDE_DIRS
   include
   ${HDF5_C_INCLUDE_DIR}
 )
 
-# main library
-add_library(ismrmrd SHARED 
+set(ISMRMRD_TARGET_SOURCES
   libsrc/ismrmrd.c
   libsrc/ismrmrd.cpp
   libsrc/dataset.c
   libsrc/dataset.cpp
   libsrc/xml.cpp
   libsrc/meta.cpp
-  libsrc/pugixml.cpp
 )
+
+set(ISMRMRD_TARGET_LINK_LIBS ${HDF5_LIBRARIES})
+
+# optional handling of system-installed pugixml
+if(USE_SYSTEM_PUGIXML)
+  find_package(PugiXML)
+  if(PugiXML_FOUND)
+    message("Found system pugixml: ${PugiXML_INCLUDE_DIR} ${PugiXML_LIBRARY}")
+    list(APPEND ISMRMRD_TARGET_INCLUDE_DIRS ${PugiXML_INCLUDE_DIR})
+    list(APPEND ISMRMRD_TARGET_LINK_LIBS ${PugiXML_LIBRARY})
+  else(PugiXML_FOUND)
+    message(FATAL_ERROR "Pugixml library not found on the system, try without "
+    "setting USE_SYSTEM_PUGIXML to use the version provided in the source "
+    "tree.")
+  endif(PugiXML_FOUND)
+  list(APPEND ISMRMRD_TARGET_INCLUDE_DIRS ${PugiXML_INCLUDE_DIR})
+  list(APPEND ISMRMRD_TARGET_LINK_LIBS ${PugiXML_LIBRARY})
+else(USE_SYSTEM_PUGIXML)
+  list(APPEND ISMRMRD_TARGET_SOURCES libsrc/pugixml.cpp)
+endif(USE_SYSTEM_PUGIXML)
+
+# main library
+include_directories(${ISMRMRD_TARGET_INCLUDE_DIRS})
+add_library(ismrmrd SHARED ${ISMRMRD_TARGET_SOURCES})
 set_target_properties(ismrmrd PROPERTIES
   VERSION ${ISMRMRD_VERSION_STRING}
   SOVERSION ${ISMRMRD_SOVERSION}
 )
-target_link_libraries(ismrmrd ${HDF5_LIBRARIES})
+target_link_libraries(ismrmrd ${ISMRMRD_TARGET_LINK_LIBS})
 
 # install the main library
 install(TARGETS ismrmrd DESTINATION lib)
diff --git a/cmake/FindPugiXML.cmake b/cmake/FindPugiXML.cmake
new file mode 100644
index 0000000..931d547
--- /dev/null
+++ b/cmake/FindPugiXML.cmake
@@ -0,0 +1,27 @@
+# Copyrigt 2012 Kamil Rytarowski <kamil AT mageia DOT org>
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+find_path(PugiXML_INCLUDE_DIR pugixml.hpp /usr/include)
+
+find_library(PugiXML_LIBRARY
+  NAMES
+  "pugixml"
+  PATHS
+  /usr/lib
+  )
+
+if(PugiXML_LIBRARY AND PugiXML_INCLUDE_DIR)
+  set(PugiXML_FOUND 1)
+  mark_as_advanced(PugiXML_LIBRARY PugiXML_INCLUDE_DIR)
+else()
+  set(PugiXML_FOUND 0)
+endif()
+  
+if(NOT PugiXML_FOUND)
+  if(PugiXML_FIND_REQUIRED)
+    message(FATAL_ERROR "PugiXML was not found.")
+  endif()
+endif()
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ismrmrd.git



More information about the debian-science-commits mailing list