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

100 lines
3.3 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..44e4939c 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -1,21 +1,38 @@
include(GNUInstallDirs)
-foreach(_library
- libprotobuf-lite
- libprotobuf
- libprotoc)
- set_property(TARGET ${_library}
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES
- $<BUILD_INTERFACE:${protobuf_source_dir}/src>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
- install(TARGETS ${_library} EXPORT protobuf-targets
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
-endforeach()
+if(protobuf_BUILD_COMPILER)
+ foreach(_library
+ libprotobuf-lite
+ libprotobuf
+ libprotoc)
+ set_property(TARGET ${_library}
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES
+ $<BUILD_INTERFACE:${protobuf_source_dir}/src>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+ install(TARGETS ${_library} EXPORT protobuf-targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
+ endforeach()
+else()
+ foreach(_library
+ libprotobuf-lite
+ libprotobuf)
+ set_property(TARGET ${_library}
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES
+ $<BUILD_INTERFACE:${protobuf_source_dir}/src>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+ install(TARGETS ${_library} EXPORT protobuf-targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
+ endforeach()
+endif()
-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,10 +111,18 @@ 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
- NAMESPACE protobuf::
- FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
-)
+if(protobuf_BUILD_COMPILER)
+ export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
+ NAMESPACE protobuf::
+ FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
+ )
+else()
+ export(TARGETS libprotobuf-lite libprotobuf
+ NAMESPACE protobuf::
+ FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
+ )
+endif()
+
install(EXPORT protobuf-targets
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"