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

conanfile: set compatibility_cppstd = False. #2860

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

vsaulue
Copy link
Contributor

@vsaulue vsaulue commented Apr 17, 2024

Description

The Catch libraries have different API/ABI depending on the C++ standard they are compiled with. For example, StringMaker::convert(std::string_view) isn't in the binary when compiled with C++14, only with C++17 or later.

By default, Conan is allowed to serve Catch libraries compiled in C++14 to a project using C++17/20, potentially causing linker errors because of missing symbols (see #2605). This PR overrides this default using conan extension properties: the C++ standard used to build the Catch library will exactly match the one of the requiring project (building Catch from source if necessary).

This is probably much more constraining than necessary (I assume it will prevent conan from using a c++17 catch2 binary into a gnu17 project). But that's the only simple solution I have. And as a user, locally rebuilding Catch "just in case" is much better than getting linker errors.

Note:

Right now for Windows, the conan-center catch2 package has only prebuilt binaries for C++14. So many Windows users are at risk of getting served C++14 Catch2 binaries in all their non-C++14 projects.

This can also happen on other platforms: if the first Catch2 binaries that ends up in your Conan cache were build in C++14, Conan will currently serve them in all your future C++17/20 projects.

The Catch libraries have different API/ABI depending on the c++
standard they are compiled with. For example, the following function
isn't in the binary when compiled with C++14, only with C++17 or later:

StringMaker<std::string_view>::convert(std::string_view str);

By default, Conan is allowed to serve Catch libraries compiled in C++14
into a project using C++17/20, potentially causing linker errors
because of missing symbols. This PR overrides this default behaviour:
the C++ standard of the Catch library will exactly match the one of
the requiring project (building Catch from source if necessary).
@vsaulue vsaulue changed the title conanfile: set compatibility_cppstr = False. conanfile: set compatibility_cppstd = False. Apr 17, 2024
Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.10%. Comparing base (53ddf37) to head (38fa5d5).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #2860      +/-   ##
==========================================
+ Coverage   91.09%   91.10%   +0.01%     
==========================================
  Files         197      197              
  Lines        8382     8382              
==========================================
+ Hits         7635     7636       +1     
+ Misses        747      746       -1     

@horenmar
Copy link
Member

Thanks. This is an interesting feature, vcpkg does not have similar one -- their workaround is to always build the impl lib with C++17.

@horenmar horenmar merged commit 8e80b8f into catchorg:devel Apr 18, 2024
81 checks passed
@horenmar horenmar added the Building and Packaging Issues affecting build/packaging scripts and utilities label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Building and Packaging Issues affecting build/packaging scripts and utilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants