Skip to content

Commit ca8c4af

Browse files
committed
fix python binary module install paths and rpaths
1 parent b196a53 commit ca8c4af

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

co_sim_io/python/CMakeLists.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ pybind11_add_module(PyCoSimIO co_sim_io_python.cpp)
88
target_link_libraries( PyCoSimIO PRIVATE co_sim_io )
99

1010
if (WIN32)
11-
set(CoSimIOPythonModuleRelativeDir "${CMAKE_INSTALL_PREFIX}/bin/CoSimIO")
11+
set(CoSimIOPythonModuleRelativeDir "bin/CoSimIO")
1212
else()
13-
set(CoSimIOPythonModuleRelativeDir "${CMAKE_INSTALL_PREFIX}/libs/CoSimIO")
13+
set(CoSimIOPythonModuleRelativeDir "libs/CoSimIO")
1414
endif()
1515
set(CoSimIOPythonModuleDir "${CMAKE_INSTALL_PREFIX}/${CoSimIOPythonModuleRelativeDir}")
1616

1717
install(TARGETS PyCoSimIO
18-
LIBRARY DESTINATION "${CoSimIOPythonModuleRelativeDir}"
19-
ARCHIVE DESTINATION "${CoSimIOPythonModuleRelativeDir}"
20-
RUNTIME DESTINATION "${CoSimIOPythonModuleRelativeDir}")
21-
set_target_properties(PyCoSimIO PROPERTIES INSTALL_RPATH "$ORIGIN/..")
18+
LIBRARY DESTINATION libs
19+
ARCHIVE DESTINATION libs
20+
RUNTIME DESTINATION bin)
21+
set_target_properties(PyCoSimIO PROPERTIES INSTALL_RPATH "$ORIGIN")
2222

2323
set(CoSimIOInitFile "${CoSimIOPythonModuleDir}/__init__.py")
2424
set(CoSimIOMPIInitFile "${CoSimIOPythonModuleDir}/mpi/__init__.py")
@@ -28,25 +28,31 @@ file(WRITE "${CoSimIOInitFile}" "from PyCoSimIO import *\nfrom PyCoSimIO import
2828

2929
# dummy init files that give proper errors in case something related to MPI was not compiled
3030
# These files will be overwritten if the corresponding option is enabled, hence here we can write then unconditionally
31-
file(WRITE ${CoSimIOMPIInitFile} "raise Exception('CoSimIO was compiled without MPI support! (use \"CO_SIM_IO_BUILD_MPI\" to enable it)')\n")
32-
file(WRITE ${mpi4pyInterfaceInitFile} "raise Exception('The mpi4py interface was not compiled! (use \"CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE\" to enable it)')\n")
31+
file(WRITE "${CoSimIOMPIInitFile}" "raise Exception('CoSimIO was compiled without MPI support! (use \"CO_SIM_IO_BUILD_MPI\" to enable it)')\n")
32+
file(WRITE "${mpi4pyInterfaceInitFile}" "raise Exception('The mpi4py interface was not compiled! (use \"CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE\" to enable it)')\n")
3333

3434
if (CO_SIM_IO_BUILD_MPI)
3535
pybind11_add_module(PyCoSimIOMPI co_sim_io_python_mpi.cpp)
3636

3737
target_link_libraries( PyCoSimIOMPI PRIVATE co_sim_io co_sim_io_mpi )
3838

39-
install(TARGETS PyCoSimIOMPI DESTINATION bin)
39+
install(TARGETS PyCoSimIOMPI
40+
LIBRARY DESTINATION libs
41+
ARCHIVE DESTINATION libs
42+
RUNTIME DESTINATION bin)
4043
set_target_properties(PyCoSimIOMPI PROPERTIES INSTALL_RPATH "$ORIGIN")
41-
file(WRITE ${CoSimIOMPIInitFile} "from PyCoSimIOMPI import *\n")
44+
file(WRITE "${CoSimIOMPIInitFile}" "from PyCoSimIOMPI import *\n")
4245

4346
OPTION ( CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE "Building the interface to mpi4py MPI communicators" OFF )
4447
if (CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE)
4548
message("Building the interface to mpi4py MPI communicators")
4649
pybind11_add_module(PyCoSimIOMPI_mpi4pyInterface mpi4py_interface.cpp)
4750
target_link_libraries( PyCoSimIOMPI_mpi4pyInterface PRIVATE ${MPI_LIBRARIES} )
48-
install(TARGETS PyCoSimIOMPI_mpi4pyInterface DESTINATION bin)
51+
install(TARGETS PyCoSimIOMPI_mpi4pyInterface
52+
LIBRARY DESTINATION libs
53+
ARCHIVE DESTINATION libs
54+
RUNTIME DESTINATION bin)
4955
set_target_properties(PyCoSimIOMPI_mpi4pyInterface PROPERTIES INSTALL_RPATH "$ORIGIN")
50-
file(WRITE ${mpi4pyInterfaceInitFile} "from PyCoSimIOMPI_mpi4pyInterface import *\n")
56+
file(WRITE "${mpi4pyInterfaceInitFile}" "from PyCoSimIOMPI_mpi4pyInterface import *\n")
5157
endif()
5258
endif()

0 commit comments

Comments
 (0)