diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 7618ba2..d282a60 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -165,8 +165,10 @@ 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 441bf55..4158820 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -1,14 +1,17 @@ include(GNUInstallDirs) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf.pc.cmake +set(LIBRARIES_TO_SET_DEST libprotobuf-lite libprotobuf) +if(protobuf_BUILD_COMPILER) + list(APPEND LIBRARIES_TO_SET_DEST libprotoc) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf.cmake ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf-lite.pc.cmake +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf-lite.cmake ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc @ONLY) foreach(_library - libprotobuf-lite - libprotobuf - libprotoc) + ${LIBRARIES_TO_SET_DEST}) set_property(TARGET ${_library} PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ @@ -19,8 +22,10 @@ foreach(_library ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library}) endforeach() -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() 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 ${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) +if(protobuf_BUILD_COMPILER) + list(APPEND FIND_DIRS libprotoc protoc) +endif() + +export(TARGETS ${FIND_DIRS} NAMESPACE protobuf:: FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake )