217 Commits

Author SHA1 Message Date
Azat Khuzhin
d5b24cc0c8
sample/becat: bufferevent cat, ncat/nc/telnet analog 2019-03-16 17:40:20 +03:00
Azat Khuzhin
42d5a36bd8
cmake: sync warnings with autotools v2
By some reason gcc reports next error:
  ../http.c:3330:11: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
       value = "";

Only under -Wwrite-strings, well this is logical, but this information
does not reflected in any documentation.

Follow-up: 8348b413 ("cmake: add various warning flags like autotools has")

f
2019-03-13 00:21:38 +03:00
Enji Cooper
5f87be42f0
Define _GNU_SOURCE properly/consistently per autoconf
Although `_GNU_SOURCE` can be defined as an arbitrary #define per the
glibc docs [1], it's best to define it in a manner consistent with the way
that autoconf defines it, i.e., `1`.

While this shouldn't matter in most cases, it does when the headers from
other projects follow the poorly defined GNU convention implemented by
autoconf and are included after the libevent's util.h header. An example
failure with clang, similar to the failure I encountered, is as follows:
```
$ printf "#define _GNU_SOURCE\n#define _GNU_SOURCE 1" | clang -c -x c -
<stdin>:2:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined]
        ^
<stdin>:1:9: note: previous definition is here
        ^
1 warning generated.
```

This happened when compiling python [2] with a stale homebrew util.h file from
libevent (which admittedly would not happen in a correct libevent install, as the
header should be installed under /usr/local/include/event2/util.h). However, if
both headers had been combined (which is more likely), it would have failed as
shown above.

Removing the ad hoc definition unbreaks compiling python's pyconfig.h.in header
when included after util.h from libevent.

1. http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
2. https://github.com/python/cpython/blob/master/configure.ac#L126

Closes: #773 (cherry-picked)

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-02-27 23:18:12 +03:00
Azat Khuzhin
8e87de3c24
cmake: fix checking of devpoll backend (like in autotools, by devpoll.h existence) 2019-02-04 22:21:28 +03:00
Azat Khuzhin
246f44041e
cmake: support static runtime (MSVC)
Fixes: #737
2018-12-17 21:49:00 +03:00
Fredrik Strupe
f33c2ce5f8 cmake: Fix some typos in option descriptions 2018-12-15 12:54:31 +01:00
Azat Khuzhin
90d80ef416
cmake: do not build both (SHARED and STATIC) for MSVC/win32
MSVC does not support SHARED and STATIC libraries with the same name,
so let's just build SHARED libraries by default instead (yes we can add
prefix but let's stick with this).

The reason for this is that in windows shared libraries requires .lib
file too, but this is not static library it is imported library for
shared (doh...), for more info [1] and [2].

  [1]: https://docs.microsoft.com/en-us/windows/desktop/dlls/dynamic-link-library-creation
  [2]: https://blogs.msdn.microsoft.com/oldnewthing/20091013-00/?p=16403

And when we build both static library can and will override shared
library imported part, let's take a look at event_extra.lib:

- before patch [3]:
  $ less libevent-fail/lib/Debug/event_extra.lib | head
  ==> use library:contained_file to view a file in the archive
  rw-rw-rw- 100666/100666  59568 Nov 21 23:55 2018 event_extra_static.dir/Debug/evrpc.obj
  rw-rw-rw- 100666/100666 252219 Nov 21 23:55 2018 event_extra_static.dir/Debug/evdns.obj
  rw-rw-rw- 100666/100666 203850 Nov 21 23:55 2018 event_extra_static.dir/Debug/http.obj
  rw-rw-rw- 100666/100666  25907 Nov 21 23:55 2018 event_extra_static.dir/Debug/event_tagging.obj

  [3]: https://ci.appveyor.com/project/azat/libevent/builds/20472024/job/t0o93v042jai0dj7

