Skip to content
20 changes: 12 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ jobs:
if [ ${{ matrix.compiler }} = ICPX ]; then
source /opt/intel/oneapi/setvars.sh
fi
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/libs
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/libs
cd tests
# TODO delete build dir to make sure the linking etc works correctly?
python run_python_tests.py
Expand All @@ -177,8 +177,8 @@ jobs:
if [ ${{ matrix.compiler }} = ICPX ]; then
source /opt/intel/oneapi/setvars.sh
fi
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/libs
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/libs
cd tests
#TODO run the tests...
# TODO delete build dir to make sure the linking etc works correctly?
Expand Down Expand Up @@ -237,8 +237,8 @@ jobs:

- name: Running tests
run: |
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/bin
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/libs
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/libs
cd tests
# TODO delete build dir to make sure the linking etc works correctly?
python run_python_tests.py
Expand Down Expand Up @@ -335,6 +335,10 @@ jobs:
shell: cmd
run: |
set PYTHONPATH=%PYTHONPATH%;%GITHUB_WORKSPACE%/bin

@REM show what's on your PYTHONPATH
dir %GITHUB_WORKSPACE%/bin

cd tests
rem TODO delete build dir to make sure the linking etc works correctly?
python run_python_tests.py
Expand Down Expand Up @@ -369,8 +373,8 @@ jobs:

- name: Running tests (Python)
run: |
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/libs
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/libs
cd tests
# TODO delete build dir to make sure the linking etc works correctly? (Needs to be done after running CTests)
python3.8 run_python_tests.py
Expand Down
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ include(GenerateExportHeader)
generate_export_header( co_sim_io EXPORT_MACRO_NAME CO_SIM_IO_API EXPORT_FILE_NAME
${CMAKE_CURRENT_SOURCE_DIR}/co_sim_io/includes/co_sim_io_api.hpp )

install(TARGETS co_sim_io DESTINATION bin)
install(TARGETS co_sim_io
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)

if (CO_SIM_IO_BUILD_MPI)
# optionally enable communication via MPI
Expand All @@ -157,7 +161,11 @@ if (CO_SIM_IO_BUILD_MPI)

target_link_libraries(co_sim_io_mpi co_sim_io ${MPI_LIBRARIES})

