[CMake] TEST_BIG_ENDIAN fails for a CXX project

George Ryan gryan at akoostix.com
Wed Jul 8 18:22:31 EDT 2009


I don't think the test should enable the C language, at least not for
the entire project because that might cause weird and unexpected
problems. It would be nice if the module could look at whether the C
language or the C++ language were enabled (or both) and select the
appropriate compiler for the setting. I don't know how easy that would
be to do, but from the user's point-of-view it would be the most
convenient.


A fair alternative might be to allow the user to supply the language
with the check, e.g., 
TEST_BIG_ENDIAN( VARIABLE_NAME CXX )

Are either of those doable?

On Wed, 2009-07-08 at 12:08 +0200, Eric Noulard wrote: 

> 2009/7/8  <gryan at akoostix.com>:
> > Hi! I have a project specified as CXX explicitly, and it requires knowing
> > the endian of the machine. I can't seem to use the TEST_BIG_ENDIAN module,
> > because it's a .c compilation and I get a
> >
> > ... /CheckIncludeFile.c".  TRY_COMPILE only works for enabled languages.
> > Currently enabled languages are: CXX
> > See PROJECT command for help enabling other languages.
> >
> > Error.
> >
> > Am I doing something wrong, or is that by design somehow? I can always
> > just let CMake determine the project type itself, but it seems like there
> > should be a way to do an endian check for a CXX project.
> 
> I did face the same issue and did manually add
> 
> ENABLE_LANGUAGE(C)
> 
> in my main CMakeLists.txt
> 
> may be the module assuming C has been enabled should
> test CMAKE_C_COMPILER_WORKS before going on.
> 
> Whether they should automatically ENABLE_LANGUAGE(C) is questionable?
> Now since most C programs can be compiled with a C++ compiler
> may be the module should directly use C++ compiler if C is not enabled?
> 
> What's your opinion?
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090708/2290c8ba/attachment.htm>


More information about the CMake mailing list