|
@@ -1,3 +1,4 @@
|
|
|
+# This file contains backwards compatibility patches for various legacy functions and variables
|
|
|
# Functions
|
|
|
|
|
|
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
|
@@ -7,49 +8,25 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
|
|
endif()
|
|
|
|
|
|
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
|
|
- # Create an include path for each file specified
|
|
|
- foreach(FIL ${ARGN})
|
|
|
- get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
|
|
- get_filename_component(ABS_PATH ${ABS_FIL} PATH)
|
|
|
- list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
|
|
- if(${_contains_already} EQUAL -1)
|
|
|
- list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
|
|
- endif()
|
|
|
- endforeach()
|
|
|
- else()
|
|
|
- set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
+ set(_append_arg APPEND_PATH)
|
|
|
endif()
|
|
|
|
|
|
if(DEFINED Protobuf_IMPORT_DIRS)
|
|
|
- foreach(DIR ${Protobuf_IMPORT_DIRS})
|
|
|
- get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
|
|
|
- list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
|
|
- if(${_contains_already} EQUAL -1)
|
|
|
- list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
|
|
- endif()
|
|
|
- endforeach()
|
|
|
+ set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS})
|
|
|
endif()
|
|
|
|
|
|
+ set(_outvar)
|
|
|
+ protobuf_generate(${append_arg} LANGUAGE cpp OUT_VAR _outvar ${_import_arg} PROTOS ${ARGN})
|
|
|
+
|
|
|
set(${SRCS})
|
|
|
set(${HDRS})
|
|
|
- foreach(FIL ${ARGN})
|
|
|
- get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
|
|
- get_filename_component(FIL_WE ${FIL} NAME_WE)
|
|
|
-
|
|
|
- list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
|
|
|
- list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
|
|
|
-
|
|
|
- add_custom_command(
|
|
|
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
|
|
|
- "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
|
|
- COMMAND ${Protobuf_PROTOC_EXECUTABLE}
|
|
|
- ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
|
|
|
- DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
|
|
|
- COMMENT "Running C++ protocol buffer compiler on ${FIL}"
|
|
|
- VERBATIM )
|
|
|
+ foreach(_file ${_outvar})
|
|
|
+ if(_file MATCHES "cc$")
|
|
|
+ list(APPEND ${SRCS} ${_file})
|
|
|
+ else()
|
|
|
+ list(APPEND ${HDRS} ${_file})
|
|
|
+ endif()
|
|
|
endforeach()
|
|
|
-
|
|
|
- set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
|
|
|
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
|
|
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
|
|
endfunction()
|
|
@@ -61,44 +38,16 @@ function(PROTOBUF_GENERATE_PYTHON SRCS)
|
|
|
endif()
|
|
|
|
|
|
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
|
|
- # Create an include path for each file specified
|
|
|
- foreach(FIL ${ARGN})
|
|
|
- get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
|
|
- get_filename_component(ABS_PATH ${ABS_FIL} PATH)
|
|
|
- list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
|
|
- if(${_contains_already} EQUAL -1)
|
|
|
- list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
|
|
- endif()
|
|
|
- endforeach()
|
|
|
- else()
|
|
|
- set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
+ set(_append_arg APPEND_PATH)
|
|
|
endif()
|
|
|
|
|
|
if(DEFINED Protobuf_IMPORT_DIRS)
|
|
|
- foreach(DIR ${Protobuf_IMPORT_DIRS})
|
|
|
- get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
|
|
|
- list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
|
|
- if(${_contains_already} EQUAL -1)
|
|
|
- list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
|
|
- endif()
|
|
|
- endforeach()
|
|
|
+ set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS})
|
|
|
endif()
|
|
|
|
|
|
- set(${SRCS})
|
|
|
- foreach(FIL ${ARGN})
|
|
|
- get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
|
|
- get_filename_component(FIL_WE ${FIL} NAME_WE)
|
|
|
-
|
|
|
- list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py")
|
|
|
- add_custom_command(
|
|
|
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py"
|
|
|
- COMMAND ${Protobuf_PROTOC_EXECUTABLE} --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
|
|
|
- DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
|
|
|
- COMMENT "Running Python protocol buffer compiler on ${FIL}"
|
|
|
- VERBATIM )
|
|
|
- endforeach()
|
|
|
-
|
|
|
- set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
|
|
+ set(_outvar)
|
|
|
+ protobuf_generate(${append_arg} LANGUAGE cpp OUT_VAR _outvar ${_import_arg} PROTOS ${ARGN})
|
|
|
+ set(${SRCS} ${_outvar} PARENT_SCOPE)
|
|
|
endfunction()
|
|
|
|
|
|
# Environment
|