changeset 382:b45bc565d82a lua-scripting

cmake for lua
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 Apr 2013 13:31:10 +0200
parents e6b4748c7d62
children 18fe778eeb95
files CMakeLists.txt Resources/CMake/BoostConfiguration.cmake Resources/CMake/DcmtkConfiguration.cmake Resources/CMake/GoogleLogConfiguration.cmake Resources/CMake/GoogleTestConfiguration.cmake Resources/CMake/JsonCppConfiguration.cmake Resources/CMake/LibCurlConfiguration.cmake Resources/CMake/LibPngConfiguration.cmake Resources/CMake/LuaConfiguration.cmake Resources/CMake/MongooseConfiguration.cmake Resources/CMake/OpenSslConfiguration.cmake Resources/CMake/SQLiteConfiguration.cmake Resources/CMake/ZlibConfiguration.cmake UnitTests/Versions.cpp
diffstat 14 files changed, 85 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Mon Apr 29 12:51:30 2013 +0200
+++ b/CMakeLists.txt	Mon Apr 29 13:31:10 2013 +0200
@@ -18,6 +18,7 @@
 SET(USE_DYNAMIC_GOOGLE_LOG ON CACHE BOOL "Use the dynamic version of Google Log")
 SET(USE_DYNAMIC_GOOGLE_TEST ON CACHE BOOL "Use the dynamic version of Google Test (not for Debian sid)")
 SET(USE_DYNAMIC_SQLITE ON CACHE BOOL "Use the dynamic version of SQLite")
+SET(USE_DYNAMIC_LUA OFF CACHE BOOL "Use the dynamic version of Lua")
 SET(DEBIAN_FORCE_HARDENING OFF CACHE BOOL "Force the injection of Debian hardening flags (unrecommended)")
 SET(DEBIAN_USE_GTEST_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (only for Debian sid)")
 SET(ONLY_CORE_LIBRARY OFF CACHE BOOL "Only build the core library")
@@ -71,6 +72,7 @@
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
+include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake)
 
 
 # Prepare the embedded files
--- a/Resources/CMake/BoostConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/BoostConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -41,7 +41,7 @@
 if (BOOST_STATIC)
   SET(BOOST_NAME boost_1_49_0)
   SET(BOOST_SOURCES_DIR ${CMAKE_BINARY_DIR}/${BOOST_NAME})
-  DownloadPackage("http://switch.dl.sourceforge.net/project/boost/boost/1.49.0/${BOOST_NAME}.tar.gz" "${BOOST_SOURCES_DIR}" "${BOOST_PRELOADED}" "${BOOST_NAME}/boost ${BOOST_NAME}/libs/thread/src ${BOOST_NAME}/libs/system/src ${BOOST_NAME}/libs/filesystem/v3/src ${BOOST_NAME}/libs/locale/src ${BOOST_NAME}/libs/date_time/src")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/${BOOST_NAME}.tar.gz" "${BOOST_SOURCES_DIR}" "${BOOST_PRELOADED}" "${BOOST_NAME}/boost ${BOOST_NAME}/libs/thread/src ${BOOST_NAME}/libs/system/src ${BOOST_NAME}/libs/filesystem/v3/src ${BOOST_NAME}/libs/locale/src ${BOOST_NAME}/libs/date_time/src")
 
   set(BOOST_SOURCES)
   if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
--- a/Resources/CMake/DcmtkConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/DcmtkConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -1,7 +1,7 @@
 if (${STATIC_BUILD})
   SET(DCMTK_VERSION_NUMBER 360)
   SET(DCMTK_SOURCES_DIR ${CMAKE_BINARY_DIR}/dcmtk-3.6.0)