- "after patch" [4] (not after but the same effect):
  $ less libevent-ok/lib/Debug/event_extra.lib | head
  ==> use library:contained_file to view a file in the archive
  --------- 0/0    509 Nov 21 23:38 2018 event_extra.dll
  ...

  [4]: https://ci.appveyor.com/project/azat/libevent/builds/20478998/job/ca9k3c76amc4qr76

Refs: #691
2018-11-23 00:41:18 +03:00
Azat Khuzhin
c9a073eae8
cmake: introduce EVENT__LIBRARY_TYPE option
Long time ago in [1] cmake build was forced to compile both libraries
(SHARED and STATIC), since this is how our autotools build works.

  [1]: 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED and STATIC libraries (like autoconf does)")

And there is no way to configure this (and indeed you need to do this
for MSVC for example), so let's introduce option for this --
EVENT__LIBRARY_TYPE.

Plus now we have INTERFACE libraries, that we can use internally in
libevent's cmake rules to avoid strict to _shared/_static variant of the
libraries to link with samples/tests (we prefer SHARED over STATIC for
linking).

Also bump minimal cmake required version to 3.1 by the following
reasons:
- 3.1 is required for RPATH configuration under APPLE
- 3.0 is required for add_library(INTERFACE) (did not found it in 2.8.x
documentation)
- remove extra conditions
(anyway 3.1 was release 4 years ago, so I guess that most of the systems
will have it)
2018-11-23 00:02:18 +03:00
Azat Khuzhin
d705e8c0e9
cmake: drop redundant add_dependencies() 2018-11-22 22:58:56 +03:00
Azat Khuzhin
bdd71f18b1
s/http-server: graceful cleanup 2018-11-13 11:10:17 +03:00
Azat Khuzhin
6d3a53966b
cmake: set CMP0075 to NEW (for ws2_32.lib in win32)
Otherwise cmake complains:
  Policy CMP0075 is not set: Include file check macros honor
  CMAKE_REQUIRED_LIBRARIES.  Run "cmake --help-policy CMP0075" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  CMAKE_REQUIRED_LIBRARIES is set to:
    ws2_32.lib

  For compatibility with CMake 3.11 and below this check is ignoring it.
2018-11-06 01:05:29 +03:00
Azat Khuzhin
65904773f2
cmake: set CMP0074 to NEW (for OPENSSL_ROOT in appveyor)
We have $env:OPENSSL_ROOT (env) equals to -DOPENSSL_ROOT (cmake
variable) anyway.

cmake complains:
  Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
  Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Environment variable OpenSSL_ROOT is set to:
    C:/OpenSSL-Win64/bin

  For compatibility, CMake is ignoring the variable.
This warning is for project developers.  Use -Wno-dev to suppress it.
2018-11-06 01:05:29 +03:00
Azat Khuzhin
3ed9399738
cmake: do not detect _GNU_SOURCE/__GNU_LIBRARY__ if it is cached 2018-11-05 17:48:07 +03:00
Azat Khuzhin
8348b41308
cmake: add various warning flags like autotools has
This is mostly to match autotools and reduce amount mixiing declarations
and code.

Added:
- -Wextra (the same as -W), -Wno-unused-parameter -Wstrict-aliasing
- -fno-strict-aliasing (gcc 2.9.5+)
- -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement (4.0+)
- -Waddress -Wno-unused-function -Wnormalized=id -Woverride-init (4.2+)
- -Wlogical-op (4.5+)

Removed:
- -Wformat (include in -Wall)

Plus use CMAKE_C_COMPILER_ID over CMAKE_COMPILER_IS_GNUCC, as
cmake-variables(7) suggesting, and add common GNUC/CLANG variables.

v2: drop checks for flags, since add_compiler_flags() will check if such
flags exists anyway (but just to note, gcc ignores non existing warning
flags by default).
2018-10-27 17:12:53 +03:00
Azat Khuzhin
cec4a37120
Add -fdiagnostics-color=always for Ninja 2018-10-17 11:16:16 +03:00
Azat Khuzhin
e85818d248
Cleanup __func__ detection
First of all __func__ is not a macro, it is char[] array, so the code
that we had before in cmake, was incorrect, i.e.:
  #if defined (__func__)
  #define EVENT____func__ __func__
  #elif defined(__FUNCTION__)
  #define EVENT____func__  __FUNCTION__
  #else
  #define EVENT____func__ __FILE__
  #endif

