[CMake] Simple CMake sample

David Sveningsson ext at sidvind.com
Tue Feb 12 08:25:10 EST 2008


Michael Wild skrev:
> 
> quite simply, e.g.:
> 
> foo/CMakeLists.txt:
> ###################
> 
> PROJECT(foo) # project name
> 
> ADD_SUBDIRECTORY( vendor/bar ) # add subdir
> 
> INCLUDE_DIRECTORIES( include vendor/bar/include ) # add to include path
> 
> ADD_EXECUTABLE(
>   foo                                          # build executable foo
>   src/source1.cpp                   # from these sources
>   src/source2.cpp
>   src/component_x/source_x.cpp
> )
> 
> TARGET_LINK_LIBRARIES(
>   foo                            # to foo link
>   bar                           # library bar which is in vendor/bar
> )
> 
> ###################
> 
> 
> vendor/bar/CMakeLists.txt
> ###################
> 
> PROJECT( bar) # if you want to
> 
> INCLUDE_DIRECTORIES( include )
> 
> ADD_LIBRARY(
>   bar
>   src/source1.cpp
> )
> 
> ###################
> 
> hth
> 
> 
> Michael
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 

Thanks, I had no idea you could add the path next to the sourcefiles. 
Maybe someone should put this or something similar on the CMake wiki, I 
mean I can't be the first one to have similar questions.
-- 


//*David Sveningsson [eXt]*

Freelance coder | Game Development Student
http://sidvind.com

Thou shalt make thy program's purpose and structure clear to thy fellow 
man by using the One True Brace Style, even if thou likest it not, for 
thy creativity is better used in solving problems than in creating 
beautiful new impediments to understanding.


More information about the CMake mailing list