Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/pybind11/PyBindImath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,24 @@ if (IMATH_INSTALL)
# Set the PYTHON_INSTALL_DIR but only if it's not already set,
# which allows an externally-set value to take effect.
#

set(PYTHON_INSTALL_DIR "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages")
# PYTHON_INSTALL_DIR should be a relative path underneath the
# INSTALL_DIR. Set it to Python3_SITEARCH, relative to the python
# system installation.
#

if (NOT Python3_PREFIX)
# if Python3_PREFIX is not set, use the location of the python executable
get_filename_component(Python3_PREFIX "${Python3_EXECUTABLE}" DIRECTORY)
get_filename_component(Python3_PREFIX "${Python3_PREFIX}" DIRECTORY)
endif()

# Ensure Python3_SITEARCH is absolute before computing relative path
file(REAL_PATH "${Python3_SITEARCH}" Python3_SITEARCH_ABS)

file(RELATIVE_PATH PYTHON_INSTALL_DIR
"${Python3_PREFIX}"
"${Python3_SITEARCH_ABS}")

message(STATUS "installing ${PYBINDIMATH_MODULE_NAME} to ${PYTHON_INSTALL_DIR}")

else()
Expand Down
26 changes: 26 additions & 0 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ if(NOT Boost_FOUND)
message(FATAL_ERROR "Could not find Boost")
endif()

if (NOT DEFINED PYTHON_INSTALL_DIR)

#
# Set the PYTHON_INSTALL_DIR but only if it's not already set,
# which allows an externally-set value to take effect.
#
# PYTHON_INSTALL_DIR should be a relative path underneath the
# INSTALL_DIR. Set it to Python3_SITEARCH, relative to the python
# system installation.
#

if (NOT Python3_PREFIX)
# if Python3_PREFIX is not set, use the location of the python executable
get_filename_component(Python3_PREFIX "${Python3_EXECUTABLE}" DIRECTORY)
get_filename_component(Python3_PREFIX "${Python3_PREFIX}" DIRECTORY)
endif()

# Ensure Python3_SITEARCH is an absolute path
get_filename_component(Python3_SITEARCH_ABS "${Python3_SITEARCH}" REALPATH)

file(RELATIVE_PATH PYTHON_INSTALL_DIR
"${Python3_PREFIX}"
"${Python3_SITEARCH_ABS}")

endif()

#
# Python library suffix string. By default, it includes the python
# version and Imath release number, e.g. "_Python3_12-3_4"
Expand Down
16 changes: 1 addition & 15 deletions src/python/PyImath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,8 @@ add_library(PyImath::Config ALIAS PyImathConfig)

if (IMATH_INSTALL)

if (NOT DEFINED PYTHON_INSTALL_DIR)
message(STATUS "installing ${PYIMATH_MODULE_NAME} module to ${PYTHON_INSTALL_DIR}")

#
# Set the PYTHON_INSTALL_DIR but only if it's not already set,
# which allows an externally-set value to take effect.
#

set(PYTHON_INSTALL_DIR "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages")
message(STATUS "installing ${PYIMATH_MODULE_NAME} module to ${PYTHON_INSTALL_DIR}")

else()

message(STATUS "installing ${PYIMATH_MODULE_NAME} module to ${PYTHON_INSTALL_DIR} (set externally)")

endif()

#
# Install the python module
#
Expand Down
16 changes: 1 addition & 15 deletions src/python/PyImathNumpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,7 @@ target_link_libraries(${PYIMATHNUMPY_MODULE}

if (IMATH_INSTALL)

#
# Set the PYTHON_INSTALL_DIR but only if it's not already set,
# which allows an externally-set value to take effect.
#

if (NOT DEFINED PYTHON_INSTALL_DIR)

set(PYTHON_INSTALL_DIR "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages")
message(STATUS "installing ${PYIMATHNUMPY_MODULE} module to ${PYTHON_INSTALL_DIR}")

else()

message(STATUS "installing ${PYIMATHNUMPY_MODULE} module to ${PYTHON_INSTALL_DIR} (set externally)")

endif()
message(STATUS "installing ${PYIMATHNUMPY_MODULE} module to ${PYTHON_INSTALL_DIR}")

install(TARGETS ${PYIMATHNUMPY_MODULE} LIBRARY DESTINATION ${PYTHON_INSTALL_DIR})

Expand Down