Reputation: 875
I have a project which is organized like this:
<path_to_project>
|_ build
|_ exe1
| |_ src
| |_ includes
|_ exe2
| |_ src
| |_ includes
|_ libs
|_ src
|_ includes
I want to manage all different compilation parts of it with CMake (I'm new to it).
For this I created a CMakeLists.txt
at the root directory, in it I added the line:
add_executable(exe1 ${EXE1_SOURCES})
Where EXE1_SOURCES
is defined, in a CMakeLists.txt
in the exe1/src
directory, with all exe1
sources files.
When I go in the build
directory, and I make cmake ..
, it says add_executable called with incorrect number of arguments
, which means it cannot find the EXE1_SOURCES
variable.
I tried two things:
CACHE INTERNAL
at the end of the set commandPARENT_SCOPE
at then end of the set command, and add exe1/MakeLists.txt
and write set(EXE1_SOURCES ${EXE1_SOURCES} PARENT_SCOPE)
But both failed.
What is the simplest way to achieve what I want to do ?
Upvotes: 1
Views: 1674
Reputation: 875
In order to make all variable defined in a subdirectory CMakeLists.txt
, I had to add add_subdirectory(${PROJECT_SOURCE_DIR}/exe1/src)
in the main CMakeLists.txt
.
Upvotes: 2