[CMake] add_custom and files generated into subdirectories
Micha Renner
Micha.Renner at t-online.de
Thu Apr 12 03:42:29 EDT 2012
I guess, this is one of the rare cases where one need:
SET_SOURCE_FILES_PROPERTIES(Foo.cpp PROPERTIES GENERATED TRUE)
Greetings
Micha
Am Mittwoch, den 11.04.2012, 11:18 -0500 schrieb William R. Otte:
> Hi -
>
> I have a question about resolving dependencies when add_custom is used to generate files into subdirectories. Consider the following example (substantially simplified from my use case, but it captures the essence of what I am trying to do:
>
> In the root of the project, I have the following:
>
> /Foo.cmake:
> add_custom_command (OUTPUT Bar/Foo.cpp
> COMMAND touch Bar/Foo.cpp
> )
>
> #end /Foo.cmake
>
> /CMakeLists.txt:
> cmake_minimum_required(VERSION 2.8)
>
> include (Foo.cmake)
> add_subdirectory (Bar)
>
> #end /CMakeLists.txt
>
> In a subdirectory Bar, I have the following:
>
> /Bar/Bar.cmake:
> add_library ( Bar SHARED
> Foo.cpp )
> #end /Bar/Bar.cmake
>
> /Bar/CMakeLists.txt:
> include (Bar.cmake)
> #end /Bar/CMakeLists.txt
>
>
> When I attempt to compile this into makefiles, I get the following diagnostic from cmake:
>
> CMake Error at Bar/Bar.cmake:1 (add_library):
> Cannot find source file:
>
> Foo.cpp
>
> Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
> .hxx .in .txx
> Call Stack (most recent call first):
> Bar/CMakeLists.txt:1 (include)
>
>
> I understand why that diagnostic is appearing (cmake knows about a Bar/Foo.cpp, but not about a Foo.cpp). Is there some way to get Cmake to automagically realize that within the context of Bar.cmake, Foo.cpp and Bar/Foo.cpp are the same thing?
>
> thanks,
> /-Will
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list