diff --git a/clients/python/CMakeLists.txt b/clients/python/CMakeLists.txt index 310a2927b..e9bfca724 100644 --- a/clients/python/CMakeLists.txt +++ b/clients/python/CMakeLists.txt @@ -20,8 +20,4 @@ # along with this program. If not, see . ################################################################################### -add_custom_command(OUTPUT villas_pb2.py - COMMAND protoc ${CMAKE_SOURCE_DIR}/lib/nodes/villas.proto - MAIN_DEPENDENCY villas.proto -) - + diff --git a/cmake/FindProtobufC.cmake b/cmake/FindProtobufC.cmake deleted file mode 100644 index d02cceba9..000000000 --- a/cmake/FindProtobufC.cmake +++ /dev/null @@ -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}) diff --git a/lib/formats/CMakeLists.txt b/lib/formats/CMakeLists.txt index f6c7828de..8e4ecee3f 100644 --- a/lib/formats/CMakeLists.txt +++ b/lib/formats/CMakeLists.txt @@ -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})