... so CL_CPU_BIG_ENDIAN_P is set in src/base/cl_sysdep.h both for
autotools and CMake builds.
Note 1.
Checking for endianness of both `short` and `int` is necessary only
for 16-bit systems (where `short` can be 8-bit). I doubt anyone is
going to run CLN on such systems in the 21st century. Nevertheless
CMake does the right thing even for such targets (i.e. it tries to
find a 16-bit integer type and figure out its endianness).
Note 2.
These days (circa 2021) the vast majority of CPU architectures are
little endian, so the problem is mostly irrelevant.
test_big_endian(cl_cv_bigendian_p)
if(cl_cv_bigendian_p)
- set(cln_cpu_big_endian 1)
+ set(short_big_endian 1 CACHE INTERNAL "CPU is big endian")
+ set(int_big_endian 1 CACHE INTERNAL "CPU is big endian")
+ set(long_big_endian 1 CACHE INTERNAL "CPU is big endian")
else()
- set(cln_cpu_big_endian 0)
+ set(short_little_endian 1 CACHE INTERNAL "CPU is little endian")
+ set(int_little_endian 1 CACHE INTERNAL "CPU is little endian")
+ set(long_little_endian 1 CACHE INTERNAL "CPU is little endian")
endif()
include(AsmUnderscore)
// #endif
#define pointer_bitsize @cl_pointer_bitsize@
#define stack_grows_down
+#cmakedefine short_little_endian
+#cmakedefine int_little_endian
+#cmakedefine long_little_endian
+#cmakedefine short_big_endian
+#cmakedefine int_big_endian
+#cmakedefine long_big_endian
${CMAKE_CURRENT_BINARY_DIR}
)
-target_compile_definitions(cln
- PRIVATE
- -DCL_CPU_BIG_ENDIAN_P=${cln_cpu_big_endian}
-)
-
install(TARGETS cln
EXPORT cln-exports
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"