Re: CHECK_SYMBOL_EXISTS and C++
Paul Osmialowski <[email protected]>
| Newsgroups | gmane.science.robotics.playerstage |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 2 Jul 2010, Rich Mattes wrote:
> There's an example of this in the check for TIMESPEC in
> cmake/internal/SearchForStuff.cmake. It's also how CMake does things like
> CHECK_INCLUDE_FILES internally.
>
> http://www.cmake.org/Wiki/CMake:How_To_Write_Platform_Checks might help,
> CHECK_C_SOURCE_COMPILES is at the bottom.
>
> Rich
I looked at SearchForStuff.cmake and found some good examples, however, I
wonder why in one file two different approaches are used:
1. CHECK_C_SOURCE_COMPILES (for me it would be CHECK_CXX_SOURCE_COMPILES):
INCLUDE (CheckCSourceCompiles)
SET (CHECK_TIMESPEC_SOURCE_CODE "#include <time.h>
int main () { struct timespec *tmp; return 0; }")
CHECK_C_SOURCE_COMPILES ("${CHECK_TIMESPEC_SOURCE_CODE}"
HAVE_STRUCT_TIMESPEC)
2. TRY_COMPILE (how does it know if it is C or C++?!):
SET (testSTLSource ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp/test_stl.cpp)
FILE (WRITE ${testSTLSource}
"#include <string>\nint main () {std::string a = \"blag\"; return
0;}\n")
TRY_COMPILE (HAVE_STL ${CMAKE_CURRENT_BINARY_DIR} ${testSTLSource})
Personally, I would take CHECK_CXX_SOURCE_COMPILES as it explicitly
picks the right compiler. Both aproaches seem to be answers for my
problem.
Paul
>
> -----Original Message-----
> From: Geoffrey Biggs [mailto:[email protected]]
> Sent: Friday, July 02, 2010 2:51 AM
> To: [email protected]
> Subject: Re: [Playerstage-developers] CHECK_SYMBOL_EXISTS and C++
>
> You can supply CMake with a short program and instruct it to see if it
> compiles, then based on the result decide if the feature that program
> uses is supported or not.
>
> Geoff
>
> On 02/07/10 15:40, Paul Osmialowski wrote:
>> Is it possible for cmake to check if some C++ stream modifier is defined?
>> I doubt CHECK_SYMBOL_EXISTS is capable to do that. I'd like to modify
>> CMakeLists.txt for epuck driver so it could check if std::showbase is
>> defined in <iostream> (which is not in older g++).
>>
>> Paul
>
> ----------------------------------------------------------------------------
> --
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Playerstage-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/playerstage-developers
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Playerstage-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/playerstage-developers
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first