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

71 lines
2.2 KiB
Diff
Raw Normal View History

2017-07-01 04:59:23 +08:00
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
2017-09-01 19:42:51 +08:00
index 7618ba2..d282a60 100644
2017-07-01 04:59:23 +08:00
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
2017-09-01 19:42:51 +08:00
@@ -165,8 +165,10 @@ endif (protobuf_UNICODE)
2017-07-01 04:59:23 +08:00
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)
2017-09-01 19:42:51 +08:00
2017-07-01 04:59:23 +08:00
diff --git a/cmake/install.cmake b/cmake/install.cmake
2017-09-21 23:30:11 +08:00
index 441bf55..20b3aa0 100644
2017-07-01 04:59:23 +08:00
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
2017-09-01 19:42:51 +08:00
@@ -1,14 +1,17 @@
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()
+
2017-09-21 23:30:11 +08:00
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf.pc.cmake
2017-09-01 19:42:51 +08:00
${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY)
2017-09-21 23:30:11 +08:00
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf-lite.pc.cmake
2017-09-01 19:42:51 +08:00
${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc @ONLY)
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>
2017-09-01 19:42:51 +08:00
@@ -19,8 +22,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()
2017-09-01 19:42:51 +08:00
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
@@ -101,7 +106,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
)