From 945def349a1b529f6bc943a2dcf94eea0be9ab38 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Sun, 25 Feb 2024 15:24:58 +0100 Subject: [PATCH] Build shared and static libs separately --- .github/workflows/ci.yml | 52 ++---------- CMakeLists.txt | 18 ++-- scripts/ci/common.sh | 4 + src/CMakeLists.txt | 19 ----- src/backends/CMakeLists.txt | 41 ---------- src/backends/db2/CMakeLists.txt | 43 +++++----- src/backends/empty/CMakeLists.txt | 38 ++++----- src/backends/firebird/CMakeLists.txt | 45 +++++----- src/backends/mysql/CMakeLists.txt | 45 +++++----- src/backends/odbc/CMakeLists.txt | 43 +++++----- src/backends/oracle/CMakeLists.txt | 46 +++++------ src/backends/postgresql/CMakeLists.txt | 45 +++++----- src/backends/sqlite3/CMakeLists.txt | 44 +++++----- src/core/CMakeLists.txt | 109 +++++++++++-------------- tests/CMakeLists.txt | 46 +---------- tests/db2/CMakeLists.txt | 13 ++- tests/empty/CMakeLists.txt | 15 ++-- tests/firebird/CMakeLists.txt | 13 ++- tests/mysql/CMakeLists.txt | 13 ++- tests/odbc/CMakeLists.txt | 68 ++++++--------- tests/oracle/CMakeLists.txt | 13 ++- tests/postgresql/CMakeLists.txt | 13 ++- tests/sqlite3/CMakeLists.txt | 14 ++-- 23 files changed, 294 insertions(+), 506 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc9df85b6..cc29fcb74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,52 +22,19 @@ on: jobs: build: - runs-on: ${{ matrix.runner || 'ubuntu-22.04' }} - container: ${{ matrix.container }} - name: ${{ matrix.name }} strategy: fail-fast: false matrix: + lib_type: [shared, static] include: # Note: the jobs are ordered in the order of decreasing running # time, as this should minimize the total run-time of all jobs. - backend: postgresql runner: macos-11 name: PostgreSQL macOS - - backend: oracle - name: Oracle 11 - no_boost: true - - backend: valgrind - name: Valgrind - - backend: odbc - name: ODBC - - backend: firebird - name: Firebird - - backend: postgresql - name: PostgreSQL Linux - - backend: mysql - name: MySQL - - backend: sqlite3 - runner: macos-11 - name: SQLite3 macOS - - backend: sqlite3 - name: SQLite3 C++17 - cxxstd: 17 - - backend: sqlite3 - name: SQLite3 - - backend: empty - runner: macos-11 - name: Empty macOS - - backend: empty - name: Empty - test_release_package: true - # Unsupported: db2exc package is only available in Ubuntu 14.04 not - # supported by GitHub Actions any longer, we'd need to run it in - # Docker container if we really need it. - # backend: db2 - - backend: empty - name: Examples - build_examples: true + + runs-on: ${{ matrix.runner }} + name: ${{ matrix.name }} env: SOCI_CI: true @@ -102,14 +69,6 @@ jobs: ;; esac - case "${{matrix.container}}" in - ubuntu:18.04) - # We need to use this option as GitHub certificate is not recognized by - # wget in this old container otherwise. - set_env_var SOCI_WGET_OPTIONS --no-check-certificate - ;; - esac - if [ -n "${{matrix.cxxstd}}" ]; then set_env_var SOCI_CXXSTD ${{matrix.cxxstd}} fi @@ -122,6 +81,9 @@ jobs: if [ "${{matrix.build_examples}}" = true ]; then set_env_var BUILD_EXAMPLES YES fi + if [ "${{matrix.lib_type}}" = "static" ]; then + set_env_var SOCI_BUILD_STATIC YES + fi - name: Install dependencies under Linux if: runner.os == 'Linux' diff --git a/CMakeLists.txt b/CMakeLists.txt index 05242b810..62f22899c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,13 @@ include(CheckCXXCompilerFlag) check_ipo_supported(RESULT LTO_AVAILABLE) -option(SOCI_SHARED "Enable building SOCI as a shared library" ON) -option(SOCI_STATIC "Enable building SOCI as a static library" ON) +if (SOCI_STATIC) + set(SHARED_DEFAULT OFF) +else() + set(SHARED_DEFAULT ON) +endif() + +option(SOCI_SHARED "Enable building SOCI as a shared library" ${SHARED_DEFAULT}) option(SOCI_TESTS "Enable building SOCI test cases" ${PROJECT_IS_TOP_LEVEL}) option(SOCI_ASAN "Enable building SOCI with enabled address sanitizers" OFF) cmake_dependent_option(SOCI_LTO "Enable link time optimizations in release builds" ON "LTO_AVAILABLE" OFF) @@ -61,11 +66,10 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -# We need a dummy source file to add as sources for libs that otherwise -# only consist of object libraries (otherwise some toolchains may complain) -set(SOCI_CXX_DUMMY_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") -if (NOT EXISTS "${SOCI_CXX_DUMMY_SOURCE}") - file(TOUCH "${SOCI_CXX_DUMMY_SOURCE}") +if (SOCI_SHARED) + set(SOCI_LIB_TYPE "SHARED") +else() + set(SOCI_LIB_TYPE "STATIC") endif() add_subdirectory(src) diff --git a/scripts/ci/common.sh b/scripts/ci/common.sh index 94a71201d..c29fdd658 100644 --- a/scripts/ci/common.sh +++ b/scripts/ci/common.sh @@ -63,6 +63,10 @@ if [ -n "${WITH_BOOST}" ]; then SOCI_COMMON_CMAKE_OPTIONS="$SOCI_COMMON_CMAKE_OPTIONS -DWITH_BOOST=${WITH_BOOST}" fi +if [ -n "${SOCI_BUILD_STATIC}" ]; then + SOCI_COMMON_CMAKE_OPTIONS="${SOCI_COMMON_CMAKE_OPTIONS} -DSOCI_SHARED=OFF" +fi + # These options are defaults and used by most builds, but not Valgrind one. SOCI_DEFAULT_CMAKE_OPTIONS="${SOCI_COMMON_CMAKE_OPTIONS} -DSOCI_ASAN=ON diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54acfd04c..252bf4d92 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,24 +1,5 @@ -add_library(soci_shared_interface INTERFACE) -add_library(SOCI::shared::soci ALIAS soci_shared_interface) - -add_library(soci_static_interface INTERFACE) -add_library(SOCI::static::soci ALIAS soci_static_interface) - add_library(soci_interface INTERFACE) add_library(SOCI::soci ALIAS soci_interface) -if (SOCI_STATIC AND SOCI_SHARED) - if (BUILD_SHARED_LIBS) - target_link_libraries(soci_interface INTERFACE SOCI::shared::soci) - else() - target_link_libraries(soci_interface INTERFACE SOCI::static::soci) - endif() -elseif(SOCI_STATIC) - target_link_libraries(soci_interface INTERFACE SOCI::static::soci) -else() - target_link_libraries(soci_interface INTERFACE SOCI::shared::soci) -endif() - - add_subdirectory(core) add_subdirectory(backends) diff --git a/src/backends/CMakeLists.txt b/src/backends/CMakeLists.txt index 052393683..6b49cd19a 100644 --- a/src/backends/CMakeLists.txt +++ b/src/backends/CMakeLists.txt @@ -1,5 +1,3 @@ -include(soci_utils) - set(SOCI_EMPTY ${PROJECT_IS_TOP_LEVEL} CACHE STRING "Include the 'empty' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") set(SOCI_DB2 "AsAvailable" CACHE STRING "Include the 'DB2' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") @@ -11,45 +9,6 @@ set(SOCI_POSTGRESQL "AsAvailable" CACHE STRING "Include the 'Postgresql' backend set(SOCI_SQLITE3 "AsAvailable" CACHE STRING "Include the 'SQLite3' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") -function(soci_backend_objects_to_lib) - set(FLAGS "") - set(ONE_VAL_OPTIONS "OBJECT_LIB" "SHARED_TARGET_NAME" "STATIC_TARGET_NAME" "ALIAS_NAME") - set(MULTI_VAL_OPTIONS "SHARED_DEPS" "STATIC_DEPS") - cmake_parse_arguments(SOCI_BACKEND_LIB "${FLAGS}" "${ONE_VAL_OPTIONS}" "${MULTI_VAL_OPTIONS}" ${ARGV}) - soci_verify_parsed_arguments( - PREFIX "SOCI_BACKEND_LIB" - FUNCTION_NAME "soci_backend_objects_to_lib" - REQUIRED "OBJECT_LIB" "SHARED_TARGET_NAME" "STATIC_TARGET_NAME" "ALIAS_NAME" - ) - - if (SOCI_SHARED) - add_library(${SOCI_BACKEND_LIB_SHARED_TARGET_NAME} SHARED "${SOCI_CXX_DUMMY_SOURCE}") - target_link_libraries(${SOCI_BACKEND_LIB_SHARED_TARGET_NAME} - PUBLIC - ${SOCI_BACKEND_LIB_OBJECT_LIB} - ${SOCI_BACKEND_LIB_SHARED_DEPS} - ) - - add_library(SOCI::shared::${SOCI_BACKEND_LIB_ALIAS_NAME} ALIAS ${SOCI_BACKEND_LIB_SHARED_TARGET_NAME}) - - target_link_libraries(soci_shared_interface INTERFACE SOCI::shared::${SOCI_BACKEND_LIB_ALIAS_NAME}) - endif() - - if (SOCI_STATIC) - add_library(${SOCI_BACKEND_LIB_STATIC_TARGET_NAME} STATIC "${SOCI_CXX_DUMMY_SOURCE}") - target_link_libraries(${SOCI_BACKEND_LIB_STATIC_TARGET_NAME} - PUBLIC - ${SOCI_BACKEND_LIB_OBJECT_LIB} - ${SOCI_BACKEND_LIB_STATIC_DEPS} - ) - - add_library(SOCI::static::${SOCI_BACKEND_LIB_ALIAS_NAME} ALIAS ${SOCI_BACKEND_LIB_STATIC_TARGET_NAME}) - - target_link_libraries(soci_static_interface INTERFACE SOCI::static::${SOCI_BACKEND_LIB_ALIAS_NAME}) - endif() -endfunction() - - foreach(CURRENT IN ITEMS "db2" "empty" "firebird" "mysql" "odbc" "oracle" "postgresql" "sqlite3") string(TOUPPER "${CURRENT}" CURRENT_UPPER) diff --git a/src/backends/db2/CMakeLists.txt b/src/backends/db2/CMakeLists.txt index fe3ac0503..1cc4ad75c 100644 --- a/src/backends/db2/CMakeLists.txt +++ b/src/backends/db2/CMakeLists.txt @@ -12,34 +12,31 @@ if (NOT DB2_FOUND) return() endif() -add_library(soci_db2_interface INTERFACE) -target_link_libraries(soci_db2_interface INTERFACE DB2::DB2 soci_core_interface) - -add_library(soci_db2_objects OBJECT - "blob.cpp" - "factory.cpp" - "row-id.cpp" - "session.cpp" - "standard-into-type.cpp" - "standard-use-type.cpp" - "statement.cpp" - "vector-into-type.cpp" - "vector-use-type.cpp" +add_library(soci_db2 + ${SOCI_LIB_TYPE} + "blob.cpp" + "factory.cpp" + "row-id.cpp" + "session.cpp" + "standard-into-type.cpp" + "standard-use-type.cpp" + "statement.cpp" + "vector-into-type.cpp" + "vector-use-type.cpp" ) -target_link_libraries(soci_db2_objects PUBLIC soci_db2_interface) +target_link_libraries(soci_db2 + PUBLIC + DB2::DB2 + SOCI::Core +) -target_include_directories(soci_db2_objects +target_include_directories(soci_db2 PRIVATE "${PROJECT_SOURCE_DIR}/include/private" "${PROJECT_SOURCE_DIR}/include/soci" ) -soci_backend_objects_to_lib( - OBJECT_LIB soci_db2_objects - SHARED_TARGET_NAME soci_db2 - STATIC_TARGET_NAME soci_db2_static - ALIAS_NAME DB2 - SHARED_DEPS SOCI::shared::Core - STATIC_DEPS SOCI::static::Core -) +add_library(SOCI::DB2 ALIAS soci_db2) + +target_link_libraries(soci_interface INTERFACE SOCI::DB2) diff --git a/src/backends/empty/CMakeLists.txt b/src/backends/empty/CMakeLists.txt index daf0a5f21..b4780ad68 100644 --- a/src/backends/empty/CMakeLists.txt +++ b/src/backends/empty/CMakeLists.txt @@ -1,31 +1,25 @@ -add_library(soci_empty_interface INTERFACE) -target_link_libraries(soci_empty_interface INTERFACE soci_core_interface) -add_library(soci_empty_objects OBJECT - "blob.cpp" - "factory.cpp" - "row-id.cpp" - "session.cpp" - "standard-into-type.cpp" - "standard-use-type.cpp" - "statement.cpp" - "vector-into-type.cpp" - "vector-use-type.cpp" +add_library(soci_empty + ${SOCI_LIB_TYPE} + "blob.cpp" + "factory.cpp" + "row-id.cpp" + "session.cpp" + "standard-into-type.cpp" + "standard-use-type.cpp" + "statement.cpp" + "vector-into-type.cpp" + "vector-use-type.cpp" ) -target_link_libraries(soci_empty_objects PUBLIC soci_empty_interface) +target_link_libraries(soci_empty PUBLIC SOCI::Core) -target_include_directories(soci_empty_objects +target_include_directories(soci_empty PRIVATE "${PROJECT_SOURCE_DIR}/include/private" "${PROJECT_SOURCE_DIR}/include/soci" ) -soci_backend_objects_to_lib( - OBJECT_LIB soci_empty_objects - SHARED_TARGET_NAME soci_empty - STATIC_TARGET_NAME soci_empty_static - ALIAS_NAME Empty - SHARED_DEPS SOCI::shared::Core - STATIC_DEPS SOCI::static::Core -) +add_library(SOCI::Empty ALIAS soci_empty) + +target_link_libraries(soci_interface INTERFACE SOCI::Empty) diff --git a/src/backends/firebird/CMakeLists.txt b/src/backends/firebird/CMakeLists.txt index a7a93d04b..d70ab73af 100644 --- a/src/backends/firebird/CMakeLists.txt +++ b/src/backends/firebird/CMakeLists.txt @@ -18,35 +18,32 @@ if (NOT Firebird_FOUND) return() endif() -add_library(soci_firebird_interface INTERFACE) -target_link_libraries(soci_firebird_interface INTERFACE Firebird::Firebird soci_core_interface) - -add_library(soci_firebird_objects OBJECT - "blob.cpp" - "common.cpp" - "error-firebird.cpp" - "factory.cpp" - "session.cpp" - "standard-into-type.cpp" - "standard-use-type.cpp" - "statement.cpp" - "vector-into-type.cpp" - "vector-use-type.cpp" +add_library(soci_firebird + ${SOCI_LIB_TYPE} + "blob.cpp" + "common.cpp" + "error-firebird.cpp" + "factory.cpp" + "session.cpp" + "standard-into-type.cpp" + "standard-use-type.cpp" + "statement.cpp" + "vector-into-type.cpp" + "vector-use-type.cpp" ) -target_link_libraries(soci_firebird_objects PUBLIC Firebird::Firebird soci_firebird_interface) +target_link_libraries(soci_firebird + PUBLIC + Firebird::Firebird + SOCI::Core +) -target_include_directories(soci_firebird_objects +target_include_directories(soci_firebird PRIVATE "${PROJECT_SOURCE_DIR}/include/private" "${PROJECT_SOURCE_DIR}/include/soci" ) -soci_backend_objects_to_lib( - OBJECT_LIB soci_firebird_objects - SHARED_TARGET_NAME soci_firebird - STATIC_TARGET_NAME soci_firebird_static - ALIAS_NAME Firebird - SHARED_DEPS SOCI::shared::Core - STATIC_DEPS SOCI::static::Core -) +add_library(SOCI::Firebird ALIAS soci_firebird) + +target_link_libraries(soci_interface INTERFACE SOCI::Firebird) diff --git a/src/backends/mysql/CMakeLists.txt b/src/backends/mysql/CMakeLists.txt index 1aefac598..d1732c81d 100644 --- a/src/backends/mysql/CMakeLists.txt +++ b/src/backends/mysql/CMakeLists.txt @@ -12,35 +12,32 @@ if (NOT MySQL_FOUND) return() endif() -add_library(soci_mysql_interface INTERFACE) -target_link_libraries(soci_mysql_interface INTERFACE MySQL::MySQL soci_core_interface) - -add_library(soci_mysql_objects OBJECT - "blob.cpp" - "common.cpp" - "factory.cpp" - "row-id.cpp" - "session.cpp" - "standard-into-type.cpp" - "standard-use-type.cpp" - "statement.cpp" - "vector-into-type.cpp" - "vector-use-type.cpp" +add_library(soci_mysql + ${SOCI_LIB_TYPE} + "blob.cpp" + "common.cpp" + "factory.cpp" + "row-id.cpp" + "session.cpp" + "standard-into-type.cpp" + "standard-use-type.cpp" + "statement.cpp" + "vector-into-type.cpp" + "vector-use-type.cpp" ) -target_link_libraries(soci_mysql_objects PUBLIC soci_mysql_interface) +target_link_libraries(soci_mysql + PUBLIC + MySQL::MySQL + SOCI::Core +) -target_include_directories(soci_mysql_objects +target_include_directories(soci_mysql PRIVATE "${PROJECT_SOURCE_DIR}/include/private" "${PROJECT_SOURCE_DIR}/include/soci" ) -soci_backend_objects_to_lib( - OBJECT_LIB soci_mysql_objects - SHARED_TARGET_NAME soci_mysql - STATIC_TARGET_NAME soci_mysql_static - ALIAS_NAME MySQL - SHARED_DEPS SOCI::shared::Core - STATIC_DEPS SOCI::static::Core -) +add_library(SOCI::MySQL ALIAS soci_mysql) + +target_link_libraries(soci_interface INTERFACE SOCI::MySQL) diff --git a/src/backends/odbc/CMakeLists.txt b/src/backends/odbc/CMakeLists.txt index 7310f0347..be3d7d88f 100644 --- a/src/backends/odbc/CMakeLists.txt +++ b/src/backends/odbc/CMakeLists.txt @@ -12,34 +12,31 @@ if (NOT ODBC_FOUND) return() endif() -add_library(soci_odbc_interface INTERFACE) -target_link_libraries(soci_odbc_interface INTERFACE ODBC::ODBC soci_core_interface) - -add_library(soci_odbc_objects OBJECT - "blob.cpp" - "factory.cpp" - "row-id.cpp" - "session.cpp" - "standard-into-type.cpp" - "standard-use-type.cpp" - "statement.cpp" - "vector-into-type.cpp" - "vector-use-type.cpp" +add_library(soci_odbc + ${SOCI_LIB_TYPE} + "blob.cpp" + "factory.cpp" + "row-id.cpp" + "session.cpp" + "standard-into-type.cpp" + "standard-use-type.cpp" + "statement.cpp" + "vector-into-type.cpp" + "vector-use-type.cpp" ) -target_link_libraries(soci_odbc_objects PUBLIC soci_odbc_interface) +target_link_libraries(soci_odbc + PUBLIC + ODBC::ODBC + SOCI::Core +) -target_include_directories(soci_odbc_objects +target_include_directories(soci_odbc PRIVATE "${PROJECT_SOURCE_DIR}/include/private" "${PROJECT_SOURCE_DIR}/include/soci" ) -soci_backend_objects_to_lib( - OBJECT_LIB soci_odbc_objects - SHARED_TARGET_NAME soci_odbc - STATIC_TARGET_NAME soci_odbc_static - ALIAS_NAME ODBC - SHARED_DEPS SOCI::shared::Core - STATIC_DEPS SOCI::static::Core -) +add_library(SOCI::ODBC ALIAS soci_odbc) + +target_link_libraries(soci_interface INTERFACE SOCI::ODBC) diff --git a/src/backends/oracle/CMakeLists.txt b/src/backends/oracle/CMakeLists.txt index 7dbd0c31e..f444eab10 100644 --- a/src/backends/oracle/CMakeLists.txt +++ b/src/backends/oracle/CMakeLists.txt @@ -12,35 +12,31 @@ if (NOT Oracle_FOUND) return() endif() -add_library(soci_oracle_interface INTERFACE) -target_link_libraries(soci_oracle_interface INTERFACE Oracle::Oracle soci_core_interface) - -add_library(soci_oracle_objects OBJECT - "blob.cpp" - "error.cpp" - "factory.cpp" - "row-id.cpp" - "session.cpp" - "standard-into-type.cpp" - "standard-use-type.cpp" - "statement.cpp" - "vector-into-type.cpp" - "vector-use-type.cpp" +add_library(soci_oracle + ${SOCI_LIB_TYPE} + "blob.cpp" + "error.cpp" + "factory.cpp" + "row-id.cpp" + "session.cpp" + "standard-into-type.cpp" + "standard-use-type.cpp" + "statement.cpp" + "vector-into-type.cpp" + "vector-use-type.cpp" +) +target_link_libraries(soci_oracle + PUBLIC + Oracle::Oracle + SOCI::Core ) -target_link_libraries(soci_oracle_objects PUBLIC soci_oracle_interface) - -target_include_directories(soci_oracle_objects +target_include_directories(soci_oracle PRIVATE "${PROJECT_SOURCE_DIR}/include/private" "${PROJECT_SOURCE_DIR}/include/soci" ) -soci_backend_objects_to_lib( - OBJECT_LIB soci_oracle_objects - SHARED_TARGET_NAME soci_oracle - STATIC_TARGET_NAME soci_oracle_static - ALIAS_NAME Oracle - SHARED_DEPS SOCI::shared::Core - STATIC_DEPS SOCI::static::Core -) +add_library(SOCI::Oracle ALIAS soci_oracle) + +target_link_libraries(soci_interface INTERFACE SOCI::Oracle) diff --git a/src/backends/postgresql/CMakeLists.txt b/src/backends/postgresql/CMakeLists.txt index 4b5e59582..1ca9656e4 100644 --- a/src/backends/postgresql/CMakeLists.txt +++ b/src/backends/postgresql/CMakeLists.txt @@ -12,35 +12,32 @@ if (NOT PostgreSQL_FOUND) return() endif() -add_library(soci_postgresql_interface INTERFACE) -target_link_libraries(soci_postgresql_interface INTERFACE PostgreSQL::PostgreSQL soci_core_interface) - -add_library(soci_postgresql_objects OBJECT - "blob.cpp" - "error.cpp" - "factory.cpp" - "row-id.cpp" - "session.cpp" - "standard-into-type.cpp" - "standard-use-type.cpp" - "statement.cpp" - "vector-into-type.cpp" - "vector-use-type.cpp" +add_library(soci_postgresql + ${SOCI_LIB_TYPE} + "blob.cpp" + "error.cpp" + "factory.cpp" + "row-id.cpp" + "session.cpp" + "standard-into-type.cpp" + "standard-use-type.cpp" + "statement.cpp" + "vector-into-type.cpp" + "vector-use-type.cpp" ) -target_link_libraries(soci_postgresql_objects PUBLIC soci_postgresql_interface) +target_link_libraries(soci_postgresql + PUBLIC + PostgreSQL::PostgreSQL + SOCI::Core +) -target_include_directories(soci_postgresql_objects +target_include_directories(soci_postgresql PRIVATE "${PROJECT_SOURCE_DIR}/include/private" "${PROJECT_SOURCE_DIR}/include/soci" ) -soci_backend_objects_to_lib( - OBJECT_LIB soci_postgresql_objects - SHARED_TARGET_NAME soci_postgresql - STATIC_TARGET_NAME soci_postgresql_static - ALIAS_NAME PostgreSQL - SHARED_DEPS SOCI::shared::Core - STATIC_DEPS SOCI::static::Core -) +add_library(SOCI::PostgreSQL ALIAS soci_postgresql) + +target_link_libraries(soci_interface INTERFACE SOCI::PostgreSQL) diff --git a/src/backends/sqlite3/CMakeLists.txt b/src/backends/sqlite3/CMakeLists.txt index 31852f92d..e7d6ca1f0 100644 --- a/src/backends/sqlite3/CMakeLists.txt +++ b/src/backends/sqlite3/CMakeLists.txt @@ -12,35 +12,31 @@ if (NOT SQLite3_FOUND) return() endif() -add_library(soci_sqlite3_interface INTERFACE) -target_link_libraries(soci_sqlite3_interface INTERFACE SQLite::SQLite3 soci_core_interface) - -add_library(soci_sqlite3_objects OBJECT - "blob.cpp" - "error.cpp" - "factory.cpp" - "row-id.cpp" - "session.cpp" - "standard-into-type.cpp" - "standard-use-type.cpp" - "statement.cpp" - "vector-into-type.cpp" - "vector-use-type.cpp" +add_library(soci_sqlite3 + ${SOCI_LIB_TYPE} + "blob.cpp" + "error.cpp" + "factory.cpp" + "row-id.cpp" + "session.cpp" + "standard-into-type.cpp" + "standard-use-type.cpp" + "statement.cpp" + "vector-into-type.cpp" + "vector-use-type.cpp" ) -target_link_libraries(soci_sqlite3_objects PUBLIC soci_sqlite3_interface) +target_link_libraries(soci_sqlite3 + PUBLIC + SQLite::SQLite3 SOCI::Core +) -target_include_directories(soci_sqlite3_objects +target_include_directories(soci_sqlite3 PRIVATE "${PROJECT_SOURCE_DIR}/include/private" "${PROJECT_SOURCE_DIR}/include/soci" ) -soci_backend_objects_to_lib( - OBJECT_LIB soci_sqlite3_objects - SHARED_TARGET_NAME soci_sqlite3 - STATIC_TARGET_NAME soci_sqlite3_static - ALIAS_NAME SQLite3 - SHARED_DEPS SOCI::shared::Core - STATIC_DEPS SOCI::static::Core -) +add_library(SOCI::SQLite3 ALIAS soci_sqlite3) + +target_link_libraries(soci_interface INTERFACE SOCI::SQLite3) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d1aa7ff22..add3834a5 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -14,74 +14,73 @@ check_cxx_source_compiles( # TODO: Actually populate this config file with something useful configure_file("${CMAKE_CURRENT_SOURCE_DIR}/soci-config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/include/soci/soci-config.h") -add_library(soci_core_interface INTERFACE) -target_include_directories(soci_core_interface - INTERFACE +add_library(soci_core + ${SOCI_LIB_TYPE} + "backend-loader.cpp" + "blob.cpp" + "common.cpp" + "connection-parameters.cpp" + "connection-pool.cpp" + "error.cpp" + "into-type.cpp" + "logger.cpp" + "once-temp-type.cpp" + "prepare-temp-type.cpp" + "procedure.cpp" + "ref-counted-prepare-info.cpp" + "ref-counted-statement.cpp" + "row.cpp" + "rowid.cpp" + "session.cpp" + "soci-simple.cpp" + "statement.cpp" + "transaction.cpp" + "use-type.cpp" + "values.cpp" +) +add_library(SOCI::Core ALIAS soci_core) + +target_include_directories(soci_core + PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include" "${PROJECT_SOURCE_DIR}/include" + PRIVATE + "${PROJECT_SOURCE_DIR}/include/soci" + "${PROJECT_SOURCE_DIR}/include/private" ) -target_compile_definitions(soci_core_interface - INTERFACE - # Define the macro SOCI_DLL on Windows - $,SOCI_DLL,> -) -if (SOCI_VISIBILITY AND SOCI_VISIBILITY_ATTRIBUTE_SUPPORTED) - target_compile_definitions(soci_core_interface - INTERFACE +if (SOCI_SHARED) + target_compile_definitions(soci_core + PUBLIC + # Define the macro SOCI_DLL on Windows + $,SOCI_DLL,> + ) +endif() + +if (SOCI_SHARED AND SOCI_VISIBILITY AND SOCI_VISIBILITY_ATTRIBUTE_SUPPORTED) + target_compile_definitions(soci_core + PUBLIC SOCI_HAVE_VISIBILITY_SUPPORT ) endif() if (SOCI_BOOST) find_package(Boost REQUIRED) - target_link_libraries(soci_core_interface INTERFACE Boost::boost) - target_compile_definitions(soci_core_interface INTERFACE SOCI_HAVE_BOOST) + target_link_libraries(soci_core PUBLIC Boost::boost) + target_compile_definitions(soci_core PUBLIC SOCI_HAVE_BOOST) if (TARGET Boost::date_time) - target_link_libraries(soci_core_interface INTERFACE Boost::date_time) - target_compile_definitions(soci_core_interface INTERFACE SOCI_HAVE_BOOST_DATE_TIME) + target_link_libraries(soci_core PUBLIC Boost::date_time) + target_compile_definitions(soci_core PUBLIC SOCI_HAVE_BOOST_DATE_TIME) endif() endif() -add_library(soci_core_objects OBJECT - "backend-loader.cpp" - "blob.cpp" - "common.cpp" - "connection-parameters.cpp" - "connection-pool.cpp" - "error.cpp" - "into-type.cpp" - "logger.cpp" - "once-temp-type.cpp" - "prepare-temp-type.cpp" - "procedure.cpp" - "ref-counted-prepare-info.cpp" - "ref-counted-statement.cpp" - "row.cpp" - "rowid.cpp" - "session.cpp" - "soci-simple.cpp" - "statement.cpp" - "transaction.cpp" - "use-type.cpp" - "values.cpp" -) - -target_link_libraries(soci_core_objects - PUBLIC - soci_core_interface +target_link_libraries(soci_core PRIVATE Threads::Threads ) -target_include_directories(soci_core_objects - PRIVATE - "${PROJECT_SOURCE_DIR}/include/soci" - "${PROJECT_SOURCE_DIR}/include/private" -) - -target_compile_definitions(soci_core_objects +target_compile_definitions(soci_core PRIVATE DEFAULT_BACKENDS_PATH="${CMAKE_INSTALL_FULL_LIBDIR}" # TODO: Configure prefix and suffix properly @@ -89,15 +88,3 @@ target_compile_definitions(soci_core_objects SOCI_LIB_SUFFIX="" ) -if (SOCI_SHARED) - add_library(soci_core SHARED) - target_link_libraries(soci_core PUBLIC soci_core_objects) - add_library(SOCI::shared::Core ALIAS soci_core) - target_link_libraries(soci_shared_interface INTERFACE SOCI::shared::core) -endif() -if (SOCI_STATIC) - add_library(soci_core_static STATIC) - target_link_libraries(soci_core_static PUBLIC soci_core_objects) - add_library(SOCI::static::Core ALIAS soci_core_static) - target_link_libraries(soci_static_interface INTERFACE SOCI::static::core) -endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b7fe2e797..fcc4e6081 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,55 +1,11 @@ -include(soci_utils) - add_library(soci_common_tests STATIC common-tests.cpp) target_include_directories(soci_common_tests PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" ) -target_link_libraries(soci_common_tests PUBLIC soci_core_interface) +target_link_libraries(soci_common_tests PUBLIC SOCI::Core) target_include_directories(soci_common_tests PUBLIC "${PROJECT_SOURCE_DIR}/include/private/") - -function(soci_make_tests) - set(FLAGS "") - set(ONE_VAL_OPTIONS "CONNECTION_STRING" "OBJECT_LIB" "SOCI_DEP_ALIAS" "SHARED_NAME" "STATIC_NAME") - set(MULTI_VAL_OPTIONS "") - cmake_parse_arguments(SOCI_MAKE_TESTS "${FLAGS}" "${ONE_VAL_OPTIONS}" "${MULTI_VAL_OPTIONS}" ${ARGV}) - soci_verify_parsed_arguments( - PREFIX "SOCI_MAKE_TESTS" - FUNCTION_NAME "soci_make_tests" - REQUIRED "CONNECTION_STRING" "OBJECT_LIB" "SHARED_NAME" "STATIC_NAME" - ) - - set(CREATED_TESTS "") - - if (SOCI_SHARED) - add_executable(${SOCI_MAKE_TESTS_SHARED_NAME} "${SOCI_CXX_DUMMY_SOURCE}") - target_link_libraries(${SOCI_MAKE_TESTS_SHARED_NAME} PRIVATE ${SOCI_MAKE_TESTS_OBJECT_LIB}) - if (SOCI_MAKE_TESTS_SOCI_DEP_ALIAS) - target_link_libraries(${SOCI_MAKE_TESTS_SHARED_NAME} PRIVATE SOCI::shared::${SOCI_MAKE_TESTS_SOCI_DEP_ALIAS}) - endif() - - list(APPEND CREATED_TESTS "${SOCI_MAKE_TESTS_SHARED_NAME}") - endif() - - if (SOCI_STATIC) - add_executable(${SOCI_MAKE_TESTS_STATIC_NAME} "${SOCI_CXX_DUMMY_SOURCE}") - target_link_libraries(${SOCI_MAKE_TESTS_STATIC_NAME} PRIVATE ${SOCI_MAKE_TESTS_OBJECT_LIB}) - if (SOCI_MAKE_TESTS_SOCI_DEP_ALIAS) - target_link_libraries(${SOCI_MAKE_TESTS_STATIC_NAME} PRIVATE SOCI::static::${SOCI_MAKE_TESTS_SOCI_DEP_ALIAS}) - endif() - - list(APPEND CREATED_TESTS "${SOCI_MAKE_TESTS_STATIC_NAME}") - endif() - - foreach (CURRENT IN LISTS CREATED_TESTS) - add_test( - NAME "${CURRENT}" - COMMAND "${CURRENT}" "${SOCI_MAKE_TESTS_CONNECTION_STRING}" "--invisibles" - ) - endforeach() -endfunction() - foreach (CURRENT_BACKEND IN ITEMS "db2" "empty" "firebird" "mysql" "odbc" "oracle" "postgresql" "sqlite3") string(TOUPPER "${CURRENT_BACKEND}" CURRENT_BACKEND_UPPER) diff --git a/tests/db2/CMakeLists.txt b/tests/db2/CMakeLists.txt index a6e1e9af1..63839ceba 100644 --- a/tests/db2/CMakeLists.txt +++ b/tests/db2/CMakeLists.txt @@ -1,12 +1,9 @@ -add_library(db2_tests OBJECT db2_tests.cpp) -target_link_libraries(db2_tests PUBLIC soci_common_tests soci_db2_interface) +add_executable(soci_db2_tests OBJECT db2_tests.cpp) +target_link_libraries(soci_db2_tests PRIVATE soci_common_tests soci_db2_interface) set(SOCI_DB2_TEST_CONNSTR "DSN=SAMPLE;Uid=db2inst1;Pwd=db2inst1;autocommit=off" CACHE STRING "The connection string to use for DB2 tests") -soci_make_tests( - OBJECT_LIB db2_tests - CONNECTION_STRING "${SOCI_DB2_TEST_CONNSTR}" - SHARED_NAME "soci_db2_test" - STATIC_NAME "soci_db2_test_static" - SOCI_DEP_ALIAS "DB2" +add_test( + NAME soci_db2_tests + COMMAND soci_db2_tests "${SOCI_DB2_TEST_CONNSTR}" "--invisibles" ) diff --git a/tests/empty/CMakeLists.txt b/tests/empty/CMakeLists.txt index 30d391ed6..2ce04d63d 100644 --- a/tests/empty/CMakeLists.txt +++ b/tests/empty/CMakeLists.txt @@ -1,11 +1,8 @@ -add_library(empty_tests OBJECT empty_tests.cpp) -target_link_libraries(empty_tests PUBLIC soci_empty_interface) -target_include_directories(empty_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../") +add_executable(soci_empty_tests empty_tests.cpp) +target_link_libraries(soci_empty_tests PRIVATE SOCI::Empty) +target_include_directories(soci_empty_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../") -soci_make_tests( - OBJECT_LIB empty_tests - CONNECTION_STRING "dummy" - SHARED_NAME "soci_empty_test" - STATIC_NAME "soci_empty_test_static" - SOCI_DEP_ALIAS "Empty" +add_test( + NAME soci_empty_tests + COMMAND soci_empty_tests "--invisibles" ) diff --git a/tests/firebird/CMakeLists.txt b/tests/firebird/CMakeLists.txt index eba55c027..275c3cf17 100644 --- a/tests/firebird/CMakeLists.txt +++ b/tests/firebird/CMakeLists.txt @@ -1,12 +1,9 @@ -add_library(firebird_tests OBJECT firebird_tests.cpp) -target_link_libraries(firebird_tests PUBLIC soci_common_tests soci_firebird_interface) +add_executable(soci_firebird_tests firebird_tests.cpp) +target_link_libraries(soci_firebird_tests PRIVATE soci_common_tests SOCI::Firebird) set(SOCI_FIREBIRD_TEST_CONNSTR "service=/tmp/soci_test.fdb user=SYSDBA password=masterkey" CACHE STRING "The connection string to use for Firebird tests") -soci_make_tests( - OBJECT_LIB firebird_tests - CONNECTION_STRING "${SOCI_FIREBIRD_TEST_CONNSTR}" - SHARED_NAME "soci_firebird_test" - STATIC_NAME "soci_firebird_test_static" - SOCI_DEP_ALIAS "Firebird" +add_test( + NAME soci_firebird_tests + COMMAND soci_firebird_tests "${SOCI_FIREBIRD_TEST_CONNSTR}" "--invisibles" ) diff --git a/tests/mysql/CMakeLists.txt b/tests/mysql/CMakeLists.txt index 0022c6886..4081ba080 100644 --- a/tests/mysql/CMakeLists.txt +++ b/tests/mysql/CMakeLists.txt @@ -1,12 +1,9 @@ -add_library(mysql_tests OBJECT mysql_tests.cpp) -target_link_libraries(mysql_tests PUBLIC soci_common_tests soci_mysql_interface) +add_executable(soci_mysql_tests mysql_tests.cpp) +target_link_libraries(soci_mysql_tests PRIVATE soci_common_tests SOCI::MySQL) set(SOCI_MYSQL_TEST_CONNSTR "db=soci_test" CACHE STRING "The connection string to use for MySQL tests") -soci_make_tests( - OBJECT_LIB mysql_tests - CONNECTION_STRING "${SOCI_MYSQL_TEST_CONNSTR}" - SHARED_NAME "soci_mysql_test" - STATIC_NAME "soci_mysql_test_static" - SOCI_DEP_ALIAS "MySQL" +add_test( + NAME soci_mysql_tests + COMMAND soci_mysql_tests "${SOCI_MYSQL_TEST_CONNSTR}" "--invisibles" ) diff --git a/tests/odbc/CMakeLists.txt b/tests/odbc/CMakeLists.txt index 282082b2f..30a2ac6b4 100644 --- a/tests/odbc/CMakeLists.txt +++ b/tests/odbc/CMakeLists.txt @@ -7,47 +7,38 @@ configure_file("test-mssql.dsn.in" "${CMAKE_CURRENT_BINARY_DIR}/test-mssql.dsn" if (WIN32) - add_library(odbc_ms_access_tests OBJECT odbc_ms_access_tests.cpp) - target_link_libraries(odbc_ms_access_tests PUBLIC soci_common_tests soci_odbc_interface) + add_executable(soci_odbc_ms_access_tests odbc_ms_access_tests.cpp) + target_link_libraries(soci_odbc_ms_access_tests PRIVATE soci_common_tests SOCI::ODBC) set(SOCI_ODBC_TEST_ACCESS_CONNSTR "FILEDSN=${CMAKE_CURRENT_BINARY_DIR}/test-access.dsn" CACHE STRING "Connection string for the ODBC MS Access test") - soci_make_tests( - OBJECT_LIB odbc_ms_access_tests - CONNECTION_STRING "${SOCI_ODBC_TEST_ACCESS_CONNSTR}" - SHARED_NAME "soci_odbc_ms_access_test" - STATIC_NAME "soci_odbc_ms_access_test_static" - SOCI_DEP_ALIAS "ODBC" + add_test( + NAME soci_odbc_ms_access_tests + COMMAND soci_odbc_ms_access_tests "${SOCI_ODBC_TEST_ACCESS_CONNSTR}" "--invisibles" ) endif() -add_library(odbc_mssql_tests OBJECT odbc_mssql_tests.cpp) -target_link_libraries(odbc_mssql_tests PUBLIC soci_common_tests soci_odbc_interface) +add_executable(soci_odbc_mssql_tests odbc_mssql_tests.cpp) +target_link_libraries(soci_odbc_mssql_tests PRIVATE soci_common_tests SOCI::ODBC) set(SOCI_ODBC_TEST_MSSQL_CONNSTR "FILEDSN=${CMAKE_CURRENT_BINARY_DIR}/test-access.dsn" CACHE STRING "Connection string for the ODBC MSSQL test") -soci_make_tests( - OBJECT_LIB odbc_mssql_tests - CONNECTION_STRING "${SOCI_ODBC_TEST_MSSQL_CONNSTR}" - SHARED_NAME "soci_odbc_mssql_test" - STATIC_NAME "soci_odbc_mssql_test_static" - SOCI_DEP_ALIAS "ODBC" +add_test( + NAME soci_odbc_mssql_tests + COMMAND soci_odbc_mssql_tests "${SOCI_ODBC_TEST_MSSQL_CONNSTR}" "--invisibles" ) -add_library(odbc_mysql_tests OBJECT odbc_mysql_tests.cpp) -target_link_libraries(odbc_mysql_tests PUBLIC soci_common_tests soci_odbc_interface) -target_include_directories(odbc_mysql_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../") +add_executable(soci_odbc_mysql_tests odbc_mysql_tests.cpp) +target_link_libraries(soci_odbc_mysql_tests PRIVATE soci_common_tests SOCI::ODBC) +target_include_directories(soci_odbc_mysql_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../") set(SOCI_ODBC_TEST_MYSQL_CONNSTR "FILEDSN=${CMAKE_CURRENT_SOURCE_DIR}/test-mysql.dsn" CACHE STRING "Connection string for the ODBC MySQL test") -soci_make_tests( - OBJECT_LIB odbc_mysql_tests - CONNECTION_STRING "${SOCI_ODBC_TEST_MYSQL_CONNSTR}" - SHARED_NAME "soci_odbc_mysql_test" - STATIC_NAME "soci_odbc_mysql_test_static" - SOCI_DEP_ALIAS "ODBC" +add_test( + NAME soci_odbc_mysql_tests + COMMAND soci_odbc_mysql_tests "${SOCI_ODBC_TEST_MYSQL_CONNSTR}" "--invisibles" ) @@ -57,34 +48,29 @@ else() set(TEST_PGSQL_DSN "test-postgresql.dsn") endif() -add_library(odbc_postgresql_tests OBJECT odbc_postgresql_tests.cpp) -target_link_libraries(odbc_postgresql_tests PUBLIC soci_common_tests soci_odbc_interface) +add_executable(soci_odbc_postgresql_tests odbc_postgresql_tests.cpp) +target_link_libraries(soci_odbc_postgresql_tests PRIVATE soci_common_tests SOCI::ODBC) set(SOCI_ODBC_TEST_POSTGRESQL_CONNSTR "FILEDSN=${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PGSQL_DSN}" CACHE STRING "Connection string for the ODBC PostgreSQL test") -soci_make_tests( - OBJECT_LIB odbc_postgresql_tests - CONNECTION_STRING "${SOCI_ODBC_TEST_POSTGRESQL_CONNSTR}" - SHARED_NAME "soci_odbc_postgresql_test" - STATIC_NAME "soci_odbc_postgresql_test_static" - SOCI_DEP_ALIAS "ODBC" +add_test( + NAME soci_odbc_postgresql_tests + COMMAND soci_odbc_postgresql_tests "${SOCI_ODBC_TEST_POSTGRESQL_CONNSTR}" "--invisibles" ) + # TODO: DB2 backend is tested by Travis CI on dedicated VM, separate from ODBC, # in order to test DB2 with ODBC, it would be best to install DB2 driver only. # if (NOT $ENV{TRAVIS}) option(WITH_ODBC_TEST_DB2 "Build ODBC DB2 test" OFF) if (WITH_ODBC_TEST_DB2) - add_library(odbc_db2_tests OBJECT odbc_db2_tests.cpp) - target_link_libraries(odbc_db2_tests PUBLIC soci_common_tests soci_odbc_interface) + add_executable(soci_odbc_db2_tests odbc_db2_tests.cpp) + target_link_libraries(osoci_dbc_db2_tests PRIVATE soci_common_tests SOCI::ODBC) set(SOCI_ODBC_TEST_DB2_CONNSTR "FILEDSN=${CMAKE_CURRENT_SOURCE_DIR}/test-db2.dsn" CACHE STRING "Connection string for the ODBC DB2 test") - soci_make_tests( - OBJECT_LIB odbc_db2_tests - CONNECTION_STRING "${SOCI_ODBC_TEST_DB2_CONNSTR}" - SHARED_NAME "soci_odbc_db2_test" - STATIC_NAME "soci_odbc_db2_test_static" - SOCI_DEP_ALIAS "ODBC" + add_test( + NAME soci_odbc_db2_tests + COMMAND soci_odbc_db2_tests "${SOCI_ODBC_TEST_DB2_CONNSTR}" "--invisibles" ) endif() diff --git a/tests/oracle/CMakeLists.txt b/tests/oracle/CMakeLists.txt index 49f6ec0da..22173e688 100644 --- a/tests/oracle/CMakeLists.txt +++ b/tests/oracle/CMakeLists.txt @@ -1,12 +1,9 @@ -add_library(oracle_tests OBJECT oracle_tests.cpp) -target_link_libraries(oracle_tests PUBLIC soci_common_tests soci_oracle_interface) +add_executable(soci_oracle_tests oracle_tests.cpp) +target_link_libraries(soci_oracle_tests PRIVATE soci_common_tests SOCI::Oracle) set(SOCI_ORACLE_TEST_CONNSTR "service=orcl user=scott password=tiger" CACHE STRING "The connection string to use for Oracle tests") -soci_make_tests( - OBJECT_LIB oracle_tests - CONNECTION_STRING "${SOCI_ORACLE_TEST_CONNSTR}" - SHARED_NAME "soci_oracle_test" - STATIC_NAME "soci_oracle_test_static" - SOCI_DEP_ALIAS "Oracle" +add_test( + NAME soci_oracle_tests + COMMAND soci_oracle_tests "${SOCI_ORACLE_TEST_CONNSTR}" "--invisibles" ) diff --git a/tests/postgresql/CMakeLists.txt b/tests/postgresql/CMakeLists.txt index 89cd142b6..f270731aa 100644 --- a/tests/postgresql/CMakeLists.txt +++ b/tests/postgresql/CMakeLists.txt @@ -1,12 +1,9 @@ -add_library(postgresql_tests OBJECT postgresql_tests.cpp) -target_link_libraries(postgresql_tests PUBLIC soci_common_tests soci_postgresql_interface) +add_executable(soci_postgresql_tests postgresql_tests.cpp) +target_link_libraries(soci_postgresql_tests PRIVATE soci_common_tests SOCI::PostgreSQL) set(SOCI_POSTGRESQL_TEST_CONNSTR "dbname=soci_test" CACHE STRING "The connection string to use for PostgreSQL tests") -soci_make_tests( - OBJECT_LIB postgresql_tests - CONNECTION_STRING "${SOCI_POSTGRESQL_TEST_CONNSTR}" - SHARED_NAME "soci_postgresql_test" - STATIC_NAME "soci_postgresql_test_static" - SOCI_DEP_ALIAS "PostgreSQL" +add_test( + NAME soci_postgresql_tests + COMMAND soci_postgresql_tests "${SOCI_POSTGRESQL_TEST_CONNSTR}" "--invisibles" ) diff --git a/tests/sqlite3/CMakeLists.txt b/tests/sqlite3/CMakeLists.txt index 16b253d2a..0bfdde594 100644 --- a/tests/sqlite3/CMakeLists.txt +++ b/tests/sqlite3/CMakeLists.txt @@ -1,13 +1,9 @@ -add_library(sqlite_tests OBJECT sqlite3_tests.cpp) -target_link_libraries(sqlite_tests PUBLIC soci_common_tests soci_sqlite3_interface) +add_executable(soci_sqlite3_tests sqlite3_tests.cpp) +target_link_libraries(soci_sqlite3_tests PRIVATE soci_common_tests SOCI::SQLite3) set(SOCI_SQLITE3_TEST_CONNSTR ":memory:" CACHE STRING "The connection string to use for SQLite3 tests") -soci_make_tests( - OBJECT_LIB sqlite_tests - CONNECTION_STRING "${SOCI_SQLITE3_TEST_CONNSTR}" - SHARED_NAME "soci_sqlite3_test" - STATIC_NAME "soci_sqlite3_test_static" - SOCI_DEP_ALIAS "SQLite3" +add_test( + NAME soci_sqlite3_tests + COMMAND soci_sqlite3_tests "${SOCI_SQLITE3_TEST_CONNSTR}" "--invisibles" ) -