[CMake] INCLUDE cannot find file

Dizzy dizzy at roedu.net
Tue Oct 2 06:28:11 EDT 2007


On Tuesday 02 October 2007 13:18:15 Shiqing Fan wrote:
> hi,
>
> Ok, now I figure it out. as the path is relative to
> ${CMAKE_CURRENT_SOURCE_DIR}, so I have to say INCLUDE
> (sub1/sub2/CMakeLists.txt) in sub2's CMakeLists, because this file is
> actually included in the top level (firstly included in sub1, then in
> top level).

Aha! This actually proves my add_subdirectory() point where the added 
directory when processed becomes the CMAKE_CURRENT_SOURCE_DIR.

> And some thing about why I use it. The project has a complicated file
> structure. Take the above structure as an example, both sub1 ans sub2
> have source files for generating a library on top level.
> And on 
> different platforms, not all the files are necessary. Yes, I could use
> SET(SOURCE ${SOURCE} file1 file2....) with relative path, but if the we
> have 4 or 5 levels of subdirectory, this is going to be a nightmare,
> because we have to manage all the source files on top level for
> different platforms.

But if the files are scattered randomly in various 4 level directories, some 
files that may need to be used on a platforms, others than dont, then you 
already have a nightmare and using SET() just shows the nightmare. Try to 
describe in more detail your project structure and also the simplest solution 
you can think of (even that it doesn't work directly with cmake like you 
think of it).

-- 
Mihai RUSU					Email: dizzy at roedu.net
			"Linux is obsolete" -- AST


More information about the CMake mailing list