diff --git a/recipes/libev/all/CMakeLists.txt b/recipes/libev/all/CMakeLists.txt new file mode 100644 index 0000000000000..e3473fd877dd1 --- /dev/null +++ b/recipes/libev/all/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.14) +project(ev C) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +set(EV_PUBLIC_HEADERS + "${EV_SRC_DIR}/ev.h" + "${EV_SRC_DIR}/config.h") +add_library(ev "${EV_SRC_DIR}/ev.c") +target_link_libraries(ev PUBLIC ws2_32) +target_compile_definitions(ev PRIVATE HAVE_CONFIG_H=1) +target_include_directories(ev PUBLIC ${EV_SRC_DIR}) + +set_target_properties(ev PROPERTIES PUBLIC_HEADER "${EV_PUBLIC_HEADERS}") +include(GNUInstallDirs) + +install(TARGETS ev + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/libev/all/conanfile.py b/recipes/libev/all/conanfile.py index bb35d60681a03..7e2f35fce7815 100644 --- a/recipes/libev/all/conanfile.py +++ b/recipes/libev/all/conanfile.py @@ -4,6 +4,7 @@ from conan.tools.env import VirtualBuildEnv from conan.tools.files import copy, get, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.cmake import CMake, CMakeToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, unix_path import os @@ -33,6 +34,10 @@ class LibevConan(ConanFile): def _settings_build(self): return getattr(self, "settings_build", self.settings) + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, dst=self.export_sources_folder) + copy(self, "config.h", self.recipe_folder, self.export_sources_folder) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -47,14 +52,12 @@ def layout(self): basic_layout(self, src_folder="src") def validate(self): - if is_msvc(self): - raise ConanInvalidConfiguration(f"{self.ref} is not supported by Visual Studio") if self.info.settings.os == "Windows" and self.info.options.shared: # libtool: error: can't build i686-pc-mingw32 shared library unless -no-undefined is specified raise ConanInvalidConfiguration(f"{self.ref} can't be built as shared on Windows") def build_requirements(self): - if self._settings_build.os == "Windows": + if self._settings_build.os == "Windows" and not is_msvc(self): self.win_bash = True if not self.conf.get("tools.microsoft.bash:path", check_type=str): self.tool_requires("msys2/cci.latest") @@ -64,21 +67,36 @@ def source(self): destination=self.source_folder, strip_root=True) def generate(self): - env = VirtualBuildEnv(self) - env.generate() - tc = AutotoolsToolchain(self) - tc.generate() + if is_msvc(self): + tc = CMakeToolchain(self) + tc.variables["EV_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + else: + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.generate() def build(self): - autotools = Autotools(self) - autotools.configure() - autotools.make() + if is_msvc(self): + base_folder = os.path.join(self.source_folder, os.pardir) + copy(self, "config.h", src=base_folder, dst=self.source_folder) + cmake = CMake(self) + cmake.configure(build_script_folder=base_folder) + cmake.build() + else: + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) - autotools = Autotools(self) - # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed - autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + if is_msvc(self): + cmake = CMake(self) + cmake.install() + else: + autotools = Autotools(self) + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) rmdir(self, os.path.join(self.package_folder, "share")) rm(self, "*.la", os.path.join(self.package_folder, "lib")) fix_apple_shared_install_name(self) diff --git a/recipes/libev/all/config.h b/recipes/libev/all/config.h new file mode 100644 index 0000000000000..083271233c6a7 --- /dev/null +++ b/recipes/libev/all/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 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 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 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 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 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 header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_EPOLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_EVENTFD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_EVENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_INOTIFY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SIGNALFD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the 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