changeset 4117:9286649df279

use of C++11 in the unit tests of the shared library
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 14:23:23 +0200
parents 7d0f42c98419
children a0c30785b7d7
files OrthancFramework/SharedLibrary/CMakeLists.txt OrthancFramework/UnitTestsSources/CMakeLists.txt
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/SharedLibrary/CMakeLists.txt	Tue Jul 07 13:12:23 2020 +0200
+++ b/OrthancFramework/SharedLibrary/CMakeLists.txt	Tue Jul 07 14:23:23 2020 +0200
@@ -466,6 +466,10 @@
       )
   endif()
 
+  if (JSONCPP_CXX11)
+    list(APPEND Flags -DUSE_CXX11=1)
+  endif()
+  
   # Build the unit tests, linking them against the just-created
   # "OrthancFramework" library
   externalproject_add(UnitTests
--- a/OrthancFramework/UnitTestsSources/CMakeLists.txt	Tue Jul 07 13:12:23 2020 +0200
+++ b/OrthancFramework/UnitTestsSources/CMakeLists.txt	Tue Jul 07 14:23:23 2020 +0200
@@ -9,6 +9,7 @@
 set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
 set(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests")
 set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
+set(USE_CXX11 OFF CACHE BOOL "Whether to enable compiler support for C++11")
 
 if (UNIT_TESTS_WITH_HTTP_CONNEXIONS)
   add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=1)
@@ -31,6 +32,14 @@
 include(${CMAKE_SOURCE_DIR}/../Resources/CMake/DownloadOrthancFramework.cmake)
 include(${CMAKE_SOURCE_DIR}/../Resources/CMake/GoogleTestConfiguration.cmake)
 
+if (USE_CXX11)
+  if (CMAKE_COMPILER_IS_GNUCXX)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
+  elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+  endif()
+endif()
+
 add_definitions(
   -DORTHANC_UNIT_TESTS_LINK_FRAMEWORK=1
   -DORTHANC_BUILD_UNIT_TESTS=1  # For "HierarchicalZipWriter" tests