changeset 2:76affd640431

fix build against system-wide Orthanc framework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 20 Sep 2021 16:38:25 +0200
parents d745ea3db32c
children e731f308b8b1
files CMakeLists.txt Sources/IndexerDatabase.h
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Mon Sep 20 16:10:42 2021 +0200
+++ b/CMakeLists.txt	Mon Sep 20 16:38:25 2021 +0200
@@ -41,10 +41,7 @@
 
 # Advanced parameters to fine-tune linking against system libraries
 set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
-set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
-set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
 set(ORTHANC_FRAMEWORK_STATIC OFF CACHE BOOL "If linking against the Orthanc framework system library, indicates whether this library was statically linked")
-mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE)
 mark_as_advanced(ORTHANC_FRAMEWORK_STATIC)
 
 
@@ -54,7 +51,7 @@
 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
   if (ORTHANC_FRAMEWORK_USE_SHARED)
     include(FindBoost)
-    find_package(Boost COMPONENTS thread)
+    find_package(Boost COMPONENTS filesystem thread)
     
     if (NOT Boost_FOUND)
       message(FATAL_ERROR "Unable to locate Boost on this system")
@@ -64,6 +61,12 @@
   endif()
 
   link_libraries(${ORTHANC_FRAMEWORK_LIBRARIES})
+  
+  set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
+  set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
+  mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE)
+  include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/GoogleTestConfiguration.cmake)
+
 else()
   include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkParameters.cmake)
   
@@ -154,6 +157,8 @@
 
 add_dependencies(UnitTests AutogeneratedTarget)
 
+target_link_libraries(UnitTests ${GOOGLE_TEST_LIBRARIES})
+
 
 message("Setting the version of the library to ${ORTHANC_PLUGIN_VERSION}")
 
--- a/Sources/IndexerDatabase.h	Mon Sep 20 16:10:42 2021 +0200
+++ b/Sources/IndexerDatabase.h	Mon Sep 20 16:38:25 2021 +0200
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <OrthancFramework.h>  // To have ORTHANC_ENABLE_SQLITE defined
 #include <SQLite/Connection.h>
 
 #include <boost/noncopyable.hpp>