[CMake] Xcode duplicate filename issue?

Watson, Andre Andre_Watson at intuit.com
Mon Jun 26 16:58:07 EDT 2017


Hi Gregor, so I wrote a really minimal test case for this, and to my surprise, it worked!  My suspicion was now that my issue is caused from using object libraries in our system, because I need to create libs of libs for ease of CMake use.  I modified my test case and got the issue again.  One of my coworkers also found this post from 2014 that is my exact issue: https://cmake.org/pipermail/cmake/2016-April/063169.html


Let me know if you still want a bug report since this has been reported before.


But for extra info, my case is slightly different than his:


Directories:

- CMakeLists.txt

- empty.cpp

- libdir

    - CMakeLists.txt

    - source.cpp

    - subdir

        - source.cpp



Root CMakeLists:

cmake_minimum_required(VERSION 3.6)
project(Test)

add_subdirectory(libdir)

set( SOURCE
    ./empty.cpp
)

add_library( ${PROJECT_NAME}
    ${SOURCE}
    $<TARGET_OBJECTS:libdir>
)



sub CMakeLists:

cmake_minimum_required(VERSION 3.6)
project(libdir)

set( SOURCE
    ./source.cpp
    ./subdir/source.cpp
)

add_library( ${PROJECT_NAME} OBJECT
    ${SOURCE}
)



source.cpp (1):

int subdir(int x);

int main()
{
    int i=subdir(5);
    return 0;
}



source.cpp (2):

int subdir(int x)
{
    int total = 0;

    for( int i=0; i<x; i++)
    {
        total += x;
    }

    return total;
}



empty.cpp is empty



Thank you!

________________________________
From: Gregor Jasny <gjasny at googlemail.com>
Sent: Monday, June 26, 2017 12:35:12 PM
To: Watson, Andre; cmake at cmake.org
Subject: Re: [CMake] Xcode duplicate filename issue?

Hello,

On 6/26/17 8:12 PM, Watson, Andre wrote:
> We're currently migrating a huge internal system over to CMake, and we're nearing completion, but have run into an issue with the generated Xcode projects.  We build this system on Windows, Linux, and Mac (both makefile and Xcode).  On all systems, we have a third party directory that has a couple of duplicate source names within a single CMakeLists.txt file.  On Windows, Linux, and makefile Mac, our projects all generate, build, and link successfully.  However, on Xcode Mac, our project builds, but fails to link.  On further inspection, the duplicate filenames are being generated into the intermediate build directories as filenames such as attributes-78663048C12E97C.o and attributes-FA2B54357D684A6E.o.  The linker, however, is looking for attributes.o.  It appears that the compiling process is recognizing the duplicate naming and adding on the hex string (the non duplicate .o's do not have these strings), but that these new filenames are not being passed to the linker.  Is this is an Xcode option that I am missing, or this something occurring within the CMake project generation that is causing is mismatch?

could you please try to create a minimal example and file a bug report?
I'll have a look then.

Thanks,
Gregor


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170626/cec791fc/attachment.html>


More information about the CMake mailing list