Closed Marwan-imverse closed 1 week ago
The install target should only build and install the dynamic library, not the static ones. Are you sure it builds both for you?
I misspoke at the end of my first comment. If I choose to "install" after I built the static library, it builds and installs the dynamic library, which is not what I'd like. The install target should either install the dynamic or the static library, depending on how the project was generated with CMake.
OK I see. I think a preliminary step for this would be to bundle the static libraries of submodules into the static library of libdatachannel.
Great, thanks! I'll keep an eye on this
@paullouisageneau I think this is still an issue, has any development been made? I'm currently able to build the static library just fine with make datachannel-static
, but then running either make install
or make install datachannel-static
doesn't install the library statically, but instead dynamically.
I suppose I could manually copy everything needed for the static install, but I wanted to check if there's an 'official' way to do this.
I got the library to statically install with
cmake \
-D USE_GNUTLS=0 -D USE_NICE=0 \
-D BUILD_SHARED_LIBS=OFF \
-D CMAKE_BUILD_TYPE=Release ..
Then, the normal make install
will work.
However, it still seems stuff is broken, when I try to include the library in my project with find_package() I get this:
@ClayJay3 The libraries are installed but I guess that for CMake to find installed dependencies, you also need to add them to the CMake export set. It should be fixed with https://github.com/paullouisageneau/libdatachannel/pull/1287
I checked out to cmake-add-install-deps-export
and it seems to have fixed the issue with the make install
command ignore that I want it to install the static libs, and I can go manually check /usr/local/lib/libdatachannel.a
and it exists. however it seems like the install library is still broken :(
When I add the library to my project with find_package() like this:
It gives me this:
Switching the link library to LibDataChannel
instead of LibDataChannelStatic
seems to find the library (is LibDataChannelStatic still relavant?), but complains about OpenSSL for some reason:
For reference, this is how I'm building and installing libdatachannel:
# Download LibDataChannel
git clone --recurse-submodules --depth 1 --branch cmake-add-install-deps-export https://github.com/paullouisageneau/libdatachannel.git libdatachannel
mkdir libdatachannel/build
cd libdatachannel/build
# Build LibDataChannel
cmake \
-D USE_GNUTLS=0 -D USE_NICE=0 \
-D BUILD_SHARED_LIBS=OFF \
-D CMAKE_BUILD_TYPE=Release ..
# Install LibDataChannel
make datachannel-static
make install datachannel-static
Forgot to mention that trying
## Find LibDataChannel
find_package(LibDataChannel-Static REQUIRED)
Does not find anything either.
The change introduced in https://github.com/paullouisageneau/libdatachannel/pull/1274 makes the LibDataChannel
default target obey the CMake flag BUILD_SHARED_LIBS
, so you can now build it statically and install it.
The LibDataChannelStatic
target is still not installable, because CMake doesn't support optionally installing a configured target. Don't try to install it.
You simply have to run:
$ mkdir libdatachannel/build
$ cd libdatachannel/build
$ cmake -D USE_GNUTLS=0 -D BUILD_SHARED_LIBS=OFF -D CMAKE_BUILD_TYPE=Release ..
$ make
$ make install
Then you can import it with:
find_package(OpenSSL REQUIRED)
find_package(LibDataChannel REQUIRED)
[...]
target_link_libraries(${EXE_NAME} PRIVATE LibDataChannel::LibDataChannel)
You have to provide the same OpenSSL version as during the build since static libraries are linked only when linking the executable.
It would be great to have the option to install either the static or the dynamic library version.
Since there are two different CMake targets, it's already possible to build either one, but the install target automatically builds both, we have no choice.