1
I have a project with the following extrusion:
Projeto A:
| CMakeLists.txt
| main.cpp
| #include "ProjetoB/ClassB.cpp"
| #include "ProjetoC/ClassC.cpp"
| vendor/
| Projeto B:
| CMakeLists.txt
| ClassB.cpp
| Helper.h
| Projeto C:
| CMakeLists.txt
| ClassC.cpp
| #include "ProjetoB/Helper.h"
My Cmake File of Project A is as follows:
cmake_minimum_required(VERSION 3.6)
project(ProjetoA)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/")
set(SOURCE_FILES main.cpp)
add_executable(ProjetoA ${SOURCE_FILES})
MACRO(LINK_PROJECT_LIBRARY lib)
target_link_libraries(ProjetoA ${lib})
ENDMACRO()
include_directories(vendor/ProjetoB/)
LINK_PROJECT_LIBRARY(ProjetoB)
include_directories(vendor/ProjetoC/)
LINK_PROJECT_LIBRARY(ProjetoC)
My problem starts with me trying to include #include "ProjetoB/Helper.h"
in Classc, because if I don’t put this include the cmake finds all dependencies and compiles cute. But since I need to include he can’t even find the file, it’s like mine include_directories
propagate to others cmake? Wanted to make a dependency system a little more dynamic.
(1) is confused... Projectob and Projectoc are really ? projects generate a lib ? in Cmakelists.txt of B and C projects there are "add_library(Projetob)" and "add_library(Projetoc)" commands? or actually there is only one "project", Project A, which uses the sources of "projects" B and C ? (2) Another thing, I find strange two commands "target_link_libraries"" for Project A, may even work, I don’t know, but the normal is that we use only one "target_link_libraries", and put the various libs in this command "target_link_libraries", instead of using a command "target_link_libraries" by lib
– zentrunix
Another thing I found strange: it should not have commands "add_subdirectory(Projectob)" and "add_subdirectory(Projectoc)" ?
– zentrunix