File: CGAL_SetupBoost.cmake

package info (click to toggle)
cgal 6.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,952 kB
  • sloc: cpp: 811,597; ansic: 208,576; sh: 493; python: 411; makefile: 286; javascript: 174
file content (67 lines) | stat: -rw-r--r-- 1,947 bytes parent folder | download
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
64
65
66
67
#.rst:
# CGAL_SetupBoost
# ---------------
#
# The module searches for the `Boost` headers and library, by calling
#
# .. code-block:: cmake
#
#    find_package(Boost)
#
# and defines the function :command:`use_CGAL_Boost_support`.

include_guard(GLOBAL)
include(${CMAKE_CURRENT_LIST_DIR}/CGAL_TweakFindBoost.cmake)

cmake_policy(VERSION 3.12...3.30)
find_package( Boost 1.74 REQUIRED )

if(Boost_FOUND AND Boost_VERSION VERSION_LESS 1.74)
  if(DEFINED Boost_DIR AND NOT Boost_DIR)
    # Unset that cache variable that is set in the cache by FindBoost
    # (while it was searching for boost-cmake).
    unset(Boost_DIR CACHE)
    set(Boost_NO_BOOST_CMAKE TRUE CACHE INTERNAL "Avoid future search of boost-cmake")
  endif()
endif()

message( STATUS "Boost include dirs: ${Boost_INCLUDE_DIRS}" )
message( STATUS "Boost libraries:    ${Boost_LIBRARIES}" )

set ( CGAL_USE_BOOST 1 )


#.rst:
# Provided Functions
# ^^^^^^^^^^^^^^^^^^
#
# .. command:: use_CGAL_Boost_support
#
#    Link the target with the `Boost` libraries::
#
#      use_CGAL_Boost_support( target [INTERFACE] )
#
#    If the option ``INTERFACE`` is passed, the dependencies are
#    added using :command:`target_link_libraries` with the ``INTERFACE``
#    keyword, or ``PUBLIC`` otherwise.

function(use_CGAL_Boost_support target)
  if(ARGV1 STREQUAL INTERFACE)
    set(keyword INTERFACE)
  else()
    set(keyword PUBLIC)
  endif()
  if(NOT Boost_FOUND)
    message(FATAL_ERROR "use_CGAL_Boost_support is use whereas Boost_FOUND is false.")
    return()
  endif()
  if(NOT CGAL_Boost_USE_STATIC_LIBS AND CGAL_AUTO_LINK_ENABLED)
    target_compile_definitions(${target} ${keyword} BOOST_ALL_DYN_LINK=1)
  endif()
  if(TARGET Boost::boost)
    target_link_libraries(${target} ${keyword} Boost::boost)
  else()
    target_include_directories(${target} SYSTEM ${keyword} ${Boost_INCLUDE_DIRS})
    target_link_libraries(${target} ${keyword} ${Boost_LIBRARIES})
  endif()
endfunction()