aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmake/install.cmake
diff options
context:
space:
mode:
authorGravatar Konstantin Podsvirov <konstantin@podsvirov.pro>2015-08-03 11:58:48 +0300
committerGravatar Konstantin Podsvirov <konstantin@podsvirov.pro>2015-08-03 11:58:48 +0300
commitebfca175e262044f538952da285ba5269f6c3e96 (patch)
tree934ab81c552467d83d012122a28707148c13f16f /cmake/install.cmake
parent0be0789018645de0b20f60b203d2627d8bc27159 (diff)
Install well-known type proto files from CMake project
Diffstat (limited to 'cmake/install.cmake')
-rw-r--r--cmake/install.cmake48
1 files changed, 46 insertions, 2 deletions
diff --git a/cmake/install.cmake b/cmake/install.cmake
index bedd0601..f8148804 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -5,7 +5,8 @@ foreach(_library
libprotobuf
libprotoc)
set_property(TARGET ${_library}
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:include>)
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES
+ $<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}
@@ -29,6 +30,8 @@ if(MSVC)
get_filename_component(_extract_from "${protobuf_SOURCE_DIR}/${_extract_from}" ABSOLUTE)
get_filename_component(_extract_name ${_extract_to} NAME)
get_filename_component(_extract_to ${_extract_to} PATH)
+ string(REPLACE "include/" "${CMAKE_INSTALL_INCLUDEDIR}/"
+ _extract_to "${_extract_to}")
if(EXISTS "${_extract_from}")
install(FILES "${_extract_from}"
DESTINATION "${_extract_to}"
@@ -42,6 +45,45 @@ if(MSVC)
endforeach()
endif()
+# Internal function for parsing auto tools scripts
+function(_protobuf_auto_list FILE_NAME VARIABLE)
+ file(STRINGS ${FILE_NAME} _strings)
+ set(_list)
+ foreach(_string ${_strings})
+ set(_found)
+ string(REGEX MATCH "^[ \t]*${VARIABLE}[ \t]*=[ \t]*" _found "${_string}")
+ if(_found)
+ string(LENGTH "${_found}" _length)
+ string(SUBSTRING "${_string}" ${_length} -1 _draft_list)
+ foreach(_item ${_draft_list})
+ string(STRIP "${_item}" _item)
+ list(APPEND _list "${_item}")
+ endforeach()
+ endif()
+ endforeach()
+ set(${VARIABLE} ${_list} PARENT_SCOPE)
+endfunction()
+
+# Install well-known type proto files
+_protobuf_auto_list("../src/Makefile.am" nobase_dist_proto_DATA)
+foreach(_file ${nobase_dist_proto_DATA})
+ get_filename_component(_file_from "../src/${_file}" ABSOLUTE)
+ get_filename_component(_file_name ${_file} NAME)
+ get_filename_component(_file_path ${_file} PATH)
+ if(EXISTS "${_file_from}")
+ install(FILES "${_file_from}"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_file_path}"
+ COMPONENT protobuf-protos
+ RENAME "${_file_name}")
+ else()
+ message(AUTHOR_WARNING "The file \"${_file_from}\" is listed in "
+ "\"${protobuf_SOURCE_DIR}/../src/Makefile.am\" as nobase_dist_proto_DATA "
+ "but there not exists. The file will not be installed.")
+ endif()
+endforeach()
+
+# Export configuration
+
install(EXPORT protobuf-targets
DESTINATION "lib/cmake/protobuf"
COMPONENT protobuf-export)
@@ -50,10 +92,12 @@ configure_file(protobuf-config.cmake.in
protobuf-config.cmake @ONLY)
configure_file(protobuf-config-version.cmake.in
protobuf-config-version.cmake @ONLY)
+configure_file(protobuf-module.cmake.in
+ protobuf-module.cmake @ONLY)
install(FILES
"${protobuf_BINARY_DIR}/protobuf-config.cmake"
"${protobuf_BINARY_DIR}/protobuf-config-version.cmake"
- "${protobuf_SOURCE_DIR}/protobuf-module.cmake"
+ "${protobuf_BINARY_DIR}/protobuf-module.cmake"
DESTINATION "lib/cmake/protobuf"
COMPONENT protobuf-export)