# HG changeset patch # User Sebastien Jodogne # Date 1432913041 -7200 # Node ID 92da9e1c2daafd851f498d904680f38842d8d49e # Parent c236a8b35a3b3e3b1bc8dd338a266a068f99cd11 improvement of samples diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/Basic/CMakeLists.txt --- a/Plugins/Samples/Basic/CMakeLists.txt Fri May 29 15:31:46 2015 +0200 +++ b/Plugins/Samples/Basic/CMakeLists.txt Fri May 29 17:24:01 2015 +0200 @@ -2,16 +2,7 @@ project(Basic) -if (${CMAKE_COMPILER_IS_GNUCXX}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Werror") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror") -endif() +set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../../) +include(${CMAKE_SOURCE_DIR}/../Common/OrthancPlugins.cmake) -include_directories(${CMAKE_SOURCE_DIR}/../../Include/) add_library(PluginTest SHARED Plugin.c) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - # Linking with "pthread" is necessary, otherwise the software crashes - # http://sourceware.org/bugzilla/show_bug.cgi?id=10652#c17 - target_link_libraries(PluginTest pthread dl) -endif() diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/Common/OrthancPlugins.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/Samples/Common/OrthancPlugins.cmake Fri May 29 17:24:01 2015 +0200 @@ -0,0 +1,37 @@ +include(CheckLibraryExists) + + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + link_libraries(uuid) + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread") +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + link_libraries(rpcrt4 ws2_32 secur32) + if (CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++") + endif() + + CHECK_LIBRARY_EXISTS(winpthread pthread_create "" HAVE_WIN_PTHREAD) + if (HAVE_WIN_PTHREAD) + # This line is necessary to compile with recent versions of MinGW, + # otherwise "libwinpthread-1.dll" is not statically linked. + SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic") + endif() +endif () + + +if (CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${ORTHANC_ROOT}/Plugins/Samples/Common/VersionScript.map -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic") +endif() + + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + # Linking with "pthread" is necessary, otherwise the software crashes + # http://sourceware.org/bugzilla/show_bug.cgi?id=10652#c17 + link_libraries(dl rt) +endif() + + +include_directories(${ORTHANC_ROOT}/Plugins/Include/) diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/Common/VersionScript.map --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/Samples/Common/VersionScript.map Fri May 29 17:24:01 2015 +0200 @@ -0,0 +1,12 @@ +# This is a version-script for Orthanc plugins + +{ +global: + OrthancPluginInitialize; + OrthancPluginFinalize; + OrthancPluginGetName; + OrthancPluginGetVersion; + +local: + *; +}; diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/GdcmDecoding/CMakeLists.txt --- a/Plugins/Samples/GdcmDecoding/CMakeLists.txt Fri May 29 15:31:46 2015 +0200 +++ b/Plugins/Samples/GdcmDecoding/CMakeLists.txt Fri May 29 17:24:01 2015 +0200 @@ -2,18 +2,15 @@ project(GdcmDecoding) -SET(ALLOW_DOWNLOADS ON CACHE BOOL "Allow CMake to download packages") +SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") SET(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost") -SET(USE_SYSTEM_GOOGLE_LOG OFF CACHE BOOL "Use the system version of Google Log") +SET(USE_SYSTEM_GOOGLE_LOG ON CACHE BOOL "Use the system version of Google Log") set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../..) -if (${CMAKE_COMPILER_IS_GNUCXX}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") -endif() - +include(CheckIncludeFiles) +include(CheckIncludeFileCXX) +include(${CMAKE_SOURCE_DIR}/../Common/OrthancPlugins.cmake) include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake) include(${ORTHANC_ROOT}/Resources/CMake/GoogleLogConfiguration.cmake) @@ -27,7 +24,6 @@ endif(GDCM_FOUND) include_directories( - ${ORTHANC_ROOT}/Plugins/Include/ ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw ) @@ -50,7 +46,3 @@ ) target_link_libraries(GdcmDecoding ${GDCM_LIBRARIES}) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - target_link_libraries(GdcmDecoding pthread dl rt) -endif() diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/ServeFolders/CMakeLists.txt --- a/Plugins/Samples/ServeFolders/CMakeLists.txt Fri May 29 15:31:46 2015 +0200 +++ b/Plugins/Samples/ServeFolders/CMakeLists.txt Fri May 29 17:24:01 2015 +0200 @@ -2,34 +2,18 @@ project(ServeFolders) -set(ALLOW_DOWNLOADS ON) -set(USE_SYSTEM_JSONCPP OFF) -include(../../../Resources/CMake/DownloadPackage.cmake) -include(../../../Resources/CMake/JsonCppConfiguration.cmake) +SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") +SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp") + +set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../../) -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - link_libraries(uuid) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread") -elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - link_libraries(rpcrt4 ws2_32 secur32) - if (CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++") - endif() -endif () +include(CheckIncludeFiles) +include(CheckIncludeFileCXX) +include(${CMAKE_SOURCE_DIR}/../Common/OrthancPlugins.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake) -if (CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/VersionScript.map -Wl,--no-undefined") -endif() - -include_directories(${CMAKE_SOURCE_DIR}/../../Include/) add_library(ServeFolders SHARED Plugin.cpp ${THIRD_PARTY_SOURCES} ) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - # Linking with "pthread" is necessary, otherwise the software crashes - # http://sourceware.org/bugzilla/show_bug.cgi?id=10652#c17 - target_link_libraries(ServeFolders dl rt) -endif() diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/ServeFolders/VersionScript.map --- a/Plugins/Samples/ServeFolders/VersionScript.map Fri May 29 15:31:46 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -# This is a version-script for Orthanc plugins - -{ -global: - OrthancPluginInitialize; - OrthancPluginFinalize; - OrthancPluginGetName; - OrthancPluginGetVersion; - -local: - *; -}; diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/StorageArea/CMakeLists.txt --- a/Plugins/Samples/StorageArea/CMakeLists.txt Fri May 29 15:31:46 2015 +0200 +++ b/Plugins/Samples/StorageArea/CMakeLists.txt Fri May 29 17:24:01 2015 +0200 @@ -2,16 +2,7 @@ project(Basic) -if (${CMAKE_COMPILER_IS_GNUCXX}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Werror") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror") -endif() +set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../../) +include(${CMAKE_SOURCE_DIR}/../Common/OrthancPlugins.cmake) -include_directories(${CMAKE_SOURCE_DIR}/../../Include/) add_library(PluginTest SHARED Plugin.cpp) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - # Linking with "pthread" is necessary, otherwise the software crashes - # http://sourceware.org/bugzilla/show_bug.cgi?id=10652#c17 - target_link_libraries(PluginTest pthread dl) -endif() diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/WebSkeleton/CMakeLists.txt --- a/Plugins/Samples/WebSkeleton/CMakeLists.txt Fri May 29 15:31:46 2015 +0200 +++ b/Plugins/Samples/WebSkeleton/CMakeLists.txt Fri May 29 17:24:01 2015 +0200 @@ -7,7 +7,8 @@ include(Framework/Framework.cmake) -include_directories(${CMAKE_SOURCE_DIR}/../../Include/) +set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../../) +include(${CMAKE_SOURCE_DIR}/../Common/OrthancPlugins.cmake) add_library(WebSkeleton SHARED ${AUTOGENERATED_SOURCES} diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/WebSkeleton/Framework/EmbedResources.py --- a/Plugins/Samples/WebSkeleton/Framework/EmbedResources.py Fri May 29 15:31:46 2015 +0200 +++ b/Plugins/Samples/WebSkeleton/Framework/EmbedResources.py Fri May 29 17:24:01 2015 +0200 @@ -210,6 +210,10 @@ cpp.write("0x%02x" % c) pos += 1 + # Zero-size array are disallowed, so we put one single void character in it. + if pos == 0: + cpp.write(' 0') + cpp.write(' };\n') cpp.write(' static const size_t resource%dSize = %d;\n' % (item['Index'], pos)) diff -r c236a8b35a3b -r 92da9e1c2daa Plugins/Samples/WebSkeleton/Framework/Framework.cmake --- a/Plugins/Samples/WebSkeleton/Framework/Framework.cmake Fri May 29 15:31:46 2015 +0200 +++ b/Plugins/Samples/WebSkeleton/Framework/Framework.cmake Fri May 29 17:24:01 2015 +0200 @@ -16,16 +16,6 @@ # along with this program. If not, see . -if (${CMAKE_COMPILER_IS_GNUCXX}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wno-unused-function") -endif() - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - # Linking with "pthread" is necessary, otherwise the software might crash - # http://sourceware.org/bugzilla/show_bug.cgi?id=10652#c17 - link_libraries(pthread dl) -endif() - if (STANDALONE_BUILD) add_definitions(-DORTHANC_PLUGIN_STANDALONE=1) @@ -61,4 +51,4 @@ list(APPEND AUTOGENERATED_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Framework/Plugin.cpp" - ) \ No newline at end of file + )