My current project structure looks like this:
Project
--src/
--CMakeLists.txt
--Graph.cpp
--Graph.hpp
--main.cpp
--build/
--CMakeLists.txt
The CMakeLists.txt in the Project folder lookalike this:
cmake_minimum_required(VERSION 3.18)
project(GRAPHTHEORY VERSION 1.0.0)
set (CMAKE_CXX_STANDARD 17)
add_subdirectory(src)
the CMakeLists.txt in src file looks like this:
add_library(Graph Graph.hpp Graph.cpp)
add_executable(graph_theory main.cpp)
target_link_libraries(graph_theory PRIVATE Graph )
When I go into the build/ directory, and run cmake .. and then make, the executable graph_theory is in a new src/ directory within build
I am not sure why a new src/ directory is being created in my `build/' directory.
Edit:
So what I was trying to do is replicate running
cmake -S src/ -B build/ from Project directory.
When I do the above and then cd into build/ and then run make, the executable is created in build/ directory.