So just detect do we have __func__/__FUNCTION__ in configure/cmake
before build and define EVENT__HAVE___func__/EVENT__HAVE___FUNCTION__
to use the later to choose which should be used as a __func__ (if it is
not presented).

Closes: #644
2018-08-02 02:50:48 +03:00
Philip Prindeville
755896efe2 Get rid of macros which are never used
There are no expansions of these macros or tests for their existence.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2018-06-16 17:04:05 -06:00
Azat Khuzhin
6e5c15d095 Fix typo in cmake because of which EVENT__SIZEOF_SIZE_T was wrong
Fixes: #580
2017-12-16 23:28:41 +03:00
Andrey Okoshkin
6ee73ea9b0 Fix generation of LibeventConfig.cmake for the installation tree
'LIBEVENT_INCLUDE_DIRS' is properly initialized in 'LibeventConfig.cmake' as
'LibeventConfig.cmake.in' contains usage of 'LIBEVENT_CMAKE_DIR' and
'EVENT_INSTALL_INCLUDE_DIR' variables but not 'EVENT_CMAKE_DIR' and
'EVENT__INCLUDE_DIRS'.
Related typos are fixed.
2017-11-29 11:13:51 +03:00
lightningkay
3f19c5eb83 cmake doesn't has POLICY CMP0054 in low version 2017-11-04 18:57:00 +03:00
Kiyoshi Aman
8b0aa7b36a Port event_rpcgen.py and test/check-dumpevents.py to Python 3.
These scripts remain compatible with Python 2.
2017-09-25 11:35:23 +03:00
Carlo Marcelo Arenas Belón
63c4bf78d6 test: fix 32bit linux regress 2017-09-01 15:50:36 -07:00
Azat Khuzhin
2773a5ed5e cmake: set CMP0054 to NEW to avoid variables over expansion (since cmake 3.8)
==> win: CMake Warning (dev) at CMakeLists.txt:782 (elseif):
==> win:   Policy CMP0054 is not set: Only interpret if() arguments as variables or
==> win:   keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
==> win:   details.  Use the cmake_policy command to set the policy and suppress this
==> win:   warning.
==> win:
==> win:   Quoted variables like "MSVC" will no longer be dereferenced when the policy
==> win:   is set to NEW.  Since the policy is not set the OLD behavior will be used.
==> win: This warning is for project developers.  Use -Wno-dev to suppress it.
2017-05-29 21:59:01 +03:00
Azat Khuzhin
8b29b13679 cmake: fix building bench/bench_cascade under win32 (missing getopt)
Because of typo in cmake, now rewrote to make it less error prone (since even
for non-win32 there are variables overlap).
2017-05-29 21:59:01 +03:00
Azat Khuzhin
346f8e1708 cmake: avoid requiring cmake 3.1 on win32 for dns-example
Avoid using target_sources() from cmake 3.1, just pass needable sources as
list.
2017-05-29 21:59:01 +03:00
Azat Khuzhin
30f2a969e8 cmake: eliminate EVENT_BUILDING_REGRESS_TEST, since we link with shared libs
Before 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED
and STATIC libraries (like autoconf does)") it links with *.c.
2017-03-14 00:33:37 +03:00
Azat Khuzhin
d5e1087044 cmake: clean not used #defines from event-config.h
- _LARGE_FILES: we have it in evconfig-private.h.in, drop from event-config.h
- EVENT___FILE_OFFSET_BITS: remove it for now
- EVENT__const
2017-03-13 22:13:13 +03:00
Azat Khuzhin
2d2299cf7a cmake: add <pthread.h> only for non-win32
Fixes: b2b4b4d74e78a3e4fe7a74224d1e6aada5bde351 ("cmake: add <pthread.h>
into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t)")
2017-03-13 22:09:27 +03:00
Azat Khuzhin
805e1aa819 cmake: support visibility for AppleClang too
Defaults apple linker behaviour is -two_levelnamespace, and you cannot
use "-undefined suppress" with it, so let's link non event_core with
event_core library to avoid undefined symbols.
2017-03-13 16:25:30 +03:00
Azat Khuzhin
fd5a3fc036 cmake: fix export absolute path and relative path and cleanup a bit
Remove next vars, since I don't think that somebody want to change it:
- bin
- lib
- include

