grpc / grpc

The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)

Home Page:https://grpc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmake folder option for dependencies

superewald opened this issue · comments

Introduce an option to CMake configuration (like gRPC_FOLDER_NAME=grpc) to move gRPC and all dependencies into a separate folder when using set_property(GLOBAL PROPERTY USE_FOLDERS ON) and Visual Studio.

Is your feature request related to a problem? Please describe.

Since it's recommended to use a local install I'm using CPM in a project targeting windows to install gRPC as dependency.
The project does build fine but the solution file generated by cmake contains all gRPC dependencies at the root level, which really makes the solution unorganized.

Example Solution

grpc_cpm

Describe the solution you'd like

I want to pass a parameter to cmake that moves all project files to a custom folder inside the solution.

Example
Running cmake -DgRPC_BUILD_TEST=OFF -DgRPC_FOLDER_NAME=Dependencies
should result in the following solution folder structure

CurrentWanted
Solution/
├─ <Project>
├─ libprotobuf
├─ grpc
├─ grpc++
├─ ...

Solution/
├─ <Project>
├─ Dependencies/
│  ├─ grpc/
│  ├─ grpc++/
│  ├─ libprotobuf/
│  ├─ ...

Additional context

Example CMakeLists.txt for reproduction
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(
    CPM_SUBP_TEST
    LANGUAGES CXX
)

include(cmake/CPM.cmake)

CPMAddPackage(
  Name grpc
  GITHUB_REPOSITORY grpc/grpc
  VERSION 1.46.3
  EXCLUDE_FROM_ALL YES
  OPTIONS
    "gRPC_BUILD_TESTS OFF"
)

set(_PROTOBUF_LIBPROTOBUF libprotobuf)
set(_REFLECTION grpc++_reflection)
set(_PROTOBUF_PROTOC $<TARGET_FILE:protoc>)
set(_GRPC_GRPCPP grpc++)
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:grpc_cpp_plugin>)




add_executable(CPM_SUBP_TEST main.cpp)
target_link_libraries(CPM_SUBP_TEST 
  ${_REFLECTION}
  ${_GRPC_GRPCPP}
  ${_PROTOBUF_LIBPROTOBUF}
)

This might be useful to organize the project but it's not clear to me what's required to do it. Would you elaborate that?

More than 30 days have passed since label "disposition/requires reporter action" was added. Closing this issue. Please feel free to re-open/create a new issue if this is still relevant.