diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 2a5b12b412e..1c76136ce3d 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -73,6 +73,11 @@ set(PACKAGE_TARNAME "<%text>${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") project(<%text>${PACKAGE_NAME} C CXX) + + set(gRPC_INSTALL_BINDIR "<%text>${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") + set(gRPC_INSTALL_LIBDIR "<%text>${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") + set(gRPC_INSTALL_INCLUDEDIR "<%text>${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") + set(gRPC_INSTALL_CMAKEDIR "<%text>${CMAKE_INSTALL_PREFIX}/lib/cmake/${PACKAGE_NAME}" CACHE PATH "Installation directory for cmake config files") # Options option(gRPC_BUILD_TESTS "Build tests" OFF) @@ -335,11 +340,6 @@ set(_gRPC_BASELIB_LIBRARIES wsock32 ws2_32) endif() - include(GNUInstallDirs) - if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR) - set(CMAKE_INSTALL_CMAKEDIR "<%text>${CMAKE_INSTALL_LIBDIR}/cmake/gRPC") - endif() - # Create directory for generated .proto files set(_gRPC_PROTO_GENS_DIR <%text>${CMAKE_BINARY_DIR}/gens) file(MAKE_DIRECTORY <%text>${_gRPC_PROTO_GENS_DIR}) @@ -500,7 +500,7 @@ ) if (gRPC_INSTALL) install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/${lib.name}.pdb - DESTINATION <%text>${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION <%text>${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -554,7 +554,7 @@ string(REPLACE "include/" "" _path <%text>${_hdr}) get_filename_component(_path <%text>${_path} PATH) install(FILES <%text>${_hdr} - DESTINATION "<%text>${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "<%text>${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() % endif @@ -622,16 +622,16 @@ <%def name="cc_install(tgt)"> if (gRPC_INSTALL) install(TARGETS ${tgt.name} EXPORT gRPCTargets - RUNTIME DESTINATION <%text>${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION <%text>${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION <%text>${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION <%text>${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION <%text>${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION <%text>${gRPC_INSTALL_LIBDIR} ) endif() if (gRPC_INSTALL) install(EXPORT gRPCTargets - DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR} + DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR} NAMESPACE gRPC:: ) endif() @@ -640,6 +640,6 @@ configure_file(tools/cmake/<%text>${_config}.cmake.in <%text>${_config}.cmake @ONLY) install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/${_config}.cmake - DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR} + DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR} ) endforeach()