Fix private linking of Python

The CMake export of Interface libraries also exports PRIVATE build
settings, which leads to build errors with non-existing include paths and .lib files for binary distributions.

Use the work-around mentioned here to circumvent this behavior:
https://gitlab.kitware.com/cmake/cmake/-/issues/15415#note_849405
This commit is contained in:
Matthias Hochsteger 2020-12-18 11:05:10 +01:00
parent 65afc44dcc
commit 94ecf8de92
8 changed files with 11 additions and 11 deletions

View File

@ -67,7 +67,7 @@ endif(USE_NUMA)
install(TARGETS ngcore DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen)
target_link_libraries(ngcore PUBLIC netgen_mpi PRIVATE netgen_python ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(ngcore PUBLIC netgen_mpi PRIVATE "$<BUILD_INTERFACE:netgen_python>" ${CMAKE_THREAD_LIBS_INIT})
install(FILES ngcore.hpp archive.hpp type_traits.hpp version.hpp ngcore_api.hpp logging.hpp
exception.hpp symboltable.hpp paje_trace.hpp utils.hpp profiler.hpp mpi_wrapper.hpp

View File

@ -11,7 +11,7 @@ if(APPLE)
set_target_properties( csg PROPERTIES SUFFIX ".so")
endif(APPLE)
target_link_libraries(csg PUBLIC mesh PRIVATE netgen_python)
target_link_libraries(csg PUBLIC mesh PRIVATE "$<BUILD_INTERFACE:netgen_python>")
if(NOT WIN32)
install( TARGETS csg ${NG_INSTALL_DIR})
endif(NOT WIN32)
@ -20,7 +20,7 @@ target_link_libraries(csg PUBLIC ngcore)
if(USE_GUI)
add_library(csgvis ${NG_LIB_TYPE} vscsg.cpp )
target_link_libraries(csgvis PRIVATE netgen_python PUBLIC ngcore)
target_link_libraries(csgvis PRIVATE "$<BUILD_INTERFACE:netgen_python>" PUBLIC ngcore)
if(NOT WIN32)
target_link_libraries(csgvis PUBLIC csg visual)
if(APPLE)

View File

@ -4,7 +4,7 @@ if(APPLE)
set_target_properties( geom2d PROPERTIES SUFFIX ".so")
endif(APPLE)
target_link_libraries(geom2d PUBLIC ngcore mesh PRIVATE netgen_python)
target_link_libraries(geom2d PUBLIC ngcore mesh PRIVATE "$<BUILD_INTERFACE:netgen_python>")
if(NOT WIN32)
install( TARGETS geom2d ${NG_INSTALL_DIR})
endif(NOT WIN32)

View File

@ -23,7 +23,7 @@ endif(APPLE)
target_link_libraries( mesh PUBLIC ngcore PRIVATE gprim la gen )
target_link_libraries( mesh PRIVATE netgen_metis netgen_python ${ZLIB_LIBRARIES} )
target_link_libraries( mesh PRIVATE netgen_metis "$<BUILD_INTERFACE:netgen_python>" ${ZLIB_LIBRARIES} )
if(NOT WIN32)
install( TARGETS mesh ${NG_INSTALL_DIR})
endif(NOT WIN32)

View File

@ -9,7 +9,7 @@ if(USE_GUI)
target_link_libraries(occvis PUBLIC ngcore)
endif(USE_GUI)
target_link_libraries(occ PUBLIC ngcore PRIVATE netgen_python)
target_link_libraries(occ PUBLIC ngcore PRIVATE "$<BUILD_INTERFACE:netgen_python>")
if(NOT WIN32)
target_link_libraries( occ PRIVATE ${OCC_LIBRARIES} )

View File

@ -8,11 +8,11 @@ if(NOT WIN32)
install( TARGETS stl ${NG_INSTALL_DIR})
endif(NOT WIN32)
target_link_libraries( stl PUBLIC ngcore PRIVATE netgen_python )
target_link_libraries( stl PUBLIC ngcore PRIVATE "$<BUILD_INTERFACE:netgen_python>" )
if(USE_GUI)
add_library(stlvis ${NG_LIB_TYPE} vsstl.cpp)
target_link_libraries(stlvis PRIVATE netgen_python PUBLIC ngcore)
target_link_libraries(stlvis PRIVATE "$<BUILD_INTERFACE:netgen_python>" PUBLIC ngcore)
if(NOT WIN32)
target_link_libraries( stlvis PUBLIC stl )
install( TARGETS stlvis ${NG_INSTALL_DIR})

View File

@ -9,7 +9,7 @@ endif(USE_GUI)
add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES})
target_link_libraries( visual PUBLIC ngcore PRIVATE netgen_python ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} )
target_link_libraries( visual PUBLIC ngcore PRIVATE "$<BUILD_INTERFACE:netgen_python>" ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} )
install( TARGETS visual ${NG_INSTALL_DIR})
install(FILES

View File

@ -47,7 +47,7 @@ if(USE_GUI)
if(WIN32)
set_target_properties( gui PROPERTIES OUTPUT_NAME libgui )
endif(WIN32)
target_link_libraries( gui PRIVATE netgen_python )
target_link_libraries( gui PRIVATE "$<BUILD_INTERFACE:netgen_python>" )
endif(USE_GUI)
@ -61,7 +61,7 @@ if(USE_PYTHON)
endif()
add_library(ngpy SHARED netgenpy.cpp)
target_link_libraries( ngpy PUBLIC nglib PRIVATE netgen_python )
target_link_libraries( ngpy PUBLIC nglib PRIVATE "$<BUILD_INTERFACE:netgen_python>" )
if(APPLE)
set_target_properties( ngpy PROPERTIES SUFFIX ".so")
elseif(WIN32)