[CMake] scope of set_source_files_properties?

David Cole david.cole at kitware.com
Mon Mar 22 04:55:56 EDT 2010


set_source_file_properties itself is not inherently scoped, but you are
using a partial relative file name for it, so of course that name is
inherently locally scoped....

Use a full path name instead, and the source file property will "stick" to
that full path name.

(i.e. -- use "${CMAKE_CURRENT_SOURCE_DIR}/subdir/test.c"
or "${CMAKE_CURRENT_SOURCE_DIR}/test.c" to refer to the file instead...)


HTH,
David


On Fri, Mar 19, 2010 at 6:42 PM, Simmons, Aaron
<asimmons at rosettastone.com>wrote:

> I'm having trouble using set_source_files_properties from a subdirectory.
>  Say I have a top-level CMakeLists.txt like this:
>        cmake_minimum_required(VERSION 2.8)
>        project(test)
>        add_subdirectory(subdir)
>        get_source_file_property( temp subdir/test.c COMPILE_FLAGS )
>        message("reading property from toplevel= ${temp}")
>
> and I have a subdir/CMakeLists.txt like this:
>        set_source_files_properties( subdir/test.c PROPERTIES COMPILE_FLAGS
> "-DBLAHBLAH")
>        get_source_file_property( temp subdir/test.c COMPILE_FLAGS )
>        message("reading property from subdir= ${temp}")
>
> then the output of cmake will be:
>        reading property from subdir= -DBLAHBLAH
>        reading property from toplevel= NOTFOUND
>
> Are source file properties inherently local scope?  Is there any way to
> specify the scope (like you can for the "set" function)?
>
>
>
> Thanks,
> aaron
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100322/c062b477/attachment.htm>


More information about the CMake mailing list