CMakeLists.txt 1.6 KB
Newer Older
1
2
3
4
# waLBerla Python module


if ( WALBERLA_BUILD_WITH_PYTHON_MODULE )
5
6
7
8
9
10

    set(PYTHON_MODULE_DEPENDENCIES blockforest boundary domain_decomposition core field geometry lbm postprocessing python_coupling timeloop vtk)
    if (WALBERLA_BUILD_WITH_CUDA)
        set(PYTHON_MODULE_DEPENDENCIES ${PYTHON_MODULE_DEPENDENCIES} cuda)
    endif()

11
    if( WALBERLA_CXX_COMPILER_IS_MSVC )
12
       set ( pythonModules ${PYTHON_MODULE_DEPENDENCIES})
13
    elseif( APPLE )
14
       set ( pythonModules "-Wl,-force_load" ${PYTHON_MODULE_DEPENDENCIES})
15
    else()
16
       set ( pythonModules "-Wl,-whole-archive" ${PYTHON_MODULE_DEPENDENCIES}  "-Wl,-no-whole-archive" )
17
18
    endif()

Martin Bauer's avatar
Martin Bauer committed
19
20
21
22
23
    if( WALBERLA_BUILD_WITH_PYTHON_LBM )
        add_library( walberla_cpp SHARED PythonModuleWithLbmModule.cpp )
    else()
        add_library( walberla_cpp SHARED PythonModule.cpp )
    endif()
24
25
26
27
28
29
30
31
32
33

    target_link_libraries( walberla_cpp ${pythonModules} ${SERVICE_LIBS}  )
    set_target_properties( walberla_cpp PROPERTIES PREFIX "")
    if ( APPLE )
       set_target_properties( walberla_cpp PROPERTIES SUFFIX ".so")
    endif()
    set_target_properties( walberla_cpp PROPERTIES MACOSX_RPATH TRUE )

    configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/setup.py  ${CMAKE_CURRENT_BINARY_DIR}/setup.py )

Martin Bauer's avatar
Martin Bauer committed
34
35
    add_custom_target( pythonModule        ALL ${PYTHON_EXECUTABLE} setup.py build   DEPENDS walberla_cpp )
    add_custom_target( pythonModuleInstall     ${PYTHON_EXECUTABLE} setup.py install DEPENDS walberla_cpp )
36
37

    add_test( NAME PythonModuleTest
Martin Bauer's avatar
Martin Bauer committed
38
              COMMAND ${PYTHON_EXECUTABLE} -m unittest discover -v -s ${walberla_SOURCE_DIR}/python/waLBerla_tests )
39
endif()