Remove exists check for Python and make GeneratedPythonSources depend on ResInsight

This commit is contained in:
Gaute Lindkvist
2020-02-26 09:30:50 +01:00
parent cd3608149d
commit 1eafe18d41
2 changed files with 93 additions and 110 deletions

View File

@@ -536,17 +536,6 @@ if(RESINSIGHT_ENABLE_UNITY_BUILD)
endforeach(fileToExclude)
endif()
#########################################################
# Generate Script stubs and Scripting API documentation #
#########################################################
if (RESINSIGHT_ENABLE_GRPC)
add_custom_command(TARGET ResInsight POST_BUILD
BYPRODUCTS ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
COMMAND $<TARGET_FILE_DIR:ResInsight>/ResInsight ARGS --console --generate ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
COMMENT "Generating ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py"
)
endif(RESINSIGHT_ENABLE_GRPC)
#############################################################################
# Copy Dlls on MSVC
#############################################################################
@@ -616,16 +605,18 @@ foreach (FILE_TO_COPY ${RI_DLL_FILENAMES})
endif()
endforeach()
# Make sure we perform the Python code generation by having a target which ResInsight depends on
# Generate Python code in a target that is part of ALL_BUILD and depends on ResInsight
if (RESINSIGHT_ENABLE_GRPC)
set(RESINSIGHT_GRPC_PYTHON_EXECUTABLE "" CACHE FILEPATH "gRPC : Path to Python 3 executable, required to build the Python client library")
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
if (EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
add_custom_target(GeneratedPythonSources DEPENDS ${GRPC_GENERATED_PYTHON_SOURCES})
add_dependencies(ResInsight GeneratedPythonSources)
else()
message(STATUS "Error installing python code: RESINSIGHT_GRPC_PYTHON_EXECUTABLE set but ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} not found")
endif(EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
add_custom_command(OUTPUT ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
COMMAND ResInsight ARGS --console --generate ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
DEPENDS ResInsight
COMMENT "Generating ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py"
)
list(APPEND GRPC_GENERATED_PYTHON_SOURCES ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py)
add_custom_target(GeneratedPythonSources ALL DEPENDS ${GRPC_GENERATED_PYTHON_SOURCES})
add_dependencies(GeneratedPythonSources ResInsight)
else()
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not install GRPC Python code.")
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
@@ -773,7 +764,7 @@ if (RESINSIGHT_PRIVATE_INSTALL)
# install gRPC Python files
if (RESINSIGHT_ENABLE_GRPC)
message(STATUS "GRPC enabled")
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
message(STATUS "Python found")
if (RESINSIGHT_GRPC_BUNDLE_PYTHON_MODULE)
message(STATUS "Bundling Python GRPC modules")

View File

@@ -78,9 +78,9 @@ else()
endif()
# Cannot use the nice new FindPackage modules for python since that is CMake 3.12+
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
message(STATUS "Using Python ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}")
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
# Proto files
set(PROTO_FILES
@@ -121,7 +121,6 @@ foreach(proto_file ${PROTO_FILES})
)
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
if (EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
set(rips_proto_python "rips/generated/${proto_file}_pb2.py")
set(rips_grpc_python "rips/generated/${proto_file}_pb2_grpc.py")
@@ -141,9 +140,6 @@ foreach(proto_file ${PROTO_FILES})
${rips_proto_python}
${rips_grpc_python}
)
else()
message(STATUS "Error generating Python for ${rips_proto}: RESINSIGHT_GRPC_PYTHON_EXECUTABLE set but ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} not found")
endif(EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
else()
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not generate GRPC Python code.")
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
@@ -161,7 +157,6 @@ foreach(proto_file ${PROTO_FILES})
endforeach(proto_file)
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
if (EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.py.cmake
${GRPC_PYTHON_SOURCE_PATH}/rips/generated/RiaVersionInfo.py)
CONFIGURE_FILE( ${GRPC_PYTHON_SOURCE_PATH}/setup.py.cmake
@@ -229,9 +224,6 @@ if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
if (MSVC)
source_group(TREE ${GRPC_PYTHON_SOURCE_PATH} FILES ${GRPC_PYTHON_SOURCES_FULL_PATH} PREFIX "GrpcInterface\\Python")
endif(MSVC)
else()
message(STATUS "Error copying GRPC Python Code to build folder: RESINSIGHT_GRPC_PYTHON_EXECUTABLE set but ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} not found")
endif(EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
else()
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not copy grpc Python code to build folder")
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)