Mercurial > hg > orthanc-dicomweb
changeset 33:d6904d8d165a
SyncOrthancFolder
line wrap: on
line diff
--- a/CMakeLists.txt Thu Jul 30 14:53:47 2015 +0200 +++ b/CMakeLists.txt Thu Jul 30 15:16:04 2015 +0200 @@ -20,7 +20,7 @@ project(OrthancDicomWeb) -set(ORTHANC_DICOM_WEB_VERSION "1.0") +set(ORTHANC_DICOM_WEB_VERSION "mainline") # Parameters of the build @@ -38,18 +38,20 @@ set(USE_GTEST_DEBIAN_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)") mark_as_advanced(USE_GTEST_DEBIAN_SOURCE_PACKAGE) - +set(USE_PUGIXML ON) +set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Orthanc) include(CheckIncludeFiles) include(CheckIncludeFileCXX) include(CheckLibraryExists) -include(${CMAKE_SOURCE_DIR}/Resources/CMake/Compiler.cmake) -include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) -include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/GoogleTestConfiguration.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/PugixmlConfiguration.cmake) + include(${CMAKE_SOURCE_DIR}/Resources/CMake/GdcmConfiguration.cmake) -include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake) -include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake) -include(${CMAKE_SOURCE_DIR}/Resources/CMake/PugixmlConfiguration.cmake) # Check that the Orthanc SDK headers are available or download them @@ -69,6 +71,8 @@ if(NOT Status EQUAL 0) message(FATAL_ERROR "Cannot download the plugin SDK") endif() + + include_directories(${AUTOGENERATED_DIR}) else () CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCPlugin.h HAVE_ORTHANC_H) if (NOT HAVE_ORTHANC_H) @@ -77,6 +81,35 @@ endif() +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + link_libraries(rt) +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lws2_32") + + execute_process( + COMMAND + ${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py + ${ORTHANC_DICOM_WEB_VERSION} "DICOMweb plugin" OrthancDicomWeb.dll + "Plugin to extend Orthanc with the DICOMweb API" + ERROR_VARIABLE Failure + OUTPUT_FILE ${AUTOGENERATED_DIR}/Version.rc + ) + + if (Failure) + message(FATAL_ERROR "Error while computing the version information: ${Failure}") + endif() + + list(APPEND AUTOGENERATED_SOURCES ${AUTOGENERATED_DIR}/Version.rc) +endif() + +if (CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/Orthanc/Plugins/Samples/Common/VersionScript.map -Wl,--no-undefined") +endif() + + + set(CORE_SOURCES ${BOOST_SOURCES} ${JSONCPP_SOURCES} @@ -93,9 +126,10 @@ ${CMAKE_SOURCE_DIR}/Plugin/QidoRs.cpp ${CMAKE_SOURCE_DIR}/Plugin/StowRs.cpp ${CMAKE_SOURCE_DIR}/Plugin/WadoRs.cpp + ${AUTOGENERATED_SOURCES} ) -target_link_libraries(OrthancDicomWeb ${GDCM_LIBRARIES} ${OS_LIBRARIES}) +target_link_libraries(OrthancDicomWeb ${GDCM_LIBRARIES}) message("Setting the version of the library to ${ORTHANC_DICOM_WEB_VERSION}") @@ -118,7 +152,7 @@ UnitTestsSources/UnitTestsMain.cpp ) -target_link_libraries(UnitTests ${GDCM_LIBRARIES} ${OS_LIBRARIES}) +target_link_libraries(UnitTests ${GDCM_LIBRARIES}) if (STATIC_BUILD OR NOT USE_SYSTEM_GDCM) add_dependencies(OrthancDicomWeb GDCM)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Plugins/Samples/Common/VersionScript.map Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,12 @@ +# This is a version-script for Orthanc plugins + +{ +global: + OrthancPluginInitialize; + OrthancPluginFinalize; + OrthancPluginGetName; + OrthancPluginGetVersion; + +local: + *; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/README.txt Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,1 @@ +This folder contains an excerpt of the source code of Orthanc.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/CMake/BoostConfiguration.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,158 @@ +if (STATIC_BUILD OR NOT USE_SYSTEM_BOOST) + set(BOOST_STATIC 1) +else() + include(FindBoost) + + set(BOOST_STATIC 0) + #set(Boost_DEBUG 1) + #set(Boost_USE_STATIC_LIBS ON) + + find_package(Boost + COMPONENTS filesystem thread system date_time regex locale) + + if (NOT Boost_FOUND) + message(FATAL_ERROR "Unable to locate Boost on this system") + endif() + + # Boost releases 1.44 through 1.47 supply both V2 and V3 filesystem + # http://www.boost.org/doc/libs/1_46_1/libs/filesystem/v3/doc/index.htm + if (${Boost_VERSION} LESS 104400) + add_definitions( + -DBOOST_HAS_FILESYSTEM_V3=0 + ) + else() + add_definitions( + -DBOOST_HAS_FILESYSTEM_V3=1 + -DBOOST_FILESYSTEM_VERSION=3 + ) + endif() + + #if (${Boost_VERSION} LESS 104800) + # boost::locale is only available from 1.48.00 + #message("Too old version of Boost (${Boost_LIB_VERSION}): Building the static version") + # set(BOOST_STATIC 1) + #endif() + + include_directories(${Boost_INCLUDE_DIRS}) + link_libraries(${Boost_LIBRARIES}) +endif() + + +if (BOOST_STATIC) + # Parameters for Boost 1.55.0 + set(BOOST_NAME boost_1_55_0) + set(BOOST_BCP_SUFFIX bcpdigest-0.7.4) + set(BOOST_MD5 "409f7a0e4fb1f5659d07114f3133b67b") + set(BOOST_FILESYSTEM_SOURCES_DIR "${BOOST_NAME}/libs/filesystem/src") + + set(BOOST_SOURCES_DIR ${CMAKE_BINARY_DIR}/${BOOST_NAME}) + DownloadPackage( + "${BOOST_MD5}" + "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/${BOOST_NAME}_${BOOST_BCP_SUFFIX}.tar.gz" + "${BOOST_SOURCES_DIR}" + ) + + set(BOOST_SOURCES) + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") + list(APPEND BOOST_SOURCES + ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/once.cpp + ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/thread.cpp + ) + add_definitions( + -DBOOST_LOCALE_WITH_ICONV=1 + ) + + if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") + add_definitions(-DBOOST_HAS_SCHED_YIELD=1) + endif() + + elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + list(APPEND BOOST_SOURCES + ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_dll.cpp + ${BOOST_SOURCES_DIR}/libs/thread/src/win32/thread.cpp + ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_pe.cpp + ${BOOST_FILESYSTEM_SOURCES_DIR}/windows_file_codecvt.cpp + ) + + # Starting with release 0.8.2, Orthanc statically links against + # libiconv, even on Windows. Indeed, the "WCONV" library of + # Windows XP seems not to support properly several codepages + # (notably "Latin3", "Hebrew", and "Arabic"). + + if (USE_BOOST_ICONV) + include(${ORTHANC_ROOT}/Resources/CMake/LibIconvConfiguration.cmake) + else() + add_definitions(-DBOOST_LOCALE_WITH_WCONV=1) + endif() + + else() + message(FATAL_ERROR "Support your platform here") + endif() + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + list(APPEND BOOST_SOURCES + ${BOOST_SOURCES_DIR}/libs/filesystem/src/utf8_codecvt_facet.cpp + ) + endif() + + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # This is a patch to compile Boost 1.55.0 with Clang 3.4 and later + # (including XCode 5.1). Fixes issue 14 of Orthanc. + # https://trac.macports.org/ticket/42282#comment:10 + execute_process( + COMMAND patch -p0 -N -i ${ORTHANC_ROOT}/Resources/Patches/boost-1.55.0-clang-atomic.patch + WORKING_DIRECTORY ${BOOST_SOURCES_DIR} + ) + endif() + + aux_source_directory(${BOOST_SOURCES_DIR}/libs/regex/src BOOST_REGEX_SOURCES) + + list(APPEND BOOST_SOURCES + ${BOOST_REGEX_SOURCES} + ${BOOST_SOURCES_DIR}/libs/date_time/src/gregorian/greg_month.cpp + ${BOOST_FILESYSTEM_SOURCES_DIR}/codecvt_error_category.cpp + ${BOOST_FILESYSTEM_SOURCES_DIR}/operations.cpp + ${BOOST_FILESYSTEM_SOURCES_DIR}/path.cpp + ${BOOST_FILESYSTEM_SOURCES_DIR}/path_traits.cpp + ${BOOST_SOURCES_DIR}/libs/locale/src/encoding/codepage.cpp + ${BOOST_SOURCES_DIR}/libs/system/src/error_code.cpp + ) + + add_definitions( + # Static build of Boost + -DBOOST_ALL_NO_LIB + -DBOOST_ALL_NOLIB + -DBOOST_DATE_TIME_NO_LIB + -DBOOST_THREAD_BUILD_LIB + -DBOOST_PROGRAM_OPTIONS_NO_LIB + -DBOOST_REGEX_NO_LIB + -DBOOST_SYSTEM_NO_LIB + -DBOOST_LOCALE_NO_LIB + -DBOOST_HAS_LOCALE=1 + -DBOOST_HAS_FILESYSTEM_V3=1 + ) + + if (CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-isystem ${BOOST_SOURCES_DIR}) + endif() + + include_directories( + ${BOOST_SOURCES_DIR} + ) + + source_group(ThirdParty\\Boost REGULAR_EXPRESSION ${BOOST_SOURCES_DIR}/.*) +else() + add_definitions( + -DBOOST_HAS_LOCALE=1 + ) +endif() + + +add_definitions( + -DBOOST_HAS_DATE_TIME=1 + -DBOOST_HAS_REGEX=1 + )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/CMake/Compiler.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,134 @@ +# This file sets all the compiler-related flags + +if (CMAKE_CROSSCOMPILING) + # Cross-compilation necessarily implies standalone and static build + SET(STATIC_BUILD ON) + SET(STANDALONE_BUILD ON) +endif() + +if (CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-long-long -Wno-implicit-function-declaration") + # --std=c99 makes libcurl not to compile + # -pedantic gives a lot of warnings on OpenSSL + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wno-long-long -Wno-variadic-macros") + + if (CMAKE_CROSSCOMPILING) + # http://stackoverflow.com/a/3543845/881731 + set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -I<CMAKE_CURRENT_SOURCE_DIR> <SOURCE> <OBJECT>") + endif() + +elseif (MSVC) + # Use static runtime under Visual Studio + # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace + # http://stackoverflow.com/a/6510446 + foreach(flag_var + CMAKE_C_FLAGS_DEBUG + CMAKE_CXX_FLAGS_DEBUG + CMAKE_C_FLAGS_RELEASE + CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_RELWITHDEBINFO) + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") + endforeach(flag_var) + + # Add /Zm256 compiler option to Visual Studio to fix PCH errors + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zm256") + + add_definitions( + -D_CRT_SECURE_NO_WARNINGS=1 + -D_CRT_SECURE_NO_DEPRECATE=1 + ) + include_directories(${ORTHANC_ROOT}/Resources/ThirdParty/VisualStudio) + link_libraries(netapi32) +endif() + + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") + + # Remove the "-rdynamic" option + # http://www.mail-archive.com/cmake@cmake.org/msg08837.html + set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + link_libraries(uuid pthread rt) + + if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed") + add_definitions( + -D_LARGEFILE64_SOURCE=1 + -D_FILE_OFFSET_BITS=64 + ) + link_libraries(dl) + endif() + +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + add_definitions( + -DWINVER=0x0501 + -D_CRT_SECURE_NO_WARNINGS=1 + ) + link_libraries(rpcrt4 ws2_32) + + if (CMAKE_COMPILER_IS_GNUCXX) + # This is a patch for MinGW64 + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++") + + 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") + add_definitions(-DHAVE_WIN_PTHREAD=1) + else() + add_definitions(-DHAVE_WIN_PTHREAD=0) + endif() + endif() + +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + add_definitions( + -D_XOPEN_SOURCE=1 + ) + link_libraries(iconv) + +endif() + + +if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward -fpermissive") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH}") +endif() + + +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + # In FreeBSD, the "/usr/local/" folder contains the ports and need to be imported + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") + SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib") +endif() + + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + CHECK_INCLUDE_FILES(rpc.h HAVE_UUID_H) +else() + CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) +endif() + +if (NOT HAVE_UUID_H) + message(FATAL_ERROR "Please install the uuid-dev package") +endif() + + +if (STATIC_BUILD) + add_definitions(-DORTHANC_STATIC=1) +else() + add_definitions(-DORTHANC_STATIC=0) +endif()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/CMake/DownloadPackage.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,138 @@ +macro(GetUrlFilename TargetVariable Url) + string(REGEX REPLACE "^.*/" "" ${TargetVariable} "${Url}") +endmacro() + + +macro(GetUrlExtension TargetVariable Url) + #string(REGEX REPLACE "^.*/[^.]*\\." "" TMP "${Url}") + string(REGEX REPLACE "^.*\\." "" TMP "${Url}") + string(TOLOWER "${TMP}" "${TargetVariable}") +endmacro() + + +## +## Check the existence of the required decompression tools +## + +if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + find_program(ZIP_EXECUTABLE 7z + PATHS + "$ENV{ProgramFiles}/7-Zip" + "$ENV{ProgramW6432}/7-Zip" + ) + + if (${ZIP_EXECUTABLE} MATCHES "ZIP_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Please install the '7-zip' software (http://www.7-zip.org/)") + endif() + +else() + find_program(UNZIP_EXECUTABLE unzip) + if (${UNZIP_EXECUTABLE} MATCHES "UNZIP_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Please install the 'unzip' package") + endif() + + find_program(TAR_EXECUTABLE tar) + if (${TAR_EXECUTABLE} MATCHES "TAR_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Please install the 'tar' package") + endif() +endif() + + +macro(DownloadPackage MD5 Url TargetDirectory) + if (NOT IS_DIRECTORY "${TargetDirectory}") + GetUrlFilename(TMP_FILENAME "${Url}") + + set(TMP_PATH "${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/${TMP_FILENAME}") + if (NOT EXISTS "${TMP_PATH}") + message("Downloading ${Url}") + + # This fixes issue 6: "I think cmake shouldn't download the + # packages which are not in the system, it should stop and let + # user know." + # https://code.google.com/p/orthanc/issues/detail?id=6 + if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS) + message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON") + endif() + + file(DOWNLOAD "${Url}" "${TMP_PATH}" SHOW_PROGRESS EXPECTED_MD5 "${MD5}") + else() + message("Using local copy of ${Url}") + endif() + + GetUrlExtension(TMP_EXTENSION "${Url}") + #message(${TMP_EXTENSION}) + message("Uncompressing ${TMP_FILENAME}") + + if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + # How to silently extract files using 7-zip + # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly + + if (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz")) + execute_process( + COMMAND ${ZIP_EXECUTABLE} e -y ${TMP_PATH} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE Failure + OUTPUT_QUIET + ) + + if (Failure) + message(FATAL_ERROR "Error while running the uncompression tool") + endif() + + if ("${TMP_EXTENSION}" STREQUAL "tgz") + string(REGEX REPLACE ".tgz$" ".tar" TMP_FILENAME2 "${TMP_FILENAME}") + else() + string(REGEX REPLACE ".gz$" "" TMP_FILENAME2 "${TMP_FILENAME}") + endif() + + execute_process( + COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_FILENAME2} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE Failure + OUTPUT_QUIET + ) + elseif ("${TMP_EXTENSION}" STREQUAL "zip") + execute_process( + COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_PATH} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE Failure + OUTPUT_QUIET + ) + else() + message(FATAL_ERROR "Support your platform here") + endif() + + else() + if ("${TMP_EXTENSION}" STREQUAL "zip") + execute_process( + COMMAND sh -c "${UNZIP_EXECUTABLE} -q ${TMP_PATH}" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE Failure + ) + elseif (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz")) + #message("tar xvfz ${TMP_PATH}") + execute_process( + COMMAND sh -c "${TAR_EXECUTABLE} xfz ${TMP_PATH}" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE Failure + ) + elseif ("${TMP_EXTENSION}" STREQUAL "bz2") + execute_process( + COMMAND sh -c "${TAR_EXECUTABLE} xfj ${TMP_PATH}" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE Failure + ) + else() + message(FATAL_ERROR "Unknown package format.") + endif() + endif() + + if (Failure) + message(FATAL_ERROR "Error while running the uncompression tool") + endif() + + if (NOT IS_DIRECTORY "${TargetDirectory}") + message(FATAL_ERROR "The package was not uncompressed at the proper location. Check the CMake instructions.") + endif() + endif() +endmacro()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/CMake/GoogleTestConfiguration.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,39 @@ +if (USE_GTEST_DEBIAN_SOURCE_PACKAGE) + set(GTEST_SOURCES /usr/src/gtest/src/gtest-all.cc) + include_directories(/usr/src/gtest) + + if (NOT EXISTS /usr/include/gtest/gtest.h OR + NOT EXISTS ${GTEST_SOURCES}) + message(FATAL_ERROR "Please install the libgtest-dev package") + endif() + +elseif (STATIC_BUILD OR NOT USE_SYSTEM_GOOGLE_TEST) + set(GTEST_SOURCES_DIR ${CMAKE_BINARY_DIR}/gtest-1.7.0) + DownloadPackage( + "2d6ec8ccdf5c46b05ba54a9fd1d130d7" + "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/gtest-1.7.0.zip" + "${GTEST_SOURCES_DIR}") + + include_directories( + ${GTEST_SOURCES_DIR}/include + ${GTEST_SOURCES_DIR} + ) + + set(GTEST_SOURCES + ${GTEST_SOURCES_DIR}/src/gtest-all.cc + ) + + # https://code.google.com/p/googletest/issues/detail?id=412 + if (MSVC) # VS2012 does not support tuples correctly yet + add_definitions(/D _VARIADIC_MAX=10) + endif() + +else() + include(FindGTest) + if (NOT GTEST_FOUND) + message(FATAL_ERROR "Unable to find GoogleTest") + endif() + + include_directories(${GTEST_INCLUDE_DIRS}) + link_libraries(${GTEST_LIBRARIES}) +endif()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/CMake/JsonCppConfiguration.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,35 @@ +if (STATIC_BUILD OR NOT USE_SYSTEM_JSONCPP) + set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-src-0.6.0-rc2) + DownloadPackage( + "363e2f4cbd3aeb63bf4e571f377400fb" + "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-src-0.6.0-rc2.tar.gz" + "${JSONCPP_SOURCES_DIR}") + + set(JSONCPP_SOURCES + ${JSONCPP_SOURCES_DIR}/src/lib_json/json_reader.cpp + ${JSONCPP_SOURCES_DIR}/src/lib_json/json_value.cpp + ${JSONCPP_SOURCES_DIR}/src/lib_json/json_writer.cpp + ) + + include_directories( + ${JSONCPP_SOURCES_DIR}/include + ) + + source_group(ThirdParty\\JsonCpp REGULAR_EXPRESSION ${JSONCPP_SOURCES_DIR}/.*) + +else() + 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() + +endif()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/CMake/PugixmlConfiguration.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,32 @@ +if (USE_PUGIXML) + add_definitions(-DORTHANC_PUGIXML_ENABLED=1) + + if (STATIC_BUILD OR NOT USE_SYSTEM_PUGIXML) + set(PUGIXML_SOURCES_DIR ${CMAKE_BINARY_DIR}/pugixml-1.4) + + DownloadPackage( + "7c56c91cfe3ecdee248a8e4892ef5781" + "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/pugixml-1.4.tar.gz" + "${PUGIXML_SOURCES_DIR}") + + include_directories( + ${PUGIXML_SOURCES_DIR}/src + ) + + set(PUGIXML_SOURCES + #${PUGIXML_SOURCES_DIR}/src/vlog_is_on.cc + ${PUGIXML_SOURCES_DIR}/src/pugixml.cpp + ) + + else() + CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H) + if (NOT HAVE_PUGIXML_H) + message(FATAL_ERROR "Please install the libpugixml-dev package") + endif() + + link_libraries(pugixml) + endif() + +else() + add_definitions(-DORTHANC_PUGIXML_ENABLED=0) +endif()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/MinGW-W64-Toolchain32.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,17 @@ +# the name of the target operating system +set(CMAKE_SYSTEM_NAME Windows) + +# which compilers to use for C and C++ +set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) +set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) + +# here is the target environment located +set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/MinGW-W64-Toolchain64.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,17 @@ +# the name of the target operating system +set(CMAKE_SYSTEM_NAME Windows) + +# which compilers to use for C and C++ +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +# here is the target environment located +set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/MinGWToolchain.cmake Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,17 @@ +# the name of the target operating system +set(CMAKE_SYSTEM_NAME Windows) + +# which compilers to use for C and C++ +set(CMAKE_C_COMPILER i586-mingw32msvc-gcc) +set(CMAKE_CXX_COMPILER i586-mingw32msvc-g++) +set(CMAKE_RC_COMPILER i586-mingw32msvc-windres) + +# here is the target environment located +set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/WindowsResources.py Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,89 @@ +#!/usr/bin/python + +# Orthanc - A Lightweight, RESTful DICOM Store +# Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# In addition, as a special exception, the copyright holders of this +# program give permission to link the code of its release with the +# OpenSSL project's "OpenSSL" library (or with modified versions of it +# that use the same license as the "OpenSSL" library), and distribute +# the linked executables. You must obey the GNU General Public License +# in all respects for all of the code used other than "OpenSSL". If you +# modify file(s) with this exception, you may extend this exception to +# your version of the file(s), but you are not obligated to do so. If +# you do not wish to do so, delete this exception statement from your +# version. If you delete this exception statement from all source files +# in the program, then also delete it here. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +import os +import sys +import datetime + +if len(sys.argv) != 5: + sys.stderr.write('Usage: %s <Version> <ProductName> <Filename> <Description>\n\n' % sys.argv[0]) + sys.stderr.write('Example: %s 0.9.1 Orthanc Orthanc.exe "Lightweight, RESTful DICOM server for medical imaging"\n' % sys.argv[0]) + sys.exit(-1) + +SOURCE = os.path.join(os.path.dirname(__file__), 'WindowsResources.rc') + +VERSION = sys.argv[1] +PRODUCT = sys.argv[2] +FILENAME = sys.argv[3] +DESCRIPTION = sys.argv[4] + +if VERSION == 'mainline': + VERSION = '999.999.999' + RELEASE = 'This is a mainline build, not an official release' +else: + RELEASE = 'Release %s' % VERSION + +v = VERSION.split('.') +if len(v) != 2 and len(v) != 3: + sys.stderr.write('Bad version number: %s\n' % VERSION) + sys.exit(-1) + +if len(v) == 2: + v.append('0') + +extension = os.path.splitext(FILENAME)[1] +if extension.lower() == '.dll': + BLOCK = '040904E4' + TYPE = 'VFT_DLL' +elif extension.lower() == '.exe': + #BLOCK = '040904B0' # LANG_ENGLISH/SUBLANG_ENGLISH_US, + BLOCK = '040904E4' # Lang=US English, CharSet=Windows Multilingual + TYPE = 'VFT_APP' +else: + sys.stderr.write('Unsupported extension (.EXE or .DLL only): %s\n' % extension) + sys.exit(-1) + + +with open(SOURCE, 'r') as source: + content = source.read() + content = content.replace('${VERSION_MAJOR}', v[0]) + content = content.replace('${VERSION_MINOR}', v[1]) + content = content.replace('${VERSION_PATCH}', v[2]) + content = content.replace('${RELEASE}', RELEASE) + content = content.replace('${DESCRIPTION}', DESCRIPTION) + content = content.replace('${PRODUCT}', PRODUCT) + content = content.replace('${FILENAME}', FILENAME) + content = content.replace('${YEAR}', str(datetime.datetime.now().year)) + content = content.replace('${BLOCK}', BLOCK) + content = content.replace('${TYPE}', TYPE) + + sys.stdout.write(content)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Resources/WindowsResources.rc Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,30 @@ +#include <winver.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION ${VERSION_MAJOR},${VERSION_MINOR},0,${VERSION_PATCH} + PRODUCTVERSION ${VERSION_MAJOR},${VERSION_MINOR},0,0 + FILEOS VOS_NT_WINDOWS32 + FILETYPE ${TYPE} + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "${BLOCK}" + BEGIN + VALUE "Comments", "${RELEASE}" + VALUE "CompanyName", "University Hospital of Liege, Belgium" + VALUE "FileDescription", "${DESCRIPTION}" + VALUE "FileVersion", "${VERSION_MAJOR}.${VERSION_MINOR}.0.${VERSION_PATCH}" + VALUE "InternalName", "${PRODUCT}" + VALUE "LegalCopyright", "(c) 2012-${YEAR}, Sebastien Jodogne, University Hospital of Liege, Belgium" + VALUE "LegalTrademarks", "Licensing information is available at http://www.orthanc-server.com/" + VALUE "OriginalFilename", "${FILENAME}" + VALUE "ProductName", "${PRODUCT}" + VALUE "ProductVersion", "${VERSION_MAJOR}.${VERSION_MINOR}" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 // U.S. English + END + END
--- a/Resources/BuildInstructions.txt Thu Jul 30 14:53:47 2015 +0200 +++ b/Resources/BuildInstructions.txt Thu Jul 30 15:16:04 2015 +0200 @@ -34,7 +34,7 @@ # mkdir Build # cd Build -# cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../Resources/MinGWToolchain.cmake +# cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=`pwd`/../Orthanc/Resources/MinGWToolchain.cmake # make
--- a/Resources/CMake/BoostConfiguration.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -# Orthanc - A Lightweight, RESTful DICOM Store -# Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -if (STATIC_BUILD OR NOT USE_SYSTEM_BOOST) - set(BOOST_STATIC 1) -else() - include(FindBoost) - set(BOOST_STATIC 0) - find_package(Boost COMPONENTS system thread filesystem regex locale) - - if (NOT Boost_FOUND) - message(FATAL_ERROR "Unable to locate Boost on this system") - endif() - - include_directories(${Boost_INCLUDE_DIRS}) - link_libraries(${Boost_LIBRARIES}) -endif() - - -if (BOOST_STATIC) - # Parameters for Boost 1.55.0 - set(BOOST_NAME boost_1_55_0) - set(BOOST_BCP_SUFFIX bcpdigest-0.7.4) - set(BOOST_MD5 "409f7a0e4fb1f5659d07114f3133b67b") - set(BOOST_FILESYSTEM_SOURCES_DIR "${BOOST_NAME}/libs/filesystem/src") - - set(BOOST_SOURCES_DIR ${CMAKE_BINARY_DIR}/${BOOST_NAME}) - DownloadPackage( - "${BOOST_MD5}" - "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/${BOOST_NAME}_${BOOST_BCP_SUFFIX}.tar.gz" - "${BOOST_SOURCES_DIR}" - ) - - add_definitions( - # Static build of Boost - -DBOOST_ALL_NO_LIB - -DBOOST_ALL_NOLIB - -DBOOST_DATE_TIME_NO_LIB - -DBOOST_THREAD_BUILD_LIB - -DBOOST_PROGRAM_OPTIONS_NO_LIB - -DBOOST_REGEX_NO_LIB - -DBOOST_SYSTEM_NO_LIB - -DBOOST_LOCALE_NO_LIB - ) - - if (${CMAKE_COMPILER_IS_GNUCXX}) - add_definitions(-isystem ${BOOST_SOURCES_DIR}) - endif() - - include_directories( - ${BOOST_SOURCES_DIR} - ) - - list(APPEND BOOST_SOURCES - ${BOOST_SOURCES_DIR}/libs/system/src/error_code.cpp - ) - - - ## Boost::thread - - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") - list(APPEND BOOST_SOURCES - ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/once.cpp - ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/thread.cpp - ) - - if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") - add_definitions(-DBOOST_HAS_SCHED_YIELD=1) - endif() - - elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - list(APPEND BOOST_SOURCES - ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_dll.cpp - ${BOOST_SOURCES_DIR}/libs/thread/src/win32/thread.cpp - ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_pe.cpp - ) - endif() - - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # This is a patch to compile Boost 1.55.0 with Clang 3.4 and later - # (including XCode 5.1). Fixes issue 14 of Orthanc. - # https://trac.macports.org/ticket/42282#comment:10 - execute_process( - COMMAND patch -p0 -i ${CMAKE_SOURCE_DIR}/Resources/Patches/boost-1.55.0-clang-atomic.patch - WORKING_DIRECTORY ${BOOST_SOURCES_DIR} - ) - endif() - - - ## Boost::filesystem - - list(APPEND BOOST_SOURCES - ${BOOST_FILESYSTEM_SOURCES_DIR}/codecvt_error_category.cpp - ${BOOST_FILESYSTEM_SOURCES_DIR}/operations.cpp - ${BOOST_FILESYSTEM_SOURCES_DIR}/path.cpp - ${BOOST_FILESYSTEM_SOURCES_DIR}/path_traits.cpp - ) - - if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - list(APPEND BOOST_SOURCES - ${BOOST_SOURCES_DIR}/libs/filesystem/src/utf8_codecvt_facet.cpp - ) - elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - list(APPEND BOOST_SOURCES - ${BOOST_FILESYSTEM_SOURCES_DIR}/windows_file_codecvt.cpp - ) - endif() - - - ## Boost::regex - - aux_source_directory(${BOOST_SOURCES_DIR}/libs/regex/src BOOST_REGEX_SOURCES) - list(APPEND BOOST_SOURCES ${BOOST_REGEX_SOURCES}) - - - ## Boost::locale - - list(APPEND BOOST_SOURCES - ${BOOST_SOURCES_DIR}/libs/locale/src/encoding/codepage.cpp - ${BOOST_SOURCES_DIR}/libs/system/src/error_code.cpp - ) - - if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - SET(GCC_ICONV_LINK_FLAGS "-liconv -framework CoreFoundation") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCC_ICONV_LINK_FLAGS}" ) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_ICONV_LINK_FLAGS}" ) - endif() - - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") - add_definitions(-DBOOST_LOCALE_WITH_ICONV=1) - endif() - - source_group(ThirdParty\\Boost REGULAR_EXPRESSION ${BOOST_SOURCES_DIR}/.*) -endif() - - -add_definitions( - -DBOOST_HAS_FILESYSTEM_V3=1 - -DBOOST_HAS_LOCALE=1 - )
--- a/Resources/CMake/Compiler.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -# Orthanc - A Lightweight, RESTful DICOM Store -# Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -# Force static build when cross-compiling -if (CMAKE_CROSSCOMPILING) - SET(STATIC_BUILD ON) - SET(STANDALONE_BUILD ON) -endif() - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - SET(OS_LIBRARIES uuid rt dl) - 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") - SET(OS_LIBRARIES rpcrt4 ws2_32 secur32) - if (CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++") - - # 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() -elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") - link_libraries(uuid) - link_directories("/usr/local/lib") - # This line helps CHECK_INCLUDE_FILE_CXX macro to find files - SET(CMAKE_REQUIRED_INCLUDES "/usr/local/include") -endif () - -if (CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/Resources/VersionScript.map -Wl,--no-undefined") -endif() - -if (MSVC) - # Use static runtime under Visual Studio - # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace - # http://stackoverflow.com/a/6510446 - foreach(flag_var - CMAKE_C_FLAGS_DEBUG - CMAKE_CXX_FLAGS_DEBUG - CMAKE_C_FLAGS_RELEASE - CMAKE_CXX_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_RELWITHDEBINFO) - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") - endforeach(flag_var) - - add_definitions( - -D_CRT_SECURE_NO_WARNINGS=1 - -D_CRT_NONSTDC_NO_DEPRECATE=1 - ) -endif()
--- a/Resources/CMake/DownloadPackage.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,156 +0,0 @@ -# Orthanc - A Lightweight, RESTful DICOM Store -# Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -macro(GetUrlFilename TargetVariable Url) - string(REGEX REPLACE "^.*/" "" ${TargetVariable} "${Url}") -endmacro() - - -macro(GetUrlExtension TargetVariable Url) - #string(REGEX REPLACE "^.*/[^.]*\\." "" TMP "${Url}") - string(REGEX REPLACE "^.*\\." "" TMP "${Url}") - string(TOLOWER "${TMP}" "${TargetVariable}") -endmacro() - - -## -## Check the existence of the required decompression tools -## - -if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - find_program(ZIP_EXECUTABLE 7z - PATHS - "$ENV{ProgramFiles}/7-Zip" - "$ENV{ProgramW6432}/7-Zip" - ) - - if (${ZIP_EXECUTABLE} MATCHES "ZIP_EXECUTABLE-NOTFOUND") - message(FATAL_ERROR "Please install the '7-zip' software (http://www.7-zip.org/)") - endif() - -else() - find_program(UNZIP_EXECUTABLE unzip) - if (${UNZIP_EXECUTABLE} MATCHES "UNZIP_EXECUTABLE-NOTFOUND") - message(FATAL_ERROR "Please install the 'unzip' package") - endif() - - find_program(TAR_EXECUTABLE tar) - if (${TAR_EXECUTABLE} MATCHES "TAR_EXECUTABLE-NOTFOUND") - message(FATAL_ERROR "Please install the 'tar' package") - endif() -endif() - - -macro(DownloadPackage MD5 Url TargetDirectory) - if (NOT IS_DIRECTORY "${TargetDirectory}") - GetUrlFilename(TMP_FILENAME "${Url}") - - set(TMP_PATH "${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/${TMP_FILENAME}") - if (NOT EXISTS "${TMP_PATH}") - message("Downloading ${Url}") - - # This fixes issue 6: "I think cmake shouldn't download the - # packages which are not in the system, it should stop and let - # user know." - # https://code.google.com/p/orthanc/issues/detail?id=6 - if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS) - message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON") - endif() - - file(DOWNLOAD "${Url}" "${TMP_PATH}" SHOW_PROGRESS EXPECTED_MD5 "${MD5}") - else() - message("Using local copy of ${Url}") - endif() - - GetUrlExtension(TMP_EXTENSION "${Url}") - #message(${TMP_EXTENSION}) - message("Uncompressing ${TMP_FILENAME}") - - if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - # How to silently extract files using 7-zip - # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly - - if (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz")) - execute_process( - COMMAND ${ZIP_EXECUTABLE} e -y ${TMP_PATH} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE Failure - OUTPUT_QUIET - ) - - if (Failure) - message(FATAL_ERROR "Error while running the uncompression tool") - endif() - - if ("${TMP_EXTENSION}" STREQUAL "tgz") - string(REGEX REPLACE ".tgz$" ".tar" TMP_FILENAME2 "${TMP_FILENAME}") - else() - string(REGEX REPLACE ".gz$" "" TMP_FILENAME2 "${TMP_FILENAME}") - endif() - - execute_process( - COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_FILENAME2} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE Failure - OUTPUT_QUIET - ) - elseif ("${TMP_EXTENSION}" STREQUAL "zip") - execute_process( - COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_PATH} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE Failure - OUTPUT_QUIET - ) - else() - message(FATAL_ERROR "Support your platform here") - endif() - - else() - if ("${TMP_EXTENSION}" STREQUAL "zip") - execute_process( - COMMAND sh -c "${UNZIP_EXECUTABLE} -q ${TMP_PATH}" - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE Failure - ) - elseif (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz")) - #message("tar xvfz ${TMP_PATH}") - execute_process( - COMMAND sh -c "${TAR_EXECUTABLE} xfz ${TMP_PATH}" - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE Failure - ) - elseif ("${TMP_EXTENSION}" STREQUAL "bz2") - execute_process( - COMMAND sh -c "${TAR_EXECUTABLE} xfj ${TMP_PATH}" - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE Failure - ) - else() - message(FATAL_ERROR "Unknown package format.") - endif() - endif() - - if (Failure) - message(FATAL_ERROR "Error while running the uncompression tool") - endif() - - if (NOT IS_DIRECTORY "${TargetDirectory}") - message(FATAL_ERROR "The package was not uncompressed at the proper location. Check the CMake instructions.") - endif() - endif() -endmacro()
--- a/Resources/CMake/GoogleTestConfiguration.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -# Orthanc - A Lightweight, RESTful DICOM Store -# Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -if (USE_GTEST_DEBIAN_SOURCE_PACKAGE) - set(GTEST_SOURCES /usr/src/gtest/src/gtest-all.cc) - include_directories(/usr/src/gtest) - - if (NOT EXISTS /usr/include/gtest/gtest.h OR - NOT EXISTS ${GTEST_SOURCES}) - message(FATAL_ERROR "Please install the libgtest-dev package") - endif() - -elseif (STATIC_BUILD OR NOT USE_SYSTEM_GOOGLE_TEST) - set(GTEST_SOURCES_DIR ${CMAKE_BINARY_DIR}/gtest-1.7.0) - DownloadPackage( - "2d6ec8ccdf5c46b05ba54a9fd1d130d7" - "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/gtest-1.7.0.zip" - "${GTEST_SOURCES_DIR}") - - include_directories( - ${GTEST_SOURCES_DIR}/include - ${GTEST_SOURCES_DIR} - ) - - set(GTEST_SOURCES - ${GTEST_SOURCES_DIR}/src/gtest-all.cc - ) - - # https://code.google.com/p/googletest/issues/detail?id=412 - if (MSVC) # VS2012 does not support tuples correctly yet - add_definitions(/D _VARIADIC_MAX=10) - endif() - -else() - include(FindGTest) - if (NOT GTEST_FOUND) - message(FATAL_ERROR "Unable to find GoogleTest") - endif() - - include_directories(${GTEST_INCLUDE_DIRS}) - link_libraries(${GTEST_LIBRARIES}) -endif()
--- a/Resources/CMake/JsonCppConfiguration.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -# Orthanc - A Lightweight, RESTful DICOM Store -# Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -if (STATIC_BUILD OR NOT USE_SYSTEM_JSONCPP) - set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-src-0.6.0-rc2) - DownloadPackage( - "363e2f4cbd3aeb63bf4e571f377400fb" - "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-src-0.6.0-rc2.tar.gz" - "${JSONCPP_SOURCES_DIR}") - - list(APPEND JSONCPP_SOURCES - ${JSONCPP_SOURCES_DIR}/src/lib_json/json_reader.cpp - ${JSONCPP_SOURCES_DIR}/src/lib_json/json_value.cpp - ${JSONCPP_SOURCES_DIR}/src/lib_json/json_writer.cpp - ) - - include_directories( - ${JSONCPP_SOURCES_DIR}/include - ) - - source_group(ThirdParty\\JsonCpp REGULAR_EXPRESSION ${JSONCPP_SOURCES_DIR}/.*) - -else() - CHECK_INCLUDE_FILE_CXX(jsoncpp/json/reader.h HAVE_JSONCPP_H) - if (NOT HAVE_JSONCPP_H) - message(FATAL_ERROR "Please install the libjsoncpp-dev package") - endif() - - 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) - -endif()
--- a/Resources/CMake/PugixmlConfiguration.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -if (STATIC_BUILD OR NOT USE_SYSTEM_PUGIXML) - set(PUGIXML_SOURCES_DIR ${CMAKE_BINARY_DIR}/pugixml-1.4) - - DownloadPackage( - "7c56c91cfe3ecdee248a8e4892ef5781" - "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/pugixml-1.4.tar.gz" - "${PUGIXML_SOURCES_DIR}") - - include_directories( - ${PUGIXML_SOURCES_DIR}/src - ) - - set(PUGIXML_SOURCES - ${PUGIXML_SOURCES_DIR}/src/pugixml.cpp - ) - -else() - CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H) - if (NOT HAVE_PUGIXML_H) - message(FATAL_ERROR "Please install the libpugixml-dev package") - endif() - - link_libraries(pugixml) -endif()
--- a/Resources/MinGW-W64-Toolchain32.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -# the name of the target operating system -set(CMAKE_SYSTEM_NAME Windows) - -# which compilers to use for C and C++ -set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) -set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) -set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) - -# here is the target environment located -set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
--- a/Resources/MinGW-W64-Toolchain64.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -# the name of the target operating system -set(CMAKE_SYSTEM_NAME Windows) - -# which compilers to use for C and C++ -set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) -set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) -set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) - -# here is the target environment located -set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
--- a/Resources/MinGWToolchain.cmake Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -# the name of the target operating system -set(CMAKE_SYSTEM_NAME Windows) - -# which compilers to use for C and C++ -set(CMAKE_C_COMPILER i586-mingw32msvc-gcc) -set(CMAKE_CXX_COMPILER i586-mingw32msvc-g++) -set(CMAKE_RC_COMPILER i586-mingw32msvc-windres) - -# here is the target environment located -set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
--- a/Resources/Patches/boost-1.55.0-clang-atomic.patch Thu Jul 30 14:53:47 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ ---- boost/atomic/detail/cas128strong.hpp -+++ boost/atomic/detail/cas128strong.hpp -@@ -196,15 +196,17 @@ class base_atomic<T, void, 16, Sign> - - public: - BOOST_DEFAULTED_FUNCTION(base_atomic(void), {}) -- explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : v_(0) -+ explicit base_atomic(value_type const& v) BOOST_NOEXCEPT - { -+ memset(&v_, 0, sizeof(v_)); - memcpy(&v_, &v, sizeof(value_type)); - } - - void - store(value_type const& value, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { -- storage_type value_s = 0; -+ storage_type value_s; -+ memset(&value_s, 0, sizeof(value_s)); - memcpy(&value_s, &value, sizeof(value_type)); - platform_fence_before_store(order); - platform_store128(value_s, &v_); -@@ -247,7 +249,9 @@ class base_atomic<T, void, 16, Sign> - memory_order success_order, - memory_order failure_order) volatile BOOST_NOEXCEPT - { -- storage_type expected_s = 0, desired_s = 0; -+ storage_type expected_s, desired_s; -+ memset(&expected_s, 0, sizeof(expected_s)); -+ memset(&desired_s, 0, sizeof(desired_s)); - memcpy(&expected_s, &expected, sizeof(value_type)); - memcpy(&desired_s, &desired, sizeof(value_type)); - ---- boost/atomic/detail/gcc-atomic.hpp -+++ boost/atomic/detail/gcc-atomic.hpp -@@ -958,14 +958,16 @@ class base_atomic<T, void, 16, Sign> - - public: - BOOST_DEFAULTED_FUNCTION(base_atomic(void), {}) -- explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : v_(0) -+ explicit base_atomic(value_type const& v) BOOST_NOEXCEPT - { -+ memset(&v_, 0, sizeof(v_)); - memcpy(&v_, &v, sizeof(value_type)); - } - - void store(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { -- storage_type tmp = 0; -+ storage_type tmp; -+ memset(&tmp, 0, sizeof(tmp)); - memcpy(&tmp, &v, sizeof(value_type)); - __atomic_store_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order)); - } -@@ -980,7 +982,8 @@ class base_atomic<T, void, 16, Sign> - - value_type exchange(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { -- storage_type tmp = 0; -+ storage_type tmp; -+ memset(&tmp, 0, sizeof(tmp)); - memcpy(&tmp, &v, sizeof(value_type)); - tmp = __atomic_exchange_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order)); - value_type res; -@@ -994,7 +997,9 @@ class base_atomic<T, void, 16, Sign> - memory_order success_order, - memory_order failure_order) volatile BOOST_NOEXCEPT - { -- storage_type expected_s = 0, desired_s = 0; -+ storage_type expected_s, desired_s; -+ memset(&expected_s, 0, sizeof(expected_s)); -+ memset(&desired_s, 0, sizeof(desired_s)); - memcpy(&expected_s, &expected, sizeof(value_type)); - memcpy(&desired_s, &desired, sizeof(value_type)); - const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, false, -@@ -1010,7 +1015,9 @@ class base_atomic<T, void, 16, Sign> - memory_order success_order, - memory_order failure_order) volatile BOOST_NOEXCEPT - { -- storage_type expected_s = 0, desired_s = 0; -+ storage_type expected_s, desired_s; -+ memset(&expected_s, 0, sizeof(expected_s)); -+ memset(&desired_s, 0, sizeof(desired_s)); - memcpy(&expected_s, &expected, sizeof(value_type)); - memcpy(&desired_s, &desired, sizeof(value_type)); - const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, true, ---
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/SyncOrthancFolder.py Thu Jul 30 15:16:04 2015 +0200 @@ -0,0 +1,37 @@ +#!/usr/bin/python + +# +# This maintenance script updates the content of the "Orthanc" folder +# to match the latest version of the Orthanc source code. +# + +import os +import shutil + +SOURCE = '/home/jodogne/Subversion/Orthanc' +TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc') + +FILES = [ + 'Plugins/Samples/Common/VersionScript.map', + 'Resources/CMake/BoostConfiguration.cmake', + 'Resources/CMake/Compiler.cmake', + 'Resources/CMake/DownloadPackage.cmake', + 'Resources/CMake/GoogleTestConfiguration.cmake', + 'Resources/CMake/JsonCppConfiguration.cmake', + 'Resources/CMake/PugixmlConfiguration.cmake', + 'Resources/MinGW-W64-Toolchain32.cmake', + 'Resources/MinGW-W64-Toolchain64.cmake', + 'Resources/MinGWToolchain.cmake', + 'Resources/WindowsResources.py', + 'Resources/WindowsResources.rc', +] + +for f in FILES: + source = os.path.join(SOURCE, f) + target = os.path.join(TARGET, f) + try: + os.makedirs(os.path.dirname(target)) + except: + pass + + shutil.copy(source, target)