-  DownloadPackage("ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk360/dcmtk-3.6.0.zip" "${DCMTK_SOURCES_DIR}" "" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/dcmtk-3.6.0.zip" "${DCMTK_SOURCES_DIR}" "" "")
 
   IF(CMAKE_CROSSCOMPILING)
     SET(C_CHAR_UNSIGNED 1 CACHE INTERNAL "Whether char is unsigned.")
--- a/Resources/CMake/GoogleLogConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/GoogleLogConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -1,6 +1,6 @@
 if (STATIC_BUILD OR NOT USE_DYNAMIC_GOOGLE_LOG)
   SET(GOOGLE_LOG_SOURCES_DIR ${CMAKE_BINARY_DIR}/glog-0.3.2)
-  DownloadPackage("http://google-glog.googlecode.com/files/glog-0.3.2.tar.gz" "${GOOGLE_LOG_SOURCES_DIR}" "" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/glog-0.3.2.tar.gz" "${GOOGLE_LOG_SOURCES_DIR}" "" "")
 
   set(GOOGLE_LOG_HEADERS
     ${GOOGLE_LOG_SOURCES_DIR}/src/glog/logging.h
--- a/Resources/CMake/GoogleTestConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/GoogleTestConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -9,7 +9,7 @@
 
 elseif (STATIC_BUILD OR NOT USE_DYNAMIC_GOOGLE_TEST)
   SET(GTEST_SOURCES_DIR ${CMAKE_BINARY_DIR}/gtest-1.6.0)
-  DownloadPackage("http://googletest.googlecode.com/files/gtest-1.6.0.zip" "${GTEST_SOURCES_DIR}" "" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/gtest-1.6.0.zip" "${GTEST_SOURCES_DIR}" "" "")
 
   include_directories(
     ${GTEST_SOURCES_DIR}/include
--- a/Resources/CMake/JsonCppConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/JsonCppConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -9,7 +9,7 @@
 
 else()
   SET(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-src-0.5.0)
-  DownloadPackage("http://downloads.sourceforge.net/project/jsoncpp/jsoncpp/0.5.0/jsoncpp-src-0.5.0.tar.gz" "${JSONCPP_SOURCES_DIR}" "" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-src-0.5.0.tar.gz" "${JSONCPP_SOURCES_DIR}" "" "")
 
   list(APPEND THIRD_PARTY_SOURCES
     ${JSONCPP_SOURCES_DIR}/src/lib_json/json_reader.cpp
--- a/Resources/CMake/LibCurlConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/LibCurlConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -1,6 +1,6 @@
 if (${STATIC_BUILD})
   SET(CURL_SOURCES_DIR ${CMAKE_BINARY_DIR}/curl-7.26.0)
-  DownloadPackage("http://curl.haxx.se/download/curl-7.26.0.tar.gz" "${CURL_SOURCES_DIR}" "" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/curl-7.26.0.tar.gz" "${CURL_SOURCES_DIR}" "" "")
 
   include_directories(${CURL_SOURCES_DIR}/include)
   AUX_SOURCE_DIRECTORY(${CURL_SOURCES_DIR}/lib CURL_SOURCES)
--- a/Resources/CMake/LibPngConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/LibPngConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -1,6 +1,6 @@
 if (${STATIC_BUILD})
   SET(LIBPNG_SOURCES_DIR ${CMAKE_BINARY_DIR}/libpng-1.5.12)
-  DownloadPackage("http://download.sourceforge.net/libpng/libpng-1.5.12.tar.gz" "${LIBPNG_SOURCES_DIR}" "${LIBPNG_PRELOADED}" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/libpng-1.5.12.tar.gz" "${LIBPNG_SOURCES_DIR}" "${LIBPNG_PRELOADED}" "")
 
   include_directories(
     ${LIBPNG_SOURCES_DIR}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/LuaConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -0,0 +1,56 @@
+if (STATIC_BUILD OR NOT USE_DYNAMIC_LUA)
+  SET(LUA_SOURCES_DIR ${CMAKE_BINARY_DIR}/lua-5.1.5)
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/lua-5.1.5.tar.gz" "${LUA_SOURCES_DIR}" "" "")
+
+  add_definitions(
+    -DLUA_COMPAT_ALL=1  # Compile a generic version of Lua
+    )
+
+  include_directories(
+    ${LUA_SOURCES_DIR}/src
+    )
+
+  set(LUA_SOURCES
+    # Core Lua
+    ${LUA_SOURCES_DIR}/src/lapi.c
+    ${LUA_SOURCES_DIR}/src/lcode.c 
+    ${LUA_SOURCES_DIR}/src/ldebug.c 
+    ${LUA_SOURCES_DIR}/src/ldo.c 
+    ${LUA_SOURCES_DIR}/src/ldump.c 
+    ${LUA_SOURCES_DIR}/src/lfunc.c 
+    ${LUA_SOURCES_DIR}/src/lgc.c
+    ${LUA_SOURCES_DIR}/src/llex.c
+    ${LUA_SOURCES_DIR}/src/lmem.c 
+    ${LUA_SOURCES_DIR}/src/lobject.c 
+    ${LUA_SOURCES_DIR}/src/lopcodes.c 
+    ${LUA_SOURCES_DIR}/src/lparser.c
+    ${LUA_SOURCES_DIR}/src/lstate.c 
+    ${LUA_SOURCES_DIR}/src/lstring.c
+    ${LUA_SOURCES_DIR}/src/ltable.c
+    ${LUA_SOURCES_DIR}/src/ltm.c
+    ${LUA_SOURCES_DIR}/src/lundump.c 
+    ${LUA_SOURCES_DIR}/src/lvm.c 
+    ${LUA_SOURCES_DIR}/src/lzio.c
+
+    # Additional modules
+    ${LUA_SOURCES_DIR}/src/lstrlib.c
+    )
+
+  add_library(Lua STATIC ${LUA_SOURCES})
+  link_libraries(Lua)
+
+  source_group(ThirdParty\\Lua REGULAR_EXPRESSION ${LUA_SOURCES_DIR}/.*)
+
+else()
+  CHECK_INCLUDE_FILE_CXX(lua.h HAVE_LUA_H)
+  if (NOT HAVE_LUA_H)
+    message(FATAL_ERROR "Please install the liblua-dev package")
+  endif()
+
+  CHECK_LIBRARY_EXISTS(lua "lua_pcall" HAVE_LUA_LIB)
+  if (NOT HAVE_LUA_LIB)
+    message(FATAL_ERROR "Please install the liblua-dev package")
+  endif()
+
+  link_libraries(lua)
+endif()
--- a/Resources/CMake/MongooseConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/MongooseConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -1,5 +1,5 @@
 SET(MONGOOSE_SOURCES_DIR ${CMAKE_BINARY_DIR}/mongoose)
-DownloadPackage("http://mongoose.googlecode.com/files/mongoose-3.1.tgz" "${MONGOOSE_SOURCES_DIR}" "" "")
+DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/mongoose-3.1.tgz" "${MONGOOSE_SOURCES_DIR}" "" "")
 
 # Patch mongoose
 execute_process(
--- a/Resources/CMake/OpenSslConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/OpenSslConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -1,6 +1,6 @@
 if (${STATIC_BUILD})
   SET(OPENSSL_SOURCES_DIR ${CMAKE_BINARY_DIR}/openssl-1.0.1c)
-  DownloadPackage("http://www.openssl.org/source/openssl-1.0.1c.tar.gz" "${OPENSSL_SOURCES_DIR}" "" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/openssl-1.0.1c.tar.gz" "${OPENSSL_SOURCES_DIR}" "" "")
 
   if (NOT EXISTS "${OPENSSL_SOURCES_DIR}/include/PATCHED")
     if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
--- a/Resources/CMake/SQLiteConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/SQLiteConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -1,6 +1,6 @@
 if (STATIC_BUILD OR NOT USE_DYNAMIC_SQLITE)
   SET(SQLITE_SOURCES_DIR ${CMAKE_BINARY_DIR}/sqlite-amalgamation-3071300)
-  DownloadPackage("http://www.sqlite.org/sqlite-amalgamation-3071300.zip" "${SQLITE_SOURCES_DIR}" "" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/sqlite-amalgamation-3071300.zip" "${SQLITE_SOURCES_DIR}" "" "")
 
   list(APPEND THIRD_PARTY_SOURCES
     ${SQLITE_SOURCES_DIR}/sqlite3.c
--- a/Resources/CMake/ZlibConfiguration.cmake	Mon Apr 29 12:51:30 2013 +0200
+++ b/Resources/CMake/ZlibConfiguration.cmake	Mon Apr 29 13:31:10 2013 +0200
@@ -6,7 +6,7 @@
 
 if (${STATIC_BUILD})
   SET(ZLIB_SOURCES_DIR ${CMAKE_BINARY_DIR}/zlib-1.2.7)
-  DownloadPackage("http://zlib.net/zlib-1.2.7.tar.gz" "${ZLIB_SOURCES_DIR}" "${ZLIB_PRELOADED}" "")
+  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/zlib-1.2.7.tar.gz" "${ZLIB_SOURCES_DIR}" "${ZLIB_PRELOADED}" "")
 
   include_directories(
     ${ZLIB_SOURCES_DIR}
--- a/UnitTests/Versions.cpp	Mon Apr 29 12:51:30 2013 +0200
+++ b/UnitTests/Versions.cpp	Mon Apr 29 13:31:10 2013 +0200
@@ -8,6 +8,7 @@
 #include <curl/curl.h>
 #include <boost/version.hpp>
 #include <sqlite3.h>
+#include <lua.h>
 
 
 TEST(Versions, Zlib)
@@ -40,6 +41,14 @@
 }
 
 
+TEST(Versions, Lua)
+{
+  // Ensure that the Lua version is above 5.1.0. This version has
+  // introduced some API changes.
+  ASSERT_GE(LUA_VERSION_NUM, 501);
+}
+
+
 #if ORTHANC_STATIC == 1
 TEST(Versions, ZlibStatic)
 {
@@ -63,7 +72,7 @@
   ASSERT_STREQ("1.5.12", PNG_LIBPNG_VER_STRING);
 }
 
-TEST(Versions, CurlSsl)
+TEST(Versions, CurlSslStatic)
 {
   curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW);
 
@@ -76,4 +85,10 @@
   ASSERT_TRUE(curlSupportsSsl);
 #endif
 }
+
+TEST(Version, LuaStatic)
+{
+  ASSERT_STREQ("Lua 5.1.5", LUA_RELEASE);
+}
 #endif
+