-
Notifications
You must be signed in to change notification settings - Fork 871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CMake build system #544
Conversation
AC_CHECK_TYPES and AC_C_BIGENDIAN were removed because nothing checks the resulting macros...
Also remove some headers which were not checked anyway and add macros to cmakeconfig.h.in (based on the headers list in the CMakeLists.txt file).
Do not use minus sign in macro names.
Must be absolute instead of relative
Remaining work: - integrate mruby and neverbleed - integrate cunit
Avoids leaking compile flags to dependents.
Might not be the best approach, maybe use thewtex/cython-cmake-example?
Remove build/host/target by a single target system name (CMake is different for cross-compiling, you are suggested to set CMAKE_TOOLCHAIN_FILE). Fix various library variables, remove CFLAGS (INCLUDE_DIRS could be used instead though, but I consider that minor information that could be added later if wanted). Fix various variable names (prefix, boost, etc.).
Add auto-detection to the most important features (app, hpack, etc.). Move options to a separate file for easier search. Add cmake-based Libevent, jansson and CUnit search. Move pkg-config handling for Libev and jemalloc to their cmake files. Note: duplicates find_package before including CMakeOptions.txt and when checking for features. Maybe that can be cleaned up later...
Split the nghttp2 library into objects and a shared library from those objects. This is needed because of symbol visibility. An advantage over the autotools build is that there are no worries about static versus static library builds. Test: cmake $srcdir make nghttpx-unittest main failmalloc make test
Need to add -fPIC to objects that will be put in a shared library.
mruby is always invoked now (mirrors the autotools behavior). It could be optimized though to only trigger the mruby build when the static library is missing. Also fix typo in NGHTTP2_TESTS_DIR macro definition (detected when invoking the Ninja generator).
FindCython.cmake was taken from https://github.com/thewtex/cython-cmake-example. The UseCython module works, but since it is lacking an installation target setup.py will be used instead.
Auto-detect spdylay availability using CMake, making pkg-config completely optional.
Some detected libraries were not reported when a feature is disabled. This change removes unnecessary second find_package calls and sets HAVE_xxx immediately based on xxx_FOUND.
The COMPILE_LANGUAGE generator expression is only supported since CMake 3.3. Moreover, it does not work with all generators (works with Makefile and Ninja, but not with Visual Studio). target_compile_options would only work if a target does not mix C and C++ sources, since the flags are intended to be set for a specific language, use set_source_files_properties instead. This approach is also less repetitive. Drop the idea of using lists and COMPILE_OPTIONS, set_source_files_properties only understands COMPILE_FLAGS (a single string, not a list).
libev 4.11 seems to build fine as demonstrated by Travis with autotools.
The name passed to find_package should match the one that is passed to find_package_handle_standard_args, otherwise the version matching is not properly done. The names are based on the FindXXX.cmake filename. This also simplifies components reporting for Libevent (done by find_package_handle_standard_args) and results in reporting a library instead of include directory when found.
Caught with cmake --warn-uninitialized.
Remove generated documentation, python and mruby build artifacts. Note that this does not work for Ninja, Makefile works fine though.
Adds missing source files and configure.ac changes since v1.7.0-93-g093eb51.
Update to latest master with appropriate cmake changes at the same time.
Add Nathan's PPA for cmake 3.2.3 (3.0 or newer is required).
NOTE: RelWithDebInfo *disables* assertions by default. To keep assertions, use CMAKE_BUILD_TYPE=Debug or CMAKE_BUILD_TYPE=None.
@tatsuhiro-t In 9218d5d you added In this PR, assertions are disabled by default (because When asserts are disabled, there are some warnings...
Should assertions always be enabled, even for release builds? |
Build type-specific flags are added before other flags, reflect this in the output.
Thank you for PR, I'll review this tomollow (I have a software release in another project today). For assertions, I personally think its effect on performance in practice is negligible, so they should be enabled by default to give us useful debugging information. FYI, autotools can use -O2 and assertion enabled at the same time. |
I also think that assertions are still useful in release builds, but the default cmake logic is apparently to disable them (that is, when you use Should I unconditionally enable assertions for various |
I also prefer the former. |
PR looks good. |
Users can disable this by setting -DCMAKE_C_FLAGS=-DNDEBUG or -DCMAKE_CXX_FLAGS=-DNDEBUG to disable assertions as desired.
Do not add _U_ and NGHTTP2_NORETURN definitions to the command line, instead add it to config.h. This matches what autotools does.
Matches autotools behavior. The m4_if logic was misread...
Avoid adding a LIBXML2_LIBRARIES-NOTFOUND to the libraries list when it is not found. Likewise for OpenSSL.
Fix Windows build by defining `ssize_t` when missing and adjusting the install commands. Add support for ENABLE_WERROR=1 while at it. Tested with MSVC 2013 on Windows 7 x64.
failmalloc and main tests succesfully pass the test now.
It was added because the default RelWithDebInfo type disabled assertions, but now that -DNDEBUG is removed from its flags, it is not necessary to change the build type anymore.
The assertions are fixed now (well, except on Windows where you have to define Speaking of Windows, the library can now be built on Windows (tested with All dependencies are missing on Windows, so I had to hack a bit to get stuff working:
Unfortunately I could not get the app to compile. The headers getopt.h and sys/un.h are missing (via utils.h) and template.h blows up completely. Nevertheless I think that the cmake build is ready to go, others can add more Windows as desired. NOTE: only a static |
LGTM. Compiling applications on Windows are known issue, currently they are *nix centric. |
Merged now. Thank you for your awesome work! |
This PR adds CMake support as discussed in #448. Advantages over autotools build include:
In theory easiersupport for Windows (only tested for the library with CUnit tests, not the examples or programs).make check
(see below for times)Notes related to CMake:
-DENABLE_WERROR=1
will additionally add-Werror
). Additionally,-Wunused-macros
and-Wstrict-prototypes
are correctly detected (autotools fails because of crap tests).check
target is missing if cunit is not availble. Could be changed to a dummy target though.CMAKE_BUILD_TYPE=RelWithDebInfo is set which adds-g -O2 -DNDEBUG
(disables assertions too!).Notable modifications to non-cmake files (
git rebase master && git diff --diff-filter=M master..
):**/Makefile.am
: added cmake-related files toEXTRA_DIST
distcheck is passing with this branch + #542 included (see https://travis-ci.org/Lekensteyn/nghttp2/builds/115968744), cmake can be built from the tarball.
Above build benchmarks were done with this script on 4d801cd, times are based on the mean of the real times, standard deviation is insignificant:
times for the
check
target with cunit installed (n=3):FWIW, make/ninja install takes 34ms, 500ms and 991s respectively.