Skip to content

CXX-3290 fix static pkgconfig requirements #1406

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

Merged
merged 4 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/projects/bsoncxx/pkg-config/static/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ set -o pipefail
exit 1
)

# Sanity-check that static libbson is required. Regression test for CXX-3290.
(pkg-config --print-requires libbsoncxx-static | grep -- bson2-static || (
(
echo "Expected bson2-static to be required" >&2
exit 1
)
))

rm -rf build/*
cd build
"${CXX:?}" $CXXFLAGS -Wall -Wextra -Werror -std="c++${CXX_STANDARD:?}" -c -o hello_bsoncxx.o ../../../hello_bsoncxx.cpp $(pkg-config --cflags libbsoncxx-static)
Expand Down
8 changes: 8 additions & 0 deletions examples/projects/mongocxx/pkg-config/static/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ set -o pipefail
exit 1
)

# Sanity-check that static libmongoc is required. Regression test for CXX-3290.
(pkg-config --print-requires libmongocxx-static | grep -- mongoc2-static || (
(
echo "Expected mongoc2-static to be required" >&2
exit 1
)
))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(pkg-config --print-requires libmongocxx-static | grep -- mongoc2-static || (
(
echo "Expected mongoc2-static to be required" >&2
exit 1
)
))
if ! pkg-config --print-requires libmongocxx-static | grep -q "mongoc2-static"; then
echo "Expected mongoc2-static to be required" >&2
exit 1
fi

Lot of subshells; this can be reduced to a straightforward conditional.

Use -q to silence grep matches + per grep manpages:

If no FILE is given [...] nonrecursive searches read standard input.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the suggestion. Updated.


rm -rf build/*
cd build
"${CXX:?}" $CXXFLAGS -Wall -Wextra -Werror -std="c++${CXX_STANDARD:?}" -c -o hello_mongocxx.o ../../../hello_mongocxx.cpp $(pkg-config --cflags libmongocxx-static)
Expand Down
2 changes: 1 addition & 1 deletion src/bsoncxx/cmake/generate-pc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if(1)
set(requires "")

if(is_static)
list(APPEND requires "bson2 >= ${bson_req_ver}")
list(APPEND requires "bson2-static >= ${bson_req_ver}")
endif()

list(JOIN requires ", " requires)
Expand Down
2 changes: 1 addition & 1 deletion src/mongocxx/cmake/generate-pc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if(1)

if(is_static)
list(APPEND requires "lib${bsoncxx_name} >= ${version}")
list(APPEND requires "mongoc2 >= ${mongoc_req_ver}")
list(APPEND requires "mongoc2-static >= ${mongoc_req_ver}")
else()
list(APPEND requires "lib${bsoncxx_name} >= ${version}")
endif()
Expand Down