summaryrefslogtreecommitdiff
path: root/libs/luajit-cmake/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'libs/luajit-cmake/Modules')
-rwxr-xr-xlibs/luajit-cmake/Modules/DetectArchitecture.c29
-rwxr-xr-xlibs/luajit-cmake/Modules/DetectArchitecture.cmake37
-rwxr-xr-xlibs/luajit-cmake/Modules/DetectFPUApi.cmake68
-rwxr-xr-xlibs/luajit-cmake/Modules/DetectFpuAbi.c34
-rw-r--r--libs/luajit-cmake/Modules/FindUnwind.cmake60
5 files changed, 228 insertions, 0 deletions
diff --git a/libs/luajit-cmake/Modules/DetectArchitecture.c b/libs/luajit-cmake/Modules/DetectArchitecture.c
new file mode 100755
index 0000000..98a2254
--- /dev/null
+++ b/libs/luajit-cmake/Modules/DetectArchitecture.c
@@ -0,0 +1,29 @@
+#if defined(__aarch64__) || defined(__arm64__)
+const char *str = "ARCHITECTURE IS AArch64";
+#elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM)
+const char *str = "ARCHITECTURE IS ARM";
+#elif defined(__alpha__)
+const char *str = "ARCHITECTURE IS Alpha";
+#elif defined(__mips64__) || defined(__mips64) || defined(__MIPS64__) || defined(__MIPS64)
+const char *str = "ARCHITECTURE IS Mips64";
+#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS)
+const char *str = "ARCHITECTURE IS Mips";
+#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
+const char *str = "ARCHITECTURE IS PowerPC";
+#elif defined(__s390__)
+const char *str = "ARCHITECTURE IS SystemZ";
+#elif defined(__sparc__)
+const char *str = "ARCHITECTURE IS Sparc";
+#elif defined(__xcore__)
+const char *str = "ARCHITECTURE IS XCore";
+#elif defined(__i386__) || defined(__i686__) || defined(_M_IX86)
+const char *str = "ARCHITECTURE IS x86";
+#elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
+const char *str = "ARCHITECTURE IS x86_64";
+#endif
+
+int main(int argc, char **argv) {
+ int require = str[argc];
+ (void)argv;
+ return require;
+}
diff --git a/libs/luajit-cmake/Modules/DetectArchitecture.cmake b/libs/luajit-cmake/Modules/DetectArchitecture.cmake
new file mode 100755
index 0000000..a35c523
--- /dev/null
+++ b/libs/luajit-cmake/Modules/DetectArchitecture.cmake
@@ -0,0 +1,37 @@
+
+##===- DetectArchitecture.cmake -------------------------------------------===##
+#
+# Performs a try_compile to determine the architecture of the target.
+#
+##===----------------------------------------------------------------------===##
+get_filename_component(__check_architecture_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+macro(detect_architecture variable)
+ try_compile(HAVE_${variable}
+ ${CMAKE_BINARY_DIR}
+ ${__check_architecture_size_dir}/DetectArchitecture.c
+ OUTPUT_VARIABLE OUTPUT
+ COPY_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectArchitecture.bin)
+
+ if(HAVE_${variable})
+ file(STRINGS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectArchitecture.bin
+ DETECT_ARCH_STRING LIMIT_COUNT 1 REGEX "ARCHITECTURE IS")
+ if(DETECT_ARCH_STRING)
+ string(REGEX MATCH "[^ ]*$" DETECT_ARCH_MATCH ${DETECT_ARCH_STRING})
+ if(DETECT_ARCH_MATCH)
+ message(STATUS "Check target system architecture: ${DETECT_ARCH_MATCH}")
+ set(${variable} ${DETECT_ARCH_MATCH})
+ else()
+ message(SEND_ERROR "Could not detect target system architecture!")
+ endif()
+ else()
+ message(SEND_ERROR "Could not detect target system architecture!")
+ endif()
+ else()
+ message(STATUS "Determine the system architecture - failed")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining the system architecture failed with the following output:\n${OUTPUT}")
+ set(${variable})
+ endif()
+
+endmacro(detect_architecture)
diff --git a/libs/luajit-cmake/Modules/DetectFPUApi.cmake b/libs/luajit-cmake/Modules/DetectFPUApi.cmake
new file mode 100755
index 0000000..0aa2528
--- /dev/null
+++ b/libs/luajit-cmake/Modules/DetectFPUApi.cmake
@@ -0,0 +1,68 @@
+
+##===- DetectArchitecture.cmake -------------------------------------------===##
+#
+# Performs a try_compile to determine the architecture of the target.
+#
+##===----------------------------------------------------------------------===##
+
+get_filename_component(__check_fpu_mode_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+macro(detect_fpu_mode variable)
+ try_compile(HAVE_${variable}
+ ${CMAKE_BINARY_DIR}
+ ${__check_fpu_mode_dir}/DetectFpuAbi.c
+ OUTPUT_VARIABLE OUTPUT
+ COPY_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectFpuAbi.bin)
+
+ if(HAVE_${variable})
+ file(STRINGS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectFpuAbi.bin
+ DETECT_FPU_STRING LIMIT_COUNT 1 REGEX "FPU IS")
+ if(DETECT_FPU_STRING)
+ string(REGEX MATCH "[^ ]*$" DETECT_FPU_MATCH ${DETECT_FPU_STRING})
+ if(DETECT_FPU_MATCH)
+ message(STATUS "Check target fpu: ${DETECT_FPU_STRING}")
+ set(${variable} ${DETECT_FPU_MATCH})
+ else()
+ message(SEND_ERROR "Could not detect target fpu mode!")
+ endif()
+ else()
+ message(SEND_ERROR "Could not detect fpu mode!")
+ endif()
+ else()
+ message(STATUS "Determine the fpu mode - failed")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining the fpu mode failed with the following output:\n${OUTPUT}")
+ set(${variable})
+ endif()
+
+endmacro(detect_fpu_mode)
+
+macro(detect_fpu_abi variable)
+ try_compile(HAVE_${variable}
+ ${CMAKE_BINARY_DIR}
+ ${__check_fpu_mode_dir}/DetectFpuAbi.c
+ OUTPUT_VARIABLE OUTPUT
+ COPY_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectFpuAbi.bin)
+
+ if(HAVE_${variable})
+ file(STRINGS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectFpuAbi.bin
+ DETECT_FPU_ABI_STRING LIMIT_COUNT 1 REGEX "FPU ABI IS")
+ if(DETECT_FPU_ABI_STRING)
+ string(REGEX MATCH "[^ ]*$" DETECT_FPU_ABI_MATCH ${DETECT_FPU_ABI_STRING})
+ if(DETECT_FPU_ABI_MATCH)
+ message(STATUS "Check target fpu abi: ${DETECT_FPU_ABI_STRING}")
+ set(${variable} ${DETECT_FPU_ABI_MATCH})
+ else()
+ message(SEND_ERROR "Could not detect target fpu abi!")
+ endif()
+ else()
+ message(SEND_ERROR "Could not detect fpu abi!")
+ endif()
+ else()
+ message(STATUS "Determine the fpu abi - failed")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining the fpu abi failed with the following output:\n${OUTPUT}")
+ set(${variable})
+ endif()
+
+endmacro(detect_fpu_abi)
diff --git a/libs/luajit-cmake/Modules/DetectFpuAbi.c b/libs/luajit-cmake/Modules/DetectFpuAbi.c
new file mode 100755
index 0000000..ebc6baa
--- /dev/null
+++ b/libs/luajit-cmake/Modules/DetectFpuAbi.c
@@ -0,0 +1,34 @@
+#if defined(__SOFTFP__) || defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) || defined(__mips_soft_float)
+#define HAS_FPU 0
+#else
+#define HAS_FPU 1
+#endif
+
+#if !HAS_FPU
+const char *str = "\0FPU IS Soft";
+#else
+const char *str = "\0FPU IS Hard";
+#endif
+
+#if defined(__SOFTFP__) || defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) || defined(__mips_soft_float)
+#define SOFT_FPU_ABI 1
+#else
+#if (defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM)) && !defined(__ARM_PCS_VFP)
+#define SOFT_FPU_ABI 1
+#else
+#define SOFT_FPU_ABI 0
+#endif
+#endif
+
+#if SOFT_FPU_ABI
+const char *fpu_abi_str = "\0FPU ABI IS Soft";
+#else
+const char *fpu_abi_str = "\0FPU ABI IS Hard";
+#endif
+
+int main(int argc, char **argv) {
+ int require = str[argc];
+ (void)argv;
+ require += fpu_abi_str[argc];
+ return require;
+}
diff --git a/libs/luajit-cmake/Modules/FindUnwind.cmake b/libs/luajit-cmake/Modules/FindUnwind.cmake
new file mode 100644
index 0000000..a3649a5
--- /dev/null
+++ b/libs/luajit-cmake/Modules/FindUnwind.cmake
@@ -0,0 +1,60 @@
+# - Try to find libunwind
+# Once done this will define
+#
+# unwind_FOUND - system has libunwind
+# unwind - cmake target for libunwind
+
+find_library (UNWIND_LIBRARY NAMES unwind DOC "unwind library")
+include (CheckIncludeFile)
+
+check_include_file (unwind.h HAVE_UNWIND_H)
+if (NOT HAVE_UNWIND_H)
+ check_include_file (libunwind.h HAVE_UNWIND_H)
+endif ()
+
+if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
+ set(LIBUNWIND_ARCH "arm")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
+ set(LIBUNWIND_ARCH "aarch64")
+elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
+ CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64" OR
+ CMAKE_SYSTEM_PROCESSOR STREQUAL "corei7-64")
+ set(LIBUNWIND_ARCH "x86_64")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
+ set(LIBUNWIND_ARCH "x86")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64")
+ set(LIBUNWIND_ARCH "ppc64")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc")
+ set(LIBUNWIND_ARCH "ppc32")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
+ set(LIBUNWIND_ARCH "mips")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^hppa")
+ set(LIBUNWIND_ARCH "hppa")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^ia64")
+ set(LIBUNWIND_ARCH "ia64")
+endif()
+
+if (UNWIND_LIBRARY MATCHES "_FOUND")
+ set(UNWIND_LIBRARY unwind)
+ set(HAVE_UNWIND_LIB ON)
+else()
+ find_library (UNWIND_LIBRARY NAMES "unwind-${LIBUNWIND_ARCH}" DOC "unwind library platform")
+ if (UNWIND_LIBRARY MATCHES "_FOUND")
+ set(HAVE_UNWIND_LIB ON)
+ set(UNWIND_LIBRARY unwind-${LIBUNWIND_ARCH})
+ endif ()
+endif()
+
+if (HAVE_UNWIND_LIB AND HAVE_UNWIND_H)
+ set(unwind_FOUND ON)
+elseif(HAVE_UNWIND_H)
+ if (CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64
+ AND CMAKE_C_COMPILER_ID STREQUAL zig
+ AND NOT ANDROID
+ AND NOT IOS)
+ set(UNWIND_LIBRARY unwind)
+ set(HAVE_UNWIND_LIB ON)
+ endif()
+else ()
+ unset(UNWIND_LIBRARY)
+endif ()