Skip to content

Commit d688b3e

Browse files
authored
CXX-3290 fix static pkgconfig requirements (#1406)
Restore behavior before 4.1.0: Have static libbsoncxx depend on static (not shared) libbson. Have static libmongocxx depend on static (not shared) libmongoc.
1 parent b68fad3 commit d688b3e

File tree

6 files changed

+40
-32
lines changed

6 files changed

+40
-32
lines changed

examples/projects/bsoncxx/pkg-config/shared/build.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ set -o pipefail
55

66
# Sanity-check that static library macros are not set when building against the shared library.
77
# Users don't need to include this section in their projects.
8-
(pkg-config --cflags libbsoncxx | grep -v -- -DBSONCXX_STATIC) ||
9-
(
10-
echo "Expected BSONCXX_STATIC to not be set" >&2
11-
exit 1
12-
)
8+
if ! pkg-config --cflags libbsoncxx | grep -v -q -- -DBSONCXX_STATIC; then
9+
echo "Expected BSONCXX_STATIC to not be set" >&2
10+
exit 1
11+
fi
1312

1413
rm -rf build/*
1514
cd build

examples/projects/bsoncxx/pkg-config/static/build.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ set -o pipefail
55

66
# Sanity-check that static library macros are set when building against the static library. Users
77
# don't need to include this section in their projects.
8-
(pkg-config --cflags libbsoncxx-static | grep -- -DBSONCXX_STATIC) ||
9-
(
10-
echo "Expected BSONCXX_STATIC to be set" >&2
11-
exit 1
12-
)
8+
if ! pkg-config --cflags libbsoncxx-static | grep -q -- -DBSONCXX_STATIC; then
9+
echo "Expected BSONCXX_STATIC to be set" >&2
10+
exit 1
11+
fi
12+
13+
# Sanity-check that static libbson is required. Regression test for CXX-3290.
14+
if ! pkg-config --print-requires libbsoncxx-static | grep -q -- bson2-static; then
15+
echo "Expected bson2-static to be required" >&2
16+
exit 1
17+
fi
1318

1419
rm -rf build/*
1520
cd build

examples/projects/mongocxx/pkg-config/shared/build.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ set -o pipefail
55

66
# Sanity-check that static library macros are not set when building against the shared library.
77
# Users don't need to include this section in their projects.
8-
(pkg-config --cflags libmongocxx | grep -v -- -DBSONCXX_STATIC) ||
9-
(
10-
echo "Expected BSONCXX_STATIC to not be set" >&2
11-
exit 1
12-
)
13-
(pkg-config --cflags libmongocxx | grep -v -- -DMONGOCXX_STATIC) ||
14-
(
15-
echo "Expected MONGOCXX_STATIC to not be set" >&2
16-
exit 1
17-
)
8+
if ! pkg-config --cflags libmongocxx | grep -v -q -- -DBSONCXX_STATIC; then
9+
echo "Expected BSONCXX_STATIC to not be set" >&2
10+
exit 1
11+
fi
12+
13+
if ! pkg-config --cflags libmongocxx | grep -v -q -- -DMONGOCXX_STATIC; then
14+
echo "Expected MONGOCXX_STATIC to not be set" >&2
15+
exit 1
16+
fi
1817

1918
rm -rf build/*
2019
cd build

examples/projects/mongocxx/pkg-config/static/build.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@ set -o pipefail
55

66
# Sanity-check that static library macros are set when building against the static library. Users
77
# don't need to include this section in their projects.
8-
(pkg-config --cflags libmongocxx-static | grep -- -DBSONCXX_STATIC) ||
9-
(
10-
echo "Expected BSONCXX_STATIC to be set" >&2
11-
exit 1
12-
)
13-
(pkg-config --cflags libmongocxx-static | grep -- -DMONGOCXX_STATIC) ||
14-
(
15-
echo "Expected MONGOCXX_STATIC to be set" >&2
16-
exit 1
17-
)
8+
if ! pkg-config --cflags libmongocxx-static | grep -q -- -DBSONCXX_STATIC; then
9+
echo "Expected BSONCXX_STATIC to be set" >&2
10+
exit 1
11+
fi
12+
13+
if ! pkg-config --cflags libmongocxx-static | grep -q -- -DMONGOCXX_STATIC; then
14+
echo "Expected MONGOCXX_STATIC to be set" >&2
15+
exit 1
16+
fi
17+
18+
# Sanity-check that static libmongoc is required. Regression test for CXX-3290.
19+
if ! pkg-config --print-requires libmongocxx-static | grep -q -- mongoc2-static; then
20+
echo "Expected mongoc2-static to be required" >&2
21+
exit 1
22+
fi
1823

1924
rm -rf build/*
2025
cd build

src/bsoncxx/cmake/generate-pc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(1)
2626
set(requires "")
2727

2828
if(is_static)
29-
list(APPEND requires "bson2 >= ${bson_req_ver}")
29+
list(APPEND requires "bson2-static >= ${bson_req_ver}")
3030
endif()
3131

3232
list(JOIN requires ", " requires)

src/mongocxx/cmake/generate-pc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if(1)
2828

2929
if(is_static)
3030
list(APPEND requires "lib${bsoncxx_name} >= ${version}")
31-
list(APPEND requires "mongoc2 >= ${mongoc_req_ver}")
31+
list(APPEND requires "mongoc2-static >= ${mongoc_req_ver}")
3232
else()
3333
list(APPEND requires "lib${bsoncxx_name} >= ${version}")
3434
endif()

0 commit comments

Comments
 (0)