install(TARGETS co_sim_io_mpi DESTINATION bin)
install(TARGETS co_sim_io_mpi
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
endif()

target_include_directories(co_sim_io PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/co_sim_io)
Expand Down
12 changes: 10 additions & 2 deletions co_sim_io/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ set_target_properties(co_sim_io_c PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)

target_link_libraries( co_sim_io_c co_sim_io )

install(TARGETS co_sim_io_c DESTINATION bin)
install(TARGETS co_sim_io_c
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)

if (CO_SIM_IO_BUILD_MPI)
add_library (co_sim_io_c_mpi SHARED co_sim_io_c_mpi.cpp)

target_link_libraries(co_sim_io_c_mpi co_sim_io_c co_sim_io_mpi)

install(TARGETS co_sim_io_c_mpi DESTINATION bin)
install(TARGETS co_sim_io_c_mpi
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
endif()
6 changes: 5 additions & 1 deletion co_sim_io/fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ add_library (co_sim_io_fortran SHARED co_sim_io.f90)

target_link_libraries( co_sim_io_fortran co_sim_io_c )

install(TARGETS co_sim_io_fortran DESTINATION bin)
install(TARGETS co_sim_io_fortran
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
41 changes: 31 additions & 10 deletions co_sim_io/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,52 @@ pybind11_add_module(PyCoSimIO co_sim_io_python.cpp)

target_link_libraries( PyCoSimIO PRIVATE co_sim_io )

install(TARGETS PyCoSimIO DESTINATION bin)
file(WRITE "${CMAKE_INSTALL_PREFIX}/bin/CoSimIO/__init__.py" "from PyCoSimIO import *\nfrom PyCoSimIO import __version__\n")
if (WIN32)
set(CoSimIOPythonModuleRelativeDir "bin/CoSimIO")
else()
set(CoSimIOPythonModuleRelativeDir "libs/CoSimIO")
endif()
set(CoSimIOPythonModuleDir "${CMAKE_INSTALL_PREFIX}/${CoSimIOPythonModuleRelativeDir}")

install(TARGETS PyCoSimIO
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin)
set_target_properties(PyCoSimIO PROPERTIES INSTALL_RPATH "$ORIGIN")

set(CoSimIOInitFile "${CoSimIOPythonModuleDir}/__init__.py")
set(CoSimIOMPIInitFile "${CoSimIOPythonModuleDir}/mpi/__init__.py")
set(mpi4pyInterfaceInitFile "${CoSimIOPythonModuleDir}/mpi/mpi4pyInterface/__init__.py")

set(CoSimIOMPIInitFile "${CMAKE_INSTALL_PREFIX}/bin/CoSimIO/mpi/__init__.py")
set(mpi4pyInterfaceInitFile "${CMAKE_INSTALL_PREFIX}/bin/CoSimIO/mpi/mpi4pyInterface/__init__.py")
file(WRITE "${CoSimIOInitFile}" "from PyCoSimIO import *\nfrom PyCoSimIO import __version__\n")

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

if (CO_SIM_IO_BUILD_MPI)
pybind11_add_module(PyCoSimIOMPI co_sim_io_python_mpi.cpp)

target_link_libraries( PyCoSimIOMPI PRIVATE co_sim_io co_sim_io_mpi )

install(TARGETS PyCoSimIOMPI DESTINATION bin)
file(WRITE ${CoSimIOMPIInitFile} "from PyCoSimIOMPI import *\n")
install(TARGETS PyCoSimIOMPI
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin)
set_target_properties(PyCoSimIOMPI PROPERTIES INSTALL_RPATH "$ORIGIN")
file(WRITE "${CoSimIOMPIInitFile}" "from PyCoSimIOMPI import *\n")

OPTION ( CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE "Building the interface to mpi4py MPI communicators" OFF )
if (CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE)
message("Building the interface to mpi4py MPI communicators")
pybind11_add_module(PyCoSimIOMPI_mpi4pyInterface mpi4py_interface.cpp)
target_link_libraries( PyCoSimIOMPI_mpi4pyInterface PRIVATE ${MPI_LIBRARIES} )
install(TARGETS PyCoSimIOMPI_mpi4pyInterface DESTINATION bin)
file(WRITE ${mpi4pyInterfaceInitFile} "from PyCoSimIOMPI_mpi4pyInterface import *\n")
install(TARGETS PyCoSimIOMPI_mpi4pyInterface
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin)
set_target_properties(PyCoSimIOMPI_mpi4pyInterface PROPERTIES INSTALL_RPATH "$ORIGIN")
file(WRITE "${mpi4pyInterfaceInitFile}" "from PyCoSimIOMPI_mpi4pyInterface import *\n")
endif()
endif()
10 changes: 10 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set_target_properties(co_sim_io_tests PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
INSTALL_RPATH "$ORIGIN/../libs"
)

doctest_discover_tests(co_sim_io_tests TEST_PREFIX "cpp_" WORKING_DIRECTORY $<TARGET_FILE_DIR:co_sim_io>)
Expand All @@ -23,6 +24,7 @@ if (CO_SIM_IO_BUILD_MPI)
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
INSTALL_RPATH "$ORIGIN/../libs"
)

doctest_discover_tests(co_sim_io_mpi_tests TEST_PREFIX "cpp_mpi_" WORKING_DIRECTORY $<TARGET_FILE_DIR:co_sim_io_mpi> TEST_EXECUTOR mpiexec TEST_EXECUTOR_ARGS -np 4)
Expand All @@ -44,6 +46,7 @@ function(add_cpp_executable TEST_SOURCE_FILE)
add_executable(${TEST_NAME} ${TEST_SOURCE_FILE})
target_link_libraries(${TEST_NAME} co_sim_io)
install(TARGETS ${TEST_NAME} DESTINATION "bin/tests_cpp")
set_target_properties(${TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../../libs")
endfunction()

file(GLOB cpp_test_files "integration_tutorials/cpp/*.cpp")
Expand Down Expand Up @@ -96,6 +99,7 @@ if (CO_SIM_IO_BUILD_MPI)
add_executable(${TEST_NAME} ${TEST_SOURCE_FILE})
target_link_libraries(${TEST_NAME} co_sim_io_mpi)
install(TARGETS ${TEST_NAME} DESTINATION "bin/tests_cpp_mpi")
set_target_properties(${TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../../libs")
endfunction()

file(GLOB cpp_mpi_test_files "integration_tutorials/cpp/mpi/*.cpp")
Expand All @@ -120,6 +124,7 @@ if(CO_SIM_IO_BUILD_C)
target_link_libraries(${TEST_NAME} co_sim_io_c)
add_test(${TEST_NAME} ${TEST_NAME})
install(TARGETS ${TEST_NAME} DESTINATION "bin/tests_c")
set_target_properties(${TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../../libs")
endfunction()

function(add_c_executable TEST_SOURCE_FILE)
Expand All @@ -129,6 +134,7 @@ if(CO_SIM_IO_BUILD_C)
add_executable(${TEST_NAME} ${TEST_SOURCE_FILE})
target_link_libraries(${TEST_NAME} co_sim_io_c)
install(TARGETS ${TEST_NAME} DESTINATION "bin/tests_c")
set_target_properties(${TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../../libs")
endfunction()

file(GLOB c_test_files
Expand Down Expand Up @@ -162,6 +168,7 @@ if(CO_SIM_IO_BUILD_C)
add_executable(${TEST_NAME} ${TEST_SOURCE_FILE})
target_link_libraries(${TEST_NAME} co_sim_io_c_mpi)
install(TARGETS ${TEST_NAME} DESTINATION "bin/tests_c_mpi")
set_target_properties(${TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../../libs")
endfunction()

function(add_c_mpi_test TEST_SOURCE_FILE)
Expand All @@ -172,6 +179,7 @@ if(CO_SIM_IO_BUILD_C)
target_link_libraries(${TEST_NAME} co_sim_io_c_mpi)
add_test(NAME ${TEST_NAME} COMMAND mpiexec -np 4 ${TEST_NAME})
install(TARGETS ${TEST_NAME} DESTINATION "bin/tests_c_mpi")
set_target_properties(${TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../../libs")
endfunction()

file(GLOB c_mpi_test_files "co_sim_io/c/mpi/*.c")
Expand Down Expand Up @@ -208,6 +216,7 @@ if(CO_SIM_IO_BUILD_FORTRAN)
target_link_libraries(${TEST_NAME} co_sim_io_fortran)
add_test(${TEST_NAME} ${TEST_NAME})
install(TARGETS ${TEST_NAME} DESTINATION "bin/tests_fortran")
set_target_properties(${TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../../libs")
endfunction()

function(add_fortran_executable TEST_SOURCE_FILE)
Expand All @@ -217,6 +226,7 @@ if(CO_SIM_IO_BUILD_FORTRAN)
add_executable(${TEST_NAME} ${TEST_SOURCE_FILE})
target_link_libraries(${TEST_NAME} co_sim_io_fortran)
install(TARGETS ${TEST_NAME} DESTINATION "bin/tests_fortran")
set_target_properties(${TEST_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../../libs")
endfunction()

file(GLOB fortran_test_files
Expand Down
Loading