changeset 2479:8437607835ef

branch integration: lua_dll->default
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Feb 2018 11:15:36 +0100
parents 8cc3ca64a534 (current diff) 1e2d5e14b3d3 (diff)
children 8f3c2017b0e3
files
diffstat 3 files changed, 30 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Feb 19 16:55:05 2018 +0100
+++ b/NEWS	Tue Feb 20 11:15:36 2018 +0100
@@ -12,6 +12,12 @@
 * New URI: "/tools/create-media-extended" to generate a DICOMDIR
   archive from several resources, including additional type-3 tags
 
+Lua
+---
+
+* New CMake option: "-DENABLE_LUA_MODULES=ON" to enable support for
+  loading external Lua modules if the Lua engine is statically linked
+
 Maintenance
 -----------
 
--- a/Resources/CMake/LuaConfiguration.cmake	Mon Feb 19 16:55:05 2018 +0100
+++ b/Resources/CMake/LuaConfiguration.cmake	Tue Feb 20 11:15:36 2018 +0100
@@ -5,11 +5,29 @@
 
   DownloadPackage(${LUA_MD5} ${LUA_URL} "${LUA_SOURCES_DIR}")
 
-  add_definitions(
-    #-DLUA_LIB=1
-    #-Dluaall_c=1
-    #-DLUA_COMPAT_ALL=1  # Compile a generic version of Lua
-    )
+  if (ENABLE_LUA_MODULES)
+    if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
+        ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
+        ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
+        ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
+      # Enable loading of shared libraries (for UNIX-like)
+      add_definitions(-DLUA_USE_DLOPEN=1)
+
+      # Publish the functions of the Lua engine (that are built within
+      # the Orthanc binary) as global symbols, so that the external
+      # shared libraries can call them
+      set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic")
+
+    elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+      add_definitions(-DLUA_DL_DLL=1)       # Enable loading of shared libraries (for Microsoft Windows)
+      
+    elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+      add_definitions(-LUA_DL_DYLD=1)       # Enable loading of shared libraries (for Apple OS X)
+      
+    else()
+      message(FATAL_ERROR "Support your platform here")
+    endif()
+  endif()
 
   include_directories(
     ${LUA_SOURCES_DIR}/src
--- a/Resources/CMake/OrthancFrameworkParameters.cmake	Mon Feb 19 16:55:05 2018 +0100
+++ b/Resources/CMake/OrthancFrameworkParameters.cmake	Tue Feb 20 11:15:36 2018 +0100
@@ -34,6 +34,7 @@
 set(ENABLE_PKCS11 OFF CACHE BOOL "Enable PKCS#11 for HTTPS client authentication using hardware security modules and smart cards")
 set(ENABLE_PROFILING OFF CACHE BOOL "Whether to enable the generation of profiling information with gprof")
 set(ENABLE_SSL ON CACHE BOOL "Include support for SSL")
+set(ENABLE_LUA_MODULES OFF CACHE BOOL "Enable support for loading external Lua modules (only meaningful if using static version of the Lua engine)")
 
 # Parameters to fine-tune linking against system libraries
 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")