[CMake] Xcode paths not turning out right

Robert Dailey rcdailey at gmail.com
Mon Sep 21 15:48:23 EDT 2009


On Mon, Sep 21, 2009 at 1:43 PM, Brad King <brad.king at kitware.com> wrote:

> Robert Dailey wrote:
>
>> My paths are correct. I'm passing in the correct absolute paths into
>> add_executable. I think that cmake is using the current cmake file instead
>> of using the one that the function call originated from. For example, I have
>> two CMake scripts:
>>
>> /Users/imac/work/redsword/CMakeLists.txt
>> /Users/imac/work/redsword/projects/Newton/CMakeLists.txt
>>
>> The former script is the one that has the function:
>>
>> function( define_project )
>>  add_executable( .... )
>> endfunction()
>>
>> And the latter script calls the define_project() function. Can anyone peek
>> at the CMake source to see if this is indeed the case? Again, I'll try to
>> find time to provide a reproducible test project.
>>
>
> By the time the Xcode generator writes the path, there is no
> distinction between add_executable being called from the
> CMakeLists.txt directly or through the function.  If you
> message() out the path inside your function just before
> or after add_executable, that is the path the generator will
> see.  I expect it is correct, and the generator or Xcode
> does something funny....especially since it works in VS.


I've attached a test project that reproduces this issue. At the root "test"
directory, create a new directory called 'build'. So you will have
"test/build".

cd into test/build and run:

cmake -G "Xcode" ..

This will generate an xcode project for you. Open that, and right click on
main.cpp (which should be colored red because it is an invalid path) and
click "Get Info". Look at the path. It's totally wrong.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090921/f68c7a7a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.rar
Type: application/octet-stream
Size: 740 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090921/f68c7a7a/attachment-0001.obj>


More information about the CMake mailing list