[CMake] ADD_DEFINITIONS and "USE*" preprocessor flags
camille chambon
camillechambon at yahoo.fr
Tue Aug 2 04:31:24 EDT 2011
Hello,
I'm trying to understand how my C++ application can be compiled using CMake.
Actually, there is an include file (foo.h) which contains this line boost::shared_ptr<imp> _p;
but which doesn't contain #include <boost/shared_ptr.hpp>.
I can't see any include or source file in my application which includes boost/shared_ptr.hpp, and which could permit boost/shared_ptr.hppto be indirectly included in foo.h.
This line is needed In the CMakeLists.txt for the compilation to succeed : ADD_DEFINITIONS(-DUSE_BOOST_REGEX)
When I generate the Makefile using this CMakeLists.txt, a DependInfo.cmake file and a flags.make file are also generated.
DependInfo.cmake contains (among other things):
# Preprocessor definitions for this target.
SET(CMAKE_TARGET_DEFINITIONS
"DEBUG"
"DEBUG_LOG"
"USE_BOOST_REGEX"
...
)
flags.make contains (among other things):
# compile CXX with /usr/bin/c++
CXX_DEFINES = DEBUG -DDEBUG_LOG -DUSE_BOOST_REGEX
Thus USE_BOOST_REGEX is a flag used by the preprocessor to enabled the compilation of boost_regex component (if not already done).
But I cant' see anything like
#ifdefined USE_BOOST_REGEX
#include <boost/shared_ptr.hpp>
#endif
in any of my application include or source files.
So, how does this flag work? Is it related to CMake or only with gcc? My knowledge about how CXX_DEFINES works are quite limited. Do all "USE*" preprocessor flags work in the same way? Generally, when do I have to add this kind of preprocessor definitions?
Thank in advance for your help.
Regards,
Camille
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110802/d912797d/attachment.htm>
More information about the CMake
mailing list