47 Commits

Author SHA1 Message Date
Azat Khuzhin
b9f442e2d7 cmake: use CMAKE_LIBRARY_OUTPUT_DIRECTORY for the final shared library symlink
Fixes: 669a53f3 ("cmake: set library names to be the same as with autotools")
2019-11-30 15:54:56 +03:00
yuangongji
dc4be869d5 cmake: improve package config file 2019-11-14 18:09:31 +08:00
yuangongji
5fe83d7433 cmake: eliminate duplicate installation of public headers 2019-10-25 21:54:13 +08:00
yuangongji
620a3fa1d5 Doxygen documentation improvements
- Documentation for `bufferevent_compat.h` and `rpc.h` is not generated
  since the `@file` command is missing. It can be fixed by adding
  `@file` in file comment block.
- The briefs of buffer.h,bufferevent.h and some other files are missing.
  Adding `@brief` command can fix it.
- The parameters in the function declaration are different from the
  parameters following the `@param` command.We should change them to the
  same.
- Documentation of `watch.h` is not generated since `watch.h` has not
  been added to the Doxyfile `INPUT` tag.

- Add link to the watch.h in event.h
2019-08-29 23:08:12 +03:00
yuangongji
1d1c19091f cmake: attach doxygen target into all target
v2: Disable non-html generator for doxygen by default
v3: convert cmake option to doxygen config
2019-08-28 01:23:26 +03:00
Azat Khuzhin
55d1e20e1a
cmake: install shared library only if it was requested
$ cmake -DEVENT__LIBRARY_TYPE=static ..
  ...
  CMake Error:
  Error evaluating generator expression:

    $<TARGET_FILE_DIR:event_core_shared>

  No target "event_core_shared"

Fixes: #853
Fixes: 669a53f3 ("cmake: set library names to be the same as with autotools")
2019-07-12 00:02:12 +03:00
yuangongji
669a53f341
cmake: set library names to be the same as with autotools
libtool has VERSION_INFO [1], cmake has SOVERSION/VERSION instead
(although it has different format). Also libtool has RELEASE [2] while
cmake do not have analog yet [3], hence manual symlinks should be
created.

  [1]: https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
  [2]: https://www.gnu.org/software/libtool/manual/html_node/Release-numbers.html
  [3]: https://gitlab.kitware.com/cmake/cmake/issues/17652

Plus osx has compatibility_version/current_version dylib properties and
cmake do not have separate properties for them [4], hence manual LINK_FLAGS.
And also there INSTALL_NAME_DIR property which should be adjusted too.

  [4]: https://public.kitware.com/Bug/view.php?id=4383

So after all changes, here is an example before/after for osx and linux:

  # osx
    # autotools
    .libs/libevent_pthreads-2.2.1.dylib
    .libs/libevent_pthreads.dylib -> libevent_pthreads-2.2.1.dylib
    /usr/local/lib/libevent_pthreads-2.2.1.dylib (compatibility version 2.0.0, current version 2.0.0)
    # cmake
      # before patch
      lib/libevent_pthreads.2.2.0.dylib
      lib/libevent_pthreads.dylib -> libevent_pthreads.2.2.0.dylib
      @rpath/libevent_pthreads.2.2.0.dylib (compatibility version 2.2.0, current version 0.0.0)
      # after patch
      lib/libevent_pthreads-2.2.1.dylib
      lib/libevent_pthreads.dylib -> libevent_pthreads-2.2.1.dylib
      /vagrant/.cmake/inst/lib/libevent_pthreads-2.2.1.dylib (compatibility version 2.0.0, current version 2.0.0)

  # linux
    # autotools
    .libs/libevent_pthreads-2.2.so.1 -> libevent_pthreads-2.2.so.1.0.0
    .libs/libevent_pthreads-2.2.so.1.0.0
    .libs/libevent_pthreads.so -> libevent_pthreads-2.2.so.1.0.0
    # cmake
      # before patch
      lib/libevent_pthreads.so -> libevent_pthreads.so.2.2.0
      lib/libevent_pthreads.so.2.2.0
      # after patch
      lib/libevent_pthreads-2.2.so -> libevent_pthreads-2.2.so.1
      lib/libevent_pthreads-2.2.so.1 -> libevent_pthreads-2.2.so.1.0.0
      lib/libevent_pthreads-2.2.so.1.0.0
      lib/libevent_pthreads.so -> libevent_pthreads-2.2.so.1.0.0

