[CMake] Simple CMake sample
Michael Wild
themiwi at gmail.com
Tue Feb 12 08:05:10 EST 2008
On 12Feb, 2008, at 13:25, David Sveningsson wrote:
> Hi, I have read the samples and parts of the documentation but I
> haven't understood how to create a simple CMakeLists.txt for a
> directory structure like this:
>
> foo/
> foo/build/
> foo/include/
> foo/include/component_x/
> foo/include/component_y/
> foo/src/
> foo/src/component_x/
> foo/src/component_y/
> foo/vendor/bar/include
> foo/vendor/bar/src
>
> where foo is the project and bar is a library required by foo. Can
> someone shed some light on this?
>
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
More information about the CMake
mailing list