[CMake] set_target_properties not setting COMPILE_DEFINITIONS?

Yuri Timenkov yuri at timenkov.ru
Mon Mar 28 14:28:22 EDT 2011


Try prefixing definitions with -D

On Mar 28, 2011 10:26 PM, "David Doria" <daviddoria at gmail.com> wrote:
> I have setup a list of definitions:
>
> SET(MAIN_BUILD_DEFINITIONS "${MAIN_BUILD_DEFINITIONS} UNIX;")
> SET(MAIN_BUILD_DEFINITIONS "${MAIN_BUILD_DEFINITIONS} PIXEL_DIMENSION=3;")
>
> I display them and apply them to my executable as follows:
>
> add_executable(ImageCompleter ${MainSources})
> message("Main build definitions: " ${MAIN_BUILD_DEFINITIONS})
> set_target_properties(ImageCompleter PROPERTIES COMPILE_DEFINITIONS
> "${MAIN_BUILD_DEFINITIONS}")
>
> The output is:
> Main build definitions: UNIX PIXEL_DIMENSION=3
>
> which looks correct (i.e. UNIX was defined)
>
> However, in my code there is:
>
> #if defined(UNIX)
> ... some code...
> #else
> #error "Not implemented for this platform!"
> #endif
>
> When I build, the error is produced, indicating that UNIX was not defined.
>
> I created a small standalone example and it worked as expected... any
> suggestions of what else to check?
>
> Thanks,
>
> David
> _______________________________________________
> 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/20110328/f6cf8acd/attachment.htm>


More information about the CMake mailing list