Add library directories when using the RESINSIGHT_GRPC_INSTALL_PREFIX

ResInsight target also need grpc library directories

Attempt to fix link errors
This commit is contained in:
Gaute Lindkvist 2020-11-03 14:15:37 +01:00
parent 5bf3bfde33
commit 751df1a421
2 changed files with 32 additions and 13 deletions

View File

@ -424,19 +424,28 @@ if(APPLE)
${CMAKE_CURRENT_BINARY_DIR}/Resources/ResInsight.icns)
endif()
if (RESINSIGHT_ENABLE_GRPC)
list(APPEND THIRD_PARTY_LIBRARIES ${RESINSIGHT_GRPC_LIBRARIES})
if (MSVC)
set_target_properties(ResInsight PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/NODEFAULTLIB:MSVCRTD.lib")
endif()
endif()
# ##############################################################################
# Set up libraries and dependent projects to link with
# ##############################################################################
set(LINK_LIBRARIES
Eigen3::Eigen
${OPM_LIBRARIES}
${RI_LIBRARIES}
${APP_FWK_LIBRARIES}
${VIZ_FWK_LIBRARIES}
${THIRD_PARTY_LIBRARIES}
${OPENGL_LIBRARIES}
${QT_LIBRARIES})
${QT_LIBRARIES}
${OPM_LIBRARIES}
${APP_FWK_LIBRARIES}
${VIZ_FWK_LIBRARIES}
${RI_LIBRARIES}
)
# According to ivarun this is needed on OpenSuse, and Fedora. See:
# https://github.com/OPM/ResInsight/pull/7
@ -444,6 +453,14 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND EXTERNAL_LINK_LIBRARIES rt)
endif()
if (DEFINED GRPC_LIBRARY_DIRS)
target_link_directories(ResInsight PRIVATE ${GRPC_LIBRARY_DIRS})
endif()
foreach(LIBRARY ${LINK_LIBRARIES})
message (STATUS "LIB: ${LIBRARY}")
endforeach()
target_link_libraries(ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
# ##############################################################################

View File

@ -76,7 +76,9 @@ if(Protobuf_FOUND)
set_target_properties(
${GRPC_LIBRARIES} PROPERTIES MAP_IMPORTED_CONFIG_MINSIZEREL RELEASE
MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE)
set(RESINSIGHT_GRPC_LIBRARIES ${GRPC_LIBRARIES} PARENT_SCOPE)
else()
message(STATUS "Using RESINSIGHT_GRPC_INSTALL_PREFIX=${RESINSIGHT_GRPC_INSTALL_PREFIX}")
set(RESINSIGHT_GRPC_INSTALL_PREFIX
""
CACHE PATH "gRPC : Install prefix for gRPC")
@ -89,8 +91,8 @@ else()
endif()
set(ENV{PKG_CONFIG_PATH} "${RESINSIGHT_GRPC_INSTALL_PREFIX}/lib/pkgconfig")
find_package(PkgConfig REQUIRED)
pkg_check_modules(GRPC REQUIRED grpc++_unsecure>=1.20 grpc_unsecure gpr
protobuf)
pkg_check_modules(GRPC REQUIRED grpc grpc++_unsecure>=1.20 grpc_unsecure gpr
protobuf libcares)
if(EXISTS "${RESINSIGHT_GRPC_INSTALL_PREFIX}/bin/protoc")
set(_PROTOBUF_PROTOC "${RESINSIGHT_GRPC_INSTALL_PREFIX}/bin/protoc")
elseif(EXISTS "${RESINSIGHT_GRPC_INSTALL_PREFIX}/tools/protobuf/protoc")
@ -108,11 +110,12 @@ else()
"${RESINSIGHT_GRPC_INSTALL_PREFIX}/tools/grpc/grpc_cpp_plugin")
endif()
include_directories(AFTER ${GRPC_INCLUDE_DIRS})
set(RESINSIGHT_GRPC_LIBRARIES ${GRPC_LINK_LIBRARIES} PARENT_SCOPE)
#list(APPEND RESINSIGHT_GRPC_LIBRARIES upb)
endif()
set(LINK_LIBRARIES
set(_LINK_LIBRARIES
${QT_LIBRARIES}
${GRPC_LIBRARIES}
LibCore
cafCommand
cafPdmCvf
@ -270,10 +273,9 @@ add_library(
${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
${GRPC_HEADER_FILES} ${GRPC_CPP_SOURCES})
if(RESINSIGHT_GRPC_INSTALL_PREFIX)
target_include_directories(${PROJECT_NAME} PRIVATE ${GRPC_INCLUDE_DIRS})
endif()
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARIES})
target_include_directories(${PROJECT_NAME} PUBLIC ${GRPC_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PUBLIC ${GRPC_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${_LINK_LIBRARIES})
if(MSVC)
# GRPC generates a lot of harmless warnings on MSVC