view Resources/CMake/LibCurlConfiguration.cmake @ 3:78b1f242f9a0 Palantir-0.1.0

close
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 Apr 2013 12:53:01 +0200
parents 3959d33612cc
children 67a6978503b7
line wrap: on
line source

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}" "" "")

  if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
    if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
      SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/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")
    SET(SOURCE_CONFIG ${CMAKE_SOURCE_DIR}/Resources/libcurl/i586-mingw32msvc)
  else()
    message(FATAL_ERROR "Support your platform here")
  endif()

  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)

  include_directories(${CURL_SOURCES_DIR}/include)

  AUX_SOURCE_DIRECTORY(${CURL_SOURCES_DIR}/lib CURL_SOURCES)

  set_property(
    SOURCE ${CURL_SOURCES}
    PROPERTY COMPILE_DEFINITIONS HAVE_CONFIG_H)

  list(APPEND THIRD_PARTY_SOURCES ${CURL_SOURCES})
  
  add_definitions(
    -DCURL_STATICLIB=1
    -DBUILDING_LIBCURL=1
    )

  #add_library(libcurl STATIC ${CURL_SOURCES})
  #link_libraries(libcurl)

else()
  include(FindCURL)
  include_directories(${CURL_INCLUDE_DIRS})
  link_libraries(${CURL_LIBRARIES})

  if (NOT ${CURL_FOUND})
    message(FATAL_ERROR "Unable to find LibCurl")
  endif()
endif()