Skip to content

Commit

Permalink
Base pkg-config libdir on CMAKE_INSTALL_LIBDIR
Browse files Browse the repository at this point in the history
Fixes #3535

Signed-off-by: Henner Zeller <[email protected]>
  • Loading branch information
hzeller committed Mar 24, 2023
1 parent be41071 commit 0445a63
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
ccache-key: linux-install-${{ matrix.compiler }}-${{ matrix.config }}

- name: Install vendored dependencies
if: ${{ !matrix.vendored_dependencies }}
run: |
git clone https://github.com/google/flatbuffers.git
pushd flatbuffers
Expand Down Expand Up @@ -84,7 +85,6 @@ jobs:
pushd antlr4
unzip ../antlr4-cpp-runtime-4.12.0-source.zip && cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DBUILD_SHARED_LIBS=ON . && cmake --build build && sudo cmake --install build
popd
if: ${{ !matrix.vendored_dependencies }}
- name: Build, install & test
run: |
Expand Down Expand Up @@ -126,6 +126,10 @@ jobs:
cmake --build tests/TestInstall/build -j $(nproc)
echo "-- pkg-config content --"
cat $INSTALL_DIR/lib/pkgconfig/Surelog.pc
PREFIX=$INSTALL_DIR make test_install_pkgconfig
- name: Prepare build artifacts
run: |
mkdir artifacts
Expand Down Expand Up @@ -473,6 +477,7 @@ jobs:
make test/unittest
make clean
make test_install
#make test_install_pkgconfig # not working yet.
- name: Prepare build artifacts
run: |
Expand Down Expand Up @@ -946,6 +951,7 @@ jobs:
make test/unittest
make clean # make sure we only see installation artifacts
make test_install
make test_install_pkgconfig
- name: Prepare build artifacts
run: |
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ test_install_pkgconfig:
PKG_CONFIG_PATH="$(PREFIX)/lib/pkgconfig:${PKG_CONFIG_PATH}" \
PKG_CONFIG_PATH_FOR_TARGET="$(PREFIX)/lib/pkgconfig:${PKG_CONFIG_PATH_FOR_TARGET}" \
$(MAKE) -f tests/TestInstall/Makefile \
build/hellosureworld \
build/hellouhdm \
build/hellodesign
tests/TestInstall/build/hellosureworld \
tests/TestInstall/build/hellouhdm \
tests/TestInstall/build/hellodesign

uninstall:
$(RM) -r $(PREFIX)/bin/surelog
Expand Down
2 changes: 1 addition & 1 deletion cmake/configs/Surelog.pc.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
libdir="${prefix}/lib/surelog"
libdir="${prefix}/@CMAKE_INSTALL_LIBDIR@/surelog"
includedir="${prefix}/include"

Name: @PROJECT_NAME@
Expand Down
13 changes: 10 additions & 3 deletions tests/TestInstall/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Simple example how to utilize pkg-config to find the cflags and libraries
CXXFLAGS=--std=c++17
CXXFLAGS+=`pkg-config --cflags Surelog`
LDFLAGS+=`pkg-config --libs Surelog`

# TODO(hzeller): should the supporting libs be mentioned in the pkg-config ?
LDFLAGS+=-lpthread

# Let's build these out-of-tree
IN_DIR=src
OUT_DIR=build
OUT_DIR=tests/TestInstall/build

$(OUT_DIR)/%.o : $(IN_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $^ -o $@
$(OUT_DIR)/%.o : $(IN_DIR)/%.cpp $(OUT_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@

% : %.o
$(CXX) $^ -o $@ $(LDFLAGS)

$(OUT_DIR):
mkdir -p $(OUT_DIR)

0 comments on commit 0445a63

Please sign in to comment.