project
|------ CMakeLists.txt (The main Cmake)
|------ somePlace/someOtherPlace/CmakeLists.txt
| |----- some.proto (google proto files)
| |----- CMakeList.txt
|------ Project2/CmakeListst.txt
|----- .cpp files
|----- .hpp files
|----- CMakeList.txt
I have a similar topology as above, my main cmake could be able to generate cmake files, and after the main cmake I could be able to build Project2 with:
make Project2
I have added Project2 as subdirectory to the main cmake. I have no problem here. But I also want to build common/someplace/CmakeLists.txt
together with the Project2, when I run make Project2
. I also know that I could be able to build common/someplace/CmakeLists.txt
inside its directory by cmake and make commands. You can check somePlace/someOtherPlace/CmakeLists.txt
:
INCLUDE(FindProtobuf)
FIND_PACKAGE(Protobuf REQUIRED)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER oamc_packets.proto)
ADD_LIBRARY(proto ${PROTO_HEADER} ${PROTO_SRC})
But I want Project2 to depend on somePlace/someOtherPlace/CmakeList.txt
and build together with it.How can I achieve it?
Should I use add_executable/add_library
commands? The problem is somePlace/someOtherPlace/CmakeLists.txt
creates header and cc file along with the .a file.
PS: I can give further information, if it is requested.