make dynamic linking of python optional

This commit is contained in:
looooo 2019-01-14 21:37:13 +01:00
parent f7a91121a8
commit 339f8a1934
10 changed files with 37 additions and 12 deletions

View File

@ -29,6 +29,7 @@ option( USE_SPDLOG "Enable spd log logging" OFF)
option( DEBUG_LOG "Enable more debug output (may increase computation time) - only works with USE_SPDLOG=ON" OFF)
option( CHECK_RANGE "Check array range access, automatically enabled if built in debug mode" OFF)
option( BUILD_WITH_CONDA "set this to on if the library is compiled with conda-buid" OFF)
option( DYNAMIC_LINK_PYTHON "set this to OFF for static linking to python" ON)
option( USE_SUPERBUILD "use ccache" ON)

View File

@ -28,8 +28,9 @@ install(TARGETS ngcore DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen)
if(USE_PYTHON)
target_compile_definitions(ngcore PUBLIC NETGEN_PYTHON)
target_include_directories(ngcore PUBLIC ${PYTHON_INCLUDE_DIRS})
target_link_libraries(ngcore PUBLIC ${PYTHON_LIBRARIES})
if(DYNAMIC_LINK_PYTHON)
target_include_directories(ngcore PUBLIC ${PYTHON_INCLUDE_DIRS})
endif(DYNAMIC_LINK_PYTHON)
endif(USE_PYTHON)
install(FILES ngcore.hpp archive.hpp type_traits.hpp version.hpp ngcore_api.hpp logging.hpp
@ -42,7 +43,9 @@ endif(ENABLE_CPP_CORE_GUIDELINES_CHECK)
if(USE_PYTHON)
pybind11_add_module(pyngcore SHARED python_ngcore.cpp)
target_link_libraries(pyngcore PUBLIC ngcore ${PYTHON_LIBRARIES})
if(DYNAMIC_LINK_PYTHON)
target_link_libraries(pyngcore PUBLIC ngcore ${PYTHON_LIBRARIES})
endif(DYNAMIC_LINK_PYTHON)
set_target_properties(pyngcore PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/${NETGEN_PYTHON_RPATH}")
install(TARGETS pyngcore DESTINATION ${NG_INSTALL_DIR_PYTHON} COMPONENT netgen)
endif(USE_PYTHON)

View File

@ -11,7 +11,10 @@ if(APPLE)
set_target_properties( csg PROPERTIES SUFFIX ".so")
endif(APPLE)
target_link_libraries(csg PUBLIC mesh ${PYTHON_LIBRARIES})
target_link_libraries(csg PUBLIC mesh)
if(DYNAMIC_LINK_PYTHON)
target_link_libraries(csg PUBLIC ${PYTHON_LIBRARIES})
endif(DYNAMIC_LINK_PYTHON)
install( TARGETS csg ${NG_INSTALL_DIR})
target_link_libraries(csg PUBLIC ngcore)

View File

@ -4,7 +4,10 @@ if(APPLE)
set_target_properties( geom2d PROPERTIES SUFFIX ".so")
endif(APPLE)
target_link_libraries(geom2d mesh ${PYTHON_LIBRARIES})
target_link_libraries(geom2d mesh)
if(DYNAMIC_LINK_PYTHON)
target_link_libraries(geom2d ${PYTHON_LIBRARIES})
endif(DYNAMIC_LINK_PYTHON)
install( TARGETS geom2d ${NG_INSTALL_DIR})
target_link_libraries(geom2d ngcore)

View File

@ -22,8 +22,11 @@ if(APPLE)
endif(APPLE)
target_link_libraries( mesh PUBLIC ngcore PRIVATE gprim la gen )
target_link_libraries( mesh PUBLIC ${ZLIB_LIBRARIES} ${MPI_CXX_LIBRARIES} ${METIS_LIBRARY})
if(DYNAMIC_LINK_PYTHON)
target_link_libraries(mesh PUBLIC ${PYTHON_LIBRARIES})
endif(DYNAMIC_LINK_PYTHON)
target_link_libraries( mesh PUBLIC ${ZLIB_LIBRARIES} ${MPI_CXX_LIBRARIES} ${PYTHON_LIBRARIES} ${METIS_LIBRARY})
install( TARGETS mesh ${NG_INSTALL_DIR})
install(FILES

View File

@ -11,7 +11,10 @@ endif(USE_GUI)
target_link_libraries(occ PUBLIC ngcore)
if(NOT WIN32)
target_link_libraries( occ PUBLIC ${OCC_LIBRARIES} ${PYTHON_LIBRARIES})
target_link_libraries( occ PUBLIC ${OCC_LIBRARIES})
if(DYNAMIC_LINK_PYTHON)
target_link_libraries(occ PUBLIC ${PYTHON_LIBRARIES})
endif(DYNAMIC_LINK_PYTHON)
install( TARGETS occ ${NG_INSTALL_DIR})
if (USE_GUI)
target_link_libraries( occvis PUBLIC occ )

View File

@ -4,7 +4,10 @@ add_library(stl ${NG_LIB_TYPE}
)
if(NOT WIN32)
target_link_libraries( stl mesh ${PYTHON_LIBRARIES})
target_link_libraries( stl mesh )
if(DYNAMIC_LINK_PYTHON)
target_link_libraries( stl ${PYTHON_LIBRARIES})
endif(DYNAMIC_LINK_PYTHON)
install( TARGETS stl ${NG_INSTALL_DIR})
endif(NOT WIN32)

View File

@ -9,7 +9,10 @@ endif(USE_GUI)
add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES})
target_link_libraries( visual ngcore ${PYTHON_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} )
target_link_libraries( visual ngcore ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} )
if(DYNAMIC_LINK_PYTHON)
target_link_libraries( visual ${PYTHON_LIBRARIES})
endif(DYNAMIC_LINK_PYTHON)
install( TARGETS visual ${NG_INSTALL_DIR})
install(FILES

View File

@ -51,7 +51,10 @@ endif(USE_GUI)
if(USE_PYTHON)
add_library(ngpy SHARED netgenpy.cpp)
target_link_libraries( ngpy PUBLIC nglib PRIVATE ${PYTHON_LIBRARIES})
target_link_libraries( ngpy PUBLIC nglib)
if(DYNAMIC_LINK_PYTHON)
target_link_libraries(ngpy PRIVATE ${PYTHON_LIBRARIES})
endif(DYNAMIC_LINK_PYTHON)
if(APPLE)
set_target_properties( ngpy PROPERTIES SUFFIX ".so")
elseif(WIN32)

View File

@ -38,9 +38,9 @@ if(USE_OCC AND NOT WIN32)
target_link_libraries(nglib PUBLIC occ)
endif(USE_OCC AND NOT WIN32)
if(USE_PYTHON)
if(USE_PYTHON AND DYNAMIC_LINK_PYTHON)
target_link_libraries(nglib PRIVATE ${PYTHON_LIBRARIES})
endif(USE_PYTHON)
endif(USE_PYTHON AND DYNAMIC_LINK_PYTHON)
install(TARGETS nglib ${NG_INSTALL_DIR})
install(FILES nglib.h DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)