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

Initial find script #14

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ryanf55
Copy link

@Ryanf55 Ryanf55 commented Jun 21, 2023

This is the PR for #13, currently in draft to garner feedback.

  • Let's somehow test the RST docs are correct
  • How are we expecting a user to install FindASIO.cmake
  • TODO: Add this to CI
  • TODO: Add cmake pre-commit hook to continue to lint the file

Note: This work was done on behalf of AeroVironment Inc.

Signed-off-by: Ryan Friedman <[email protected]>
@OlivierLDff
Copy link
Owner

Looks fine, waiting for CI & doc 🚀

ASIO_VERSION_MAJOR
ASIO_VERSION_MINOR
ASIO_VERSION_PATCH
ASIO_VERSION
Copy link
Author

Choose a reason for hiding this comment

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

Unclear - do we need to add ASIO_FOUND to the REQUIRED_VARS?

Copy link
Owner

Choose a reason for hiding this comment

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

Isn't it supposed to do it by itself? Only a test can make sure of that.

Copy link
Author

Choose a reason for hiding this comment

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

Yea, it would be nicer if the CMake docs would explain this point. I'll do a test.

cmake/FindASIO.cmake Show resolved Hide resolved
ASIO_VERSION_MINOR
ASIO_VERSION_PATCH
ASIO_VERSION
VERSION_VAR ASIO_VERSION
Copy link
Author

Choose a reason for hiding this comment

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

Right now, the version is required. Since this works since asio 0.3.8, I'd just recommend making it always part of the interface.

Copy link
Owner

Choose a reason for hiding this comment

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

What work since asio 0.3.8?

Copy link
Author

Choose a reason for hiding this comment

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

Parsing the asio/version.hpp for version info using the same regex.
Since 0.3.8, the version format has been the same and the regex is the same.

target_include_directories(asio INTERFACE ${Asio_INCLUDE_DIR})
target_compile_definitions(asio
INTERFACE
# ASIO_STANDALONE
Copy link
Author

Choose a reason for hiding this comment

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

I would like to understand what to do with the asio macros:

https://think-async.com/Asio/asio-1.28.0/doc/asio/using.html#asio.using.macros

Should these all be exposed as CMake OPTIONs, then set here in target_compile_definitions and a call to target_compile_options?

Copy link
Owner

Choose a reason for hiding this comment

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

Hard to answer here. It was easy when cmake when creating the asio target. I guess when asio is system installed this is the header only version no?

Copy link
Author

Choose a reason for hiding this comment

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

On ubuntu, I get the asio.cpp file but not the asio_ssl.cpp.

$ find /usr | grep asio | grep -v boost | grep cpp
/usr/include/asio/impl/src.cpp

From what I understand, which is used for the pre-compiled header, however 99% of asio is implemented in header files anyways. The find script here ideally should be able to support using asio in either mode. I have only gotten the header-only version working, pre-compiled has errors.

Copy link
Owner

Choose a reason for hiding this comment

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

I guess action with matrix is the way to test everything

cmake/FindASIO.cmake Show resolved Hide resolved
@Ryanf55
Copy link
Author

Ryanf55 commented Jun 22, 2023

Found a bug - if any of the major, minor, or patch versions are 0, the find_package_handle_standard_args reports the variables as not found.

@OlivierLDff
Copy link
Owner

That is odd, because 0.0.1 shoudl be a valid version or 1.0.0

@Ryanf55
Copy link
Author

Ryanf55 commented Jun 22, 2023

ASIO_VERSION_PATCH

Correct, that is a valid version, however I don't think you are supposed to put ASIO_VERSION_PATCH in the required variables. The math call should never fail.

We can assume if ASIO_VERSION exists, the other related version variables should work.

@OlivierLDff
Copy link
Owner

Seems fair

* Remove extra variables that are already set

Signed-off-by: Ryan Friedman <[email protected]>
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.

2 participants