Skip to content

Conversation

@J-B-Blankenship
Copy link

@J-B-Blankenship J-B-Blankenship commented Jan 27, 2026

CMake Approach Issues

First Issue
Non-ASCII characters cannot be parsed by glob.

ERROR: /root/.cache/bazel/_bazel_root/646bcbb063181c5dac5a581e1c4fefdd/external/_main~_repo_rules~cpr/BUILD.bazel:22:6: Foreign Cc - CMake: Building cpr failed: error reading file '@@_main~_repo_rules~cpr//:test/data/test_file_hello_äüöp_2585_你好.txt': /root/.cache/bazel/_bazel_root/646bcbb063181c5dac5a581e1c4fefdd/external/_main~_repo_rules~cpr/test/data/test_file_hello_äüöp_2585_你好.txt (No such file or directory)

Second Issue
Resolving this error still causes an issue with <filesystem>. I was unable to override C++17 for C++20 to make this work with the cmake toolchain.

Repo Reference Issue
In addition, the referenced Bazel repo is deprecated by several years. I was unable to get them to work with BAZEL modules.

Solution
Use Bazel to build the project with a patch to remove the generated version file cpr/cprver.h (only created with the CMake command).

This was confirmed to work on Ubuntu 24.04. Modifications should be straightforward for Bazel users on Windows or Mac as it uses common toolchains.

Non-ASCII characters cannot be parsed by glob.

Resolves the following error when trying to build:
ERROR: /root/.cache/bazel/_bazel_root/646bcbb063181c5dac5a581e1c4fefdd/external/_main~_repo_rules~cpr/BUILD.bazel:22:6: Foreign Cc - CMake: Building cpr failed: error reading file '@@_main~_repo_rules~cpr//:test/data/test_file_hello_äüöp_2585_你好.txt': /root/.cache/bazel/_bazel_root/646bcbb063181c5dac5a581e1c4fefdd/external/_main~_repo_rules~cpr/test/data/test_file_hello_äüöp_2585_你好.txt (No such file or directory)
Updated Bazel dependencies and build configuration for cpr.
Removed reference to external Bazel repository due to being years out of date.
@J-B-Blankenship J-B-Blankenship changed the title Refine srcs glob to include and exclude patterns Updated Bazel Instructions Jan 28, 2026
@COM8
Copy link
Member

COM8 commented Jan 30, 2026

@J-B-Blankenship thanks for contributing! Could you please provide a minimal example for this? I've never really used bazel and this would make testing a bit easier.

@J-B-Blankenship
Copy link
Author

J-B-Blankenship commented Jan 30, 2026

@J-B-Blankenship thanks for contributing! Could you please provide a minimal example for this? I've never really used bazel and this would make testing a bit easier.

I have this repo where it is being used: https://github.com/RogueDB/roguedb-open-source. It should be stable for the master branch.

If you want a quick test, you can do the following:

  • docker compose run develop to build and run the image with all the dependencies pre-installed

Inside the container:

  • bazel build //... -> There is C++ code in getting_started/ that is using CPR. If it builds (as it should), then you are good to go.

The change primarily does the following:

  • Uses the compiler used by Bazel (clang in my case)
  • Uses the flags in .bazelrc or passed via command line (eg. using C++20 with -O3)
  • Bypasses CMake and excludes the generated version file with a patch (eg. in-place application of a git diff).

Please let me know if you have additional questions. If I can make the instructions clearer, I can also do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants