[CMake] project command not working, when used via macro (from an included file)

Chuck Atkins chuck.atkins at kitware.com
Wed Apr 27 11:05:45 EDT 2016


Perhaps I spoke to hastily.  It seems the unsupported configuration is if
project(...) is actually called from an include file, which makes sense
given various scoping issues.  Give that, what you have should work fine.
What doesn't work as expected?  It seems to work just fine when I try it
from a macro defined in an include file.  Also, what version of CMake are
you using so I can try to reproduce your configuration more closely?

- Chuck

On Wed, Apr 27, 2016 at 10:09 AM, aj neu <ajneu1 at gmail.com> wrote:

> Ok thanks.
> But it is unfortunate, since it means that really great macros, such as
> project_guarded
> (see http://stackoverflow.com/a/33100078)
> cannot be used everywhere, as a substitute for project.
>
>
>
> On Tue, Apr 26, 2016 at 8:04 PM, Chuck Atkins <chuck.atkins at kitware.com>
> wrote:
>
>> ajneu,
>>
>> The call to project(...) needs to be explicit.  See
>> https://cmake.org/cmake/help/v3.5/command/project.html:
>>
>> The top-level CMakeLists.txt file for a project must contain a literal,
>> direct call to the project()
>> <https://cmake.org/cmake/help/v3.5/command/project.html#command:project>
>> command; loading one through the include()
>> <https://cmake.org/cmake/help/v3.5/command/include.html#command:include>
>> command is not sufficient.
>>
>> - Chuck
>>
>> On Tue, Apr 26, 2016 at 1:57 PM, aj neu <ajneu1 at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> when calling `project`
>>> ...as seen here
>>> ...
>>> https://github.com/ajneu/cmake_project_via_macro/blob/5972c7362e11fdbaa09d9defe8cca2dcea79e606/CMakeLists.txt#L33
>>> everything is ok.
>>>
>>>
>>> BUT when calling `project` via a macro (that was included)
>>> ... as seen here
>>> ...
>>> https://github.com/ajneu/cmake_project_via_macro/blob/master/CMakeLists.txt#L33
>>> the behaviour is not as expected.
>>>
>>> Why?
>>>
>>> (Details are here: https://github.com/ajneu/cmake_project_via_macro)
>>>
>>>
>>> Is this a bug?
>>>
>>> Thanks
>>> ajneu
>>>
>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160427/fea74c68/attachment.html>


More information about the CMake mailing list