Skip to content

Support additional CMake build options #20

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

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

Conversation

alebcay
Copy link

@alebcay alebcay commented Aug 14, 2021

This pull request proposes additional build options to the CMake-based install. Some files have been moved around/touched slightly also to facilitate some of these options/features, which are described below. These options would be helpful for building/shipping libsdptransform for use in package managers and other distributions.

The defaults for these new options have been set to follow the existing behavior at build right now (with no options), so build commands/scripts should work like before and produce the same build outputs.

The changes here are not trivial, so please advise if there's anything that you don't like here and we can hopefully find some happy medium or workaround.


  • Add option BUILD_TESTS. Default to ON (following existing behavior)
  • Add option BUILD_README_HELPER. Default to ON (following existing behavior).
  • Add option BUILD_SHARED_LIBS. Default to OFF (following existing behavior).
  • Add option USE_EXTERNAL_JSON. Default to OFF (following existing behavior).

BUILD_TESTS and BUILD_README_HELPER toggle whether contents in subdirectories test and readme-helper will be built.

BUILD_SHARED_LIBS toggles whether libsdptransform will be built as a static or shared library. add_library automatically checks the value of BUILD_SHARED_LIBS at configure/build time.

USE_EXTERNAL_JSON toggles whether an external (e.g. system) copy of nlohmann-json should be used instead of the bundled one. If enabled, CMake will automatically search for an installation of nlohmann-json on the system and configure step will fail if not found. If nlohmann-json is installed in a non-standard location, CMAKE_MODULE_PATH can be set so that CMake can find the nlohmann-json installation.

json.hpp has been moved from include/ to new folder thirdparty/, so that the thirdparty folder can be added as an include directory when external nlohmann-json is not in use.

include/sdptransform.hpp is now include/sdptransform.hpp.in. At configure time, the .hpp.in file is preprocessed into the build tree. This step is necessary in order to set the #include path to json.hpp in sdptransform.hpp.

- Add option BUILD_TESTS. Default to ON (following existing behavior)
- Add option BUILD_README_HELPER. Default to ON (following existing behavior).
- Add option BUILD_SHARED_LIBS. Default to OFF (following existing behavior).
- Add option USE_EXTERNAL_JSON. Default to OFF (following existing behavior).

BUILD_TESTS and BUILD_README_HELPER toggle whether contents in subdirectories
"test" and "readme-helper" will be built.

BUILD_SHARED_LIBS toggles whether libsdptransform will be built as a static
or shared library. add_library automatically checks the value of
BUILD_SHARED_LIBS at configure/build time.

USE_EXTERNAL_JSON toggles whether an external (e.g. system) copy of
nlohmann-json should be used instead of the bundled one. If enabled,
CMake will automatically search for an installation of nlohmann-json on the
system and configure step will fail if not found. If nlohmann-json is
installed in a non-standard location, CMAKE_MODULE_PATH can be set so that
CMake can find the nlohmann-json installation.

json.hpp has been moved from include/ to new folder thirdparty/, so that
the thirdparty folder can be added as an include directory when external
nlohmann-json is not in use.

include/sdptransform.hpp is now include/sdptransform.hpp.in. At configure
time, the .hpp.in file is preprocessed into the build tree. This step is
necessary in order to set the #include path to json.hpp in sdptransform.hpp.
With changes in top-level CMakeLists.txt logic, sdptransform's
includes are automatically added since readme-helper links to the
sdptransform target.
With changes in top-level CMakeLists.txt logic, sdptransform's
includes are automatically added since test links to the
sdptransform target.
Copy link
Owner

@ibc ibc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good, thanks for this. Please allow us to fully review this next week.

@ibc ibc self-requested a review August 15, 2021 10:38
@ibc
Copy link
Owner

ibc commented Aug 15, 2021

@jmillan can you take a look?

@jmillan
Copy link

jmillan commented Aug 17, 2021

Hi @alebcay,

I find the changes OK overall, but this PR modifies a file in sdptransform, which is an external dependency that cannot be modified here.

@alebcay
Copy link
Author

alebcay commented Aug 17, 2021

Thanks for taking a look.

I find the changes OK overall, but this PR modifies a file in sdptransform, which is an external dependency that cannot be modified here.

Just wanted to clarify - are you referring to sdptransform.hpp? And is the issue that I've modified it (touched the line for the #include "json.hpp"), or is the issue that the build now preprocesses this file at configure time (substitutes @JSON_HPP_LOCATION@ with include file path)?

@ibc
Copy link
Owner

ibc commented Aug 17, 2021

sdptransform.hpp is part of a separate library that we include in libmediasoupclient. We cannot modify it here. Please look for sdptransform project in Versatica GitHub repositories.

@alebcay
Copy link
Author

alebcay commented Aug 17, 2021

I see, you are referring to https://github.com/versatica/libmediasoupclient/tree/v3/deps/libsdptransform.

Would the correct course of action be to open this PR in that repository instead, to make the changes there first?

@ibc
Copy link
Owner

ibc commented Aug 17, 2021

I see, you are referring to https://github.com/versatica/libmediasoupclient/tree/v3/deps/libsdptransform.

Would the correct course of action be to open this PR in that repository instead, to make the changes there first?

Exactly :)

Then we release a new version of libsdptransform, and current PR must update it.

@alebcay
Copy link
Author

alebcay commented Aug 17, 2021

I see, thanks. It was unclear to me whether here or the other repository was the "upstream".

Can I make the CMake-related changes in this PR over there too? The modification to sdptransform.hpp needs to happen together with the CMake-related changes in this PR.

@ibc
Copy link
Owner

ibc commented Aug 17, 2021

Not sure if I follow. Can you make a PR to libsdptransform, we release a new version and then you update this PR with that new version? See scripts/get-dep.sh in this repo.

@alebcay
Copy link
Author

alebcay commented Aug 18, 2021

Sure, opened versatica/libmediasoupclient#125.

@jmillan
Copy link

jmillan commented Aug 18, 2021

Ok. This PR already targets libdsptransform 🤦 , sorry for the confusion @alebcay. We were thinking it was targeting libmediasoupclient.

I just have one question:

- install(TARGETS sdptransform DESTINATION lib)
+ install(TARGETS sdptransform)

why the removal of the DESTINATION?

@alebcay
Copy link
Author

alebcay commented Aug 18, 2021

The sdptransform target contains a library (libsdptransform), and the implicit/default destination for installing those is lib.

It can be added back of course; my understanding however is that it's unnecessary.

@ibc
Copy link
Owner

ibc commented Dec 22, 2022

@alebcay libsdptransform 1.2.10 has been released and comes with Catch v3. Can you adapt your PR to it?

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.

3 participants