Interface target for OpenCascade libraries

This commit is contained in:
Matthias Hochsteger 2023-09-14 11:39:07 +02:00
parent 291a5e4aa6
commit f1ec19b35b
2 changed files with 17 additions and 8 deletions

View File

@ -356,6 +356,7 @@ endif (USE_MPI)
install(TARGETS netgen_mpi netgen_metis ${NG_INSTALL_DIR})
#######################################################################
add_library(occ_libs INTERFACE IMPORTED)
if (USE_OCC)
find_package(OpenCascade NAMES OpenCASCADE opencascade REQUIRED CMAKE_FIND_ROOT_PATH_BOTH)
add_definitions(-DOCCGEOMETRY)
@ -393,30 +394,38 @@ if (USE_OCC)
TKXSBase
TKernel
)
foreach(LIB_NAME ${OCC_LIBRARIES})
set(LIB_VAR "LIB_${LIB_NAME}")
find_library(${LIB_VAR} ${LIB_NAME} NO_DEFAULT_PATH HINTS ${OpenCASCADE_LIBRARY_DIR})
target_link_libraries(occ_libs INTERFACE ${${LIB_VAR}})
endforeach()
include_directories(${OpenCASCADE_INCLUDE_DIR})
if(NOT OpenCASCADE_BUILD_SHARED_LIBS)
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
target_link_libraries(occ_libs INTERFACE -Wl,--start-group)
endif()
if(OpenCASCADE_WITH_FREETYPE)
find_library( FREETYPE NAMES freetype HINTS ${OpenCASCADE_INSTALL_PREFIX}/lib)
find_library( FREETYPE NAMES freetype HINTS ${OpenCASCADE_LIBRARY_DIR})
list(APPEND OCC_LIBRARIES ${FREETYPE})
target_link_libraries(occ_libs INTERFACE ${FREETYPE})
if(UNIX AND NOT APPLE)
find_package(Fontconfig REQUIRED)
list(APPEND OCC_LIBRARIES ${Fontconfig_LIBRARIES})
target_link_libraries(occ_libs INTERFACE ${Fontconfig_LIBRARIES})
endif()
endif(OpenCASCADE_WITH_FREETYPE)
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
list(APPEND OCC_LIBRARIES Threads::Threads)
list(PREPEND OCC_LIBRARIES -Wl,--start-group)
list(APPEND OCC_LIBRARIES -Wl,--end-group)
target_link_libraries(occ_libs INTERFACE Threads::Threads)
target_link_libraries(occ_libs INTERFACE -Wl,--end-group)
endif()
if(WIN32)
list(APPEND OCC_LIBRARIES Ws2_32.lib)
target_link_libraries(occ_libs INTERFACE Threads::Threads)
endif()
endif()
message(STATUS "OCC DIRS ${OpenCASCADE_INCLUDE_DIR}")
if(WIN32 AND USE_GUI)
target_link_libraries(nggui PRIVATE ${OCC_LIBRARIES})
target_link_libraries(nggui PRIVATE occ_libs)
endif(WIN32 AND USE_GUI)
endif (USE_OCC)

View File

@ -13,7 +13,7 @@ else(EMSCRIPTEN)
target_link_libraries(nglib PUBLIC ngcore)
endif(EMSCRIPTEN)
target_link_libraries( nglib PRIVATE ${MPI_CXX_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} netgen_cgns )
target_link_libraries( nglib PRIVATE ${MPI_CXX_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} occ_libs netgen_cgns )
install(TARGETS nglib netgen_cgns ${NG_INSTALL_DIR})
install(FILES nglib.h DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)