From 36ba9ec8a3ed38554f06ce9a3e3aac2eeef06772 Mon Sep 17 00:00:00 2001 From: Matthew Parno Date: Tue, 16 Aug 2022 13:54:32 -0400 Subject: [PATCH] Allowed for separation of python installation path to support conda package. --- CMakeLists.txt | 4 ++++ bindings/python/CMakeLists.txt | 4 ++-- cmake/SetInstallPaths.cmake | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 cmake/SetInstallPaths.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 71709872..50e5f648 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ option(MPART_MATLAB "Build matlab bindings with pybind11" ON) option(MPART_JULIA "Build julia bindings with CxxWrap.jl" ON) option(MPART_FETCH_DEPS "If CMake should be allowed to fetch and build external dependencies that weren't found." ON) +############################################################## +# Installation path configuration +Include(SetInstallPaths) + ############################################################## # Compiler configuration diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index e2a7f630..2b9f4b5f 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -17,5 +17,5 @@ pybind11_add_module(pympart SHARED NO_EXTRAS ${PYTHON_BINDING_SOURCES}) target_link_libraries(pympart PRIVATE mpart Kokkos::kokkos Eigen3::Eigen) # Add an installation target for the python bindings -install(TARGETS pympart DESTINATION python/mpart) -install(DIRECTORY package/ DESTINATION python/mpart) \ No newline at end of file +install(TARGETS pympart DESTINATION "${PYTHON_INSTALL_PREFIX}/mpart") +install(DIRECTORY package/ DESTINATION "${PYTHON_INSTALL_PREFIX}/mpart") \ No newline at end of file diff --git a/cmake/SetInstallPaths.cmake b/cmake/SetInstallPaths.cmake new file mode 100644 index 00000000..1e5d6b2e --- /dev/null +++ b/cmake/SetInstallPaths.cmake @@ -0,0 +1,10 @@ + + +if(PYTHON_INSTALL_PREFIX) + message(STATUS "PYTHON_INSTALL_PREFIX was set by user to be ${PYTHON_INSTALL_PREFIX}.") +else() + message(STATUS "PYTHON_INSTALL_PREFIX was not set by user, defaulting to CMAKE_INSTALL_PREFIX/python.") + set(PYTHON_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/python) +endif() + +message(STATUS "Python packages will be installed to ${PYTHON_INSTALL_PREFIX}.")