Mercurial > hg > orthanc-postgresql
changeset 99:db42bf101349
sync
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Sat, 14 May 2016 16:39:32 +0200 |
| parents | baf715163ca1 |
| children | d681914735b3 |
| files | Orthanc/Core/Endianness.h Orthanc/Resources/CMake/BoostConfiguration.cmake Orthanc/Resources/CMake/Compiler.cmake Orthanc/Resources/CMake/JsonCppConfiguration.cmake |
| diffstat | 4 files changed, 96 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Orthanc/Core/Endianness.h Fri Mar 25 18:05:00 2016 +0100 +++ b/Orthanc/Core/Endianness.h Sat May 14 16:39:32 2016 +0200 @@ -37,7 +37,8 @@ ** LINUX ARCHITECTURES ********************************************************************/ -#if defined(__linux) +#if defined(__linux__) +# define ORTHANC_HAS_BUILTIN_BYTE_SWAP 1 # include <endian.h> #endif @@ -45,19 +46,28 @@ /******************************************************************** ** WINDOWS ARCHITECTURES ** - ** On Windows, "host" will always be little-endian ("le"). + ** On Windows x86, "host" will always be little-endian ("le"). ********************************************************************/ #if defined(_WIN32) # if defined(_MSC_VER) -// http://msdn.microsoft.com/en-us/library/a3140177.aspx +// Visual Studio - http://msdn.microsoft.com/en-us/library/a3140177.aspx +# define ORTHANC_HAS_BUILTIN_BYTE_SWAP 1 # define be16toh(x) _byteswap_ushort(x) # define be32toh(x) _byteswap_ulong(x) # define be64toh(x) _byteswap_uint64(x) -# else // MinGW +# elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) +// MinGW >= 4.3 - Use builtin intrinsic for byte swapping +# define ORTHANC_HAS_BUILTIN_BYTE_SWAP 1 # define be16toh(x) __builtin_bswap16(x) # define be32toh(x) __builtin_bswap32(x) # define be64toh(x) __builtin_bswap64(x) +# else +// MinGW <= 4.2, we must manually implement the byte swapping +# define ORTHANC_HAS_BUILTIN_BYTE_SWAP 0 +# define be16toh(x) __orthanc_bswap16(x) +# define be32toh(x) __orthanc_bswap32(x) +# define be64toh(x) __orthanc_bswap64(x) # endif # define htobe16(x) be16toh(x) @@ -79,6 +89,7 @@ ********************************************************************/ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# define ORTHANC_HAS_BUILTIN_BYTE_SWAP 1 # include <arpa/inet.h> #endif @@ -88,6 +99,7 @@ ********************************************************************/ #if defined(__APPLE__) +# define ORTHANC_HAS_BUILTIN_BYTE_SWAP 1 # include <libkern/OSByteOrder.h> # define be16toh(x) OSSwapBigToHostInt16(x) # define be32toh(x) OSSwapBigToHostInt32(x) @@ -105,3 +117,41 @@ # define le32toh(x) OSSwapLittleToHostInt32(x) # define le64toh(x) OSSwapLittleToHostInt64(x) #endif + + +/******************************************************************** + ** PORTABLE (BUT SLOW) IMPLEMENTATION OF BYTE-SWAPPING + ********************************************************************/ + +#if ORTHANC_HAS_BUILTIN_BYTE_SWAP != 1 + +#include <stdint.h> + +static inline uint16_t __orthanc_bswap16(uint16_t a) +{ + return (a << 8) | (a >> 8); +} + +static inline uint32_t __orthanc_bswap32(uint32_t a) +{ + const uint8_t* p = reinterpret_cast<const uint8_t*>(&a); + return (static_cast<uint32_t>(p[0]) << 24 | + static_cast<uint32_t>(p[1]) << 16 | + static_cast<uint32_t>(p[2]) << 8 | + static_cast<uint32_t>(p[3])); +} + +static inline uint64_t __orthanc_bswap64(uint64_t a) +{ + const uint8_t* p = reinterpret_cast<const uint8_t*>(&a); + return (static_cast<uint64_t>(p[0]) << 56 | + static_cast<uint64_t>(p[1]) << 48 | + static_cast<uint64_t>(p[2]) << 40 | + static_cast<uint64_t>(p[3]) << 32 | + static_cast<uint64_t>(p[4]) << 24 | + static_cast<uint64_t>(p[5]) << 16 | + static_cast<uint64_t>(p[6]) << 8 | + static_cast<uint64_t>(p[7])); +} + +#endif
--- a/Orthanc/Resources/CMake/BoostConfiguration.cmake Fri Mar 25 18:05:00 2016 +0100 +++ b/Orthanc/Resources/CMake/BoostConfiguration.cmake Sat May 14 16:39:32 2016 +0200 @@ -42,7 +42,7 @@ # Parameters for Boost 1.60.0 set(BOOST_NAME boost_1_60_0) set(BOOST_BCP_SUFFIX bcpdigest-1.0.1) - set(BOOST_MD5 "0646971514a1e012fbe382c5662a8605") + set(BOOST_MD5 "a789f8ec2056ad1c2d5f0cb64687cc7b") set(BOOST_URL "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/${BOOST_NAME}_${BOOST_BCP_SUFFIX}.tar.gz") set(BOOST_FILESYSTEM_SOURCES_DIR "${BOOST_NAME}/libs/filesystem/src") set(BOOST_SOURCES_DIR ${CMAKE_BINARY_DIR}/${BOOST_NAME})
--- a/Orthanc/Resources/CMake/Compiler.cmake Fri Mar 25 18:05:00 2016 +0100 +++ b/Orthanc/Resources/CMake/Compiler.cmake Sat May 14 16:39:32 2016 +0200 @@ -10,7 +10,7 @@ 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") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-variadic-macros") if (CMAKE_CROSSCOMPILING) # http://stackoverflow.com/a/3543845/881731 @@ -73,6 +73,11 @@ link_libraries(dl) endif() + CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) + if (NOT HAVE_UUID_H) + message(FATAL_ERROR "Please install the uuid-dev package") + endif() + elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") if (MSVC) message("MSVC compiler version = " ${MSVC_VERSION} "\n") @@ -97,6 +102,11 @@ link_libraries(rpcrt4 ws2_32) if (CMAKE_COMPILER_IS_GNUCXX) + # Some additional C/C++ compiler flags for MinGW + SET(MINGW_NO_WARNINGS "-Wno-unused-function -Wno-unused-variable") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MINGW_NO_WARNINGS} -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MINGW_NO_WARNINGS}") + # 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++") @@ -120,6 +130,11 @@ ) link_libraries(iconv) + CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) + if (NOT HAVE_UUID_H) + message(FATAL_ERROR "Please install the uuid-dev package") + endif() + endif() @@ -139,17 +154,6 @@ 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()
--- a/Orthanc/Resources/CMake/JsonCppConfiguration.cmake Fri Mar 25 18:05:00 2016 +0100 +++ b/Orthanc/Resources/CMake/JsonCppConfiguration.cmake Sat May 14 16:39:32 2016 +0200 @@ -32,4 +32,29 @@ message(FATAL_ERROR "Please install the libjsoncpp-dev package") endif() + # Switch to the C++11 standard if the version of JsonCpp is 1.y.z + if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h) + file(STRINGS + "${JSONCPP_INCLUDE_DIR}/json/version.h" + JSONCPP_VERSION_MAJOR1 REGEX + ".*define JSONCPP_VERSION_MAJOR.*") + + if (NOT JSONCPP_VERSION_MAJOR1) + message(FATAL_ERROR "Unable to extract the major version of JsonCpp") + endif() + + string(REGEX REPLACE + ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1" + JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1}) + message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}") + + if (CMAKE_COMPILER_IS_GNUCXX AND + JSONCPP_VERSION_MAJOR GREATER 0) + message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations") + endif() + else() + message("Unable to detect the major version of JsonCpp, assuming < 1.0.0") + endif() + endif()
