diff --git a/.github/workflows/c.yml b/.github/workflows/c.yml index bd76fd1..b06cff8 100644 --- a/.github/workflows/c.yml +++ b/.github/workflows/c.yml @@ -68,7 +68,7 @@ jobs: env: CC: clang CXX: clang++ - CXXFLAGS: -Werror -Wall -pedantic -std=c++17 + CXXFLAGS: -Werror -Wall -pedantic BUILD_TYPE: Debug steps: - uses: actions/checkout@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 147d012..90644c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,14 @@ project(osmpbf VERSION 1.5.0) include(GNUInstallDirs) +# This is needed for the protobuf_generate_cpp() function to work on newer +# versions of the Protobuf CMake config. +set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "") + +# This is needed so that we pick up the (more modern) CONFIG mode cmake file +# before the (older) MODULE mode cmake config file. Seems to be needed on macOS. +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) + find_package(Protobuf REQUIRED) add_subdirectory(osmpbf) diff --git a/osmpbf/CMakeLists.txt b/osmpbf/CMakeLists.txt index 41f3c2a..92a5ef3 100644 --- a/osmpbf/CMakeLists.txt +++ b/osmpbf/CMakeLists.txt @@ -1,12 +1,13 @@ protobuf_generate_cpp(CPPS HS fileformat.proto osmformat.proto) add_library(osmpbf STATIC ${CPPS}) +target_compile_features(osmpbf PUBLIC cxx_std_11) +target_link_libraries(osmpbf PRIVATE protobuf::libprotobuf) target_include_directories(osmpbf SYSTEM PUBLIC ${Protobuf_INCLUDE_DIRS}) -set_property(TARGET osmpbf PROPERTY CXX_STANDARD 11) install(TARGETS osmpbf ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) add_library(osmpbf_shared SHARED ${CPPS}) -set_property(TARGET osmpbf_shared PROPERTY CXX_STANDARD 11) +target_compile_features(osmpbf_shared PUBLIC cxx_std_11) target_link_libraries(osmpbf_shared PRIVATE protobuf::libprotobuf) target_include_directories(osmpbf_shared SYSTEM PUBLIC ${Protobuf_INCLUDE_DIRS}) set_target_properties(osmpbf_shared PROPERTIES OUTPUT_NAME osmpbf