2012-10-20 28 views
6

aşağıdaki yapıya sahip bir proje var: cmake: hiyerarşik proje kurulum

proj: 
-CMakeLists.txt  
-subdir0 
    -CMakeLists.txt  
    -app0.cpp 
    -app1.cpp 
-subdir1 
    -CMakeLists.txt  
    -app2.cpp 

Ve yapı sonra, Sevdiğim

olması:

proj:  
-CMakeLists.txt  
-subdir0 
    -CMakeLists.txt  
    -app0.cpp 
    -app1.cpp 
-subdir1 
    -CMakeLists.txt  
    -app2.cpp 
-build 
    -subdir0 
    -app0.exec 
    -app1.exec 
    -subdir1 
    -app2.exec 

CKağıt doc okuma ve oldukça zordur Buraya bir örnek (örneğin, mevcut bir proje) bunun nasıl ayarlanacağıdır ...

çok teşekkürler!

proj/CMakeLists.txt:

cevap

5

Aşağıdaki istiyorum

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: Bir komut isteminde Sonra

add_executable(app2 app2.cpp) 


basitçe yapın:

mkdir <root of proj>/build 
cd <root of proj>/build 
cmake .. 
+0

... Ne?!? Bu yorum nasıl ilgili? –

+1

@OrenS Hiçbir ipucu, ben sileceğim. Diğer siteler bazen yanlış iş parçacığına bağlı yorumlarla ilgili sıkıntı çekiyorlardı, ama bunun SO'yı etkilediğinin farkında değilim ...?! – Mark