[CMake] multiple source directories

pellegrini pellegrini at ill.fr
Wed Sep 28 06:51:53 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
                            Src/file2.f90)
and further
    add_executable(prog2 ${SOURCES})

when compiling with CMake I get the following error:

##############################################
CMake Error at CMakeLists.txt:35 (add_executable):
  Cannot find source file:

    ../../prog1/Src/file1.f90

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm 
.hpp  .hxx .in .txx
###############################################

It seems that CMake cna not deal with relative path when declaring the 
sources for a project. I tried using the option CMAKE_USE_RELATIVE_PATHS
but it might not be defined for that purpose as it did not solve the 
problem. Would you have any idea how to solve that problem ?

thanks a lot

Eric




-- 
Eric Pellegrini
Calcul Scientifique
Institut Laue-Langevin
Grenoble, France



More information about the CMake mailing list