1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

cmake: improve handling of protofbuf outputs

This commit is contained in:
Steffen Vogel 2018-07-03 18:24:20 +02:00
parent b35a60e038
commit 54c9964f6c
3 changed files with 30 additions and 47 deletions

View file

@ -20,8 +20,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###################################################################################
add_custom_command(OUTPUT villas_pb2.py
COMMAND protoc ${CMAKE_SOURCE_DIR}/lib/nodes/villas.proto
MAIN_DEPENDENCY villas.proto
)

View file

@ -1,20 +0,0 @@
pkg_check_modules(PC_PROTOBUFC QUIET libprotobuf-c)
set(PROTOBUFC_DEFINITIONS ${PC_PROTOBUFC_CFLAGS_OTHER})
find_path(PROTOBUFC_INCLUDE_DIR google/protobuf-c/protobuf-c.h
HINTS ${PC_PROTOBUFC_INCLUDEDIR} ${PC_PROTOBUFC_INCLUDE_DIRS}
PATH_SUFFIXES libprotobuf-c)
find_library(PROTOBUFC_LIBRARY NAMES protobuf-c
HINTS ${PC_PROTOBUFC_LIBDIR}
${PC_PROTOBUFC_LIBRARY_DIRS})
find_program(PROTOBUFC_COMPILER protoc-c)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libprotobuf-c DEFAULT_MSG
PROTOBUFC_LIBRARY PROTOBUFC_INCLUDE_DIR PROTOBUFC_COMPILER)
mark_as_advanced(PROTOBUFC PROTOBUFC_INCLUDE_DIR PROTOBUFC_LIBRARY)
set(PROTOBUFC_LIBRARIES ${PROTOBUFC_LIBRARY})
set(PROTOBUFC_INCLUDE_DIRS ${PROTOBUFC_INCLUDE_DIR})

View file

@ -38,6 +38,31 @@ set(LIBRARIES
${OPENSSL_LIBRARIES}
)
if(DEFINED PROTOBUF_COMPILER)
add_custom_target(protobuf ALL
COMMAND ${PROTOBUF_COMPILER}
--python_out=${CMAKE_CURRENT_BINARY_DIR}
#--php_out=${CMAKE_BINARY_DIR}
--js_out=${CMAKE_CURRENT_BINARY_DIR}
--cpp_out=${CMAKE_CURRENT_BINARY_DIR}
villas.proto
DEPENDS villas.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
if(DEFINED PROTOBUFC_COMPILER)
add_custom_target(protobuf-c ALL
COMMAND ${PROTOBUFC_COMPILER}
--c_out=${CMAKE_CURRENT_BINARY_DIR}
villas.proto
DEPENDS villas.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(protobuf protobuf-c)
endif()
# Enable Google Protobuf format
if(ProtobufC_FOUND)
list(APPEND FORMAT_SRC
@ -59,27 +84,9 @@ if(ProtobufC_FOUND)
GENERATED TRUE
)
add_custom_command(
COMMAND ${PROTOBUFC_COMPILER} --c_out=${CMAKE_CURRENT_BINARY_DIR} villas.proto
OUTPUT
villas.pb-c.c
villas.pb-c.h
MAIN_DEPENDENCY villas.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(formats protobuf-c)
endif()
add_library(villas-formats SHARED ${FORMAT_SRC})
target_include_directories(villas-formats PUBLIC ${INCLUDE_DIRS})
target_link_libraries(villas-formats PUBLIC ${LIBRARIES})
#set_target_properties(villas-formats PROPERTIES
# VERSION ${PROJECT_VERSION}
# SOVERSION ${PROJECT_SOVERSION}
#)
install(
TARGETS villas-formats
COMPONENT lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
add_library(formats STATIC ${FORMAT_SRC})
target_include_directories(formats PUBLIC ${INCLUDE_DIRS})
target_link_libraries(formats INTERFACE ${LIBRARIES})