diff --git a/CMakeLists.txt b/CMakeLists.txt index ec6ba1e4..4ad86305 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,15 @@ if(NOT IS_SUBPROJECT) message(STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------") endif() +# Python Support +option(PythonSupport "Build with Python support" ON) +if(PythonSupport AND NOT TRIQS_WITH_PYTHON_SUPPORT) + message(FATAL_ERROR "TRIQS was installed without Python support. Cannot build the Python Interface. Disable the build with -DPythonSupport=OFF") +endif() + +# Documentation +option(Build_Documentation "Build documentation" OFF) + # Testing option(Build_Tests "Build tests" ON) if(Build_Tests) @@ -116,28 +125,19 @@ if(Build_Tests) add_subdirectory(test) endif() -if(TRIQS_WITH_PYTHON_SUPPORT) - # Python interface +# Python +if(PythonSupport) add_subdirectory(python/app4triqs) +endif() - # Build the documentation - option(Build_Documentation "Build documentation" OFF) - if(Build_Documentation AND NOT IS_SUBPROJECT) - if(NOT TRIQS_WITH_DOCUMENTATION) - message(WARNING "TRIQS was installed without documentation! Cannot build documentation.") - else() - message(STATUS "Documentation Build enabled") - add_subdirectory(doc) - endif() - endif() -else() - message(WARNING "TRIQS was installed without Python support. Cannot build the Python Interface and Documentation.") +# Docs +if(Build_Documentation) + add_subdirectory(doc) endif() # Additional configuration files add_subdirectory(share) - # ############# # Debian Package @@ -156,4 +156,3 @@ if(BUILD_DEBIAN_PACKAGE AND NOT IS_SUBPROJECT) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) include(CPack) endif() - diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 5dc4e9dc..fc016f80 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -54,10 +54,12 @@ external_dependency(GTest EXCLUDE_FROM_ALL ) -# -- Cpp2Py -- -external_dependency(Cpp2Py - GIT_REPO https://github.com/TRIQS/cpp2py - VERSION 2.0 - GIT_TAG master - EXCLUDE_FROM_ALL -) +if(PythonSupport OR Build_Documentation) + # -- Cpp2Py -- + external_dependency(Cpp2Py + GIT_REPO https://github.com/TRIQS/cpp2py + VERSION 2.0 + GIT_TAG master + EXCLUDE_FROM_ALL + ) +endif() \ No newline at end of file diff --git a/deps/external_dependency.cmake b/deps/external_dependency.cmake index 8487fdc4..186a15ea 100644 --- a/deps/external_dependency.cmake +++ b/deps/external_dependency.cmake @@ -46,6 +46,7 @@ function(external_dependency) if(ARG_EXCLUDE_FROM_ALL) set(subdir_opts EXCLUDE_FROM_ALL) set(Build_Tests OFF) + set(Build_Documentation OFF) endif() if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}) message(STATUS "Found sources for dependency ${ARGV0} at ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 0d2f596b..358e9aa2 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -2,6 +2,12 @@ add_subdirectory(cmake) if(NOT CMAKE_INSTALL_PREFIX STREQUAL TRIQS_ROOT AND NOT IS_SUBPROJECT) + if(PythonSupport) + set(EXPORT_PYTHON_PATH "export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${CPP2PY_PYTHON_LIB_DEST_ROOT}:$PYTHONPATH") + set(MODFILE_PYTHON_PATH "prepend-path PYTHONPATH $root/${CPP2PY_PYTHON_LIB_DEST_ROOT}") + + endif() + configure_file(app4triqs.modulefile.in app4triqs.modulefile @ONLY) configure_file(app4triqsvars.sh.in app4triqsvars.sh @ONLY) diff --git a/share/app4triqs.modulefile.in b/share/app4triqs.modulefile.in index ee0ffd00..d90ae7b1 100644 --- a/share/app4triqs.modulefile.in +++ b/share/app4triqs.modulefile.in @@ -35,5 +35,5 @@ prepend-path PATH $root/bin prepend-path CPLUS_INCLUDE_PATH $root/include prepend-path LIBRARY_PATH $root/lib prepend-path LD_LIBRARY_PATH $root/lib -prepend-path PYTHONPATH $root/@TRIQS_PYTHON_LIB_DEST_ROOT@ prepend-path CMAKE_PREFIX_PATH $root/lib/cmake/app4triqs +@MODFILE_PYTHON_PATH@ diff --git a/share/app4triqsvars.sh.in b/share/app4triqsvars.sh.in index 6c41747e..c4d1987f 100644 --- a/share/app4triqsvars.sh.in +++ b/share/app4triqsvars.sh.in @@ -6,5 +6,5 @@ export CPLUS_INCLUDE_PATH=@CMAKE_INSTALL_PREFIX@/include:$CPLUS_INCLUDE_PATH export PATH=@CMAKE_INSTALL_PREFIX@/bin:$PATH export LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:$LIBRARY_PATH export LD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:$LD_LIBRARY_PATH -export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/@CPP2PY_PYTHON_LIB_DEST_ROOT@:$PYTHONPATH export CMAKE_PREFIX_PATH=@CMAKE_INSTALL_PREFIX@:$CMAKE_PREFIX_PATH +@EXPORT_PYTHON_PATH@ diff --git a/share/cmake/app4triqs-config.cmake.in b/share/cmake/app4triqs-config.cmake.in index 6837f5c1..4a7f1629 100644 --- a/share/cmake/app4triqs-config.cmake.in +++ b/share/cmake/app4triqs-config.cmake.in @@ -25,4 +25,7 @@ message(STATUS "Found app4triqs-config.cmake with version @PROJECT_VERSION@, has # Was the Project built with Documentation? set(APP4TRIQS_WITH_DOCUMENTATION @Build_Documentation@) +# Was the Project built with PythonSupport? +set(APP4TRIQS_WITH_PYTHON_SUPPORT @PythonSupport@) + endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 51d3086f..e79313ff 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory(c++) -if(${TRIQS_WITH_PYTHON_SUPPORT}) +if(PythonSupport) add_subdirectory(python) endif()