vcpkg/ports/protobuf/001-add-compiler-flag.patch

66 lines
1.9 KiB
Diff

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 7618ba21..bd92b09d 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -165,8 +165,11 @@ endif (protobuf_UNICODE)
include(libprotobuf-lite.cmake)
include(libprotobuf.cmake)
-include(libprotoc.cmake)
-include(protoc.cmake)
+
+if(protobuf_BUILD_COMPILER)
+ include(libprotoc.cmake)
+ include(protoc.cmake)
+endif()
if (protobuf_BUILD_TESTS)
include(tests.cmake)
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 28dc90dc..52c1f721 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -1,9 +1,12 @@
include(GNUInstallDirs)
+set(LIBRARIES_TO_SET_DEST libprotobuf-lite libprotobuf)
+if(protobuf_BUILD_COMPILER)
+ list(APPEND LIBRARIES_TO_SET_DEST libprotoc)
+endif()
+
foreach(_library
- libprotobuf-lite
- libprotobuf
- libprotoc)
+ ${LIBRARIES_TO_SET_DEST})
set_property(TARGET ${_library}
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${protobuf_source_dir}/src>
@@ -14,8 +17,10 @@ foreach(_library
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
endforeach()
-install(TARGETS protoc EXPORT protobuf-targets
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
+if(protobuf_BUILD_COMPILER)
+ install(TARGETS protoc EXPORT protobuf-targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
+endif()
file(STRINGS extract_includes.bat.in _extract_strings
REGEX "^copy")
@@ -94,7 +99,12 @@ configure_file(protobuf-options.cmake
${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY)
# Allows the build directory to be used as a find directory.
-export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
+set(FIND_DIRS libprotobuf-lite libprotobuf)
+if(protobuf_BUILD_COMPILER)
+ list(APPEND FIND_DIRS libprotoc protoc)
+endif()
+
+export(TARGETS ${FIND_DIRS}
NAMESPACE protobuf::
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
)