[CMake] multiple source directories

Rolf Eike Beer eike at sf-mail.de
Wed Sep 28 07:30:21 EDT 2011


> Hi all,
>
> I have a project with the following structure:
>
> root/
>     CMakeLists.txt
>     prog1/
>         CMakeLists.txt
>         Src/
>             file1.f90
>     prog2/
>         CMakeLists.txt
>         Src/
>             file2.f90
>
> where prog1, prog2 are individual projects.
>
> I would like to add file1.90 to the build process of prog2. To do so, in
> the CMakeLists.txt file of prog2 project, I put:
>
>     set(SOURCES ../../prog1/Src/file1.f90

Try ${CMAKE_CURRENT_SOURCE_DIR}/../../prog1/Src/file1.f90 here.

>                             Src/file2.f90)
> and further
>     add_executable(prog2 ${SOURCES})

Then it should work.

Eike


More information about the CMake mailing list