Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ jobs:
uses: actions/cache@v4
with:
path: build/_deps
key: ${{ runner.os }}-${{ matrix.name }}-googletest-1.14.0
# Include repo name in the key so a repo rename (which changes the
# absolute work-dir path baked into FetchContent's subbuild cache)
# invalidates stale caches automatically.
key: ${{ runner.os }}-${{ matrix.name }}-${{ github.event.repository.name }}-googletest-1.14.0

- name: Configure
run: cmake -S . -B build -DGEO_UTILS_BUILD_TESTS=ON -DGEO_UTILS_BUILD_EXAMPLES=ON
run: cmake -S . -B build -DGEO_UTILS_CPP_BUILD_TESTS=ON -DGEO_UTILS_CPP_BUILD_EXAMPLES=ON

- name: Build
run: cmake --build build --config Release
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# then generates a Cobertura-XML report scoped to include/ (the public headers).
# The report is uploaded to Codecov for tracking over time.
#
# Linux-only: relies on gcc + gcov; the GEO_UTILS_ENABLE_COVERAGE option in CMakeLists.txt
# Linux-only: relies on gcc + gcov; the GEO_UTILS_CPP_ENABLE_COVERAGE option in CMakeLists.txt
# is GCC/Clang-specific.
#
# Triggered automatically on push/PR to master/main; can also be run manually
Expand Down Expand Up @@ -36,13 +36,16 @@ jobs:
uses: actions/cache@v4
with:
path: build/_deps
key: ${{ runner.os }}-coverage-googletest-1.14.0
# Include repo name in the key so a repo rename (which changes the
# absolute work-dir path baked into FetchContent's subbuild cache)
# invalidates stale caches automatically.
key: ${{ runner.os }}-coverage-${{ github.event.repository.name }}-googletest-1.14.0

- name: Install gcovr
run: pip install gcovr

- name: Configure
run: cmake -S . -B build -DGEO_UTILS_BUILD_TESTS=ON -DGEO_UTILS_ENABLE_COVERAGE=ON
run: cmake -S . -B build -DGEO_UTILS_CPP_BUILD_TESTS=ON -DGEO_UTILS_CPP_ENABLE_COVERAGE=ON

- name: Build
run: cmake --build build
Expand Down
35 changes: 32 additions & 3 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Installs the library to a temporary prefix, then configures and builds a
# minimal consumer project (tests/consumer/) against that prefix using
# `find_package(GeoUtils 1.0 REQUIRED)` and `target_link_libraries(... geo::utils)`.
# `find_package(GeoUtilsCpp 1.0.1 REQUIRED)` and `target_link_libraries(... geo::utils)`.
# Runs the consumer to verify end-to-end integration.
#
# Catches regressions in install paths, exported target names, and
Expand Down Expand Up @@ -41,14 +41,43 @@ jobs:
steps:
- uses: actions/checkout@v4

# CMAKE_INSTALL_PREFIX is set at configure time so it's baked into the
# generated .pc file; the install step must not pass --prefix or the
# .pc would point at the configure-time prefix while files land elsewhere.
- name: Configure library
run: cmake -S . -B build
run: cmake -S . -B build -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/prefix

- name: Build library
run: cmake --build build --config Release

- name: Install library
run: cmake --install build --config Release --prefix ${{ runner.temp }}/prefix
run: cmake --install build --config Release

# pkg-config sanity: catches regressions in the .pc template, including
# malformed includedirs (doubled prefix → //) and non-relocatable templates
# (the resolved includedir must actually contain our headers, not point at
# a configure-time prefix that no longer matches the install location).
# Skipped on Windows — pkg-config isn't part of the default toolchain.
- name: Verify pkg-config metadata
if: runner.os != 'Windows'
env:
PKG_CONFIG_PATH: ${{ runner.temp }}/prefix/lib/pkgconfig
run: |
version=$(pkg-config --modversion geo-utils-cpp)
cflags=$(pkg-config --cflags geo-utils-cpp)
include_dir=$(pkg-config --variable=includedir geo-utils-cpp)
echo "version: $version"
echo "cflags: $cflags"
echo "includedir: $include_dir"
test "$version" = "1.0.1"
case "$cflags" in
*//*) echo "ERROR: doubled-slash in include path: $cflags" >&2; exit 1 ;;
esac
test -f "$include_dir/geo/geo.hpp" || {
echo "ERROR: header missing at $include_dir/geo/geo.hpp" >&2
echo " (the .pc file points outside the install prefix — likely a relocation bug)" >&2
exit 1
}

