File: CMakeLists.txt

package info (click to toggle)
psi4 1:1.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 229,808 kB
  • sloc: cpp: 416,201; python: 207,680; perl: 4,328; makefile: 384; sh: 158; csh: 6
file content (28 lines) | stat: -rw-r--r-- 1,387 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
find_package(pybind11 2.2 CONFIG QUIET)

if(${pybind11_FOUND})
    message(STATUS "${Cyan}Found pybind11${ColourReset}: ${pybind11_INCLUDE_DIR} (found version ${pybind11_VERSION})")
    add_library(pybind11_external INTERFACE)  # dummy
else()
    if(${CMAKE_INSIST_FIND_PACKAGE_pybind11})
        message(FATAL_ERROR "Suitable pybind11 could not be externally located as user insists")
    endif()

    include(ExternalProject)
    message(STATUS "Suitable pybind11 could not be located, ${Magenta}Building pybind11${ColourReset} instead.")
    ExternalProject_Add(pybind11_external
        GIT_REPOSITORY https://github.com/pybind/pybind11
        GIT_TAG v2.2.3
        UPDATE_COMMAND ""
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
                   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
                   -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}  # unused, but needs working compiler
                   -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}  # ditto
                   -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
                   -DCMAKE_CXX_STANDARD=${psi4_CXX_STANDARD}
                   -DPYBIND11_TEST=OFF
        INSTALL_COMMAND DESTDIR=${CMAKE_BINARY_DIR}/stage ${CMAKE_MAKE_PROGRAM} install)

    set(pybind11_DIR ${STAGED_INSTALL_PREFIX}/share/cmake/pybind11 CACHE PATH "path to internally built pybind11Config.cmake" FORCE)
endif()