2012-10-20 7 views
6

Ich habe ein Projekt mit folgenden Struktur:Cmake: hierarchischer Projekt-Setup

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

Und nach dem Bauprozess, Ich mag haben:

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

Die CMake doc ziemlich schwierig ist, und alles lesen Ich brauche hier ein Beispiel (zB ein bestehendes Projekt) wie man das einrichtet ...

vielen dank!

Antwort

5

Sie möchten die folgenden:

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) 


dann in einer Eingabeaufforderung einfach tun:

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

... Was?!? Inwiefern bezieht sich dieser Kommentar auf @Mark? –

+1

@OrenS Keine Ahnung, ich werde löschen. Andere Seiten hatten manchmal Probleme mit Kommentaren, die an den falschen Thread gebunden waren, aber ich bin mir nicht bewusst, dass SO davon betroffen ist. – Mark

Verwandte Themen