Robert Dailey wrote:
Hi,

I want to define a preprocessor directive through CMakeLists.txt, however the only documented method of doing this that I see is *add_definitions()*. Is there a better way of doing this? According to the documentation this isn't 100% portable, which in my opinion defeats the entire purpose of using CMake to begin with (Or at the very least that function itself). I don't think it is right to have to specify -D. I should be able to do:

add_definitions( BOOST_ALL_NO_LIB )

However, I have to do:

add_definitions( -DBOOST_ALL_NO_LIB )

Any help would be greatly appreciated.


We have yet to find a compiler that does not support -D. However, it seems unportable. In cmake 2.6 we added properties on directories and targets that do not have the -D:

http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_dir:COMPILE_DEFINITIONS
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:COMPILE_DEFINITIONS

That said, in doing that cmake parses add_definitions for -D and turns it into one of those properties anyway. So, both are equally compiler portable at this point should we ever see a compiler that does not use -D...

-Bill
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to