# HG changeset patch # User Sebastien Jodogne # Date 1346246833 -7200 # Node ID 042ac60f5bf972b43a0b269d98f3c28558dc28d2 # Parent ef264c1e9ee5a105d44073581ed43c4c369376fa simplified build of curl diff -r ef264c1e9ee5 -r 042ac60f5bf9 CMakeLists.txt --- a/CMakeLists.txt Wed Aug 29 11:07:55 2012 +0200 +++ b/CMakeLists.txt Wed Aug 29 15:27:13 2012 +0200 @@ -29,6 +29,13 @@ ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp ) +if (${ENABLE_SSL}) + add_definitions(-DPALANTIR_SSL_ENABLED=1) + include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake) +else() + add_definitions(-DPALANTIR_SSL_ENABLED=0) +endif() + include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake) include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake) include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake) @@ -39,10 +46,6 @@ include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake) include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake) -if (${ENABLE_SSL}) - include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake) -endif() - if (${CMAKE_COMPILER_IS_GNUCXX}) set(CMAKE_C_FLAGS "-Wall -Wno-long-long -Wno-implicit-function-declaration") diff -r ef264c1e9ee5 -r 042ac60f5bf9 PalantirCppClient/HttpClient.cpp --- a/PalantirCppClient/HttpClient.cpp Wed Aug 29 11:07:55 2012 +0200 +++ b/PalantirCppClient/HttpClient.cpp Wed Aug 29 15:27:13 2012 +0200 @@ -44,6 +44,7 @@ { if (code != CURLE_OK) { + printf("ICI: %s\n", curl_easy_strerror(code)); throw HttpException("CURL: " + std::string(curl_easy_strerror(code))); } diff -r ef264c1e9ee5 -r 042ac60f5bf9 Resources/CMake/LibCurlConfiguration.cmake --- a/Resources/CMake/LibCurlConfiguration.cmake Wed Aug 29 11:07:55 2012 +0200 +++ b/Resources/CMake/LibCurlConfiguration.cmake Wed Aug 29 15:27:13 2012 +0200 @@ -2,29 +2,31 @@ 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}" "" "") - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/WithSsl/x86_64-linux) - elseif ("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") - SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/i686-pc-linux-gnu) + if (0) + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/WithSsl/x86_64-linux) + elseif ("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") + SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/i686-pc-linux-gnu) + else() + message(FATAL_ERROR "Support your platform here") + endif() + elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + if (${MSVC}) + SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/msvc) + else() + SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/i586-mingw32msvc) + endif() else() message(FATAL_ERROR "Support your platform here") endif() - elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - if (${MSVC}) - SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/msvc) - else() - SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/i586-mingw32msvc) + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + configure_file("${SOURCE_CONFIG}/curl_config.h" "${CURL_SOURCES_DIR}/lib/curl_config.h" COPYONLY) + configure_file("${SOURCE_CONFIG}/curlbuild.h" "${CURL_SOURCES_DIR}/include/curl/curlbuild.h" COPYONLY) + elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + configure_file("${SOURCE_CONFIG}/curlbuild.h" "${CURL_SOURCES_DIR}/include/curl/curlbuild.h" COPYONLY) endif() - else() - message(FATAL_ERROR "Support your platform here") - endif() - - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - configure_file("${SOURCE_CONFIG}/curl_config.h" "${CURL_SOURCES_DIR}/lib/curl_config.h" COPYONLY) - configure_file("${SOURCE_CONFIG}/curlbuild.h" "${CURL_SOURCES_DIR}/include/curl/curlbuild.h" COPYONLY) - elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - configure_file("${SOURCE_CONFIG}/curlbuild.h" "${CURL_SOURCES_DIR}/include/curl/curlbuild.h" COPYONLY) endif() include_directories(${CURL_SOURCES_DIR}/include) @@ -32,20 +34,88 @@ AUX_SOURCE_DIRECTORY(${CURL_SOURCES_DIR}/lib CURL_SOURCES) source_group(ThirdParty\\LibCurl REGULAR_EXPRESSION ${CURL_SOURCES_DIR}/.*) - list(APPEND THIRD_PARTY_SOURCES ${CURL_SOURCES}) - + #list(APPEND THIRD_PARTY_SOURCES ${CURL_SOURCES}) + add_library(Curl STATIC ${CURL_SOURCES}) + link_libraries(Curl) + add_definitions( -DCURL_STATICLIB=1 -DBUILDING_LIBCURL=1 -DCURL_DISABLE_LDAPS=1 -DCURL_DISABLE_LDAP=1 -D_WIN32_WINNT=0x0501 + + -DCURL_DISABLE_DICT=1 + -DCURL_DISABLE_FILE=1 + -DCURL_DISABLE_FTP=1 + -DCURL_DISABLE_GOPHER=1 + -DCURL_DISABLE_LDAP=1 + -DCURL_DISABLE_LDAPS=1 + -DCURL_DISABLE_POP3=1 + -DCURL_DISABLE_PROXY=1 + -DCURL_DISABLE_RTSP=1 + -DCURL_DISABLE_TELNET=1 + -DCURL_DISABLE_TFTP=1 ) + if (${ENABLE_SSL}) + add_definitions( + #-DHAVE_LIBSSL=1 + -DUSE_OPENSSL=1 + -DUSE_SSLEAY=1 + ) + endif() + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + #set_property( + # SOURCE ${CURL_SOURCES} + # PROPERTY COMPILE_DEFINITIONS HAVE_CONFIG_H) + if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + SET(TMP_OS "x86_64") + else() + SET(TMP_OS "x86") + endif() + set_property( SOURCE ${CURL_SOURCES} - PROPERTY COMPILE_DEFINITIONS HAVE_CONFIG_H) + PROPERTY COMPILE_DEFINITIONS "HAVE_TIME_H;HAVE_STRUCT_TIMEVAL;HAVE_SYS_STAT_H;HAVE_SOCKET;HAVE_STRUCT_SOCKADDR_STORAGE;HAVE_SYS_SOCKET_H;HAVE_SOCKET;HAVE_SYS_SOCKET_H;HAVE_NETINET_IN_H;HAVE_NETDB_H;HAVE_FCNTL_O_NONBLOCK;HAVE_FCNTL_H;HAVE_SELECT;HAVE_ERRNO_H;HAVE_SEND;HAVE_RECV;OS=\"${TMP_OS}\"") + if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + add_definitions( + -DRECV_TYPE_ARG1=int + -DRECV_TYPE_ARG2=void* + -DRECV_TYPE_ARG3=size_t + -DRECV_TYPE_ARG4=int + -DRECV_TYPE_RETV=ssize_t + -DSEND_TYPE_ARG1=int + -DSEND_TYPE_ARG2=void* + -DSEND_QUAL_ARG2=const + -DSEND_TYPE_ARG3=size_t + -DSEND_TYPE_ARG4=int + -DSEND_TYPE_RETV=ssize_t + -DSIZEOF_SHORT=2 + -DSIZEOF_INT=4 + -DSIZEOF_SIZE_T=8 + ) + elseif ("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") + add_definitions( + -DRECV_TYPE_ARG1=SOCKET + -DRECV_TYPE_ARG2=char* + -DRECV_TYPE_ARG3=int + -DRECV_TYPE_ARG4=int + -DRECV_TYPE_RETV=int + -DSEND_TYPE_ARG1=SOCKET + -DSEND_TYPE_ARG2=char* + -DSEND_QUAL_ARG2=const + -DSEND_TYPE_ARG3=int + -DSEND_TYPE_ARG4=int + -DSEND_TYPE_RETV=int + -DSIZEOF_SHORT=2 + -DSIZEOF_INT=4 + -DSIZEOF_SIZE_T=4 + ) + else() + message(FATAL_ERROR "Support your platform here") + endif() endif() else() diff -r ef264c1e9ee5 -r 042ac60f5bf9 Resources/CMake/MongooseConfiguration.cmake --- a/Resources/CMake/MongooseConfiguration.cmake Wed Aug 29 11:07:55 2012 +0200 +++ b/Resources/CMake/MongooseConfiguration.cmake Wed Aug 29 15:27:13 2012 +0200 @@ -18,7 +18,6 @@ if (${ENABLE_SSL}) add_definitions( - -DPALANTIR_SSL_ENABLED=1 -DNO_SSL_DL=1 ) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") @@ -27,7 +26,6 @@ else() add_definitions( - -DPALANTIR_SSL_ENABLED=0 -DNO_SSL=1 # Remove SSL support from mongoose ) endif() diff -r ef264c1e9ee5 -r 042ac60f5bf9 Resources/CMake/OpenSslConfiguration.cmake --- a/Resources/CMake/OpenSslConfiguration.cmake Wed Aug 29 11:07:55 2012 +0200 +++ b/Resources/CMake/OpenSslConfiguration.cmake Wed Aug 29 15:27:13 2012 +0200 @@ -3,8 +3,8 @@ DownloadPackage("http://www.openssl.org/source/openssl-1.0.1c.tar.gz" "${OPENSSL_SOURCES_DIR}" "" "") if (NOT EXISTS "${OPENSSL_SOURCES_DIR}/include/PATCHED") - message("Patching the symbolic links") if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + message("Patching the symbolic links") # Patch the symbolic links by copying the files file(GLOB headers "${OPENSSL_SOURCES_DIR}/include/openssl/*.h") foreach(header ${headers}) @@ -139,7 +139,8 @@ ${OPENSSL_SOURCES_DIR}/ssl/ssl_task.c ) - if (${MSVC}) + #if (${MSVC}) + if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set_source_files_properties( ${OPENSSL_SOURCES} PROPERTIES COMPILE_DEFINITIONS diff -r ef264c1e9ee5 -r 042ac60f5bf9 UnitTests/Versions.cpp --- a/UnitTests/Versions.cpp Wed Aug 29 11:07:55 2012 +0200 +++ b/UnitTests/Versions.cpp Wed Aug 29 15:27:13 2012 +0200 @@ -50,3 +50,18 @@ ASSERT_STREQ("1.5.12", PNG_LIBPNG_VER_STRING); } #endif + + +TEST(Versions, CurlSsl) +{ + curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW); + + // Check that SSL support is enabled when required + bool curlSupportsSsl = vinfo->features & CURL_VERSION_SSL; + +#if PALANTIR_SSL_ENABLED == 0 + ASSERT_FALSE(curlSupportsSsl); +#else + ASSERT_TRUE(curlSupportsSsl); +#endif +} diff -r ef264c1e9ee5 -r 042ac60f5bf9 UnitTests/main.cpp --- a/UnitTests/main.cpp Wed Aug 29 11:07:55 2012 +0200 +++ b/UnitTests/main.cpp Wed Aug 29 15:27:13 2012 +0200 @@ -273,15 +273,6 @@ ASSERT_EQ("SGVsbG8gd29ybGQ=", Toolbox::EncodeBase64("Hello world")); } -TEST(tutu, tata) -{ - HttpClient c; - c.SetUrl("https://localhost:8000/instances"); - std::string s; - ASSERT_TRUE(c.Apply(s)); -} - - int main(int argc, char **argv) { PalantirInitialize();