[CMake] cmake: Duplicate file name conflict
Petr Kmoch
petr.kmoch at gmail.com
Wed Jul 8 03:58:53 EDT 2015
I can't see anything obviously wrong with your setup. Can you post the
error you're getting as well?
The only candidate for trouble I can think of is AUTOMOC. I don't have
experience with that, but is it possible the name clash comes from
AUTOMOC-generated files?
Petr
On Wed, Jul 8, 2015 at 9:46 AM, Jan Steinke <jan.steinke at gmail.com> wrote:
> Hi Peter,
> Thanks for your quick reply.
>
> My file structure is as such
> someFolder/
> library/code/include/*sameName.h*
> library/code/include/anotherName.h
> library/code/source/sameName.cpp
> library/code/source/anotherName.cpp
>
> application/code/include/*sameName.h*
> application/code/include/yetAnotherName.h
> application/code/source/*sameName.cpp*
> application/code/source/yetAnotherName.cpp
>
> *My CMakeLists.txt for the library:*
> cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
> project(library)
> set(Headers include/sameName.h
> include/anotherName.h)
>
> set(Sources source/sameName.cpp
> sources/anotherName.h)
> set(CMAKE_AUTOMOC ON)
> include_directories(include)
> add_library(${PROJECT_NAME} STATIC ${Headers} ${Sources})
> target_link_libraries(${PROJECT_NAME})
>
> *CMakeLists.txt for the application:*
> cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
> project(application)
> set(Headers include/sameName.h
> include/yetAnotherName.h)
> set(Sources source/sameName.cpp
> source/yetAnotherName.cpp)
> set(CMAKE_AUTOMOC ON)
> set(CMAKE_AUTORCC ON)
> set(LIBRARY_ROOT ${PROJECT_SOURCE_DIR}/../../library)
>
> include_directories(include)
> include_directories(include/remotes)
> include_directories($LIBRARY_ROOT}/code/include)
> include_directories(${PROJECT_BINARY_DIR}
>
> add_subdirectory(${LIBRARY_ROOT}/code library)
> add_executable(${PROJECT_NAME} ${Forms} ${Headers}
> resources/${PROJECT_NAME}.qrc ${Sources})
> target_link_libraries(${PROJECT_NAME} library)
>
> I hope that helps understanding my problem. Since the content of
> sameName.h and sameName.cpp of the library is different from those of the
> application it doesn't build. However, it would be confusing to name them
> differently since their job is the same.
>
> Thanks in advance,
> Jan
>
> On Wed, Jul 8, 2015 at 9:03 AM Petr Kmoch <petr.kmoch at gmail.com> wrote:
>
>> Hi Jan,
>>
>> it'simpossible to answer such questions without seeing your setup. Can
>> you post your CMakeList and your directory structure?
>>
>> Petr
>>
>> On Tue, Jul 7, 2015 at 6:36 PM, Jan Steinke <jan.steinke at gmail.com>
>> wrote:
>>
>>> Dear all,
>>> I came across a problem, for me it seems that cmake does not allow
>>> header files to be have the same name. Or am I doing something wrong?
>>>
>>> I have two projects, a library and an application. Both have files with
>>> similar content, but the same file names. I am using cmake to compile the
>>> app and the aim is that cmake also compiles the library if it doesn't yet
>>> exist. I was stuck for a few days on that problem until I figured out that
>>> it was due to the same file names. When renaming the files in my
>>> application it builds correctly. Before I switched to cmake a week ago, I
>>> used qmake integrated into Qt Creator, and it compiled just fine.
>>>
>>> Is it wanted behavior, that cmake does not allow the same file names? Am
>>> I doing something wrong? Altough it works with renaming the files I would
>>> like to find a "cleaner" way that prevents this from happening in the
>>> future, having same file names is nothing you can prevent if you work in a
>>> team.
>>>
>>> I hope you are able to help me,
>>> Jan
>>> --
>>> Jan
>>>
>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Kitware offers various services to support the CMake community. For more
>>> information on each offering, please visit:
>>>
>>> CMake Support: http://cmake.org/cmake/help/support.html
>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/cmake
>>>
>>
>> --
> Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150708/acc73d6e/attachment-0001.html>
More information about the CMake
mailing list