Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to honor CMAKE_INSTALL_PREFIX when installing the python package
[simgrid.git] / CMakeLists.txt
index 981691f..10ccdbd 100644 (file)
@@ -840,8 +840,13 @@ if(enable_python)
     set_property(TARGET python-bindings
                  APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
+    if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
+      set(pybind_install_dir ${Python3_SITEARCH})
+    else()
+      string(REGEX REPLACE "^/usr/" "${CMAKE_INSTALL_PREFIX}/" pybind_install_dir ${Python3_SITEARCH})
+    endif()
     install(TARGETS python-bindings 
-           LIBRARY DESTINATION "${Python3_SITEARCH}")
+           LIBRARY DESTINATION "${pybind_install_dir}")
   else()
     message(FATAL_ERROR "Please install pybind11-dev to build the Python bindings (or disable that option).")
   endif()
@@ -946,7 +951,7 @@ endif()
 if(pybind11_FOUND)
   message("        Compile Python bindings .....: ${enable_python}")
   message("          module ....................: ${PYTHON_MODULE_PREFIX}simgrid${PYTHON_MODULE_EXTENSION}")
-  message("          install path ..............: ${Python3_SITEARCH}")
+  message("          install path ..............: ${pybind_install_dir}")
 else()
   message("        Compile Python bindings .....: OFF (disabled, or pybind11 not found)")
 endif()