summaryrefslogtreecommitdiffstats
path: root/src/arrow/cpp/cmake_modules/FindBoostAlt.cmake
blob: 1771937125e4bc0acd5fbbb83c2fc7355a3c727c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

if(DEFINED ENV{BOOST_ROOT} OR DEFINED BOOST_ROOT)
  # In older versions of CMake (such as 3.2), the system paths for Boost will
  # be looked in first even if we set $BOOST_ROOT or pass -DBOOST_ROOT
  set(Boost_NO_SYSTEM_PATHS ON)
endif()

set(BoostAlt_FIND_VERSION_OPTIONS)
if(BoostAlt_FIND_VERSION)
  list(APPEND BoostAlt_FIND_VERSION_OPTIONS ${BoostAlt_FIND_VERSION})
endif()
if(BoostAlt_FIND_REQUIRED)
  list(APPEND BoostAlt_FIND_VERSION_OPTIONS REQUIRED)
endif()
if(BoostAlt_FIND_QUIETLY)
  list(APPEND BoostAlt_FIND_VERSION_OPTIONS QUIET)
endif()

if(ARROW_BOOST_USE_SHARED)
  # Find shared Boost libraries.
  set(Boost_USE_STATIC_LIBS OFF)
  set(BUILD_SHARED_LIBS_KEEP ${BUILD_SHARED_LIBS})
  set(BUILD_SHARED_LIBS ON)

  find_package(Boost ${BoostAlt_FIND_VERSION_OPTIONS} COMPONENTS system filesystem)
  set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_KEEP})
  unset(BUILD_SHARED_LIBS_KEEP)
else()
  # Find static boost headers and libs
  # TODO Differentiate here between release and debug builds
  set(Boost_USE_STATIC_LIBS ON)
  find_package(Boost ${BoostAlt_FIND_VERSION_OPTIONS} COMPONENTS system filesystem)
endif()

if(Boost_FOUND)
  set(BoostAlt_FOUND ON)
  if(MSVC_TOOLCHAIN)
    # disable autolinking in boost
    add_definitions(-DBOOST_ALL_NO_LIB)
    if(ARROW_BOOST_USE_SHARED)
      # force all boost libraries to dynamic link
      add_definitions(-DBOOST_ALL_DYN_LINK)
    endif()
  endif()
else()
  set(BoostAlt_FOUND OFF)
endif()