Closes: #838 (cherry-picked)
Closes: #760
2019-07-11 10:11:38 +03:00
yuangongji
7201062f3e
cmake: add missing autotools targets (doxygen, uninstall, event_rpcgen.py)
Close: #832 (cherry-picked)
2019-06-13 21:57:39 +03:00
Enji Cooper
0b468bb07e Fix typos in a comment describing the purpose of VersionViaGit.cmake
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-02-28 17:35:02 -08: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
4c61a04cd5
Make cmake's check_const_exists() rely on cache 2018-10-18 23:16:05 +03:00
Azat Khuzhin
accf383e04 Fix CheckFunctionExistsEx() cmake macro on win32
For example under mingw64 it could not detect that strtok_r() exists,
because it checks with:
  void *p = func_name;

And for this you need the function to be defined, so just sync our
CheckFunctionExistsEx.c with CheckFunctionExists.c from cmake (and later
we should drop them out) since it does correct things to detech
functions existence.

Also for WIN32 there is -FIwinsock2.h -FIws2tcpip.h, and I guess that is
not works for mingw gcc (since -F in gcc is framework, and in windows
-FI is like -include in gcc). But looks like we do not need them
already (due to fixed CheckFunctionExistsEx()).

Refs: #605
2018-04-26 01:14:49 +03:00
Philip Herron
0fa43c99fb cmake: ensure windows dll's are installed as well as lib files
Closes: #621
2018-04-09 00:15:03 +03:00
Carlo Marcelo Arenas Belón
1dfec8a970 configure: avoid false positive in DragonFlyBSD
by default, the max buffer size is 16K and histeresis is at 50%, so
a bigger read is needed to unlock writes than you would expect from
other BSD (512 bytes)

this doesn't introduce any regression on FreeBSD 11.1, OpenBSD 6.1, NetBSD 7.1,
macOS 10.12.6 and of course DragonFlyBSD 4.8.1, and most of them show
a max pipe size of 64K, so the read call should drain them all regardless
of how conservative they are on the free pipe space they will require
(usually 512 bytes) before kevent reports the fd as ready for write.

I couldn't find a reference to which bug this code was trying to look for
and it seems to be there from the beginning of git history so it might be
no longer relevant.

Issue: #548
2017-09-11 01:48:35 +03:00
Azat Khuzhin
b1e8a4138f cmake: use APPEND during exporting targets (for old cmake)
On centos with cmake 2.8.12.2:
  CMake Error at cmake/AddEventLibrary.cmake:92 (export):
    export called with target "event_extra_shared" which requires target
    "event_core_shared" that is not in the export list.

    If the required target is not easy to reference in this call, consider
    using the APPEND option with multiple separate calls.

But on newer cmake I guess everything is ok.

Fixes: 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED
and STATIC libraries (like autoconf does)")
2017-03-14 13:37:59 +03:00
Azat Khuzhin
882f537c40 cmake: fix pkgconfig generation (copy-paste typo) 2017-03-13 21:41:10 +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
86c7357525 cmake: generate and install pkgconfig files
Fixes: #443
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
Azat Khuzhin
d65e3e1dbe cmake: fix extracting of the version from git (check for number of matches) 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
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
Azat Khuzhin
0344edf62d Do not overwrite version from GIT if it is older then defaults 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
43b69b2aed cmake: fix CheckFunctionExistsEx/CheckPrototypeDefinition (CMP0054) 2016-10-26 18:48:41 +03:00
Azat Khuzhin
51019e9460 Bump version to 2.1.6-beta everywhere
- cmake basic
- cmake detecting from git -- event_fuzzy_version_from_git()
- autotools
- win32
- appveyor
2016-08-27 01:28:36 +03:00
Azat Khuzhin
43eb56c7c7 tests: use waitpid(..., WNOWAIT) to fix failing of main/fork under solaris
According to solaris docs:
  "One instance of a SIGCHLD signal is queued for each child process whose
  status has changed. If waitpid() returns because the status of a child
  process is available, and WNOWAIT was not specified in options, any pending
  SIGCHLD signal associated with the process ID of that child process is
  discarded. Any other pending SIGCHLD signals remain pending."

