From 0257f416b2065ad87fe73569d1e4da437893b69f Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 25 Jan 2018 14:01:57 +0100 Subject: [PATCH] [cmake] Search pybind11 if USE_SUPERBUILD=OFF Also don't install the pybind headers without superbuild --- CMakeLists.txt | 12 ++++++++++-- cmake/SuperBuild.cmake | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c1bdadf..504e4314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,12 +257,20 @@ endif (USE_GUI) ####################################################################### if (USE_PYTHON) add_definitions(-DNG_PYTHON) + find_path(PYBIND_INCLUDE_DIR pybind11/pybind11.h HINTS ${PYTHON_INCLUDE_DIR}) + if( PYBIND_INCLUDE_DIR ) + message(STATUS "Found Pybind11: ${PYBIND_INCLUDE_DIR}") + else( PYBIND_INCLUDE_DIR ) + message(FATAL_ERROR "Could NOT find pybind11!") + endif( PYBIND_INCLUDE_DIR ) include_directories(${PYBIND_INCLUDE_DIR}) include_directories(${PYTHON_INCLUDE_DIRS}) - install(DIRECTORY ${PYBIND_INCLUDE_DIR}/pybind11 DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel) - install(FILES ${PYBIND_INCLUDE_DIR}/../LICENSE DESTINATION ${NG_INSTALL_DIR_INCLUDE}/pybind11 COMPONENT netgen_devel) + if(NG_INSTALL_PYBIND) + install(DIRECTORY ${PYBIND_INCLUDE_DIR}/pybind11 DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel) + install(FILES ${PYBIND_INCLUDE_DIR}/../LICENSE DESTINATION ${NG_INSTALL_DIR_INCLUDE}/pybind11 COMPONENT netgen_devel) + endif(NG_INSTALL_PYBIND) endif (USE_PYTHON) ####################################################################### diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 40fb8d69..86daba2e 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -51,10 +51,11 @@ endif(NOT WIN32) ####################################################################### if (USE_PYTHON) find_path(PYBIND_INCLUDE_DIR pybind11/pybind11.h PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/pybind11/include NO_DEFAULT_PATH) + set(NG_INSTALL_PYBIND ON) if( NOT PYBIND_INCLUDE_DIR ) # if the pybind submodule is missing, try to initialize and update all submodules execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - find_path(PYBIND_INCLUDE_DIR pybind11/pybind11.h ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/pybind11/include) + find_path(PYBIND_INCLUDE_DIR pybind11/pybind11.h PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/pybind11/include NO_DEFAULT_PATH) endif( NOT PYBIND_INCLUDE_DIR ) if( PYBIND_INCLUDE_DIR ) message("-- Found Pybind11: ${PYBIND_INCLUDE_DIR}") @@ -64,7 +65,14 @@ if (USE_PYTHON) find_package(PythonInterp 3 REQUIRED) find_package(PythonLibs 3 REQUIRED) - set_vars(NETGEN_CMAKE_ARGS PYTHON_INCLUDE_DIRS PYTHON_LIBRARIES PYTHON_EXECUTABLE PYTHON_VERSION PYBIND_INCLUDE_DIR) + set_vars(NETGEN_CMAKE_ARGS + PYTHON_INCLUDE_DIRS + PYTHON_LIBRARIES + PYTHON_EXECUTABLE + PYTHON_VERSION + PYBIND_INCLUDE_DIR + NG_INSTALL_PYBIND + ) endif (USE_PYTHON) #######################################################################