Re: [CMake] multiple source directories - solved

2011-09-28 Thread pellegrini
thanks for the hints and your help, guys. Indeed, There was one '..\' 
too much in my source files path.


Eric

Andreas Pakulat a écrit :

On 28.09.11 12:51:53, pellegrini wrote:
  

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.



Relative paths work just fine, but your expecting a different base-path
than cmake is. In the above example the current directory when
assembling the sources is root/prog2 not root/prog2/Src which you seem
to assume. Hence you have one ".." too much in your set-line. This
should work:

set( SOURCES ../prog1/Src/file1.f90 Src/file2.f90 )

Andreas

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
  



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

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] multiple source directories

2011-09-28 Thread Andreas Pakulat
On 28.09.11 12:51:53, pellegrini wrote:
> 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.

Relative paths work just fine, but your expecting a different base-path
than cmake is. In the above example the current directory when
assembling the sources is root/prog2 not root/prog2/Src which you seem
to assume. Hence you have one ".." too much in your set-line. This
should work:

set( SOURCES ../prog1/Src/file1.f90 Src/file2.f90 )

Andreas

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] multiple source directories

2011-09-28 Thread Rolf Eike Beer
> 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
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] multiple source directories

2011-09-28 Thread Martin Kupke
I have a same problem (even relative paths should not be used, as I 
understood from documentation) and I fixed my problem by setting a 
variable in the /root/CMakeLists.txt e.g.

set( MY_PROJECT_PROG1 ${CMAKE_CURRENT_SOURCE_DIR}/prog1 )
set( MY_PROJECT_PROG2 ${CMAKE_CURRENT_SOURCE_DIR}/prog2 )
The subprojects / subfolders always inherit the settings / variables, so 
you can work with ${MY_PROJECT_PROG1} in your /root/prog1/CMakeLists.txt.


Martin

On 28.09.11 12:51, pellegrini wrote:

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






--



*martin kupke*

can diagnostics engineer | senior software developer

*m*:+49.151.5511.3632| *e*:martin.ku...@novero.com 



skype:martin.kupke_novero | w:www.novero.com 

novero GmbH
meesmannstr.103 | 44807 Bochum | germany


novero gmbh | parsevalstr. 7 a | 40468 düsseldorf | germany | 
amtsgericht düsseldorf | hrb 58283 | umsatzsteueridentifikationsnummer: 
de 814973142 | geschäftsführender gesellschafter: razvan olosu


--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] multiple source directories

2011-09-28 Thread pellegrini

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

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Multiple source directories.

2008-10-23 Thread Andreas Pakulat
On 24.10.08 00:22:25, Stefán Freyr Stefánsson wrote:
> ADD_EXECUTABLE( app src/app.cpp )
> 
> When app.cpp is compiled I get an error complaining that there is an 
> "undefined reference to Config::Config()".
> 
> So (finally) my question is: Since common has no executables, how exactly 
> should I tell CMake that it needs to compile Config.cpp before moduleA 
> compiles its executable for app.cpp to get rid of this error?

You either need to create a library for the common project or you need to
add Config.cpp do "app", i.e. instead of the above add_executable this one:

add_executable( app src/app.cpp
${COMMON_SOURCE_DIR}/src/Config.cpp )
 
> Do I need to add something to the common CMakeLists.txt file (which would be 
> the cleanest solution IMHO), and then what exactly is it that I need to add, 
> or should I somehow indicate that this file needs to be compiled in the 
> moduleA CMakeLists.txt (which feels a bit wrong since the idea about the 
> common project is to be referenced by more than one module). I guess I could 
> use ADD_LIBRARY like in the example, but is that the right thing to do? I 
> mean, basically I just want to reference the files from my modules, it's not 
> exactly a library, just some common files. Maybe this is my mistake?

Well, what you actually want is the code from common to be available inside
"app". This means the code either has to be compiled into app like shown
above. Or app has to link against a library that provides the code. If you
don't want to compile Config.cpp as often as you have moduleX, then I
suggest to create a static library inside common that each app links
against. This means no runtime-dependency on that library, but your
moduleX's can share the code without each compiling it.

Andreas

-- 
Good day for a change of scene.  Repaper the bedroom wall.
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Multiple source directories.

2008-10-23 Thread Stefán Freyr Stefánsson
Hello.

I have a project that has roughly the following structure:

root/dir/
  +-- common/
  |+-- include/   #.h files
  ||+-- Config.h
  |+-- src/   #.cpp files
  ||+-- Config.cpp
  |+-- CMakeLists.txt
  |
  +-- moduleA/
  |+-- include/   #.h files
  |+-- src/   #.cpp files
  ||+-- app.cpp
  |+-- CMakeLists.txt
  |
  +-- #potentially more modules
  |
  +-- CMakeLists.txt

So I have a class that is defined in root/dir/common/include/Config.h and 
implemented in root/dir/common/src/Config.cpp and then I have a program in 
/root/dir/moduleA/src/app.cpp.

app.cpp includes Config.h.

root/dir/CMakeLists.txt only includes all subdirectories:
ADD_SUBDIRECTORIES( common )
ADD_SUBDIRECTORIES( moduleA )

root/dir/common/CMakeLists.txt only has:
PROJECT( COMMON )
INCLUDE_DIRECTORIES (
include/
)

root/dir/moduleA/CMakeLists.txt has:
PROJECT( MODULEA )
INCLUDE_DIRECTORIES (
include/
${COMMON_SOURCE_DIR}/include
)
ADD_EXECUTABLE( app src/app.cpp )

When app.cpp is compiled I get an error complaining that there is an "undefined 
reference to Config::Config()".

So (finally) my question is: Since common has no executables, how exactly 
should I tell CMake that it needs to compile Config.cpp before moduleA compiles 
its executable for app.cpp to get rid of this error?

Do I need to add something to the common CMakeLists.txt file (which would be 
the cleanest solution IMHO), and then what exactly is it that I need to add, or 
should I somehow indicate that this file needs to be compiled in the moduleA 
CMakeLists.txt (which feels a bit wrong since the idea about the common project 
is to be referenced by more than one module). I guess I could use ADD_LIBRARY 
like in the example, but is that the right thing to do? I mean, basically I 
just want to reference the files from my modules, it's not exactly a library, 
just some common files. Maybe this is my mistake?

I hope I've made myself understood and I apologize for the length of this 
email. Any help would be appreciated.

Kind regards, Stefan Freyr.

signature.asc
Description: This is a digitally signed message part.
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake