Skip to content
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

Modernize CMakeLists.txt #5

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

lindblandro
Copy link

Refactor the build file to use a more modern set of CMake features than the current master branch. Since cpp_redis has merged similar PR the main build is broken:

In file included from /home/xxx/cpp_redis/sources/network/redis_connection.cpp:29:
/home/xxx/cpp_redis/includes/cpp_redis/network/tcp_client.hpp:28:10: fatal error: tacopie/tacopie: No such file or directory
   28 | #include <tacopie/tacopie>
      |          ^~~~~~~~~~~~~~~~~

This PR fixes that by setting tacopie target public include directories so that consuming projects can just link against the target and get all the configuration goodies without manually having to specify them.

This PR fixes cpp-redis/cpp_redis#105 once the cpp_redis tacopie submodule has been updated.

Henrik Lindblom added 23 commits November 22, 2019 16:08
 - Use CMAKE_CXX_STANDARD
 - Use PROJET_NAME
 - Set PROJECT_VERSION
 - Use CMake search paths to find ExternalProject
The recommended method is to explicitly list all sources files for
targets. This way build configuration only needs to change if
CMakeFiles.txt is explicitly modified. There's no confusion about what
files are part of the build.
Each user configurable setting should have a corresponding option()
for booleans or typed cache variable for strings and paths.
The original library type was unclear, but POSITION_INDEPENDENT_CODE
would hint that shared library was intended. CMake automatically
enables PIC for shared libraries and modules.
The package creates an imported target Threads::Threads that
configures the correct library.
The test directory doesn't need to be a project, in fact it SHOULDN'T
be a project. All necessary flags etc. should be set by the library
target the tests link against.
ExternalProject used the most recent version of gtest which will
eventually lead to failing tests. Pin the version using a submodule.
Adding SOVERSION property to the target makes CMake generate symlinks
during installation. The RESOURCE property is supported by
install(TARGETS) and can be used to automatically install *.pc
files. The install(TARGETS) call specifies an EXPORT target name,
initialized to PROJECT_NAME, that can be used when adding this
repository as a submodule:

set(EXPORT_TARGET_NAME myproj)
add_subdirectory(tacopie)
install(TARGETS myexe EXPORT myproj
  RUNTIME)
install(EXPORT myproj DESTINATION lib/myproj)

The last line will generate ${PREFIX}/lib/myproj/myproj.cmake that
contains necessary CMake spells to include the installed files in
another projects as CMake targets. Somewhat like pkg-config, but nicer
for Windows people.
@jgwinner
Copy link

Just chiming in, this would be a huge help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot build latest version due to tacopie dependency
2 participants