我有一个带有以下结构的项目:
proj:
-CMakeLists.txt
-subdir0
-CMakeLists.txt
-app0.cpp
-app1.cpp
-subdir1
-CMakeLists.txt
-app2.cpp
构建后,我喜欢:
proj:
-CMakeLists.txt
-subdir0
-CMakeLists.txt
-app0.cpp
-app1.cpp
-subdir1
-CMakeLists.txt
-app2.cpp
-build
-subdir0
-app0.exec
-app1.exec
-subdir1
-app2.exec
cmake doc很难阅读,我需要的只是一个示例(例如现有项目)如何设置此问题...
非常感谢!
您想要以下内容:
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)
然后在命令提示符中只需做:
mkdir <root of proj>/build
cd <root of proj>/build
cmake ..