On 07/14/2010 04:37 PM, [email protected] wrote:
> Hello,
> 
> My project has third party source in a subdirectory.  The third party
> source has to be compiled without special options.  With autoconf, we
> had "CFLAGS =".  How would I do the same with cmake and restore CFLAGS
> to their original value in the parent directory?

In the third party sources' CMakeLists.txt, do:

SET_DIRECTORY_PROPERTIES(PROPERTIES COMPILE_DEFINITIONS "")
GET_DIRECTORY_PROPERTY(DEFS DEFINITIONS)
SEPARATE_ARGUMENTS(DEFS)
REMOVE_DEFINITIONS(${DEFS})

The GET_DIRECTORY_PROPERTY()/REMOVE_DEFINITIONS() combination should be
obvious, and the SEPARATE_ARGUMENTS() is necessary to prepare the flags
for removal. Unfortunately, it fails with defines like -DNAME="ABC XYZ"
that will be split at the space in -DNAME="ABC and XYZ", but luckily in
turn, REMOVE_DEFINITIONS() silently ignores such strange flags. Though,
these defines would still show up in the compilation lines, so remove
them with SET_DIRECTORY_PROPERTIES(). Of course, you mustn't have any
properties on targets or sources with additional flags or definitions
in that directory.

As a last resort, you can manipulate the CMAKE_<LANG>_COMPILE_OBJECT
variables in that directory only, i.e. remove <FLAGS> and <DEFINES>,
but this depends on a certain knowledge of these rule variables, i.e.
it's doubtful if this works the same for all platforms, compilers etc.

'hope that helps.

Regards,

Michael
_______________________________________________
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

Reply via email to