From 23a06e9d1ef02714a6dce79c0e464cb3a740eda8 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 11 May 2015 16:55:23 +0100 Subject: [PATCH 1/2] [cmake] Add eglib --- CMakeLists.txt | 19 ++++++ eglib/CMakeLists.txt | 93 +++++++++++++++++++++++++++ eglib/config.h.cmake | 128 ++++++++++++++++++++++++++++++++++++++ eglib/src/CMakeLists.txt | 73 ++++++++++++++++++++++ eglib/test/CMakeLists.txt | 34 ++++++++++ 5 files changed, 347 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 eglib/CMakeLists.txt create mode 100644 eglib/config.h.cmake create mode 100644 eglib/src/CMakeLists.txt create mode 100644 eglib/test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000000..33058c505c8e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required (VERSION 3.1) + +project (mono) + +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set (DARWIN 1) +endif () + +## FIXME +# set (ANDROID ) + +include (CheckIncludeFile) +include (CheckLibraryExists) +include (CheckSymbolExists) +include (CheckFunctionExists) +include (CheckTypeSize) +include (CheckCSourceCompiles) + +add_subdirectory (eglib) diff --git a/eglib/CMakeLists.txt b/eglib/CMakeLists.txt new file mode 100644 index 000000000000..252abb9a957a --- /dev/null +++ b/eglib/CMakeLists.txt @@ -0,0 +1,93 @@ +project (eglib) + +include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") +include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/src") + +set (PROJECT_VERSION "0.3") + +set (PACKAGE "${PROJECT_NAME}") +set (PACKAGE_VERSION "${PROJECT_VERSION}") +set (PACKAGE_BUGREPORT "http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono") +set (PACKAGE_NAME "${PACKAGE}") +set (PACKAGE_STRING "${PACKAGE} ${PACKAGE_VERSION}") +set (PACKAGE_TARNAME "${PACKAGE}") +set (PACKAGE_URL "") + +if (ANDROID) + set (PLATFORM_ANDROID 1) +elseif (DARWIN) + set (TARGET_MACH 1) + + check_c_source_compiles ( +" +#include +#if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1 +#error fail this for ios +#endif +int main (void) { return 0; } +" + COMPILATION_SUCCESS + ) + + if (COMPILATION_SUCCESS) + set (TARGET_OSX 1) + else () + set (TARGET_IOS 1) + endif () +endif (ANDROID) + +check_include_file ("dlfcn.h" HAVE_DLFCN_H) +check_include_file ("getopt.h" HAVE_GETOPT_H) +check_include_file ("iconv.h" HAVE_ICONV_H) +check_include_file ("inttypes.h" HAVE_INTTYPES_H) +check_include_file ("langinfo.h" HAVE_LANGINFO_H) +check_include_file ("localcharset.h" HAVE_LOCALCHARSET_H) +check_include_file ("memory.h" HAVE_MEMORY_H) +check_include_file ("pwd.h" HAVE_PWD_H) +check_include_file ("stdint.h" HAVE_STDINT_H) +check_include_file ("stdlib.h" HAVE_STDLIB_H) +check_include_file ("string.h" HAVE_STRING_H) +check_include_file ("strings.h" HAVE_STRINGS_H) +check_include_file ("sys/resource.h" HAVE_SYS_RESOURCE_H) +check_include_file ("sys/select.h" HAVE_SYS_SELECT_H) +check_include_file ("sys/stat.h" HAVE_SYS_STAT_H) +check_include_file ("sys/time.h" HAVE_SYS_TIME_H) +check_include_file ("sys/types.h" HAVE_SYS_TYPES_H) +check_include_file ("sys/wait.h" HAVE_SYS_WAIT_H) +check_include_file ("unistd.h" HAVE_UNISTD_H) + +check_symbol_exists (getrlimit "sys/resource.h" HAVE_GETRLIMIT) +check_symbol_exists (rewinddir "dirent.h" HAVE_REWINDDIR) +check_symbol_exists (stpcpy "string.h" HAVE_STPCPY) +check_symbol_exists (strlcpy "string.h" HAVE_STRLCPY) +check_symbol_exists (strtok_r "string.h" HAVE_STRTOK_R) +check_symbol_exists (vasprintf "stdio.h" HAVE_VASPRINTF) + +if (HAVE_ICONV_H) + check_library_exists (iconv iconv "-liconv" HAVE_ICONV) +endif () + +# Mono currently supports 10.6, but strndup is not available prior to 10.7; avoiding +# the detection of strndup on OS X so Mono built on 10.7+ still runs on 10.6. This can be +# removed once support for 10.6 is dropped. +# +# iOS detection of strndup and getpwuid_r is faulty for some reason so let's simply avoid it +if (TARGET_OSX) + check_function_exists (getpwuid_r HAVE_GETPWUID_R) +elseif (NOT TARGET_IOS) + check_function_exists (getpwuid_r HAVE_GETPWUID_R) + check_function_exists (strndup HAVE_STRNDUP) +endif () + +check_type_size ("int" SIZEOF_INT) +check_type_size ("long" SIZEOF_LONG) +check_type_size ("long long" SIZEOF_LONG_LONG) +check_type_size ("void*" SIZEOF_VOID_P) + +configure_file ( + "${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/config.h" +) + +add_subdirectory (src) +add_subdirectory (test) diff --git a/eglib/config.h.cmake b/eglib/config.h.cmake new file mode 100644 index 000000000000..26bd602e5a81 --- /dev/null +++ b/eglib/config.h.cmake @@ -0,0 +1,128 @@ +/* Name of package */ +#cmakedefine PACKAGE "${PROJECT_NAME}" + +/* 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}" + +/* Targeting the Android platform */ +#cmakedefine PLATFORM_ANDROID 1 + +/* The JIT/AOT targets iOS */ +#cmakedefine TARGET_IOS 1 + +/* The JIT/AOT targets Apple platforms */ +#cmakedefine TARGET_MACH 1 + +/* The JIT/AOT targets OSX */ +#cmakedefine TARGET_OSX 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getpwuid_r' function. */ +#cmakedefine HAVE_GETPWUID_R 1 + +/* Define to 1 if you have the `getrlimit' function. */ +#cmakedefine HAVE_GETRLIMIT 1 + +/* Define if you have the iconv() function and it works. */ +#cmakedefine HAVE_ICONV 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ICONV_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LANGINFO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LOCALCHARSET_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PWD_H 1 + +/* Define to 1 if you have the `rewinddir' function. */ +#cmakedefine HAVE_REWINDDIR 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#cmakedefine HAVE_STPCPY 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#cmakedefine HAVE_STRLCPY 1 + +/* Define to 1 if you have the `strndup' function. */ +#cmakedefine HAVE_STRNDUP 1 + +/* Define to 1 if you have the `strtok_r' function. */ +#cmakedefine HAVE_STRTOK_R 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `vasprintf' function. */ +#cmakedefine HAVE_VASPRINTF 1 + +/* The size of `int', as computed by sizeof. */ +#cmakedefine SIZEOF_INT ${SIZEOF_INT} + +/* The size of `long', as computed by sizeof. */ +#cmakedefine SIZEOF_LONG ${SIZEOF_LONG} + +/* The size of `long long', as computed by sizeof. */ +#cmakedefine SIZEOF_LONG_LONG ${SIZEOF_LONG_LONG} + +/* The size of `void *', as computed by sizeof. */ +#cmakedefine SIZEOF_VOID_P ${SIZEOF_VOID_P} diff --git a/eglib/src/CMakeLists.txt b/eglib/src/CMakeLists.txt new file mode 100644 index 000000000000..f2e8c5a67b5b --- /dev/null +++ b/eglib/src/CMakeLists.txt @@ -0,0 +1,73 @@ + +list (APPEND SOURCES + eglib-remap.h + sort.frag.h + glib.h + garray.c + gbytearray.c + gerror.c + vasprintf.h + ghashtable.c + giconv.c + gmem.c + gmodule.h + goutput.c + gqsort.c + gstr.c + gslist.c + gstring.c + gptrarray.c + glist.c + gqueue.c + gpath.c + gshell.c + gspawn.c + gfile.c + gfile-posix.c + gpattern.c + gmarkup.c + gutf8.c + gunicode.c + unicode-data.h +) + +if (NEED_VASPRINTF) + list (APPEND SOURCES vasprintf.c) +endif (NEED_VASPRINTF) + +if (HOST_WIN32) + list (APPEND SOURCES + eglib-config.hw + gdate-win32.c + gdir-win32.c + gfile-win32.c + gmisc-win32.c + gmodule-win32.c + gtimer-win32.c + ) +else () + list (APPEND SOURCES + gdate-unix.c + gdir-unix.c + gfile-unix.c + gmisc-unix.c + gmodule-unix.c + gtimer-unix.c + ) +endif (HOST_WIN32) + +add_library (eglib-obj OBJECT ${SOURCES}) +set_target_properties (eglib-obj PROPERTIES COMPILE_FLAGS "-g -Wall -D_FORTIFY_SOURCE=2") + +add_library (eglib SHARED $) +add_library (eglib-static STATIC $) + +if (HOST_WIN32) + set_target_properties (eglib PROPERTIES LINK_FLAGS "-lm -lpsapi ${LIBICONV}") + set_target_properties (eglib-static PROPERTIES LINK_FLAGS "-lm -lpsapi ${LIBICONV}") +elseif (PLATFORM_ANDROID) + set_target_properties (eglib PROPERTIES LINK_FLAGS "-llog") + set_target_properties (eglib-static PROPERTIES LINK_FLAGS "-llog ${LIBICONV}") +else () + set_target_properties (eglib-static PROPERTIES LINK_FLAGS "${LIBICONV}") +endif (HOST_WIN32) diff --git a/eglib/test/CMakeLists.txt b/eglib/test/CMakeLists.txt new file mode 100644 index 000000000000..9f9733b0c841 --- /dev/null +++ b/eglib/test/CMakeLists.txt @@ -0,0 +1,34 @@ + +list (APPEND SOURCES + test.c + test.h + tests.h + driver.c + hashtable.c + string-util.c + string.c + slist.c + sizes.c + ptrarray.c + list.c + array.c + fake.c + path.c + queue.c + shell.c + spawn.c + timer.c + file.c + pattern.c + dir.c + markup.c + unicode.c + utf8.c + endian.c + module.c + memory.c +) + +add_executable (test-eglib EXCLUDE_FROM_ALL ${SOURCES}) +set_target_properties (test-eglib PROPERTIES COMPILE_FLAGS "-Wall -DEGLIB_TESTS=1 -D_FORTIFY_SOURCE=2 -DDRIVER_NAME=\\\"EGlib\\\"") +target_link_libraries (test-eglib eglib-static) From c3f66be4a82ac7ed58384ad6f74016cc92978f40 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 11 May 2015 17:02:21 +0100 Subject: [PATCH 2/2] [cmake] Fix potential build issue on windows --- eglib/src/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eglib/src/CMakeLists.txt b/eglib/src/CMakeLists.txt index f2e8c5a67b5b..ab88386ac58f 100644 --- a/eglib/src/CMakeLists.txt +++ b/eglib/src/CMakeLists.txt @@ -35,7 +35,7 @@ if (NEED_VASPRINTF) list (APPEND SOURCES vasprintf.c) endif (NEED_VASPRINTF) -if (HOST_WIN32) +if (WIN32) list (APPEND SOURCES eglib-config.hw gdate-win32.c @@ -54,7 +54,7 @@ else () gmodule-unix.c gtimer-unix.c ) -endif (HOST_WIN32) +endif (WIN32) add_library (eglib-obj OBJECT ${SOURCES}) set_target_properties (eglib-obj PROPERTIES COMPILE_FLAGS "-g -Wall -D_FORTIFY_SOURCE=2") @@ -62,12 +62,12 @@ set_target_properties (eglib-obj PROPERTIES COMPILE_FLAGS "-g -Wall -D_FORTIFY_S add_library (eglib SHARED $) add_library (eglib-static STATIC $) -if (HOST_WIN32) +if (WIN32) set_target_properties (eglib PROPERTIES LINK_FLAGS "-lm -lpsapi ${LIBICONV}") set_target_properties (eglib-static PROPERTIES LINK_FLAGS "-lm -lpsapi ${LIBICONV}") -elseif (PLATFORM_ANDROID) +elseif (ANDROID) set_target_properties (eglib PROPERTIES LINK_FLAGS "-llog") set_target_properties (eglib-static PROPERTIES LINK_FLAGS "-llog ${LIBICONV}") else () set_target_properties (eglib-static PROPERTIES LINK_FLAGS "${LIBICONV}") -endif (HOST_WIN32) +endif (WIN32)