[CMake] Can't get include() to work!

Philip Lowman philip at yhbt.com
Mon Dec 1 22:53:59 EST 2008


On Mon, Dec 1, 2008 at 7:59 PM, Michael Jackson <mike.jackson at bluequartz.net
> wrote:

>
> On Dec 1, 2008, at 5:12 PM, Robert Dailey wrote:
>
>  For some reason I cannot get include() to work.
>>
>> In a CMakeLists.txt of mine (not the root CMakeLists.txt) I call the
>> following:
>>
>> cmake_minimum_required( VERSION 2.6 )
>> include( includes.cmake )
>> project( vfx )
>>
>> And I have a file called includes.cmake in the same directory containing
>> the CMakeLists.txt above. When I run cmake -G "Visual Studio 9 2008", I get
>> the following output:
>>
>> C:\IT\work\jewett>cmake -G "Visual Studio 9 2008"
>> CMake Error at vfx/CMakeLists.txt:2 (include):
>>  include could not find load file:
>>
>>    includes.cmake
>>
>
>
> How is your cmake file being called? If it is being called with
> "include(...)" then basically your file contents is substituted for the
> "include(...)" call. So the file "includes.cmake" without any leading prefix
> directory makes sense that it can not be found.
>
> You basically need to get the current directory that CMake is traversing to
> figure out what prefix to use.
>
> Do you _really_ need to place the include(includes.cmake) BEFORE the
> project() command? If you can swap these two lines then you can do something
> like:
>
> project (vfx)
> include ( ${vfx_SOURCE_DIR}/includes.cmake ) and it should find the
> "includes.cmake" file in the same directory as the vfx CMakeLists.txt file.
>
> Hope that helps.


include( ${CMAKE_CURRENT_SOURCE_DIR}/includes.cmake)
should also work.
CMAKE_MODULE_PATH may also help you if you have a lot of includes.

http://www.vtk.org/Wiki/CMake_Useful_Variables

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081201/1bb7fe9f/attachment.htm>


More information about the CMake mailing list