diff options
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() |