changeset 269:938257eebc03

simplification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 16:47:06 +0200
parents 6171ef61c512
children 3e9307f6da67
files CMakeLists.txt Resources/Orthanc/CMake/Compiler.cmake Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Resources/Orthanc/CMake/DownloadPackage.cmake Resources/SyncOrthancFolder.py
diffstat 5 files changed, 77 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Wed Jun 10 14:54:45 2020 +0200
+++ b/CMakeLists.txt	Wed Jun 10 16:47:06 2020 +0200
@@ -55,20 +55,16 @@
 
 
 # Download and setup the Orthanc framework
-include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake)
-
-
 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
-  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)
+  set(ENABLE_GOOGLE_TEST ON)
+  include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake)
 
   include_directories(
     ${CMAKE_SOURCE_DIR}/Resources/Orthanc/
     )
   link_libraries(OrthancFramework)
 else()
+  include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake)
   include(${ORTHANC_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
   
   set(ENABLE_LOCALE OFF)         # Disable support for locales (notably in Boost)
--- a/Resources/Orthanc/CMake/Compiler.cmake	Wed Jun 10 14:54:45 2020 +0200
+++ b/Resources/Orthanc/CMake/Compiler.cmake	Wed Jun 10 16:47:06 2020 +0200
@@ -1,5 +1,7 @@
 # This file sets all the compiler-related flags
 
+include(CheckLibraryExists)
+
 if ((CMAKE_CROSSCOMPILING AND NOT
       "${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg") OR    
     "${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
--- a/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake	Wed Jun 10 14:54:45 2020 +0200
+++ b/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake	Wed Jun 10 16:47:06 2020 +0200
@@ -135,7 +135,8 @@
       endif()
     endif()
   endif()
-else()
+
+elseif (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
   message("Using the Orthanc framework from a path of the filesystem. Assuming mainline version.")
   set(ORTHANC_FRAMEWORK_MAJOR 999)
   set(ORTHANC_FRAMEWORK_MINOR 999)
@@ -383,6 +384,14 @@
 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
   set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "")
 
+  if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
+      CMAKE_COMPILER_IS_GNUCXX) # MinGW
+    set(DYNAMIC_MINGW_STDLIB ON)   # Disable static linking against libc (to throw exceptions)
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
+  endif()
+  
+  include(CheckIncludeFile)
   include(CheckIncludeFileCXX)
   include(FindPythonInterp)
   include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)
@@ -390,40 +399,76 @@
   include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
   set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py)
 
-  # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
-  find_path(JSONCPP_INCLUDE_DIR json/reader.h
-    /usr/include/jsoncpp
-    /usr/local/include/jsoncpp
-    )
+  if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
+    # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
+    find_path(JSONCPP_INCLUDE_DIR json/reader.h
+      /usr/include/jsoncpp
+      /usr/local/include/jsoncpp
+      )
+
+    message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
+    include_directories(${JSONCPP_INCLUDE_DIR})
+    link_libraries(jsoncpp)
+
+    CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
+    if (NOT HAVE_JSONCPP_H)
+      message(FATAL_ERROR "Please install the libjsoncpp-dev package")
+    endif()
+
+    # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake)
+    include(FindBoost)
+    find_package(Boost COMPONENTS filesystem thread system date_time regex)
 
-  message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
-  include_directories(${JSONCPP_INCLUDE_DIR})
-  link_libraries(jsoncpp)
+    if (NOT Boost_FOUND)
+      message(FATAL_ERROR "Unable to locate Boost on this system")
+    endif()
+    
+    include_directories(${Boost_INCLUDE_DIRS})
+    link_libraries(${Boost_LIBRARIES})
+
+    # Optional component - Lua
+    if (ENABLE_LUA)
+      include(FindLua)
 
-  CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
-  if (NOT HAVE_JSONCPP_H)
-    message(FATAL_ERROR "Please install the libjsoncpp-dev package")
+      if (NOT LUA_FOUND)
+        message(FATAL_ERROR "Please install the liblua-dev package")
+      endif()
+
+      include_directories(${LUA_INCLUDE_DIR})
+      link_libraries(${LUA_LIBRARIES})
+    endif()
+
+    # Optional component - SQLite
+    if (ENABLE_SQLITE)    
+      CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H)
+      if (NOT HAVE_SQLITE_H)
+        message(FATAL_ERROR "Please install the libsqlite3-dev package")
+      endif()
+      link_libraries(sqlite3)
+    endif()
   endif()
 
-  # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake)
-  include(FindBoost)
-  find_package(Boost COMPONENTS filesystem thread system date_time regex)
-
-  if (NOT Boost_FOUND)
-    message(FATAL_ERROR "Unable to locate Boost on this system")
+  # Optional component - Google Test
+  if (ENABLE_GOOGLE_TEST)
+    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_CURRENT_LIST_DIR}/GoogleTestConfiguration.cmake)
   endif()
-  
-  include_directories(${Boost_INCLUDE_DIRS})
-  link_libraries(${Boost_LIBRARIES})
 
   # Look for Orthanc framework shared library
   include(CheckCXXSymbolExists)
 
-  find_path(ORTHANC_FRAMEWORK_INCLUDE_DIR OrthancFramework.h
-    /usr/include/orthanc-framework
-    /usr/local/include/orthanc-framework
-    ${ORTHANC_FRAMEWORK_ROOT}
-    )
+  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
+    set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT})
+    include_directories(${ORTHANC_FRAMEWORK_ROOT}/..)
+  else()
+    find_path(ORTHANC_FRAMEWORK_INCLUDE_DIR OrthancFramework.h
+      /usr/include/orthanc-framework
+      /usr/local/include/orthanc-framework
+      ${ORTHANC_FRAMEWORK_ROOT}
+      )
+  endif()
   
   message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
   include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR})
--- a/Resources/Orthanc/CMake/DownloadPackage.cmake	Wed Jun 10 14:54:45 2020 +0200
+++ b/Resources/Orthanc/CMake/DownloadPackage.cmake	Wed Jun 10 16:47:06 2020 +0200
@@ -206,9 +206,6 @@
 
 
 macro(DownloadCompressedFile MD5 Url TargetFile)
-  message(${MD5})
-  message(${Url})
-  message(${TargetFile})
   if (NOT EXISTS "${TargetFile}")
     DownloadFile("${MD5}" "${Url}")
     
--- a/Resources/SyncOrthancFolder.py	Wed Jun 10 14:54:45 2020 +0200
+++ b/Resources/SyncOrthancFolder.py	Wed Jun 10 16:47:06 2020 +0200
@@ -21,9 +21,9 @@
     ('Plugins/Samples/Common/VersionScript.map', 'Plugins'),
     ('Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
     ('Resources/CMake/Compiler.cmake', 'CMake'),
+    ('Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'),
     ('Resources/CMake/DownloadPackage.cmake', 'CMake'),
     ('Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'),
-    ('Resources/DownloadOrthancFramework.cmake', 'CMake'),
     ('Resources/EmbedResources.py', 'CMake'),
     ('Resources/LinuxStandardBaseToolchain.cmake', 'Toolchains'),
     ('Resources/MinGW-W64-Toolchain32.cmake', 'Toolchains'),