And fix exports problem:
  CMake Error: INSTALL(EXPORT "LibeventTargets") given absolute DESTINATION "/usr/lib/cmake/libevent" but the export references an installation of target "event_core_static" which has relative DESTINATION "lib".
2017-03-13 16:20:40 +03:00
Azat Khuzhin
7182c2f561 cmake: build SHARED and STATIC libraries (like autoconf does)
Since they are useful for debugging, and if autotools build them then
cmamke has to do this too, to make migration more simple.

And now:
- tests: uses shared libraries (since this is upstreams one)
- other binaries: uses static libraries

This removes next private config:
- EVENT__NEED_DLLIMPORT
2017-03-13 16:20:40 +03:00
Azat Khuzhin
72ef9d1652 cmake: add missing event_openssl/event_pthreads libraries
This will remove openssl requirement if you don't use it (i.e. if you
not link with openssl_pthreads).

Plus it fixes some linking dependencies:
- libm required only for test-ratelim

And fix some coding style alignment issues.

Refs: #246
2017-03-13 12:57:22 +03:00
Shuo Chen
65870949e7 Fix detection of timerfd_create() in CMake. 2017-03-12 01:00:41 -08:00
Azat Khuzhin
819d049377 Do not add epoll_sub (syscall wrappers) for epoll in cmake
Nowadays mostly all supported OS'es has this wrappers, and some of them (like
SmartOS) has wrappers but doesn't have __NR_epoll* defines for syscall numbers,
so just drop them (instead of adding yet another check int cmake like autotools
has, since this will break building in cross-compile environment).

Also one minor note, configure doesn't added epoll_sub.c either, since it check
epoll_create() in runtime.

And I tested it in SmartOS and it even works (`make verify`).

Fixes: #463
2017-03-08 23:34:44 +03:00
Marek Sebera
6541168d70 Detect arch4random_addrandom() existence
Refs: #370
Refs: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
71a56bd3a7 cmake: detect _GNU_SOURCE not by __GNU_LIBRARY__ only (fallback to _GNU_SOURCE)
Fixes pipe2() on Android-9/armv7-a

Refs: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
66a4eb0c3a Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)
Because checking in cmake breaks cross-compiling.

Introduced-in: 43eb56c7c738e3642f0981e3dd6ab9e082eec798.
Fixes: #482
Fixes: #462
Refs: #475

v2: use waitid() with WNOWAIT
v3: use WNOWAIT only if it available in waitpid(), because not all netbsd
    supports it
2017-03-08 13:31:55 +03:00
Azat Khuzhin
b2b4b4d74e cmake: add <pthread.h> into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t)
Fixes: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
fa135bdcd9 cmake: Fix checking of enum values from sysctl.h
CheckSymbolExists do not do this, so add new CheckConstExists that will
use CheckCSourceCompiles() to check this.

v2: use set() instead of string(APPEND)
2017-03-08 12:47:22 +03:00
Pierce Lopez
5d18d87916 Do not check for ERR_remove_thread_state() (do not link ssl into every library)
This reverts commit c4e9d9bd662de7f575f2172c160795d452ebe709
("sample/https-client: check for ERR_remove_thread_state() existence").

Calling AC_SEARCH_LIBS() modifies LIBS - -lcrypto incorrectly
ends up in LIBS, and thus linked to by libevent_core.so.

Checking for ERR_remove_thread_state should no longer be needed
because it was introduced in openssl 1.0.0, and the previous line
0.9.8 had support discontinued at the end of 2015.

