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

66 lines
1.9 KiB
Diff
Raw Normal View History

2017-07-01 04:59:23 +08:00
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
2017-07-01 04:59:23 +08:00
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -1,9 +1,12 @@
2017-07-01 04:59:23 +08:00
include(GNUInstallDirs)
+set(LIBRARIES_TO_SET_DEST libprotobuf-lite libprotobuf)
+if(protobuf_BUILD_COMPILER)
+ list(APPEND LIBRARIES_TO_SET_DEST libprotoc)
+endif()
+
foreach(_library
2017-07-01 04:59:23 +08:00
- 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()
2017-07-01 04:59:23 +08:00
-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
2017-07-01 04:59:23 +08:00
${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)
2017-07-01 04:59:23 +08:00
+if(protobuf_BUILD_COMPILER)
+ list(APPEND FIND_DIRS libprotoc protoc)
2017-07-01 04:59:23 +08:00
+endif()
+
+export(TARGETS ${FIND_DIRS}
NAMESPACE protobuf::
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
)