Link grpc libraries statically on UNIX/Linux

This commit is contained in:
Gaute Lindkvist
2019-05-20 15:43:18 +02:00
parent 5e23bd5578
commit c4a4ceef29

View File

@@ -347,7 +347,7 @@ if (RESINSIGHT_ENABLE_GRPC)
) )
if (DEFINED GRPC_LIBRARY_DIRS) if (DEFINED GRPC_LIBRARY_DIRS)
message(STATUS "Using GRPC Library Dir: ${GRPC_LIBRARY_DIRS}") message(STATUS "Using GRPC Library Dir: ${GRPC_LIBRARY_DIRS}")
link_directories("${GRPC_LIBRARY_DIRS}") link_directories(${GRPC_LIBRARY_DIRS})
endif(DEFINED GRPC_LIBRARY_DIRS) endif(DEFINED GRPC_LIBRARY_DIRS)
endif(RESINSIGHT_ENABLE_GRPC) endif(RESINSIGHT_ENABLE_GRPC)
@@ -405,8 +405,14 @@ set( LINK_LIBRARIES
) )
if (RESINSIGHT_ENABLE_GRPC) if (RESINSIGHT_ENABLE_GRPC)
if (UNIX)
foreach(GRPC_LIBRARY ${GRPC_LIBRARIES})
list(APPEND LINK_LIBRARIES "${GRPC_LIBRARY_DIRS}/lib${GRPC_LIBRARY}.a")
endforeach()
else()
list(APPEND LINK_LIBRARIES ${GRPC_LIBRARIES}) list(APPEND LINK_LIBRARIES ${GRPC_LIBRARIES})
endif() endif()
endif()
# According to ivarun this is needed on OpenSuse, and Fedora. See: https://github.com/OPM/ResInsight/pull/7 # According to ivarun this is needed on OpenSuse, and Fedora. See: https://github.com/OPM/ResInsight/pull/7
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@@ -536,16 +542,6 @@ endforeach()
# Copy all grpc libraries and python files # Copy all grpc libraries and python files
if (RESINSIGHT_ENABLE_GRPC) if (RESINSIGHT_ENABLE_GRPC)
if(UNIX)
foreach (GRPC_LIBRARY ${GRPC_LIBRARIES})
add_custom_command(TARGET ResInsight POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${GRPC_INSTALL_PREFIX}/lib/lib${GRPC_LIBRARY}.so"
"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>"
)
endforeach(GRPC_LIBRARY ${GRPC_LIBRARIES})
endif(UNIX)
if (PYTHON_EXECUTABLE AND EXISTS ${PYTHON_EXECUTABLE}) if (PYTHON_EXECUTABLE AND EXISTS ${PYTHON_EXECUTABLE})
add_custom_target(GeneratedPythonSources DEPENDS ${GRPC_GENERATED_PYTHON_SOURCES}) add_custom_target(GeneratedPythonSources DEPENDS ${GRPC_GENERATED_PYTHON_SOURCES})
add_dependencies(ResInsight GeneratedPythonSources) add_dependencies(ResInsight GeneratedPythonSources)