Fixes: #473
2017-03-06 01:39:29 +03:00
Trond Norbye
cc0e04d798 Fix RPATH for APPLE
By setting the CMake minimum version to 3.1 CMake automatically
adds the correct magic to make the library relocatable on
the filesystem (instead of burning the location of the library
at link time into the binary).

ex:
otool -L bin/http-connect
bin/http-connect:
	@rpath/libevent_extra.2.2.0.dylib (compatibility version 2.2.0, current version 0.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

Fixes: #468 (cherry-picked)
2017-02-28 11:02:39 +03:00
Azat Khuzhin
b24a78cccf cmake: check for 'struct linger' existence 2017-01-29 23:06:34 +03:00
Azat Khuzhin
fe2c2622c3 Make EVENT_STAGE_NAME non cached
It did not work before correctly anyway, since cmake do not reset cache
entries by default, so that reset to "beta" didn't work.

But I don't think that making this variable cached is useful, so let's
remove this.
2017-01-29 20:35:57 +03:00
Azat Khuzhin
efcfa046ae Bump version in master to 2.2.0-alpha-dev
And according to f8d80a285cf941505277d9060d0357b5b7e543d2 ("Bump version
to 2.1.3-alpha-dev") numeric version have 1 at the end, since it means
"-dev".
2017-01-29 20:33:55 +03:00
Azat Khuzhin
9b63b5d410 Bump version to 2.1.8-stable everywhere
P.S. in referenced commit I made a mistake and instead of *-rc* I wrote
*-beta*.

See-also: f4489b8323cda0bf8eed7c1353911a852d7a947c ("Bump version to
2.1.7-beta everywhere")
2017-01-26 02:36:00 +03:00
Azat Khuzhin
f4489b8323 Bump version to 2.1.7-beta everywhere
- cmake basic
- cmake detecting from git -- event_fuzzy_version_from_git()
- autotools
- win32
- appveyor
2016-11-04 23:05:20 +03:00
Azat Khuzhin
40fbffc0df Fix cmake -DEVENT__COVERAGE=ON
- do not use compiler check from the root cmake rules with syntax error,
  let CodeCoverage check it
- fix CodeCoverage to check C compiler not CXX
- case insensitive checking of CMAKE_BUILD_TYPE
- replace flags with --coverage, and fix flags with linking with
  --coverate, otherwise it will not compile during checking flags and
  fails.
2016-11-02 11:36:24 +03:00
Azat Khuzhin
3453c0815f cmake: fix finding python2, and check that it is really 2
python version check removed in a4d044c0cd97f68b4b3dde414b83d609719d33d7
("cmake: use PYTHON_EXECUTABLE to find python2"), but in
bcb990ab7cf4921c2c30a1aa4fcb4c0131fffe94 ("cmake/win32: fix running
regress, but fixing finding python2 interpreter") we set
PYTHON_EXECUTABLE only if it exists.
2016-10-31 02:25:43 +03:00
Zonr Chang
dc624adf42 cmake: cleanup
- Remove a redundant check on netdb.h (EVENT__HAVE_NETDB_H).
- Properly setup EVENT__SIZEOF_SSIZE_T for the case where "ssize_t" is
  not "int".
- Remove unused EVENT__HAVE_PTHREAD.
- Set EVENT__HAVE_LIBZ instead of EVENT__HAVE_ZLIB (and remove the
  latter).

Closes: #391 (cherry-picked from PR)
2016-10-26 18:48:41 +03:00
Azat Khuzhin
bcb990ab7c cmake/win32: fix running regress, but fixing finding python2 interpreter
Could not find executable C:/projects/libevent/build/bin/regress
  Looked in the following places:
  C:/projects/libevent/build/bin/regress
  C:/projects/libevent/build/bin/regress.exe
  ...
   9/13 Test  #9: regress__WIN32_debug ................***Not Run   0.00 sec

Link: https://ci.appveyor.com/project/nmathewson/libevent/build/2.1.6.271/job/wvy2jp7uojcut5cx#L1256
Fixes: #411
2016-10-26 01:41:07 +03:00