From: Alexey Sheplyakov Date: Sat, 2 Jan 2021 16:34:34 +0000 (+0400) Subject: cmake: defined `short_little_endian`, `int_little_endian` macros X-Git-Tag: cln_1-3-7~26 X-Git-Url: https://www.ginac.de/CLN/cln.git//cln.git?a=commitdiff_plain;h=1be3b72d21461cfb50c7b6f4ee0bec559080b32d;p=cln.git cmake: defined `short_little_endian`, `int_little_endian` macros ... 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. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c89ae1c..ba2d356 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,9 +135,13 @@ set(CMAKE_REQUIRED_LIBRARIES ${_save_required_libraries}) 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) diff --git a/include/cln/intparam.h.cmake b/include/cln/intparam.h.cmake index 7cea90b..a6febae 100644 --- a/include/cln/intparam.h.cmake +++ b/include/cln/intparam.h.cmake @@ -7,3 +7,9 @@ // #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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4305804..9602e67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -988,11 +988,6 @@ target_include_directories(cln ${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}"