From f9f185840db17c28ff63ec1d5d0bd3be31b11cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Fri, 3 Apr 2026 21:59:14 +0200 Subject: [PATCH 1/2] Fix required C++ version for CMake builds Current GTest versions required C++14 or C++17, so set the appropriate version in the compile_features. Also change the library from using CMAKE_CXX_STANDARD to the equivalent target_compile_features. This avoids downgrading the used standard version and is properly exported to CMake Target. Fixes #539. --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c23d634e..9d853c97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,15 +8,6 @@ cmake_minimum_required(VERSION 3.5...4.0) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # custom CMake modules like FindSQLiteCpp project(SQLiteCpp VERSION 3.3.3) -# SQLiteC++ 3.x requires C++11 features -if (NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) -elseif (CMAKE_CXX_STANDARD LESS 11) - message(WARNING "CMAKE_CXX_STANDARD has been set to '${CMAKE_CXX_STANDARD}' which is lower than the minimum required standard (c++11).") -endif () -message(STATUS "Using c++ standard c++${CMAKE_CXX_STANDARD}") -set(CMAKE_CXX_STANDARD_REQUIRED ON) - message (STATUS "CMake version: ${CMAKE_VERSION}") message (STATUS "Project version: ${PROJECT_VERSION}") @@ -212,6 +203,8 @@ endif() # add sources of the wrapper as a "SQLiteCpp" static library add_library(SQLiteCpp ${SQLITECPP_SRC} ${SQLITECPP_INC} ${SQLITECPP_DOC} ${SQLITECPP_SCRIPT}) +# SQLiteC++ 3.x requires C++11 features +target_compile_features(SQLiteCpp PUBLIC cxx_std_11) # Options relative to SQLite and SQLiteC++ functions @@ -475,10 +468,15 @@ if (SQLITECPP_BUILD_TESTS) target_link_libraries(SQLiteCpp_tests SQLiteCpp) find_package(GTest) - if (GTEST_FOUND) + if (GTest_FOUND) message(STATUS "Link to GTest system library") target_link_libraries(SQLiteCpp_tests GTest::GTest GTest::Main) - else (GTEST_FOUND) + if (GTest_VERSION AND (GTest_VERSION VERSION_LESS 1.17)) + target_compile_features(SQLiteCpp_tests PRIVATE cxx_std_14) + else() + target_compile_features(SQLiteCpp_tests PRIVATE cxx_std_17) + endif() + else (GTest_FOUND) message(STATUS "Compile googletest from source in submodule") # deactivate some warnings for compiling the googletest library if (NOT MSVC) @@ -505,7 +503,8 @@ if (SQLITECPP_BUILD_TESTS) endif (MSVC) target_link_libraries(SQLiteCpp_tests gtest_main) - endif (GTEST_FOUND) + target_compile_features(SQLiteCpp_tests PUBLIC cxx_std_17) + endif (GTest_FOUND) # add a "test" target: enable_testing() From 63eeef9d76ff7228dd1cc08dda77a8d080529da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Fri, 3 Apr 2026 22:31:16 +0200 Subject: [PATCH 2/2] Generate pkgconfig file also from CMake build Fixes #540. --- CMakeLists.txt | 12 ++++++++++++ cmake/sqlitecpp.pc.in | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 cmake/sqlitecpp.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d853c97..20c05624 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -381,6 +381,18 @@ if (SQLITECPP_INSTALL) ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + + cmake_path( + RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR + BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX} + OUTPUT_VARIABLE PC_RELATIVE_LIBDIR) + string(JOIN " -l" PC_LIBS_PRIVATE "" ${CMAKE_DL_LIBS}) + string(PREPEND PC_LIBS_PRIVATE ${CMAKE_THREAD_LIBS_INIT}) + # Use lowercase name for compatibility with Meson build + configure_file(cmake/sqlitecpp.pc.in cmake/sqlitecpp.pc @ONLY) + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/cmake/sqlitecpp.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/) endif (SQLITECPP_INSTALL) # Optional additional targets: diff --git a/cmake/sqlitecpp.pc.in b/cmake/sqlitecpp.pc.in new file mode 100644 index 00000000..d964000c --- /dev/null +++ b/cmake/sqlitecpp.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/@PC_RELATIVE_LIBDIR@ + +Name: sqlitecpp +Description: a smart and easy to use C++ SQLite3 wrapper. +Version: @PROJECT_VERSION@ +Requires.private: sqlite3 +Libs: -L${libdir} -lsqlitecpp +Libs.private: @PC_LIBS_PRIVATE@ +Cflags: -I${includedir}