Skip to content

Instantly share code, notes, and snippets.

@isilkor
Last active August 18, 2016 09:25
Show Gist options
  • Save isilkor/9c52c903bed9358d40df20cb9cbad886 to your computer and use it in GitHub Desktop.
Save isilkor/9c52c903bed9358d40df20cb9cbad886 to your computer and use it in GitHub Desktop.
libffi 3.1 CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
project(libffi C ASM_MASM)
set(VERSION 3.1)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/src/x86" "${CMAKE_CURRENT_BINARY_DIR}")
add_definitions(-DHAVE_CONFIG_H -DDLL_EXPORT -DPIC)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TARGET X86_WIN64)
else()
set(TARGET X86_WIN32)
endif()
include(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(memcpy string.h HAVE_MEMCPY)
CHECK_SYMBOL_EXISTS(alloca "alloca.h" HAVE_ALLOCA)
include(CheckIncludeFile)
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H)
CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
CHECK_INCLUDE_FILE("sys/mman.h" HAVE_SYS_MMAN_H)
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
include(CheckTypeSize)
CHECK_TYPE_SIZE("double" SIZEOF_DOUBLE BUILTIN_TYPES_ONLY)
CHECK_TYPE_SIZE("long double" SIZEOF_LONG_DOUBLE BUILTIN_TYPES_ONLY)
if(SIZEOF_LONG_DOUBLE AND SIZEOF_LONG_DOUBLE GREATER SIZEOF_DOUBLE)
set(HAVE_LONG_DOUBLE 1)
else()
set(HAVE_LONG_DOUBLE 0)
endif()
set(FFI_EXEC_TRAMPOLINE_TABLE 0)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/ffi.h.in" "${CMAKE_CURRENT_BINARY_DIR}/ffi.h")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/fficonfig.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/fficonfig.h")
# In theory, CMake supports MASM. What it neglects to tell you is that it only
# does when you use a Makefile-based generator. Otherwise it just silently
# ignores assembly files, not even emitting a warning. Because that's totally
# useful.
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ASM_SRC win64)
set(SAFESEH_PARAM)
else()
set(ASM_SRC win32)
set(SAFESEH_PARAM -safeseh)
endif()
add_custom_command(OUTPUT "${ASM_SRC}.asm"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/x86/${ASM_SRC}.S"
COMMAND
"${CMAKE_C_COMPILER}" "-I${CMAKE_CURRENT_SOURCE_DIR}/include" "-I${CMAKE_CURRENT_BINARY_DIR}" "-I${CMAKE_CURRENT_SOURCE_DIR}/src/x86"
-DHAVE_CONFIG_H -DDLL_EXPORT -DPIC
-P -EP -Fi${ASM_SRC}.asm -nologo
"${CMAKE_CURRENT_SOURCE_DIR}/src/x86/${ASM_SRC}.S"
)
add_custom_command(OUTPUT "${ASM_SRC}.obj"
DEPENDS "${ASM_SRC}.asm"
COMMAND
${CMAKE_ASM_MASM_COMPILER}
-c $<$<NOT:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>>:-safeseh> -nologo ${ASM_SRC}.asm
)
add_library(ffi STATIC
src/x86/ffi.c
src/closures.c
src/java_raw_api.c
src/prep_cif.c
src/raw_api.c
src/types.c
${ASM_SRC}.obj
)
set_property(TARGET ffi PROPERTY PUBLIC_HEADER ffi.h src/x86/ffitarget.h)
install(TARGETS ffi
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
/* fficonfig.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#cmakedefine AC_APPLE_UNIVERSAL_BUILD
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#cmakedefine CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#cmakedefine C_ALLOCA
/* Define to the flags needed for the .section .eh_frame directive. */
#cmakedefine EH_FRAME_FLAGS
/* Define this if you want extra debugging. */
#cmakedefine FFI_DEBUG
/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
#cmakedefine FFI_EXEC_TRAMPOLINE_TABLE
/* Define this if you want to enable pax emulated trampolines */
#cmakedefine FFI_MMAP_EXEC_EMUTRAMP_PAX
/* Cannot use malloc on this target, so, we revert to alternative means */
#cmakedefine FFI_MMAP_EXEC_WRIT
/* Define this if you do not want support for the raw API. */
#cmakedefine FFI_NO_RAW_API
/* Define this if you do not want support for aggregate types. */
#cmakedefine FFI_NO_STRUCTS
/* Define to 1 if you have `alloca', as a function or macro. */
#cmakedefine HAVE_ALLOCA 1
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#cmakedefine HAVE_ALLOCA_H 1
/* Define if your assembler supports .ascii. */
#cmakedefine HAVE_AS_ASCII_PSEUDO_OP 1
/* Define if your assembler supports .cfi_* directives. */
#cmakedefine HAVE_AS_CFI_PSEUDO_OP 1
/* Define if your assembler supports .register. */
#cmakedefine HAVE_AS_REGISTER_PSEUDO_OP 1
/* Define if your assembler and linker support unaligned PC relative relocs.
*/
#cmakedefine HAVE_AS_SPARC_UA_PCREL 1
/* Define if your assembler supports .string. */
#cmakedefine HAVE_AS_STRING_PSEUDO_OP 1
/* Define if your assembler supports unwind section type. */
#cmakedefine HAVE_AS_X86_64_UNWIND_SECTION_TYPE 1
/* Define if your assembler supports PC relative relocs. */
#cmakedefine HAVE_AS_X86_PCREL 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H 1
/* Define if __attribute__((visibility("hidden"))) is supported. */
#cmakedefine HAVE_HIDDEN_VISIBILITY_ATTRIBUTE 1
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1
/* Define if you have the long double type and it is bigger than a double */
#cmakedefine HAVE_LONG_DOUBLE 1
/* Define if you support more than one size of the long double type */
#cmakedefine HAVE_LONG_DOUBLE_VARIANT 1
/* Define to 1 if you have the `memcpy' function. */
#cmakedefine HAVE_MEMCPY 1
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H 1
/* Define to 1 if you have the `mmap' function. */
#cmakedefine HAVE_MMAP 1
/* Define if mmap with MAP_ANON(YMOUS) works. */
#cmakedefine HAVE_MMAP_ANON 1
/* Define if mmap of /dev/zero works. */
#cmakedefine HAVE_MMAP_DEV_ZERO 1
/* Define if read-only mmap of a plain file works. */
#cmakedefine HAVE_MMAP_FILE 1
/* Define if .eh_frame sections should be read-only. */
#cmakedefine HAVE_RO_EH_FRAME 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H 1
/* Define to 1 if you have the <sys/mman.h> header file. */
#cmakedefine HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#cmakedefine LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#cmakedefine NO_MINUS_C_MINUS_O
/* Name of package */
#cmakedefine PACKAGE "@PACKAGE@"
/* Define to the address where bug reports for this package should be sent. */
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
/* Define to the full name of this package. */
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
/* Define to the full name and version of this package. */
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
/* Define to the one symbol short name of this package. */
#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@"
/* Define to the home page for this package. */
#cmakedefine PACKAGE_URL "@PACKAGE_URL@"
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
/* The size of `double', as computed by sizeof. */
#cmakedefine SIZEOF_DOUBLE @SIZEOF_DOUBLE@
/* The size of `long double', as computed by sizeof. */
#cmakedefine SIZEOF_LONG_DOUBLE @SIZEOF_LONG_DOUBLE@
/* The size of `size_t', as computed by sizeof. */
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#cmakedefine STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS
/* Define if symbols are underscored. */
#cmakedefine SYMBOL_UNDERSCORE
/* Define this if you are using Purify and want to suppress spurious messages.
*/
#cmakedefine USING_PURIFY
/* Version number of package */
#cmakedefine VERSION
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define to `unsigned int' if <sys/types.h> does not define. */
#cmakedefine size_t
#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
#ifdef LIBFFI_ASM
#define FFI_HIDDEN(name) .hidden name
#else
#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
#endif
#else
#ifdef LIBFFI_ASM
#define FFI_HIDDEN(name)
#else
#define FFI_HIDDEN
#endif
#endif
--- a/gettext-runtime/config.h.cmake 2012-08-06 19:17:29.000000000 +0200
+++ b/gettext-runtime/config.h.cmake 2016-01-10 14:18:49.404888300 +0100
@@ -944,7 +944,7 @@
#cmakedefine HAVE___FSETLOCKING 1
/* Define as const if the declaration of iconv() needs const. */
-#cmakedefine ICONV_CONST @ICONV_CONST@
+#define ICONV_CONST @ICONV_CONST@
/* Define to a symbolic name denoting the flavor of iconv_open()
implementation. */
--- a/gettext-runtime/intl/intl.def 2012-08-06 19:17:29.000000000 +0200
+++ b/gettext-runtime/intl/intl.def 2016-01-10 14:18:49.411389400 +0100
@@ -49,3 +49,5 @@
libintl_textdomain
libintl_version
locale_charset
+libintl_printf
+libintl_sprintf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment