I have a project with the following structure:
proj:
-CMakeLists.txt
-subdir0
-CMakeLists.txt
-app0.cpp
-app1.cpp
-subdir1
-CMakeLists.txt
-app2.cpp
And after build, I like to have:
proj:
-CMakeLists.txt
-subdir0
-CMakeLists.txt
-app0.cpp
-app1.cpp
-subdir1
-CMakeLists.txt
-app2.cpp
-build
-subdir0
-app0.exec
-app1.exec
-subdir1
-app2.exec
The CMake doc is quite difficult to read and all I need here is an example (e.g. an existing project) how to set this up...
thanks a lot!
You want the following:
proj/CMakeLists.txt:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(MyTest)
add_subdirectory(subdir0)
add_subdirectory(subdir1)
proj/subdir0/CMakeLists.txt:
add_executable(app0 app0.cpp)
add_executable(app1 app1.cpp)
proj/subdir1/CMakeLists.txt:
add_executable(app2 app2.cpp)
Then in a command prompt simply do:
mkdir <root of proj>/build
cd <root of proj>/build
cmake ..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With