changeset 2404:e6af2c5cd0f1

migration of Google Test into OrthancFramework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 08 Sep 2017 16:48:33 +0200
parents 06536b4f30c0
children 85a22aad7dfe
files CMakeLists.txt Resources/CMake/GoogleTestConfiguration.cmake Resources/CMake/OrthancFrameworkConfiguration.cmake Resources/CMake/OrthancFrameworkParameters.cmake
diffstat 4 files changed, 34 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri Sep 08 16:34:47 2017 +0200
+++ b/CMakeLists.txt	Fri Sep 08 16:48:33 2017 +0200
@@ -11,6 +11,9 @@
 
 # Enable all the optional components of the Orthanc framework
 set(ENABLE_CRYPTO_OPTIONS ON)
+set(ENABLE_DCMTK ON)
+set(ENABLE_DCMTK_NETWORKING ON)
+set(ENABLE_GOOGLE_TEST ON)
 set(ENABLE_JPEG ON)
 set(ENABLE_LOCALE ON)
 set(ENABLE_LUA ON)
@@ -19,8 +22,7 @@
 set(ENABLE_SQLITE ON)
 set(ENABLE_WEB_CLIENT ON)
 set(ENABLE_WEB_SERVER ON)
-set(ENABLE_DCMTK ON)
-set(ENABLE_DCMTK_NETWORKING ON)
+
 set(HAS_EMBEDDED_RESOURCES ON)
 
 
@@ -36,12 +38,6 @@
 SET(ENABLE_PLUGINS ON CACHE BOOL "Enable plugins")
 SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests")
 
-# Advanced parameters to fine-tune linking against system libraries
-SET(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
-SET(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
-
-mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE)
-
 
 #####################################################################
 ## Configuration of the Orthanc framework
@@ -49,7 +45,6 @@
 
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/VisualStudioPrecompiledHeaders.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/OrthancFrameworkConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
 
 include_directories(${ORTHANC_ROOT})
 
@@ -319,8 +314,12 @@
   ${ORTHANC_UNIT_TESTS_SOURCES}
   )
 
-target_link_libraries(UnitTests ServerLibrary CoreLibrary ${DCMTK_LIBRARIES})
-
+target_link_libraries(UnitTests
+  ServerLibrary
+  CoreLibrary
+  ${DCMTK_LIBRARIES}
+  ${GOOGLE_TEST_LIBRARIES}
+  )
 
 
 #####################################################################
--- a/Resources/CMake/GoogleTestConfiguration.cmake	Fri Sep 08 16:34:47 2017 +0200
+++ b/Resources/CMake/GoogleTestConfiguration.cmake	Fri Sep 08 16:48:33 2017 +0200
@@ -16,7 +16,10 @@
   message("Path to the Debian Google Test sources: ${GOOGLE_TEST_DEBIAN_SOURCES_DIR}")
   message("Path to the Debian Google Test includes: ${GOOGLE_TEST_DEBIAN_INCLUDE_DIR}")
 
-  set(GOOGLE_TEST_SOURCES ${GOOGLE_TEST_DEBIAN_SOURCES_DIR}/src/gtest-all.cc)
+  set(GOOGLE_TEST_SOURCES
+    ${GOOGLE_TEST_DEBIAN_SOURCES_DIR}/src/gtest-all.cc
+    )
+
   include_directories(${GOOGLE_TEST_DEBIAN_SOURCES_DIR})
 
   if (NOT EXISTS ${GOOGLE_TEST_SOURCES} OR
@@ -54,5 +57,7 @@
   endif()
 
   include_directories(${GOOGLE_TEST_INCLUDE_DIRS})
-  link_libraries(${GOOGLE_TEST_LIBRARIES})
+
+  # The variable GOOGLE_TEST_LIBRARIES contains the shared library of
+  # Google Test
 endif()
--- a/Resources/CMake/OrthancFrameworkConfiguration.cmake	Fri Sep 08 16:34:47 2017 +0200
+++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake	Fri Sep 08 16:48:33 2017 +0200
@@ -287,6 +287,19 @@
 endif()
 
 
+##
+## Google Test for unit testing
+##
+
+if (ENABLE_GOOGLE_TEST)
+  include(${CMAKE_CURRENT_LIST_DIR}/GoogleTestConfiguration.cmake)
+else()
+  unset(USE_SYSTEM_GOOGLE_TEST CACHE)
+  unset(USE_GOOGLE_TEST_DEBIAN_PACKAGE CACHE)
+endif()
+
+
+
 #####################################################################
 ## Inclusion of mandatory third-party dependencies
 #####################################################################
--- a/Resources/CMake/OrthancFrameworkParameters.cmake	Fri Sep 08 16:34:47 2017 +0200
+++ b/Resources/CMake/OrthancFrameworkParameters.cmake	Fri Sep 08 16:48:33 2017 +0200
@@ -34,6 +34,7 @@
 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
 set(USE_SYSTEM_CIVETWEB ON CACHE BOOL "Use the system version of Civetweb (experimental)")
 set(USE_SYSTEM_CURL ON CACHE BOOL "Use the system version of LibCurl")
+set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
 set(USE_SYSTEM_LIBICONV ON CACHE BOOL "Use the system version of libiconv")
 set(USE_SYSTEM_LIBJPEG ON CACHE BOOL "Use the system version of libjpeg")
@@ -55,10 +56,12 @@
 set(ENABLE_DCMTK_JPEG_LOSSLESS ON CACHE BOOL "Enable JPEG-LS (Lossless) decompression")
 
 # Advanced and distribution-specific parameters
+set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
 set(SYSTEM_MONGOOSE_USE_CALLBACKS ON CACHE BOOL "The system version of Mongoose uses callbacks (version >= 3.7)")
 set(USE_BOOST_ICONV ON CACHE BOOL "Use iconv instead of wconv (Windows only)")
 set(USE_PUGIXML ON CACHE BOOL "Use the Pugixml parser (turn off only for debug)")
 
+mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE)
 mark_as_advanced(SYSTEM_MONGOOSE_USE_CALLBACKS)
 mark_as_advanced(USE_BOOST_ICONV)
 mark_as_advanced(USE_PUGIXML)
@@ -75,6 +78,7 @@
 
 set(ENABLE_CRYPTO_OPTIONS OFF CACHE INTERNAL "Show options related to cryptography")
 set(ENABLE_JPEG OFF CACHE INTERNAL "Enable support of JPEG")
+set(ENABLE_GOOGLE_TEST OFF CACHE INTERNAL "Enable support of Google Test")
 set(ENABLE_LOCALE OFF CACHE INTERNAL "Enable support for locales (notably in Boost)")
 set(ENABLE_LUA OFF CACHE INTERNAL "Enable support of Lua scripting")
 set(ENABLE_PNG OFF CACHE INTERNAL "Enable support of PNG")