I got it to work with the built in TestBigEndian (as of 2.4.3)
INCLUDE(TestBigEndian)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
IF (WORDS_BIGENDIAN)
ADD_DEFINITIONS("-DB_ENDIAN")
ELSE (WORDS_BIGENDIAN)
ADD_DEFINITIONS("-DL_ENDIAN")
ENDIF (WORDS_BIGENDIAN)
Thanks everyone for the help
--
Mike Jackson Senior Research Engineer
Innovative Management & Technology Services
On Nov 22, 2006, at 1:15 PM, Brandon J. Van Every wrote:
Eric Noulard wrote:
May be you could use TRY_RUN to detect endianity
with something like:
TRY_RUN(
ENDIANESS_RESULT
ENDIANESS_COMPILE
/tmp/
${CMAKE_CURRENT_SOURCE_DIR}/make/endianess.c
OUTPUT_VARIABLE ENDIANESS_OUT
)
MESSAGE(STATUS "ENDIANITY is :${ENDIANESS_OUT}")
endianess.c is attached.
The trouble I have is that I expected to have
my "endianess" program output in ${ENDIANESS_OUT}
but I get too much including
compilation process ouput.
The format is:
TRY_RUN(RUN_RESULT_VAR COMPILE_RESULT_VAR
bindir srcfile <CMAKE_FLAGS <Flags>>
<COMPILE_DEFINITIONS <flags>>
<OUTPUT_VARIABLE var>
<ARGS <arg1> <arg2>..
Write a test called IsBigEndian.c. When run, have it return either
0 or 1. Get the result with RUN_RESULT_VAR. Use it and be happy.
Caveat: 0 is typically regarded as a *success* code when running a
system tool, so go over your bit twiddling convention carefully. I
can't remember what I did in Chicken's StackGrowsDownward.c, only
that Felix caught me doing it backwards and I was surprised.
Use COMPILER_RESULT_VAR to make sure your code actually worked, and
throw errors if it doesn't. Your code should always compile; this
would be a strange / severe / exceptional error.
OUTPUT_VARIABLE isn't useful for this kind of problem. It gives
you all the stdout stuff and you don't want that.
A complete working example of this kind of code is available in the
Chicken CMake build. Search CMakeLists.txt for
STACK_GROWS_DOWNWARD. http://www.call-with-current-
continuation.org . I think I'll document it more, so that the
return code conventions are less confusing.
Cheers,
Brandon Van Every
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake