diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6e8016c..20fa33a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -82,11 +82,11 @@ jobs: - name: Configure (${{ matrix.configuration }}) run: | if [ "${{ matrix.toolchain }}" == "windows-msvc-shared" ]; then - cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON + cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=~/install elif [ "${{ matrix.toolchain }}" == "windows-msvc-static" ]; then - cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DBASH_EXECUTABLE="C:/Program Files/Git/bin/bash.exe" -DBUILD_SHARED_LIBS=OFF + cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DBASH_EXECUTABLE="C:/Program Files/Git/bin/bash.exe" -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=~/install else - cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON + cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=~/install fi - name: Build with ${{ matrix.compiler }} @@ -100,6 +100,14 @@ jobs: - name: Test run: ctest --test-dir build --build-config ${{ matrix.configuration }} --verbose + - name: Install + run: | + if [ "${{ matrix.compiler }}" == "msvc" ]; then + cmake --build build --target install --config ${{ matrix.configuration }} + else + cmake --build build --target install + fi + build-cmake-cygwin: name: windows-cygwin runs-on: windows-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c261f5..7e5cdd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,23 @@ file(RELATIVE_PATH RELATIVE_LIBDIR message(STATUS "CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}") +set(prefix "${CMAKE_INSTALL_PREFIX}") +set(exec_prefix "\${prefix}") +if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + set(libdir "${CMAKE_INSTALL_LIBDIR}") +else() + set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") +endif() +if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") +else() + set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +endif() +set(SHAPELIB_PC ${CMAKE_CURRENT_BINARY_DIR}/shapelib.pc) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/shapelib.pc.cmake.in + ${SHAPELIB_PC} @ONLY +) + if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) # Set a default build type for single-configuration cmake generators # if no build type is set. @@ -221,6 +238,9 @@ install(TARGETS ${executables} # Install header install(FILES shapefil.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +# Install pkg-config file +install(FILES "${SHAPELIB_PC}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + if(BUILD_TESTING) # Set up tests: diff --git a/Makefile.am b/Makefile.am index a65e4a4..0229a10 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,6 +16,7 @@ EXTRA_DIST = makefile.vc CMakeLists.txt autogen.sh \ cmake/contrib.cmake \ cmake/project-config-version.cmake.in \ cmake/project-config.cmake.in \ + cmake/shapelib.pc.cmake.in \ tests/CMakeLists.txt \ tests/dbf_test.cc \ tests/sbn_test.cc \ diff --git a/cmake/shapelib.pc.cmake.in b/cmake/shapelib.pc.cmake.in new file mode 100644 index 0000000..4222a76 --- /dev/null +++ b/cmake/shapelib.pc.cmake.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +datarootdir=${prefix}/share +datadir=${datarootdir} +includedir=@includedir@ + +Name: shapelib +Description: C API for processing ESRI Shapefiles +Version: @PROJECT_VERSION@ +Libs: -L${libdir} -lshp +Cflags: -I${includedir}