External_boost.cmake 4.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
message(STATUS "Setup Boost ...")

set(proj BOOST)

set(DEFAULT_USE_SYSTEM_BOOST  ON)

option(USE_SYSTEM_BOOST "  Use a system build of Boost." ${DEFAULT_USE_SYSTEM_BOOST})
mark_as_advanced(USE_SYSTEM_BOOST)

if(USE_SYSTEM_BOOST)
  message(STATUS "  Using Boost system version")
else()
13
  SETUP_SUPERBUILD(PROJECT ${proj})
14
  
15 16
  option(SUPERBUILD_BOOST_HEADER_ONLY "Only use Boost headers" ON)
  mark_as_advanced(SUPERBUILD_BOOST_HEADER_ONLY)
17
  
18
  if(UNIX)
19
    if(SUPERBUILD_BOOST_HEADER_ONLY)
Guillaume Pasero's avatar
Guillaume Pasero committed
20
      ExternalProject_Add(${proj}
21
        PREFIX ${proj}
22 23
        URL "http://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz/download"
        URL_MD5 efbfbff5a85a9330951f243d0a46e4b9
24 25 26 27 28 29 30 31 32
        BINARY_DIR ${BOOST_SB_BUILD_DIR}
        INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
        CMAKE_CACHE_ARGS
        -DCMAKE_INSTALL_PREFIX:STRING=${CMAKE_INSTALL_PREFIX}
        -DCMAKE_BUILD_TYPE:STRING=Release
        -DBUILD_SHARED_LIBS:BOOL=ON
        PATCH_COMMAND ${CMAKE_COMMAND} -E copy 
        ${CMAKE_SOURCE_DIR}/patches/${proj}/CMakeLists.txt 
        ${BOOST_SB_SRC}
Guillaume Pasero's avatar
Guillaume Pasero committed
33 34 35 36 37 38 39 40 41 42 43 44 45
      )
    else()
      ExternalProject_Add(${proj}
        PREFIX ${proj}
        URL "http://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz/download"
        URL_MD5 efbfbff5a85a9330951f243d0a46e4b9
        BINARY_DIR ${BOOST_SB_BUILD_DIR}
        INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
        CONFIGURE_COMMAND
          ${BOOST_SB_BUILD_DIR}/bootstrap.sh
            --prefix=${CMAKE_INSTALL_PREFIX}
        BUILD_COMMAND ./b2
        INSTALL_COMMAND ./b2 install
46 47 48
        PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory
          ${CMAKE_SOURCE_DIR}/patches/${proj}/1.54.0
          ${BOOST_SB_SRC}
Guillaume Pasero's avatar
Guillaume Pasero committed
49 50 51 52 53 54 55 56 57
      )
      
      ExternalProject_Add_Step(${proj} copy_source
        COMMAND ${CMAKE_COMMAND} -E copy_directory
          ${BOOST_SB_SRC} ${BOOST_SB_BUILD_DIR}
        DEPENDEES patch update
        DEPENDERS configure
      )
    endif()
58 59 60
    
    message(STATUS "  Using Boost SuperBuild version")
    
61 62 63 64
  else(MSVC)
    #TODO: find hash for archives properly
    set(BOOST_HEADERS_URL_HASH 1605dc6085cb2dc778ef5ab6c0e59083)
    set(BOOST_GRAPH_URL_HASH c246516ca84a3c79ae8a0b22fceb0344)
65
    set(BOOST_REGEX_URL_HASH a3bfc2dc9a3ebe3c050518ecb29d6f8b)
66 67
    set(BOOST_UTF_URL_HASH 75971963a74c76d32e01974a8e48be11)
    
68 69 70 71 72 73
    if(MSVC10)
        set(BOOST_HEADERS_URL_HASH 1605dc6085cb2dc778ef5ab6c0e59083)
        set(BOOST_GRAPH_URL_HASH c246516ca84a3c79ae8a0b22fceb0344)
        set(BOOST_REGEX_URL_HASH a3bfc2dc9a3ebe3c050518ecb29d6f8b)
        set(BOOST_UTF_URL_HASH 75971963a74c76d32e01974a8e48be11)
    else(MSVC80)
74
 
75
    else(CMAKE_COMPILER_2005)
76
   
77
    endif()
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107

    set(BOOST_HEADERS_URL "http://sourceforge.net/projects/boost/files/boost-binaries/1.50.0/boost_1_50_headers.zip/download")
    set(BOOST_GRAPH_URL "http://sourceforge.net/projects/boost/files/boost-binaries/1.50.0/libboost_graph-vc100-mt-1_50.zip/download")
    set(BOOST_UTF_URL "http://sourceforge.net/projects/boost/files/boost-binaries/1.50.0/boost_unit_test_framework-vc100-mt-1_50.zip/download")
    set(BOOST_REGEX_URL "http://sourceforge.net/projects/boost/files/boost-binaries/1.50.0/libboost_regex-vc100-mt-1_50.zip/download")

    ExternalProject_Add(${proj}_HEADERS
        PREFIX ${proj}/_HEADERS
        URL ${BOOST_HEADERS_URL}
        URL_MD5 ${BOOST_HEADERS_URL_HASH}
        SOURCE_DIR ${BOOST_SB_SRC}/include/boost
        CONFIGURE_COMMAND ""
        BUILD_COMMAND ""
        INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${BOOST_SB_SRC}/include/ ${CMAKE_INSTALL_PREFIX}/include/
     )
    set(BOOSTLIBS)
    foreach(BOOSTLIB "REGEX" "GRAPH" "UTF")
        ExternalProject_Add(${proj}_${BOOSTLIB}
            PREFIX ${proj}/_${BOOSTLIB}
            URL ${BOOST_${BOOSTLIB}_URL}
            URL_MD5 ${BOOST_${BOOSTLIB}_URL_HASH} 
            SOURCE_DIR ${BOOST_SB_SRC}/lib
            DEPENDS ${proj}_HEADERS
            CONFIGURE_COMMAND ""
            BUILD_COMMAND ""
            INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${BOOST_SB_SRC}/lib ${CMAKE_INSTALL_PREFIX}/lib
        )
    list(APPEND BOOSTLIBS ${proj}_${BOOSTLIB})
    endforeach()
    
108 109 110 111 112 113 114 115 116
    ExternalProject_Add(${proj}
      PREFIX ${proj}
      DOWNLOAD_COMMAND ""
      SOURCE_DIR ${BOOST_SB_SRC}
      DEPENDS ${BOOSTLIBS}
      CONFIGURE_COMMAND ""
      BUILD_COMMAND ""
      INSTALL_COMMAND ""
    )
117

118 119 120
    message(STATUS "  Using Boost SuperBuild version (prebuilt binaries)")
    
  endif() #end else MSVC
121
  
122
endif()