scylladb / cpp-rust-driver

API-compatible rewrite of https://github.com/scylladb/cpp-driver as a wrapper for Rust driver.
GNU Lesser General Public License v2.1
16 stars 11 forks source link

Add install capabilities to top-level CMake config #101

Closed avelanarius closed 4 months ago

avelanarius commented 1 year ago

Before this change, the generated Makefile by CMake lacked the capability to run make install. This PR makes it possible to run make install, for example:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCASS_INSTALL_PKG_CONFIG=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib64 ..
make DESTDIR=/tmp/example install

The names and contents of installed files try to mimic the original C++ Driver files. For example, installation of C++ Driver generates the following .so files/symlinks:

usr/lib64/libscylla-cpp-driver.so -> libscylla-cpp-driver.so.2
usr/lib64/libscylla-cpp-driver.so.2 -> libscylla-cpp-driver.so.2.16.2
usr/lib64/libscylla-cpp-driver.so.2.16.2

This particular behavior is replicated in a new build-cmake-compat.sh script, which is executed as a BUILD_COMMAND in the Rust external project in the top-level CMakeLists.txt.

Unfortunately, I have not been able to configure CMake to create such symlinks on its own. One of the reasons is an unfixed bug in CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/23249#note_1277271. Therefore, the build-cmake-compat.sh is introduced to create the necessary files in a way it's easy to install for CMake.

The third commit includes the static library in the installed files.

Those are the contents of DESTDIR (as in make DESTDIR=... install) in the original C++ driver:

DESTDIR
└── usr
    ├── include
    │   ├── cassandra.h
    │   └── dse.h
    └── lib64
        ├── libscylla-cpp-driver.so -> libscylla-cpp-driver.so.2
        ├── libscylla-cpp-driver.so.2 -> libscylla-cpp-driver.so.2.16.2
        ├── libscylla-cpp-driver.so.2.16.2
        └── libscylla-cpp-driver_static.a

and after this PR in the bindings:

DESTDIR
└── usr
    ├── include
    │   └── cassandra.h
    └── lib64
        ├── libscylla-cpp-driver.so -> libscylla-cpp-driver.so.0
        ├── libscylla-cpp-driver.so.0 -> libscylla-cpp-driver.so.0.0.1
        ├── libscylla-cpp-driver.so.0.0.1
        └── libscylla-cpp-driver_static.a

This PR is a prerequisite for a follow-up PR reworking #88.

Pre-review checklist

roydahan commented 4 months ago

@avelanarius is this one still needed? If so, what's preventing it from being merged?

roydahan commented 4 months ago

Closing in favor of #88

Lorak-mmk commented 4 months ago

Did you mean #122 ?

roydahan commented 4 months ago

Yes