Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Cmake refactor #52
Cmake refactor #52
Conversation
- Move project definition to the top and add VERSION - Remove obsolete variable PROJECT and use standard PROJECT_NAME - Require a more modern version of CMake - Use CMAKE_CXX_STANDARD instead of manually adding -std=c++11 - Only include ExternalProject if required
Rules from: https://community.kde.org/Policies/CMake_Coding_Style#Indentation Since rest of the codebase doesn't use tabs, CMake files shouldn't either.
CMake sets PIC automatically for shared libraries and modules.
This enables PROJECT_* variables.
Don't add headers as direct dependencies to targets. Compilers can
detect header dependencies and manage recompilation automatically.
Use list(APPEND ...) in favor of the less explicit set(var ${var} ...).
Downcase variable names to separate project local variables to CMake
vars.
Set configuration parameters before adding tacopie subdirectory to force wanted behavior.
A common use case is to integrate libraries as git submodules and a
single project might have multiple modules each with test dependencies
to gtest. Usually the top level project configures gtest, propagating
the target to it's submodules. This is preferable to the case where
each submodule uses ExternalProject to build & install gtest in a
custom location with possibly arbitrary target names (googletest,
gtest, <foobar>_gtest, etc.) as this can easily lead to multiple gtest
builds.
As a solution check if gtest (which is defined by googletest's build
files) is an existing target to determine if project's own googletest
submodule should be added to the build. Either way the subsequent
add_subdirectory() tests will have a target "gtest" to link
against. Various INTERFACE flags will take care of the rest.
A further improvement is to add "${PROJECT_NAME}::" as a prefix to the
tests. This helps when cpp_redis is a part of a larger project
and (for any reason) developers want to run cpp_redis' tests only
using "ctest -R cpp_redis".
They make maintaining the file extremely frustrating as they break all the time. AFAIK the style if (<condition>) endif (<condition>) is rarely seen anymore.
When building the include directories should be absolute paths, but obviously when installing / exporting the paths should be relative.
- add SOVERSION and RESOURCE properties The former results in a symlink during installation phase (on platforms that support such things) and the latter makes it easier to install extra stuff in install(TARGETS). - add EXPORT target name - remove unnecessary and harmful install(DIRECTORY) calls
Support for EXPORT_TARGET_NAME and better install support all around.
Using tacopie from system libdir might be good feature to have, but the current implementation is buggy. Add it properly later using pkgconfig or CMake imports.
The call will automatically install the project configuration as an importable file called lib/cpp_redis/cpp_redis.cmake. The file will configure installed targets as imports so that they can be used like regular CMake targets.
Allow the configuration to go slightly further with older versions.
Also move the cmake_minimum_required() at the top of the file as per cmake official recommendations.
CMake's OSx tarball contents are different than on Linux. Handle those in travis.
Travis build file was getting harder to read. Extract the same steps into scripts. Most of the files need to be sourced as they conditionally set environment variables.
Tar creates a directory called ${CMAKE_FILE}, just use that in ${CMAKE_INSTALL_DIR}.
After the last change CMAKE_INSTALL_DIR was defined in terms of CMAKE_DOWNLOAD_DIR.
This is basically a complete rewrite of the existing CMake build files to better enable incorporating this repository as a submodule in other projects. The old CMake implementation was full of hacks and didn't use of CMake's INTERFACE_* features. I have currently tested this on x86_64 as well as on a Yocto build for arm.
Major changes are the new submodule location for tacopie (currently my own fork, it might be best if tacopie would be merged into this repo), cmake_minimum_required() bump and gtest added as a submodule. These might be dealbreakers and some of them can probably be worked around.
I realise this is a big pull request, but I'd like comments so that I can eventually get this to be merged in some form.