[CMake] How to query compiler definitions?
Michael Wild
themiwi at gmail.com
Wed Jan 19 10:00:14 EST 2011
On 01/19/2011 03:45 PM, SF Markus Elfring wrote:
>> set_source_files_properties(debug_funcs.c PROPERTIES
>> EXCLUDE_FROM_CONFIGURATIONS "Release;MinSizeRel")
>
> I do not want to exclude this file based on the value of the variable
> "CMAKE_BUILD_TYPE". ;-)
Why not? That's mostly equivalent to doing it based on -DNDEBUG (which
is automatically defined for Release and MinSizeRel). Or is it actually
another criterion (such as whether testing is enabled)?
>
>
>> I don't think it would make to do this based on preprocessor definitions.
>
> It seems that our ideas converge. :-)
>
>
>> So, toy.cxx is not actually the problem,
>
> Correct.
>
>
>> but you don't want to link against the XML library.
>
> Partly. yes.
>
> I am affected by a general issue from C++ class libraries. The
> corresponding free source files were copied to a subdirectory of the
> project I am interested in because a public shared library (*.so/*.dll)
> seems to be missing for it. (The project has got its own bundle of
> external software.)
>
> Library features are used in a limited way so far. This has got the
> consequence that its compilation should be optional for specific
> application parts.
>
>
>> Do you need the library anyways (e.g. for other targets) [...] ?
>
> The software test part depends on the C++ class library unconditionally.
So, you always build tinyxml? In that case, simply use this:
------------<8------------
add_library(tinyxml STATIC
tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp)
------------<8------------
add_executable(super a.cpp b.cpp c.cpp toy.cpp)
target_link_libraries(super debug tinyxml)
In that case, super will be linked against the tinyxml target only for
the debugging configurations.
>
>
>> However, if libxml is required for debugging only and you don't want to
>> require it unconditionally, you have a problem and I can't see an easy
>> way around it.
>
> The utility "http://grinninglizard.com/tinyxml/index.html" is needed in
> my case.
>
> Regards,
> Markus
Michael
More information about the CMake
mailing list