- name: Configure consumer
run: cmake -S tests/consumer -B build-consumer -DCMAKE_PREFIX_PATH=${{ runner.temp }}/prefix
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## v1.0.1

Renamed package to `geo-utils-cpp` to avoid a name collision with an existing
`geo-utils` component on [repology](https://repology.org). The public C++ API
is unchanged — downstream source code does not need to be updated.

### Changed

- pkg-config name: `geo-utils` → `geo-utils-cpp` (`.pc` file installed as
`geo-utils-cpp.pc`).
- CPack package name: `geo-utils` → `geo-utils-cpp`.
- CMake package name: `find_package(GeoUtils ...)` → `find_package(GeoUtilsCpp ...)`.
Config files install to `${CMAKE_INSTALL_LIBDIR}/cmake/GeoUtilsCpp/` as
`GeoUtilsCppConfig.cmake`, `GeoUtilsCppConfigVersion.cmake`, and
`GeoUtilsCppTargets.cmake`.
- Build options renamed with `GEO_UTILS_CPP_` prefix:
`GEO_UTILS_BUILD_TESTS` → `GEO_UTILS_CPP_BUILD_TESTS`,
`GEO_UTILS_BUILD_EXAMPLES` → `GEO_UTILS_CPP_BUILD_EXAMPLES`,
`GEO_UTILS_ENABLE_COVERAGE` → `GEO_UTILS_CPP_ENABLE_COVERAGE`,
`GEO_UTILS_INSTALL_PKGCONFIG` → `GEO_UTILS_CPP_INSTALL_PKGCONFIG`.

### Unchanged (downstream-compatible)

- Imported target `geo::utils`.
- C++ namespace `geo::` and `geo::detail::`.
- Public headers: `<geo/geo.hpp>`, `<geo/latlng.hpp>`, `<geo/spherical.hpp>`,
`<geo/poly.hpp>`.

## v1.0.0

Initial stable release. Header-only C++17 library for spherical geographic
Expand Down
92 changes: 46 additions & 46 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
cmake_minimum_required(VERSION 3.14)
project(GeoUtils VERSION 1.0.0 LANGUAGES CXX)
project(GeoUtilsCpp VERSION 1.0.1 LANGUAGES CXX)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(_geo_utils_is_top_level ON)
set(_geo_utils_cpp_is_top_level ON)
else()
set(_geo_utils_is_top_level OFF)
set(_geo_utils_cpp_is_top_level OFF)
endif()

include(CMakeDependentOption)
option(GEO_UTILS_BUILD_TESTS "Build geo-utils tests" ${_geo_utils_is_top_level})
option(GEO_UTILS_BUILD_EXAMPLES "Build geo-utils examples" ${_geo_utils_is_top_level})
cmake_dependent_option(GEO_UTILS_ENABLE_COVERAGE
option(GEO_UTILS_CPP_BUILD_TESTS "Build geo-utils-cpp tests" ${_geo_utils_cpp_is_top_level})
option(GEO_UTILS_CPP_BUILD_EXAMPLES "Build geo-utils-cpp examples" ${_geo_utils_cpp_is_top_level})
cmake_dependent_option(GEO_UTILS_CPP_ENABLE_COVERAGE
"Enable gcov coverage instrumentation (GCC/Clang only)" OFF
"GEO_UTILS_BUILD_TESTS" OFF)
"GEO_UTILS_CPP_BUILD_TESTS" OFF)

# Header-only interface target
add_library(geo_utils INTERFACE)
add_library(geo::utils ALIAS geo_utils)
add_library(geo_utils_cpp INTERFACE)
add_library(geo::utils ALIAS geo_utils_cpp)

# So the exported imported target is geo::utils (matches the build-tree alias)
set_target_properties(geo_utils PROPERTIES EXPORT_NAME utils)
set_target_properties(geo_utils_cpp PROPERTIES EXPORT_NAME utils)

target_include_directories(geo_utils INTERFACE
target_include_directories(geo_utils_cpp INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(geo_utils INTERFACE cxx_std_17)
target_compile_features(geo_utils_cpp INTERFACE cxx_std_17)

# Tests
if(GEO_UTILS_BUILD_TESTS)
if(GEO_UTILS_CPP_BUILD_TESTS)
include(CTest)
include(GoogleTest)

Expand Down Expand Up @@ -65,36 +65,36 @@ if(GEO_UTILS_BUILD_TESTS)
endif()
endif()

add_executable(geo_utils_tests tests/tests.cpp)
target_link_libraries(geo_utils_tests
add_executable(geo_utils_cpp_tests tests/tests.cpp)
target_link_libraries(geo_utils_cpp_tests
PRIVATE geo::utils GTest::GTest GTest::Main
)
gtest_discover_tests(geo_utils_tests)
gtest_discover_tests(geo_utils_cpp_tests)

if(GEO_UTILS_ENABLE_COVERAGE)
if(GEO_UTILS_CPP_ENABLE_COVERAGE)
# `--coverage` is split: compile inserts gcov hooks, link pulls in the
# gcov runtime. The compiler-flag check must include both stages — see
# CMAKE_REQUIRED_LINK_OPTIONS (CMake 3.14+). Otherwise the test object
# compiles fine but link fails on missing gcov symbols, giving a false
# negative on toolchains that actually support the flag (e.g. AppleClang).
include(CheckCXXCompilerFlag)
set(CMAKE_REQUIRED_LINK_OPTIONS --coverage)
check_cxx_compiler_flag(--coverage GEO_UTILS_HAS_COVERAGE_FLAG)
check_cxx_compiler_flag(--coverage GEO_UTILS_CPP_HAS_COVERAGE_FLAG)
unset(CMAKE_REQUIRED_LINK_OPTIONS)

if(NOT GEO_UTILS_HAS_COVERAGE_FLAG)
if(NOT GEO_UTILS_CPP_HAS_COVERAGE_FLAG)
message(FATAL_ERROR
"GEO_UTILS_ENABLE_COVERAGE=ON requested, but the C++ compiler "
"GEO_UTILS_CPP_ENABLE_COVERAGE=ON requested, but the C++ compiler "
"(${CMAKE_CXX_COMPILER_ID}) does not support --coverage. "
"Coverage instrumentation requires GCC or Clang.")
endif()
target_compile_options(geo_utils_tests PRIVATE --coverage)
target_link_options(geo_utils_tests PRIVATE --coverage)
target_compile_options(geo_utils_cpp_tests PRIVATE --coverage)
target_link_options(geo_utils_cpp_tests PRIVATE --coverage)
endif()
endif()

# Examples
if(GEO_UTILS_BUILD_EXAMPLES)
if(GEO_UTILS_CPP_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

Expand All @@ -104,50 +104,50 @@ include(GNUInstallDirs)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(TARGETS geo_utils
EXPORT GeoUtilsTargets
install(TARGETS geo_utils_cpp
EXPORT GeoUtilsCppTargets
)
install(EXPORT GeoUtilsTargets
FILE GeoUtilsTargets.cmake
install(EXPORT GeoUtilsCppTargets
FILE GeoUtilsCppTargets.cmake
NAMESPACE geo::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GeoUtils
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GeoUtilsCpp
)

include(CMakePackageConfigHelpers)

configure_package_config_file(
cmake/GeoUtilsConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/GeoUtilsConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GeoUtils
cmake/GeoUtilsCppConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/GeoUtilsCppConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GeoUtilsCpp
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/GeoUtilsConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/GeoUtilsCppConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/GeoUtilsConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/GeoUtilsConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GeoUtils
${CMAKE_CURRENT_BINARY_DIR}/GeoUtilsCppConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/GeoUtilsCppConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GeoUtilsCpp
)

# pkg-config
option(GEO_UTILS_INSTALL_PKGCONFIG "Install a pkg-config (.pc) file" ON)
if(GEO_UTILS_INSTALL_PKGCONFIG)
option(GEO_UTILS_CPP_INSTALL_PKGCONFIG "Install a pkg-config (.pc) file" ON)
if(GEO_UTILS_CPP_INSTALL_PKGCONFIG)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/geo-utils.pc.in
${CMAKE_CURRENT_BINARY_DIR}/geo-utils.pc
${CMAKE_CURRENT_SOURCE_DIR}/cmake/geo-utils-cpp.pc.in
${CMAKE_CURRENT_BINARY_DIR}/geo-utils-cpp.pc
@ONLY
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geo-utils.pc
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geo-utils-cpp.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()

if(_geo_utils_is_top_level)
set(CPACK_PACKAGE_NAME "geo-utils")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_GENERATOR "ZIP")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
include(CPack)
if(_geo_utils_cpp_is_top_level)
set(CPACK_PACKAGE_NAME "geo-utils-cpp")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_GENERATOR "ZIP")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
include(CPack)
endif()
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# geo-utils
# geo-utils-cpp

<p align="left">
<a href="https://github.com/gistrec/geo-utils/actions/workflows/ci.yml">
<img src="https://github.com/gistrec/geo-utils/actions/workflows/ci.yml/badge.svg" alt="CI">
<a href="https://github.com/gistrec/geo-utils-cpp/actions/workflows/ci.yml">
<img src="https://github.com/gistrec/geo-utils-cpp/actions/workflows/ci.yml/badge.svg" alt="CI">
</a>
<a href="https://app.codacy.com/gh/gistrec/geo-utils/dashboard">
<a href="https://app.codacy.com/gh/gistrec/geo-utils-cpp/dashboard">
<img src="https://img.shields.io/codacy/grade/bcff544711544d5fb7da95b68abf566d" alt="Code quality">
</a>
<a href="https://codecov.io/gh/gistrec/geo-utils">
<img src="https://codecov.io/gh/gistrec/geo-utils/graph/badge.svg" alt="Coverage">
<a href="https://codecov.io/gh/gistrec/geo-utils-cpp">
<img src="https://codecov.io/gh/gistrec/geo-utils-cpp/graph/badge.svg" alt="Coverage">
</a>
<a href="https://github.com/gistrec/geo-utils/releases">
<img src="https://img.shields.io/github/v/release/gistrec/geo-utils" alt="Release">
<a href="https://github.com/gistrec/geo-utils-cpp/releases">
<img src="https://img.shields.io/github/v/release/gistrec/geo-utils-cpp" alt="Release">
</a>
</p>
<p align="left">
Expand All @@ -27,8 +27,8 @@
<a href="#">
<img src="https://img.shields.io/badge/platform-Linux%20%C2%B7%20macOS%20%C2%B7%20Windows-brightgreen" alt="Supported platforms">
</a>
<a href="https://github.com/gistrec/geo-utils/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/gistrec/geo-utils?color=brightgreen" alt="License">
<a href="https://github.com/gistrec/geo-utils-cpp/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/gistrec/geo-utils-cpp?color=brightgreen" alt="License">
</a>
</p>

Expand Down Expand Up @@ -64,19 +64,19 @@ Uses spherical Earth approximation (like Google Maps).
include(FetchContent)

FetchContent_Declare(
GeoUtils
GIT_REPOSITORY https://github.com/gistrec/geo-utils.git
GIT_TAG v1.0.0
GeoUtilsCpp
GIT_REPOSITORY https://github.com/gistrec/geo-utils-cpp.git
GIT_TAG v1.0.1
)
FetchContent_MakeAvailable(GeoUtils)
FetchContent_MakeAvailable(GeoUtilsCpp)

target_link_libraries(your_target PRIVATE geo::utils)
```

### find_package

```cmake
find_package(GeoUtils 1.0 REQUIRED)
find_package(GeoUtilsCpp 1.0.1 REQUIRED)
target_link_libraries(your_target PRIVATE geo::utils)
```

Expand Down Expand Up @@ -111,7 +111,7 @@ See [docs/api.md](docs/api.md) for the full API reference.

## Support

[Please open an issue on GitHub](https://github.com/gistrec/geo-utils/issues)
[Please open an issue on GitHub](https://github.com/gistrec/geo-utils-cpp/issues)

## License

Expand Down
5 changes: 0 additions & 5 deletions cmake/GeoUtilsConfig.cmake.in

This file was deleted.

5 changes: 5 additions & 0 deletions cmake/GeoUtilsCppConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/GeoUtilsCppTargets.cmake")

check_required_components(GeoUtilsCpp)
8 changes: 8 additions & 0 deletions cmake/geo-utils-cpp.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
prefix=@CMAKE_INSTALL_PREFIX@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Comment thread
gistrec marked this conversation as resolved.

Name: geo-utils-cpp
Description: Header-only C++ geographic utilities
URL: https://github.com/gistrec/geo-utils-cpp
Version: @PROJECT_VERSION@
Cflags: -I${includedir}
Loading
Loading