diff options
Diffstat (limited to 'vcpkg/ports/nanopb')
| -rw-r--r-- | vcpkg/ports/nanopb/fix-cmakelist.patch | 63 | ||||
| -rw-r--r-- | vcpkg/ports/nanopb/portfile.cmake | 61 | ||||
| -rw-r--r-- | vcpkg/ports/nanopb/vcpkg.json | 28 |
3 files changed, 152 insertions, 0 deletions
diff --git a/vcpkg/ports/nanopb/fix-cmakelist.patch b/vcpkg/ports/nanopb/fix-cmakelist.patch new file mode 100644 index 0000000..99bebfe --- /dev/null +++ b/vcpkg/ports/nanopb/fix-cmakelist.patch @@ -0,0 +1,63 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 301501d..c7e8e42 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -16,12 +16,6 @@ option(nanopb_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) + + set(nanopb_PYTHON_INSTDIR_OVERRIDE "" CACHE PATH "Override the default python installation directory with the given path") + +-find_program(nanopb_PROTOC_PATH protoc PATHS generator-bin generator NO_DEFAULT_PATH) +-find_program(nanopb_PROTOC_PATH protoc) +-if(NOT EXISTS ${nanopb_PROTOC_PATH}) +- message(FATAL_ERROR "protoc compiler not found") +-endif() +- + if(NOT DEFINED CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX "d") + endif() +@@ -44,7 +38,6 @@ endif() + + # Determine Python module installation path + if (NOT nanopb_PYTHON_INSTDIR_OVERRIDE) +- find_package(Python REQUIRED COMPONENTS Interpreter) + file(TO_CMAKE_PATH "${Python_SITELIB}" PYTHON_INSTDIR) + else() + set(PYTHON_INSTDIR ${nanopb_PYTHON_INSTDIR_OVERRIDE}) +@@ -54,6 +47,10 @@ message(STATUS "Python install dir: ${PYTHON_INSTDIR}") + # Package nanopb generator as Python module 'nanopb' + if(nanopb_BUILD_GENERATOR) + # Copy Python code files related to the generator ++ if(NOT EXISTS ${nanopb_PROTOC_PATH}) ++ message(FATAL_ERROR "protoc compiler not found") ++ endif() ++ + add_custom_target(nanopb_generator ALL + COMMAND ${CMAKE_COMMAND} -E make_directory + ${PROJECT_BINARY_DIR}/nanopb/generator/proto +@@ -83,24 +80,14 @@ if(nanopb_BUILD_GENERATOR) + + # Install Python module files + install( +- DIRECTORY ${PROJECT_BINARY_DIR}/nanopb +- DESTINATION ${PYTHON_INSTDIR} ++ DIRECTORY ${PROJECT_BINARY_DIR}/nanopb/generator ++ DESTINATION ${CMAKE_INSTALL_BINDIR} + FILES_MATCHING + PATTERN *.py + PATTERN *.proto + PATTERN __pycache__ EXCLUDE + ) + +- # Generate a wrapper script that calls nanopb.generator Python module when invoked +- configure_file( +- extra/script_wrappers/nanopb_generator.py.in +- ${PROJECT_BINARY_DIR}/nanopb_generator.py +- ) +- install( +- PROGRAMS ${PROJECT_BINARY_DIR}/nanopb_generator.py +- DESTINATION ${CMAKE_INSTALL_BINDIR} +- ) +- + # Install shell/bat script wrappers for invoking nanopb_generator.py. + # protoc-gen-nanopb is automatically used by protoc when --nanopb_out= option is used. + if(WIN32) diff --git a/vcpkg/ports/nanopb/portfile.cmake b/vcpkg/ports/nanopb/portfile.cmake new file mode 100644 index 0000000..6c7a527 --- /dev/null +++ b/vcpkg/ports/nanopb/portfile.cmake @@ -0,0 +1,61 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO nanopb/nanopb
+ REF ${VERSION}
+ SHA512 1580c94d558f707c88d8d2ddf4aa3bf4ef244ddc07b13e02de7124da8d156fb30a6999bb3c54ff0497abb033e498fb85ea671774f2fb817f55fa64937f537c77
+ HEAD_REF master
+ PATCHES
+ fix-cmakelist.patch
+)
+
+string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" nanopb_BUILD_STATIC_LIBS)
+string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" nanopb_STATIC_LINKING)
+
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ FEATURES
+ generator nanopb_BUILD_GENERATOR
+)
+
+vcpkg_find_acquire_program(PYTHON3)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH ${SOURCE_PATH}
+ OPTIONS
+ -DPython_EXECUTABLE=${PYTHON3}
+ -Dnanopb_BUILD_RUNTIME=ON
+ -DBUILD_STATIC_LIBS=${nanopb_BUILD_STATIC_LIBS}
+ -Dnanopb_MSVC_STATIC_RUNTIME=${nanopb_STATIC_LINKING}
+ "-Dnanopb_PROTOC_PATH=${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}"
+ ${FEATURE_OPTIONS}
+ -DCMAKE_INSTALL_DATADIR=share/${PORT}
+ MAYBE_UNUSED_VARIABLES
+ Python_EXECUTABLE
+ nanopb_PROTOC_PATH
+)
+vcpkg_cmake_install()
+
+vcpkg_copy_pdbs()
+
+vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}")
+
+if(nanopb_BUILD_GENERATOR)
+ file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/generator/" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
+ if(VCPKG_TARGET_IS_WINDOWS)
+ file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/nanopb_generator.bat" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
+ file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/protoc-gen-nanopb.bat" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
+ else()
+ file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/nanopb_generator" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
+ file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/protoc-gen-nanopb" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
+ endif()
+endif()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
+
+if(nanopb_BUILD_STATIC_LIBS)
+ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
+endif()
+# Handle copyright
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
diff --git a/vcpkg/ports/nanopb/vcpkg.json b/vcpkg/ports/nanopb/vcpkg.json new file mode 100644 index 0000000..3e2d065 --- /dev/null +++ b/vcpkg/ports/nanopb/vcpkg.json @@ -0,0 +1,28 @@ +{ + "name": "nanopb", + "version": "0.4.9.1", + "description": "A small code-size Protocol Buffers implementation in ANSI C.", + "homepage": "https://jpa.kapsi.fi/nanopb/", + "license": "Zlib", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "generator": { + "description": "build the generator", + "dependencies": [ + { + "name": "protobuf", + "host": true + } + ] + } + } +} |