-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
303 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
From bb07532831ddb1fb379e2314d96b54e9dd601049 Mon Sep 17 00:00:00 2001 | ||
From: Jihadist <tomasiche@gmail.com> | ||
Date: Wed, 9 Nov 2022 20:48:19 +0300 | ||
Subject: [PATCH 2/2] cmake for msvc | ||
|
||
--- | ||
CMakeLists.txt | 30 ++++++++++ | ||
config.h | 128 +++++++++++++++++++++++++++++++++++++++++++ | ||
internal_utils.cmake | 65 ++++++++++++++++++++++ | ||
3 files changed, 223 insertions(+) | ||
create mode 100644 CMakeLists.txt | ||
create mode 100644 config.h | ||
create mode 100644 internal_utils.cmake | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
new file mode 100644 | ||
index 0000000..9a94160 | ||
--- /dev/null | ||
+++ b/CMakeLists.txt | ||
@@ -0,0 +1,26 @@ | ||
+cmake_minimum_required(VERSION 3.14) | ||
+project(ev C) | ||
+ | ||
+include(internal_utils.cmake) | ||
+config_compiler_and_linker() | ||
+ | ||
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
+ | ||
+set(LIBEV_PUBLIC_HEADERS | ||
+ ev.h | ||
+ config.h) | ||
+add_library(ev ev.c ${LIBEV_PUBLIC_HEADERS}) | ||
+target_link_libraries(ev PUBLIC ws2_32) | ||
+target_compile_definitions(ev PRIVATE HAVE_CONFIG_H=1) | ||
+target_include_directories(ev PUBLIC ${PROJECT_SOURCE_DIR}) | ||
+ | ||
+ | ||
+set_target_properties(ev PROPERTIES PUBLIC_HEADER "${LIBEV_PUBLIC_HEADERS}") | ||
+include(GNUInstallDirs) | ||
+ | ||
+install(TARGETS ev | ||
+ EXPORT ${EXPORT_NAME}Targets DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime | ||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel | ||
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT devel | ||
+) | ||
diff --git a/config.h b/config.h | ||
new file mode 100644 | ||
index 0000000..0832712 | ||
--- /dev/null | ||
+++ b/config.h | ||
@@ -0,0 +1,128 @@ | ||
+/* config.h.in. Generated from configure.ac by autoheader. */ | ||
+ | ||
+/* Define to 1 if you have the `clock_gettime' function. */ | ||
+#undef HAVE_CLOCK_GETTIME | ||
+ | ||
+/* Define to 1 to use the syscall interface for clock_gettime */ | ||
+#undef HAVE_CLOCK_SYSCALL | ||
+ | ||
+/* Define to 1 if you have the <dlfcn.h> header file. */ | ||
+#undef HAVE_DLFCN_H | ||
+ | ||
+/* Define to 1 if you have the `epoll_ctl' function. */ | ||
+#undef HAVE_EPOLL_CTL | ||
+ | ||
+/* Define to 1 if you have the `eventfd' function. */ | ||
+#undef HAVE_EVENTFD | ||
+ | ||
+/* Define to 1 if the floor function is available */ | ||
+#undef HAVE_FLOOR | ||
+ | ||
+/* Define to 1 if you have the `inotify_init' function. */ | ||
+#undef HAVE_INOTIFY_INIT | ||
+ | ||
+/* Define to 1 if you have the <inttypes.h> header file. */ | ||
+#undef HAVE_INTTYPES_H | ||
+ | ||
+/* Define to 1 if you have the `kqueue' function. */ | ||
+#undef HAVE_KQUEUE | ||
+ | ||
+/* Define to 1 if you have the `rt' library (-lrt). */ | ||
+#undef HAVE_LIBRT | ||
+ | ||
+/* Define to 1 if you have the <memory.h> header file. */ | ||
+#undef HAVE_MEMORY_H | ||
+ | ||
+/* Define to 1 if you have the `nanosleep' function. */ | ||
+#undef HAVE_NANOSLEEP | ||
+ | ||
+/* Define to 1 if you have the `poll' function. */ | ||
+#undef HAVE_POLL | ||
+ | ||
+/* Define to 1 if you have the <poll.h> header file. */ | ||
+#undef HAVE_POLL_H | ||
+ | ||
+/* Define to 1 if you have the `port_create' function. */ | ||
+#undef HAVE_PORT_CREATE | ||
+ | ||
+/* Define to 1 if you have the <port.h> header file. */ | ||
+#undef HAVE_PORT_H | ||
+ | ||
+/* Define to 1 if you have the `select' function. */ | ||
+#undef HAVE_SELECT | ||
+ | ||
+/* Define to 1 if you have the `signalfd' function. */ | ||
+#undef HAVE_SIGNALFD | ||
+ | ||
+/* Define to 1 if you have the <stdint.h> header file. */ | ||
+#undef HAVE_STDINT_H | ||
+ | ||
+/* Define to 1 if you have the <stdlib.h> header file. */ | ||
+#undef HAVE_STDLIB_H | ||
+ | ||
+/* Define to 1 if you have the <strings.h> header file. */ | ||
+#undef HAVE_STRINGS_H | ||
+ | ||
+/* Define to 1 if you have the <string.h> header file. */ | ||
+#undef HAVE_STRING_H | ||
+ | ||
+/* Define to 1 if you have the <sys/epoll.h> header file. */ | ||
+#undef HAVE_SYS_EPOLL_H | ||
+ | ||
+/* Define to 1 if you have the <sys/eventfd.h> header file. */ | ||
+#undef HAVE_SYS_EVENTFD_H | ||
+ | ||
+/* Define to 1 if you have the <sys/event.h> header file. */ | ||
+#undef HAVE_SYS_EVENT_H | ||
+ | ||
+/* Define to 1 if you have the <sys/inotify.h> header file. */ | ||
+#undef HAVE_SYS_INOTIFY_H | ||
+ | ||
+/* Define to 1 if you have the <sys/select.h> header file. */ | ||
+#undef HAVE_SYS_SELECT_H | ||
+ | ||
+/* Define to 1 if you have the <sys/signalfd.h> header file. */ | ||
+#undef HAVE_SYS_SIGNALFD_H | ||
+ | ||
+/* Define to 1 if you have the <sys/stat.h> header file. */ | ||
+#undef HAVE_SYS_STAT_H | ||
+ | ||
+/* Define to 1 if you have the <sys/types.h> header file. */ | ||
+#undef HAVE_SYS_TYPES_H | ||
+ | ||
+/* Define to 1 if you have the <unistd.h> header file. */ | ||
+#undef HAVE_UNISTD_H | ||
+ | ||
+/* Define to the sub-directory in which libtool stores uninstalled libraries. | ||
+ */ | ||
+#undef LT_OBJDIR | ||
+ | ||
+/* Name of package */ | ||
+#undef PACKAGE | ||
+ | ||
+/* Define to the address where bug reports for this package should be sent. */ | ||
+#undef PACKAGE_BUGREPORT | ||
+ | ||
+/* Define to the full name of this package. */ | ||
+#undef PACKAGE_NAME | ||
+ | ||
+/* Define to the full name and version of this package. */ | ||
+#undef PACKAGE_STRING | ||
+ | ||
+/* Define to the one symbol short name of this package. */ | ||
+#undef PACKAGE_TARNAME | ||
+ | ||
+/* Define to the home page for this package. */ | ||
+#undef PACKAGE_URL | ||
+ | ||
+/* Define to the version of this package. */ | ||
+#undef PACKAGE_VERSION | ||
+ | ||
+/* Define to 1 if you have the ANSI C header files. */ | ||
+#undef STDC_HEADERS | ||
+ | ||
+/* Version number of package */ | ||
+#undef VERSION | ||
+ | ||
+#define HAVE_SELECT 1 | ||
+#define HAVE_SYS_SELECT_H 1 | ||
diff --git a/internal_utils.cmake b/internal_utils.cmake | ||
new file mode 100644 | ||
index 0000000..f738e79 | ||
--- /dev/null | ||
+++ b/internal_utils.cmake | ||
@@ -0,0 +1,65 @@ | ||
+macro(fix_default_compiler_settings_) | ||
+ if (MSVC) | ||
+ foreach (flag_var | ||
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE | ||
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) | ||
+ # We prefer more strict warning checking for building Google Test. | ||
+ # Replaces /W3 with /W4 in defaults. | ||
+ string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}") | ||
+ endforeach() | ||
+ endif() | ||
+endmacro() | ||
+ | ||
+# Defines the compiler/linker flags used to build | ||
+macro(config_compiler_and_linker) | ||
+ # Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT. | ||
+ find_package(Threads) | ||
+ fix_default_compiler_settings_() | ||
+ | ||
+ if (MSVC) | ||
+ set(cxx_base_flags "-GS -W4 -wd4251 -wd4275 -nologo -J -Zi -DWIN32") | ||
+ if (MSVC_VERSION LESS 1400) # 1400 is Visual Studio 2005 | ||
+ # Suppress spurious warnings MSVC 7.1 sometimes issues. | ||
+ # Forcing value to bool. | ||
+ set(cxx_base_flags "${cxx_base_flags} -wd4800") | ||
+ # Copy constructor and assignment operator could not be generated. | ||
+ set(cxx_base_flags "${cxx_base_flags} -wd4511 -wd4512") | ||
+ # Compatibility warnings not applicable to Google Test. | ||
+ # Resolved overload was found by argument-dependent lookup. | ||
+ set(cxx_base_flags "${cxx_base_flags} -wd4675") | ||
+ endif() | ||
+ if (MSVC_VERSION LESS 1500) # 1500 is Visual Studio 2008 | ||
+ # Conditional expression is constant. | ||
+ # When compiling with /W4, we get several instances of C4127 | ||
+ # (Conditional expression is constant). In our code, we disable that | ||
+ # warning on a case-by-case basis. However, on Visual Studio 2005, | ||
+ # the warning fires on std::list. Therefore on that compiler and earlier, | ||
+ # we disable the warning project-wide. | ||
+ set(cxx_base_flags "${cxx_base_flags} -wd4127") | ||
+ endif() | ||
+ if (NOT (MSVC_VERSION LESS 1700)) # 1700 is Visual Studio 2012. | ||
+ # Suppress "unreachable code" warning on VS 2012 and later. | ||
+ # http://stackoverflow.com/questions/3232669 explains the issue. | ||
+ set(cxx_base_flags "${cxx_base_flags} -wd4702") | ||
+ endif() | ||
+# if (NOT (MSVC_VERSION GREATER 1900)) # 1900 is Visual Studio 2015 | ||
+# # BigObj required for tests. | ||
+# set(cxx_base_flags "${cxx_base_flags} -bigobj") | ||
+# endif() | ||
+ | ||
+ set(cxx_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32") | ||
+ set(cxx_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN") | ||
+ set(c_flags "${cxx_flags}") | ||
+ set(CMAKE_CXX_FLAGS "${cxx_flags}") | ||
+ set(CMAKE_C_FLAGS "${c_flags}") | ||
+ | ||
+ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") | ||
+ set(base_flags "-fpic -pthread -O2 -g -fno-strict-aliasing -fwrapv -Wall -Wextra") | ||
+ set(base_flags "${base_flags} -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function") | ||
+ set(cxx_flags "-std=c++11 ${base_flags}") | ||
+ set(c_flags "-std=gnu11 ${base_flags}") | ||
+ set(CMAKE_CXX_FLAGS "${cxx_flags}") | ||
+ set(CMAKE_C_FLAGS "${c_flags}") | ||
+ endif() | ||
+endmacro() | ||
+ | ||
-- | ||
2.34.1.windows.1 | ||
|