• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018-2020 Peter Dimov
2# Distributed under the Boost Software License, Version 1.0.
3# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
4
5cmake_minimum_required(VERSION 3.5)
6
7if(POLICY CMP0074)
8  cmake_policy(SET CMP0074 NEW)
9endif()
10
11project(CmakeConfigPythonTest LANGUAGES CXX)
12
13include(${CMAKE_CURRENT_LIST_DIR}/../BoostVersion.cmake)
14
15find_package(PythonLibs ${USE_PYTHON_VERSION} REQUIRED)
16
17set(BOOST_HINTS)
18
19if(USE_STAGED_BOOST)
20  set(BOOST_HINTS HINTS ../../../../stage)
21endif()
22
23set(component python)
24
25if(USE_PYTHON_COMPONENT)
26
27  set(component ${USE_PYTHON_COMPONENT})
28  find_package(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS ${component} ${BOOST_HINTS})
29
30else()
31
32  # use the found Python version in case more than one Boost.Python is installed
33  set(Boost_PYTHON_VERSION ${PYTHONLIBS_VERSION_STRING})
34
35  if(USE_BOOST_PACKAGE)
36
37    find_package(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS python ${BOOST_HINTS})
38
39  else()
40
41    find_package(boost_python ${BOOST_VERSION} EXACT CONFIG REQUIRED ${BOOST_HINTS})
42
43  endif()
44endif()
45
46add_executable(main quick.cpp)
47target_link_libraries(main Boost::${component} ${PYTHON_LIBRARIES})
48target_include_directories(main PRIVATE ${PYTHON_INCLUDE_DIRS})
49
50enable_testing()
51add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
52
53add_test(main main)
54