mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
Make CMake-setup for python sources work
This commit is contained in:
parent
80bae6df45
commit
861577922a
@ -355,22 +355,24 @@ endforeach()
|
|||||||
# Generate Python code in a target that is part of ALL_BUILD and depends on
|
# Generate Python code in a target that is part of ALL_BUILD and depends on
|
||||||
# ResInsight
|
# ResInsight
|
||||||
if(RESINSIGHT_ENABLE_GRPC)
|
if(RESINSIGHT_ENABLE_GRPC)
|
||||||
|
set(GENERATED_CLASSES_FILE ${CMAKE_SOURCE_DIR}/GrpcInterface/Python/rips/generated/resinsight_classes.py)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT
|
OUTPUT
|
||||||
${CMAKE_SOURCE_DIR}/GrpcInterface/Python/rips/generated/resinsight_classes.py
|
${GENERATED_CLASSES_FILE}
|
||||||
COMMAND
|
COMMAND
|
||||||
ResInsight ARGS --console --generate
|
ResInsight ARGS --console --generate
|
||||||
${CMAKE_SOURCE_DIR}/GrpcInterface/Python/rips/generated/resinsight_classes.py
|
${GENERATED_CLASSES_FILE}
|
||||||
DEPENDS ResInsight
|
DEPENDS ResInsight
|
||||||
COMMENT
|
COMMENT
|
||||||
"Generating ${CMAKE_SOURCE_DIR}/GrpcInterface/Python/rips/generated/resinsight_classes.py"
|
"Generating ${GENERATED_CLASSES_FILE}"
|
||||||
)
|
)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
ResInsightPythonClasses ALL
|
RipsGeneratedPythonClasses ALL
|
||||||
DEPENDS
|
SOURCES
|
||||||
${CMAKE_SOURCE_DIR}/GrpcInterface/Python/rips/generated/resinsight_classes.py
|
${GENERATED_CLASSES_FILE}
|
||||||
)
|
)
|
||||||
add_dependencies(ResInsightPythonClasses ResInsight)
|
source_group("Source Files" ${GENERATED_CLASSES_FILE})
|
||||||
|
add_dependencies(RipsGeneratedPythonClasses ResInsight)
|
||||||
|
|
||||||
endif(RESINSIGHT_ENABLE_GRPC)
|
endif(RESINSIGHT_ENABLE_GRPC)
|
||||||
|
|
||||||
|
@ -135,17 +135,7 @@ set(_LINK_LIBRARIES
|
|||||||
ApplicationLibCode)
|
ApplicationLibCode)
|
||||||
|
|
||||||
# Proto files
|
# Proto files
|
||||||
set(PROTO_FILES
|
file(GLOB GRPC_PROTO_FILES GrpcProtos/*.proto)
|
||||||
"Definitions"
|
|
||||||
"PdmObject"
|
|
||||||
"Case"
|
|
||||||
"SimulationWell"
|
|
||||||
"Project"
|
|
||||||
"Commands"
|
|
||||||
"NNCProperties"
|
|
||||||
"App"
|
|
||||||
"Properties"
|
|
||||||
"Grid")
|
|
||||||
|
|
||||||
set(GRPC_PYTHON_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Python")
|
set(GRPC_PYTHON_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Python")
|
||||||
|
|
||||||
@ -157,18 +147,15 @@ else()
|
|||||||
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not install Python client code")
|
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not install Python client code")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
foreach(proto_file ${PROTO_FILES})
|
foreach(rips_proto ${GRPC_PROTO_FILES})
|
||||||
get_filename_component(
|
get_filename_component(rips_proto_name ${rips_proto} NAME_WE)
|
||||||
rips_proto "GrpcProtos/${proto_file}.proto"
|
get_filename_component(rips_proto_path ${rips_proto} PATH)
|
||||||
ABSOLUTE)
|
|
||||||
get_filename_component(rips_proto_path "${rips_proto}" PATH)
|
|
||||||
|
|
||||||
list(APPEND GRPC_PROTO_FILES_FULL_PATH ${rips_proto})
|
|
||||||
|
|
||||||
set(rips_proto_srcs "${CMAKE_BINARY_DIR}/Generated/${proto_file}.pb.cc")
|
set(rips_proto_srcs "${CMAKE_BINARY_DIR}/Generated/${rips_proto_name}.pb.cc")
|
||||||
set(rips_proto_hdrs "${CMAKE_BINARY_DIR}/Generated/${proto_file}.pb.h")
|
set(rips_proto_hdrs "${CMAKE_BINARY_DIR}/Generated/${rips_proto_name}.pb.h")
|
||||||
set(rips_grpc_srcs "${CMAKE_BINARY_DIR}/Generated/${proto_file}.grpc.pb.cc")
|
set(rips_grpc_srcs "${CMAKE_BINARY_DIR}/Generated/${rips_proto_name}.grpc.pb.cc")
|
||||||
set(rips_grpc_hdrs "${CMAKE_BINARY_DIR}/Generated/${proto_file}.grpc.pb.h")
|
set(rips_grpc_hdrs "${CMAKE_BINARY_DIR}/Generated/${rips_proto_name}.grpc.pb.h")
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${rips_proto_srcs}" "${rips_proto_hdrs}" "${rips_grpc_srcs}"
|
OUTPUT "${rips_proto_srcs}" "${rips_proto_hdrs}" "${rips_grpc_srcs}"
|
||||||
@ -179,8 +166,8 @@ foreach(proto_file ${PROTO_FILES})
|
|||||||
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" "${rips_proto}"
|
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" "${rips_proto}"
|
||||||
DEPENDS "${rips_proto}")
|
DEPENDS "${rips_proto}")
|
||||||
|
|
||||||
set(rips_proto_python "rips/generated/${proto_file}_pb2.py")
|
set(rips_proto_python "rips/generated/${rips_proto_name}_pb2.py")
|
||||||
set(rips_grpc_python "rips/generated/${proto_file}_pb2_grpc.py")
|
set(rips_grpc_python "rips/generated/${rips_proto_name}_pb2_grpc.py")
|
||||||
|
|
||||||
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
@ -194,15 +181,14 @@ foreach(proto_file ${PROTO_FILES})
|
|||||||
DEPENDS "${rips_proto}"
|
DEPENDS "${rips_proto}"
|
||||||
COMMENT "Generating ${rips_proto_python} and ${rips_grpc_python}"
|
COMMENT "Generating ${rips_proto_python} and ${rips_grpc_python}"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
list(APPEND GRPC_PYTHON_GENERATED_SOURCES ${rips_proto_python}
|
list(APPEND GRPC_PYTHON_GENERATED_SOURCES "${GRPC_PYTHON_SOURCE_PATH}/${rips_grpc_python}")
|
||||||
${rips_grpc_python})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND GRPC_HEADER_FILES ${rips_proto_hdrs} ${rips_grpc_hdrs})
|
list(APPEND GRPC_HEADER_FILES ${rips_proto_hdrs} ${rips_grpc_hdrs})
|
||||||
|
|
||||||
list(APPEND GRPC_CPP_SOURCES ${rips_proto_srcs} ${rips_grpc_srcs})
|
list(APPEND GRPC_CPP_SOURCES ${rips_proto_srcs} ${rips_grpc_srcs})
|
||||||
|
|
||||||
endforeach(proto_file)
|
endforeach(rips_proto)
|
||||||
|
|
||||||
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/ApplicationLibCode/Adm/RiaVersionInfo.py.cmake
|
configure_file(${CMAKE_SOURCE_DIR}/ApplicationLibCode/Adm/RiaVersionInfo.py.cmake
|
||||||
@ -211,69 +197,25 @@ if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
|||||||
${GRPC_PYTHON_SOURCE_PATH}/setup.py)
|
${GRPC_PYTHON_SOURCE_PATH}/setup.py)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
list (APPEND GRPC_PYTHON_GENERATED_SOURCES ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/RiaVersionInfo.py)
|
||||||
|
|
||||||
|
file(GLOB GRPC_PYTHON_RIPS_SOURCES ${GRPC_PYTHON_SOURCE_PATH}/rips/*.py)
|
||||||
|
file(GLOB GRPC_PYTHON_EXAMPLE_SOURCES ${GRPC_PYTHON_SOURCE_PATH}/rips/PythonExamples/*.py)
|
||||||
|
file(GLOB GRPC_PYTHON_TEST_SOURCES ${GRPC_PYTHON_SOURCE_PATH}/rips/tests/*.py)
|
||||||
|
file(GLOB GRPC_PYTHON_OTHER_FILES "${GRPC_PYTHON_SOURCE_PATH}/setup.py" "${GRPC_PYTHON_SOURCE_PATH}/requirements.txt" "${GRPC_PYTHON_SOURCE_PATH}/README.md" "${GRPC_PYTHON_SOURCE_PATH}/LICENSE")
|
||||||
|
|
||||||
list(
|
list(
|
||||||
APPEND
|
APPEND
|
||||||
GRPC_PYTHON_SOURCES
|
GRPC_PYTHON_SOURCES
|
||||||
"rips/generated/RiaVersionInfo.py"
|
${GRPC_PYTHON_RIPS_SOURCES}
|
||||||
"rips/__init__.py"
|
${GRPC_PYTHON_EXAMPLE_SOURCES}
|
||||||
"rips/case.py"
|
${GRPC_PYTHON_TEST_SOURCES}
|
||||||
"rips/contour_map.py"
|
${GRPC_PYTHON_OTHER_FILES}
|
||||||
"rips/grid.py"
|
${GRPC_PROTO_FILES}
|
||||||
"rips/gridcasegroup.py"
|
)
|
||||||
"rips/instance.py"
|
|
||||||
"rips/pdmobject.py"
|
|
||||||
"rips/plot.py"
|
|
||||||
"rips/project.py"
|
|
||||||
"rips/simulation_well.py"
|
|
||||||
"rips/view.py"
|
|
||||||
"rips/well_log_plot.py"
|
|
||||||
"rips/PythonExamples/instance_example.py"
|
|
||||||
"rips/PythonExamples/command_example.py"
|
|
||||||
"rips/PythonExamples/case_grid_group.py"
|
|
||||||
"rips/PythonExamples/case_info_streaming_example.py"
|
|
||||||
"rips/PythonExamples/create_wbs_plot.py"
|
|
||||||
"rips/PythonExamples/export_plots.py"
|
|
||||||
"rips/PythonExamples/export_snapshots.py"
|
|
||||||
"rips/PythonExamples/error_handling.py"
|
|
||||||
"rips/PythonExamples/import_well_paths_and_logs.py"
|
|
||||||
"rips/PythonExamples/soil_porv_async.py"
|
|
||||||
"rips/PythonExamples/soil_porv_sync.py"
|
|
||||||
"rips/PythonExamples/selected_cases.py"
|
|
||||||
"rips/PythonExamples/all_cases.py"
|
|
||||||
"rips/PythonExamples/replace_case.py"
|
|
||||||
"rips/PythonExamples/set_grid_properties.py"
|
|
||||||
"rips/PythonExamples/set_cell_result.py"
|
|
||||||
"rips/PythonExamples/set_flow_diagnostics_result.py"
|
|
||||||
"rips/PythonExamples/grid_information.py"
|
|
||||||
"rips/PythonExamples/input_prop_test_sync.py"
|
|
||||||
"rips/PythonExamples/input_prop_test_async.py"
|
|
||||||
"rips/PythonExamples/soil_average_async.py"
|
|
||||||
"rips/PythonExamples/soil_average_sync.py"
|
|
||||||
"rips/PythonExamples/view_example.py"
|
|
||||||
"rips/tests/test_cases.py"
|
|
||||||
"rips/tests/test_grids.py"
|
|
||||||
"rips/tests/test_properties.py"
|
|
||||||
"rips/tests/test_project.py"
|
|
||||||
"rips/tests/conftest.py"
|
|
||||||
"rips/tests/dataroot.py"
|
|
||||||
"rips/tests/test_nnc_properties.py"
|
|
||||||
"rips/tests/test_simulation_wells.py"
|
|
||||||
"rips/tests/test_summary_cases.py"
|
|
||||||
"rips/tests/test_wells.py"
|
|
||||||
"requirements.txt"
|
|
||||||
"setup.py"
|
|
||||||
"README.md"
|
|
||||||
"LICENSE")
|
|
||||||
|
|
||||||
list(APPEND GRPC_PYTHON_SOURCES ${GRPC_PYTHON_GENERATED_SOURCES})
|
list(APPEND GRPC_PYTHON_SOURCES ${GRPC_PYTHON_GENERATED_SOURCES})
|
||||||
|
|
||||||
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
|
||||||
foreach(PYTHON_SCRIPT ${GRPC_PYTHON_SOURCES})
|
|
||||||
list(APPEND GRPC_PYTHON_SOURCES_FULL_PATH
|
|
||||||
"${GRPC_PYTHON_SOURCE_PATH}/${PYTHON_SCRIPT}")
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
${PROJECT_NAME} OBJECT
|
${PROJECT_NAME} OBJECT
|
||||||
${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
|
${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
|
||||||
@ -318,13 +260,13 @@ if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND RESINSIGHT_GRPC_BUNDLE_PYTHON_MODULE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
add_custom_target(GeneratedPythonSources ALL
|
add_custom_target(Rips ALL
|
||||||
DEPENDS ${GRPC_PYTHON_SOURCES_FULL_PATH})
|
SOURCES ${GRPC_PYTHON_SOURCES})
|
||||||
add_dependencies(${PROJECT_NAME} GeneratedPythonSources)
|
add_dependencies(${PROJECT_NAME} Rips)
|
||||||
|
|
||||||
if(RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE)
|
if(RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE)
|
||||||
add_dependencies(${PROJECT_NAME} PipInstall)
|
add_dependencies(${PROJECT_NAME} PipInstall)
|
||||||
add_dependencies(GeneratedPythonSources PipInstall)
|
add_dependencies(Rips PipInstall)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -333,4 +275,8 @@ if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
|||||||
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/Python)
|
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/Python)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
source_group("GrpcProtos" FILES ${GRPC_PROTO_FILES_FULL_PATH})
|
source_group("Generated" FILES ${GRPC_PYTHON_GENERATED_SOURCES})
|
||||||
|
source_group("Sources" FILES ${GRPC_PYTHON_RIPS_SOURCES})
|
||||||
|
source_group("Protos" FILES ${GRPC_PROTO_FILES})
|
||||||
|
source_group("PythonExamples" FILES ${GRPC_PYTHON_EXAMPLE_SOURCES})
|
||||||
|
source_group("Tests" FILES ${GRPC_PYTHON_TEST_SOURCES})
|
||||||
|
Loading…
Reference in New Issue
Block a user