[CMake] Using the -C option to cmake

Andreas Pakulat apaku at gmx.de
Fri Jun 29 09:37:26 EDT 2012


Hi,

On Fri, Jun 29, 2012 at 2:44 PM, Christian Arnault <arnault at lal.in2p3.fr>wrote:

>  Hi,
>
> I wanted to factor out some initial stuff of my CMakeLists.txt that I
> systematically include.
>
> typically I include the following lines at the beginning of all my
> CMakeLists.txt:
>
> cmake_minimum_required(VERSION 2.8)
> function (AA)
>   message ("calling AA")
> endfunction()
>
> AA()
>
> Then I thought by using the -C option as follows:
>
> > cmake --build=. -C %CMTROOT%\Init.cmake ..\CMakeLists.txt
>
> with Init.cmake file containing
>
> function(AA)
>   message("calling aaaa")
> endfunction()
>
> This would be equivalent.
>
> Apparently this is not the case. In particular, the function definitions
> are not transmitted by this mechanism
>
> loading initial cache file ...\Init.cmake
>
> ... the functions defined in Init.cmake are not recognized
>

The cmake manual explains why this happens, the script is only executed to
prefill the cache file, its not prepended to the cmakelists.txt files that
are being run.


> Of course I could 'manually' include my module in all CMakeLists.txt but
> ...
>
> Can someone explain why?
>
> Or, how could I obtain what I need?
>

Use include() in your cmakelists.txt files.

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120629/28c4808e/attachment.htm>


More information about the CMake mailing list