diff options
author | Feng Xiao <xiaofeng@google.com> | 2016-06-07 10:14:20 -0700 |
---|---|---|
committer | Feng Xiao <xiaofeng@google.com> | 2016-06-07 10:14:20 -0700 |
commit | dfe0c9ad3836dc3756a908fa0e4aee1c2b3f2ce1 (patch) | |
tree | 7e5c78c392443c383f3f73b1e290f03cadbf44c7 /cmake/install.cmake | |
parent | ed1d560023c5e355b06a896700730725ce7623b8 (diff) | |
parent | 23fef56e6d1541344401191bffa3f5218278f2e3 (diff) | |
download | protobuf-dfe0c9ad3836dc3756a908fa0e4aee1c2b3f2ce1.tar.gz protobuf-dfe0c9ad3836dc3756a908fa0e4aee1c2b3f2ce1.tar.bz2 protobuf-dfe0c9ad3836dc3756a908fa0e4aee1c2b3f2ce1.zip |
Merge pull request #1643 from yeswalrus/cmake-examples
Build examples in CMake
Diffstat (limited to 'cmake/install.cmake')
-rw-r--r-- | cmake/install.cmake | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/cmake/install.cmake b/cmake/install.cmake index a5040b22..94ef2198 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -6,6 +6,7 @@ foreach(_library 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} @@ -80,29 +81,43 @@ foreach(_file ${nobase_dist_proto_DATA}) endif() endforeach() -# Export configuration +# Install configuration set(_cmakedir_desc "Directory relative to CMAKE_INSTALL to install the cmake configuration files") if(NOT MSVC) set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/protobuf" CACHE STRING "${_cmakedir_desc}") else() set(CMAKE_INSTALL_CMAKEDIR "cmake" CACHE STRING "${_cmakedir_desc}") endif() - -install(EXPORT protobuf-targets - DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" - NAMESPACE protobuf:: - COMPONENT protobuf-export) +mark_as_advanced(CMAKE_INSTALL_CMAKEDIR) configure_file(protobuf-config.cmake.in - protobuf-config.cmake @ONLY) + ${CMAKE_INSTALL_CMAKEDIR}/protobuf-config.cmake @ONLY) configure_file(protobuf-config-version.cmake.in - protobuf-config-version.cmake @ONLY) + ${CMAKE_INSTALL_CMAKEDIR}/protobuf-config-version.cmake @ONLY) configure_file(protobuf-module.cmake.in - protobuf-module.cmake @ONLY) + ${CMAKE_INSTALL_CMAKEDIR}/protobuf-module.cmake @ONLY) +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 +) -install(FILES - "${protobuf_BINARY_DIR}/protobuf-config.cmake" - "${protobuf_BINARY_DIR}/protobuf-config-version.cmake" - "${protobuf_BINARY_DIR}/protobuf-module.cmake" +install(EXPORT protobuf-targets DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" + NAMESPACE protobuf:: COMPONENT protobuf-export) + +install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/ + DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" + COMPONENT protobuf-export + PATTERN protobuf-targets.cmake EXCLUDE +) + +option(protobuf_INSTALL_EXAMPLES "Install the examples folder" OFF) +if(protobuf_INSTALL_EXAMPLES) + install(DIRECTORY ../examples/ DESTINATION examples + COMPONENT protobuf-examples) +endif() |