And interesting thing that it works if you add sleep(1) before waitpid(), and
also if you run with --verbose (some race or what).

But linux doesn't support WNOWAIT in waitpid() so add detection into
cmake/autotools.

Fixes: #387
Link: https://bugzilla.redhat.com/show_bug.cgi?id=840782
2016-08-11 17:08:35 +03:00
Azat Khuzhin
36588e169d cmake: fix adding of compiler flags, and now it will
- add_compiler_flags() must accept array IOW just ARGN will be enoough
- add_compiler_flags() called with variable name instead of it's value

P.S. and fix some alignments issues
P.P.S. more cmake issues expected since now CFLAGS actually works
P.P.P.S. some issues with cmake cache is possible, so just reset it
2016-03-10 00:48:16 +03:00
Mark Ellzey
49a53811a6 More cmake updates, lot's of missing definitions 2015-12-20 21:44:04 -08:00
Mark Ellzey
a9db46aec2 CMAKE CMAKE CMAKE CLEANUPS
It's almost useful.
2015-12-20 00:43:46 -08:00
Mark Ellzey
8b228e27f5 Lot's of cmake updates
This is still not done, cmake here was a horrid mess, but we're
getting our act together now.
2015-12-19 01:47:49 -08:00
Joakim Söderberg
19ba454317 This fixes a bug introduced in 27bd9faf498b91923296cc91643e03ec4055c230
CMake configuration files are intended to be used by other projects to find the library. Specifically the CMake find_package command can use it to find all files related to the project.

The idea is to support 2 different CMake configuration files for Libevent. One if you simply build libevent that is generated for the build tree.
And a second one that is generated for an install target that will be installed on the system and point to where on the system the lib files and such can be find.

So for instance, in the build tree the config would set the cmake variable `LIBEVENT_INCLUDE_DIRS` to `/path/to/libevent/build/include`.
And for the system config it would be set to `/usr/local/include` (or whatever target the user chose when running cmake).

27bd9faf498b91923296cc91643e03ec4055c230 changed this behavior so that both configs would point to the system wide path `/usr/local/include`

This meant that projects just wanting to import directly for the build tree would fail.
2015-02-05 17:34:50 +01:00
Acer Yang
befbd13071 Fix cmake error when the Module path has more than one entry.
CMAKE_MODULE_PATH is usually a list instead of single entry. Especially
for projects contain sub cmake projects. My patch replace the
CMAKE_MODULE_PATH with fixed path, to locate the `.in` file.
2014-11-30 10:19:35 -05:00
Sergey Nikulov
27bd9faf49 updates in cmake build 2014-09-02 18:25:52 +04:00
Joakim Söderberg
2b41bcf8ea Export event_extra not event_extras. 2014-03-07 18:09:56 +01:00
Joakim Söderberg
4e1439588f Change all uses of WIN32 to _WIN32 2014-01-21 11:30:27 +01:00
Joakim Soderberg
49ab363271 Some work on making it possible to simply do add_subdirectory() on the project. 2014-01-14 13:01:31 +00:00
Joakim Soderberg
f3446ed5fb Add CMake config and install targets.
Make it easier for other projects to do find_package by creating config
files both in the build and install tree.
2014-01-09 13:45:52 +01:00
Joakim Soderberg
f7805939d1 Only look for ZLib when it is used (if tests are included).
Also make the project language C.
2013-12-19 10:46:04 +00:00
Joakim Soderberg
f2483f8b3d Add a "make verify_coverage" target generation coverage info.
Use lcov/gcov to gather coverage info for the tests (Only works with gcc/clang and make).

cmake -DEVENT__COVERAGE=1 -DCMAKE_BUILD_TYPE=Debug ..
make
make verify_coverage

Current coverage (run on debian):
Line coverage 79.1 %	10231 / 12939
Function coverage 86.1 %	933 / 1083
2013-12-17 15:17:29 +00:00
Joakim Söderberg
2799b359d3 Added a test for testing if kqueue works with pipes. 2013-12-17 14:01:21 +01:00
Joakim Soderberg
c259d53c82 Add copyright and licensing files for CMake modules. 2013-12-16 11:27:13 +01:00
Joakim Soderberg
e415196a7d Initial CMake commit. 2013-12-09 18:05:32 +01:00