First draft of new cmake

This commit is contained in:
Robert Adam
2024-01-03 14:57:27 +01:00
parent 4440c78913
commit 0d85e89923
46 changed files with 579 additions and 2325 deletions

View File

@@ -1,257 +1,71 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2009-2013 Mateusz Loskot <mateusz@loskot.net>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
# General settings
###############################################################################
cmake_minimum_required(VERSION 2.8...3.20 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(SOCI)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/find_modules")
if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14)
set(CMAKE_CXX_STANDARD 14)
endif()
include(soci_parse_version)
soci_parse_version(
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE SOCI_VERSION
)
project(SOCI
VERSION ${SOCI_VERSION}
DESCRIPTION "C++ database access library"
HOMEPAGE_URL "https://soci.sourceforge.net/"
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Path to additional CMake modules
set(CMAKE_MODULE_PATH ${SOCI_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH ${SOCI_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(CMakeDependentOption)
include(CheckIPOSupported)
include(CheckCXXCompilerFlag)
include(SociUtilities)
check_ipo_supported(RESULT LTO_AVAILABLE)
###############################################################################
# Build features and variants
##############################################################################
option(SOCI_SHARED "Enable building SOCI as a shared library" ON)
option(SOCI_STATIC "Enable building SOCI as a static library" ON)
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)
option(SOCI_VISIBILITY "Make all functions hidden by default - this exposes only explicitly exported functions" ON)
set(SOCI_LD "" CACHE STRING "Specify a non-default linker")
option(SOCI_BOOST "Whether to enable Boost-specific bindings" ON)
option(SOCI_SHARED "Enable build of shared libraries" ON)
option(SOCI_STATIC "Enable build of static libraries" ON)
option(SOCI_TESTS "Enable build of collection of SOCI tests" ON)
option(SOCI_ASAN "Enable address sanitizer on GCC v4.8+/Clang v 3.1+" OFF)
option(SOCI_LTO "Enable link time optimization" OFF)
option(SOCI_VISIBILITY "Enable hiding private symbol using ELF visibility if supported by the platform" ON)
if (SOCI_LTO)
cmake_minimum_required(VERSION 3.9)
# Check and enable lto support
include(CheckIPOSupported)
check_ipo_supported(RESULT supported)
if (NOT supported)
message(STATUS "IPO / LTO not supported")
endif()
if (supported AND NOT SOCI_ASAN)
message(STATUS "IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Check for lld as clang lto works best with its own linker
soci_use_ld_if_supported(lld)
endif()
elseif(supported)
message(STATUS "IPO / LTO is supported but conflicts with ASAN and not enabled")
endif()
endif()
# Configure LTO for anything but Debug builds (if enabled in the first place)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${SOCI_LTO})
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_Debug OFF)
if (SOCI_VISIBILITY)
# Test whether visibility is supported
include(CheckCSourceCompiles)
check_c_source_compiles(
"
__attribute__ (( visibility(\"default\") )) int f1() { return 0; }
__attribute__ (( visibility(\"hidden\") )) int f2() { return 1; }
int main(int argc, char* argv[]) { f1(); f2(); return 0; }
"
SOCI_HAVE_VISIBILITY_SUPPORT
)
if (SOCI_HAVE_VISIBILITY_SUPPORT)
message(STATUS "gcc / clang visibility enabled")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
cmake_policy(SET CMP0063 NEW)
endif()
else()
set(SOCI_HAVE_VISIBILITY_SUPPORT off)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
endif()
# Allow using alternative linker such as mold, which can be significantly
# faster than GNU ld.
option(SOCI_LD "Use non-default linker, such as 'mold'" "")
if(SOCI_LD)
# -fuse-ld works only with recent gcc (>= 12), but we don't need to support
# this with all gcc versions as this is entirely optional. I.e. if we really
# wanted to, we could use -B option as explained in mold README to make it
# work with any gcc, but for now keep the things simple.
soci_use_ld_if_supported(${SOCI_LD})
if (SOCI_LD)
# CMake asks the compiler to do the linking so we have to pass the desired linker to the compiler
set(USE_LD_FLAG "-fuse-ld=${SOCI_LD}")
check_cxx_compiler_flag("${USE_LD_FLAG}" CAN_USE_CUSTOM_LD)
if (NOT CAN_USE_CUSTOM_LD)
message(FATAL_ERROR "Can't use custom linker '${SOCI_LD}' - compiler doesn't accept flag '${USE_LD_FLAG}'")
endif()
add_link_options("${USE_LD_FLAG}")
endif()
###############################################################################
# SOCI configuration
###############################################################################
include(SociConfig)
colormsg(_HIBLUE_ "Configuring SOCI:")
###############################################################################
# SOCI version information
###############################################################################
include(SociVersion)
soci_version()
###############################################################################
# Build features and variants
##############################################################################
boost_report_value(SOCI_SHARED)
boost_report_value(SOCI_STATIC)
boost_report_value(SOCI_TESTS)
boost_report_value(SOCI_ASAN)
# from SociConfig.cmake
boost_report_value(LIB_SUFFIX)
# Put the libaries and binaries that get built into directories at the
# top of the build tree rather than in hard-to-find leaf
# directories. This simplifies manual testing and the use of the build
# tree rather than installed Boost libraries.
# Ensure that libraries and executables end up at the top of the build tree
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)
###############################################################################
# Find SOCI dependencies
###############################################################################
set(SOCI_CORE_TARGET)
set(SOCI_CORE_TARGET_STATIC)
set(SOCI_CORE_DEPS_LIBS)
include(SociDependencies)
get_property(SOCI_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY INCLUDE_DIRECTORIES)
if(Threads_FOUND)
list(APPEND SOCI_CORE_DEPS_LIBS ${CMAKE_THREAD_LIBS_INIT})
else()
message(FATAL_ERROR "No thread library found")
endif()
if(NOT MSVC)
set(DL_FIND_QUIETLY TRUE)
find_package(DL)
if(DL_FOUND)
list(APPEND SOCI_CORE_DEPS_LIBS ${DL_LIBRARY})
set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES ${DL_INCLUDE_DIR})
add_definitions(-DHAVE_DL=1)
endif()
endif()
if(Boost_FOUND)
get_property(SOCI_COMPILE_DEFINITIONS
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY COMPILE_DEFINITIONS)
set(SOCI_HAVE_BOOST ON)
list(APPEND SOCI_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB")
if(Boost_DATE_TIME_FOUND)
list(APPEND SOCI_CORE_DEPS_LIBS ${Boost_DATE_TIME_LIBRARY})
set(SOCI_HAVE_BOOST_DATE_TIME ON)
endif()
list(APPEND SOCI_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
list(APPEND SOCI_CORE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
set_directory_properties(PROPERTY COMPILE_DEFINITIONS "${SOCI_COMPILE_DEFINITIONS}")
set_property(DIRECTORY ${SOCI_SOURCE_DIR}
PROPERTY COMPILE_DEFINITIONS "${SOCI_COMPILE_DEFINITIONS}")
else()
set(SOCI_HAVE_BOOST OFF)
set(SOCI_HAVE_BOOST_DATE_TIME OFF)
endif()
set(SOCI_HAVE_BOOST ${SOCI_HAVE_BOOST} CACHE INTERNAL "Boost library")
set(SOCI_HAVE_BOOST_DATE_TIME ${SOCI_HAVE_BOOST_DATE_TIME} CACHE INTERNAL "Boost date_time library")
list(APPEND SOCI_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY
INCLUDE_DIRECTORIES ${SOCI_INCLUDE_DIRS})
###############################################################################
# Installation
###############################################################################
include(GNUInstallDirs)
###############################################################################
# Configuration files
###############################################################################
set(CONFIG_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
install(DIRECTORY ${CONFIG_INCLUDE_DIR}/soci DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(CONFIG_FILE_IN "include/soci/soci-config.h.in")
set(CONFIG_FILE_OUT "${CONFIG_INCLUDE_DIR}/soci/soci-config.h")
###############################################################################
# Build configured components
###############################################################################
include(SociBackend)
include_directories(${SOCI_SOURCE_DIR}/include ${CONFIG_INCLUDE_DIR})
add_subdirectory(src)
if(SOCI_TESTS)
###############################################################################
# Enable tests
###############################################################################
if (SOCI_TESTS)
include(CTest)
enable_testing()
file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} TEST_ACCESS_PATH)
configure_file(${PROJECT_SOURCE_DIR}/cmake/configs/test-access.cmake ${PROJECT_SOURCE_DIR}/tests/odbc/test-access.dsn @ONLY)
set(MYSQL_DRIVER_NAME "MySQL")
if(WIN32)
set(MYSQL_DRIVER_NAME "MySQL ODBC 5.3 ANSI Driver")
endif()
configure_file(${PROJECT_SOURCE_DIR}/cmake/configs/test-mysql.cmake ${PROJECT_SOURCE_DIR}/tests/odbc/test-mysql.dsn @ONLY)
# Define "make check" as alias for "make test"
add_custom_target(check COMMAND ctest)
add_subdirectory(tests)
endif()
###############################################################################
# build config file
###############################################################################
get_cmake_property(ALL_VARIABLES CACHE_VARIABLES)
set(CONFIGURED_VARIABLES)
foreach(v ${ALL_VARIABLES})
if (v MATCHES "^SOCI_HAVE.*")
get_property(CACHE_HELPSTRING CACHE ${v} PROPERTY HELPSTRING)
set(CONFIGURED_VARIABLES "${CONFIGURED_VARIABLES}\n// ${CACHE_HELPSTRING}\n")
if (${${v}})
set(CONFIGURED_VARIABLES "${CONFIGURED_VARIABLES}#define ${v}\n")
else()
set(CONFIGURED_VARIABLES "${CONFIGURED_VARIABLES}/* #undef ${v} */\n")
endif()
endif()
endforeach()
configure_file("${CONFIG_FILE_IN}" "${CONFIG_FILE_OUT}")
message(STATUS "")

21
cmake/.gitignore vendored
View File

@@ -1,21 +0,0 @@
*~
*.kdev[0-9]
*.swp
aclocal.m4
autom4te.cache
confdefs.h
config.guess
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
m4
missing
Makefile
Makefile.in
tmp

View File

@@ -1,13 +0,0 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2009 Mateusz Loskot
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
# install the cmake modules
file(GLOB SOCI_CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake")

View File

@@ -1,388 +0,0 @@
################################################################################
# SociBackend.cmake - part of CMake configuration of SOCI library
################################################################################
# Copyright (C) 2010-2013 Mateusz Loskot <mateusz@loskot.net>
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
# Macros in this module:
#
# soci_backend
# - defines project of a database backend for SOCI library
#
# soci_backend_test
# - defines test project of a database backend for SOCI library
################################################################################
macro(soci_backend_deps_found NAME DEPS SUCCESS)
#message(STATUS "DEPS=${DEPS}")
# Determine required dependencies
set(DEPS_INCLUDE_DIRS)
set(DEPS_LIBRARIES)
set(DEPS_NOT_FOUND)
# CMake 2.8+ syntax only:
#foreach(dep IN LISTS DEPS)
foreach(dep ${DEPS})
soci_check_package_found(${dep} DEPEND_FOUND)
if(NOT DEPEND_FOUND)
list(APPEND DEPS_NOT_FOUND ${dep})
else()
string(TOUPPER "${dep}" DEPU)
if( ${DEPU}_INCLUDE_DIR )
list(APPEND DEPS_INCLUDE_DIRS ${${DEPU}_INCLUDE_DIR})
endif()
if( ${DEPU}_INCLUDE_DIRS )
list(APPEND DEPS_INCLUDE_DIRS ${${DEPU}_INCLUDE_DIRS})
endif()
list(APPEND DEPS_LIBRARIES ${${DEPU}_LIBRARIES})
endif()
endforeach()
list(LENGTH DEPS_NOT_FOUND NOT_FOUND_COUNT)
if (NOT_FOUND_COUNT GREATER 0)
set(${SUCCESS} False)
else()
set(${NAME}_DEPS_INCLUDE_DIRS ${DEPS_INCLUDE_DIRS})
set(${NAME}_DEPS_LIBRARIES ${DEPS_LIBRARIES})
set(${SUCCESS} True)
endif()
#message(STATUS "soci_backend_deps_found: ${SUCCESS}=${${SUCCESS}}")
endmacro()
# Defines project of a database backend for SOCI library
#
# soci_backend(backendname
# DEPENDS dependency1 dependency2
# DESCRIPTION description
# AUTHORS author1 author2
# MAINTAINERS maintainer1 maintainer2)
#
macro(soci_backend NAME)
parse_arguments(THIS_BACKEND
"DEPENDS;DESCRIPTION;AUTHORS;MAINTAINERS;"
""
${ARGN})
colormsg(HIGREEN "${NAME} - ${THIS_BACKEND_DESCRIPTION}")
# Backend name variants utils
string(TOLOWER "${PROJECT_NAME}" PROJECTNAMEL)
string(TOLOWER "${NAME}" NAMEL)
string(TOUPPER "${NAME}" NAMEU)
# Backend option available to user
set(THIS_BACKEND_OPTION SOCI_${NAMEU})
soci_backend_deps_found(${NAMEU} "${THIS_BACKEND_DEPENDS}" ${NAMEU}_DEPS_FOUND)
if(NOT ${NAMEU}_DEPS_FOUND)
colormsg(_RED_ "WARNING: Some required dependencies of ${NAME} backend not found:")
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
foreach(dep ${DEPENDS_NOT_FOUND})
colormsg(RED " ${dep}")
endforeach()
else()
foreach(dep IN LISTS DEPENDS_NOT_FOUND)
colormsg(RED " ${dep}")
endforeach()
endif()
# TODO: Abort or warn compilation may fail? --mloskot
colormsg(RED "Skipping")
set(${THIS_BACKEND_OPTION} OFF)
else()
if(${THIS_BACKEND_OPTION})
get_directory_property(THIS_INCLUDE_DIRS INCLUDE_DIRECTORIES)
get_directory_property(THIS_COMPILE_DEFS COMPILE_DEFINITIONS)
# Backend-specific depedencies
set(THIS_BACKEND_DEPENDS_INCLUDE_DIRS ${${NAMEU}_DEPS_INCLUDE_DIRS})
set(THIS_BACKEND_DEPENDS_LIBRARIES ${${NAMEU}_DEPS_LIBRARIES})
set(THIS_BACKEND_DEPENDS_DEFS ${${NAMEU}_DEPS_DEFS})
# Collect include directories
list(APPEND THIS_INCLUDE_DIRS ${SOCI_SOURCE_DIR}/include/private)
list(APPEND THIS_INCLUDE_DIRS ${THIS_BACKEND_DEPENDS_INCLUDE_DIRS})
# Collect compile definitions
list(APPEND THIS_COMPILE_DEFS ${THIS_BACKEND_DEPENDS_DEFS})
set_directory_properties(PROPERTIES
INCLUDE_DIRECTORIES "${THIS_INCLUDE_DIRS}"
COMPILE_DEFINITIONS "${THIS_COMPILE_DEFS}")
# Backend target
set(THIS_BACKEND_VAR SOCI_${NAMEU})
set(THIS_BACKEND_TARGET ${PROJECTNAMEL}_${NAMEL})
set(THIS_BACKEND_TARGET_VAR ${THIS_BACKEND_VAR}_TARGET)
set(${THIS_BACKEND_TARGET_VAR} ${THIS_BACKEND_TARGET})
soci_target_output_name(${THIS_BACKEND_TARGET} ${THIS_BACKEND_VAR}_OUTPUT_NAME)
set(THIS_BACKEND_OUTPUT_NAME ${${THIS_BACKEND_VAR}_OUTPUT_NAME})
set(THIS_BACKEND_OUTPUT_NAME_VAR ${THIS_BACKEND_VAR}_OUTPUT_NAME)
set(${THIS_BACKEND_VAR}_COMPILE_DEFINITIONS ${THIS_COMPILE_DEFS})
set(THIS_BACKEND_COMPILE_DEFINITIONS_VAR ${THIS_BACKEND_VAR}_COMPILE_DEFINITIONS)
set(${THIS_BACKEND_VAR}_INCLUDE_DIRECTORIES ${THIS_INCLUDE_DIRS})
set(THIS_BACKEND_INCLUDE_DIRECTORIES_VAR ${THIS_BACKEND_VAR}_INCLUDE_DIRECTORIES)
# Backend installable headers and sources
file(GLOB THIS_BACKEND_HEADERS ${SOCI_SOURCE_DIR}/include/soci/${NAMEL}/*.h)
file(GLOB THIS_BACKEND_SOURCES *.cpp)
set(THIS_BACKEND_HEADERS_VAR SOCI_${NAMEU}_HEADERS)
set(${THIS_BACKEND_HEADERS_VAR} ${THIS_BACKEND_HEADERS})
# Group source files for IDE source explorers (e.g. Visual Studio)
source_group("Header Files" FILES ${THIS_BACKEND_HEADERS})
source_group("Source Files" FILES ${THIS_BACKEND_SOURCES})
source_group("CMake Files" FILES CMakeLists.txt)
# TODO: Extract as macros: soci_shared_lib_target and soci_static_lib_target --mloskot
# Shared library target
if (SOCI_SHARED)
add_library(${THIS_BACKEND_TARGET}
SHARED
${THIS_BACKEND_SOURCES}
${THIS_BACKEND_HEADERS})
add_library(Soci::${NAMEL} ALIAS ${THIS_BACKEND_TARGET})
target_link_libraries(${THIS_BACKEND_TARGET}
${SOCI_CORE_TARGET}
${THIS_BACKEND_DEPENDS_LIBRARIES})
if(WIN32)
set_target_properties(${THIS_BACKEND_TARGET}
PROPERTIES
OUTPUT_NAME ${THIS_BACKEND_OUTPUT_NAME}
DEFINE_SYMBOL SOCI_DLL)
else()
set_target_properties(${THIS_BACKEND_TARGET}
PROPERTIES
SOVERSION ${${PROJECT_NAME}_SOVERSION}
INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
if(APPLE)
set_target_properties(${THIS_BACKEND_TARGET}
PROPERTIES
LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
endif()
set_target_properties(${THIS_BACKEND_TARGET}
PROPERTIES
VERSION ${${PROJECT_NAME}_VERSION}
CLEAN_DIRECT_OUTPUT 1)
endif()
# Static library target
if(SOCI_STATIC)
set(THIS_BACKEND_TARGET_STATIC ${THIS_BACKEND_TARGET}_static)
add_library(${THIS_BACKEND_TARGET_STATIC}
STATIC
${THIS_BACKEND_SOURCES}
${THIS_BACKEND_HEADERS})
add_library(Soci::${NAMEL}_static ALIAS ${THIS_BACKEND_TARGET_STATIC})
# Still need to link the libraries for tests to work
target_link_libraries (${THIS_BACKEND_TARGET_STATIC}
${THIS_BACKEND_DEPENDS_LIBRARIES}
)
set_target_properties(${THIS_BACKEND_TARGET_STATIC}
PROPERTIES
OUTPUT_NAME ${THIS_BACKEND_OUTPUT_NAME}
PREFIX "lib"
CLEAN_DIRECT_OUTPUT 1)
endif()
# Backend installation
install(FILES ${THIS_BACKEND_HEADERS}
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/${PROJECTNAMEL}/${NAMEL})
if (SOCI_SHARED)
install(TARGETS ${THIS_BACKEND_TARGET}
EXPORT SOCI
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if (SOCI_STATIC)
install(TARGETS ${THIS_BACKEND_TARGET_STATIC}
EXPORT SOCI
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
else()
colormsg(YELLOW "${NAME} backend explicitly disabled")
endif()
endif()
boost_report_value(${THIS_BACKEND_OPTION})
if(${THIS_BACKEND_OPTION})
boost_report_value(${THIS_BACKEND_TARGET_VAR})
boost_report_value(${THIS_BACKEND_OUTPUT_NAME_VAR})
boost_report_value(${THIS_BACKEND_COMPILE_DEFINITIONS_VAR})
boost_report_value(${THIS_BACKEND_INCLUDE_DIRECTORIES_VAR})
endif()
# LOG
#message("soci_backend:")
#message("NAME: ${NAME}")
#message("${THIS_BACKEND_OPTION} = ${SOCI_BACKEND_SQLITE3}")
#message("DEPENDS: ${THIS_BACKEND_DEPENDS}")
#message("DESCRIPTION: ${THIS_BACKEND_DESCRIPTION}")
#message("AUTHORS: ${THIS_BACKEND_AUTHORS}")
#message("MAINTAINERS: ${THIS_BACKEND_MAINTAINERS}")
#message("SOURCES: ${THIS_BACKEND_SOURCES}")
#message("DEPENDS_LIBRARIES: ${THIS_BACKEND_DEPENDS_LIBRARIES}")
#message("DEPENDS_INCLUDE_DIRS: ${THIS_BACKEND_DEPENDS_INCLUDE_DIRS}")
endmacro()
# Generates .vcxproj.user for target of each test.
#
# soci_backend_test_create_vcxproj_user(
# PostgreSQLTest
# "host=localhost dbname=soci_test user=mloskot")
#
function(soci_backend_test_create_vcxproj_user TARGET_NAME TEST_CMD_ARGS)
if(MSVC)
set(SYSTEM_NAME $ENV{USERDOMAIN})
set(USER_NAME $ENV{USERNAME})
set(SOCI_TEST_CMD_ARGS ${TEST_CMD_ARGS})
if(MSVC_VERSION EQUAL 1600)
configure_file(
${SOCI_SOURCE_DIR}/cmake/resources/vs2010-test-cmd-args.vcxproj.user.in
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.vcxproj.user
@ONLY)
endif()
endif()
endfunction(soci_backend_test_create_vcxproj_user)
# Defines test project of a database backend for SOCI library
#
# soci_backend_test(BACKEND mybackend SOURCE mytest1.cpp
# NAME mytest1
# CONNSTR "my test connection"
# DEPENDS library1 library2)
#
macro(soci_backend_test)
parse_arguments(THIS_TEST
"BACKEND;SOURCE;CONNSTR;NAME;DEPENDS;"
""
${ARGN})
# Test backend name
string(TOUPPER "${THIS_TEST_BACKEND}" BACKENDU)
string(TOLOWER "${THIS_TEST_BACKEND}" BACKENDL)
if(SOCI_TESTS AND SOCI_${BACKENDU} AND NOT SOCI_${BACKENDU}_DO_NOT_TEST)
# Test name
if(THIS_TEST_NAME)
string(TOUPPER "${THIS_TEST_NAME}" NAMEU)
set(TEST_FULL_NAME SOCI_${BACKENDU}_TEST_${NAMEU})
else()
set(TEST_FULL_NAME SOCI_${BACKENDU}_TEST)
endif()
string(TOLOWER "${TEST_FULL_NAME}" TEST_TARGET)
string(TOUPPER "${TEST_FULL_NAME}" NAMEU)
soci_backend_deps_found(${NAMEU} "${THIS_TEST_DEPENDS}" ${NAMEU}_DEPS_FOUND)
if(${NAMEU}_DEPS_FOUND)
get_directory_property(THIS_INCLUDE_DIRS INCLUDE_DIRECTORIES)
get_directory_property(THIS_COMPILE_DEFS COMPILE_DEFINITIONS)
set(THIS_TEST_DEPENDS_INCLUDE_DIRS ${${NAMEU}_DEPS_INCLUDE_DIRS})
set(THIS_TEST_DEPENDS_LIBRARIES ${${NAMEU}_DEPS_LIBRARIES})
set(THIS_TEST_DEPENDS_DEFS ${${NAMEU}_DEPS_DEFS})
list(APPEND THIS_INCLUDE_DIRS ${THIS_TEST_DEPENDS_INCLUDE_DIRS})
list(APPEND THIS_COMPILE_DEFS ${THIS_TEST_DEPENDS_DEFS})
set_directory_properties(PROPERTIES
INCLUDE_DIRECTORIES "${THIS_INCLUDE_DIRS}"
COMPILE_DEFINITIONS "${THIS_COMPILE_DEFS}")
else()
colormsg(_RED_ "WARNING: Some dependencies of ${THIS_TEST_BACKEND} test not found")
endif()
set(TEST_CONNSTR_VAR ${TEST_FULL_NAME}_CONNSTR)
set(${TEST_CONNSTR_VAR} ""
CACHE STRING "Connection string for ${BACKENDU} test")
if(NOT ${TEST_CONNSTR_VAR} AND THIS_TEST_CONNSTR)
set(${TEST_CONNSTR_VAR} ${THIS_TEST_CONNSTR})
endif()
boost_message_value(${TEST_CONNSTR_VAR})
if( SOCI_SHARED )
# Shared libraries test
add_executable(${TEST_TARGET} ${THIS_TEST_SOURCE})
target_link_libraries(${TEST_TARGET}
${SOCI_CORE_DEPS_LIBS}
${THIS_TEST_DEPENDS_LIBRARIES}
soci_core
soci_${BACKENDL})
add_test(${TEST_TARGET}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_TARGET}
${${TEST_CONNSTR_VAR}} --invisibles)
soci_backend_test_create_vcxproj_user(${TEST_TARGET} "\"${${TEST_CONNSTR_VAR}}\"")
# Ask make check to try to build tests first before executing them
add_dependencies(check ${TEST_TARGET})
endif(SOCI_SHARED)
# Static libraries test
if(SOCI_STATIC)
set(TEST_TARGET_STATIC ${TEST_TARGET}_static)
add_executable(${TEST_TARGET_STATIC} ${THIS_TEST_SOURCE})
target_link_libraries(${TEST_TARGET_STATIC}
${SOCI_CORE_DEPS_LIBS}
${THIS_TEST_DEPENDS_LIBRARIES}
soci_${BACKENDL}_static
soci_core_static)
add_test(${TEST_TARGET_STATIC}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_TARGET_STATIC}
${${TEST_CONNSTR_VAR}} --invisibles)
soci_backend_test_create_vcxproj_user(${TEST_TARGET_STATIC} "\"${${TEST_CONNSTR_VAR}}\"")
# Ask make check to try to build tests first before executing them
add_dependencies(check ${TEST_TARGET_STATIC})
endif(SOCI_STATIC)
# Group source files for IDE source explorers (e.g. Visual Studio)
source_group("Source Files" FILES ${THIS_TEST_SOURCE})
source_group("CMake Files" FILES CMakeLists.txt)
endif()
endmacro()

View File

@@ -1,97 +0,0 @@
################################################################################
# SociConfig.cmake - CMake build configuration of SOCI library
################################################################################
# Copyright (C) 2010 Mateusz Loskot <mateusz@loskot.net>
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
include(CheckCXXSymbolExists)
if(WIN32)
check_cxx_symbol_exists("_M_AMD64" "" SOCI_TARGET_ARCH_X64)
if(NOT RTC_ARCH_X64)
check_cxx_symbol_exists("_M_IX86" "" SOCI_TARGET_ARCH_X86)
endif(NOT RTC_ARCH_X64)
# add check for arm here
# see http://msdn.microsoft.com/en-us/library/b0084kay.aspx
else(WIN32)
check_cxx_symbol_exists("__i386__" "" SOCI_TARGET_ARCH_X86)
check_cxx_symbol_exists("__x86_64__" "" SOCI_TARGET_ARCH_X64)
check_cxx_symbol_exists("__arm__" "" SOCI_TARGET_ARCH_ARM)
endif(WIN32)
if(NOT DEFINED LIB_SUFFIX)
if(SOCI_TARGET_ARCH_X64)
set(_lib_suffix "64")
else()
set(_lib_suffix "")
endif()
set(LIB_SUFFIX ${_lib_suffix} CACHE STRING "Specifies suffix for the lib directory")
endif()
#
# Force compilation flags and set desired warnings level
#
# This is used to set the -Werror compilation flag only when explicitly
# requested, as e.g. in CI builds.
set(SOCI_WERROR_OPTION "")
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNING)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /we4266")
endif()
if (SOCI_ENABLE_WERROR)
set(SOCI_WERROR_OPTION "/WX")
endif (SOCI_ENABLE_WERROR)
else()
if (SOCI_ENABLE_WERROR)
set(SOCI_WERROR_OPTION "-Werror")
endif (SOCI_ENABLE_WERROR)
set(SOCI_GCC_CLANG_COMMON_FLAGS
"-pedantic -Wno-error=parentheses -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Woverloaded-virtual -Wredundant-decls -Wno-long-long")
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang")
if(NOT CMAKE_CXX_COMPILER_VERSION LESS 3.1 AND SOCI_ASAN)
set(SOCI_GCC_CLANG_COMMON_FLAGS "${SOCI_GCC_CLANG_COMMON_FLAGS} -fsanitize=address")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SOCI_GCC_CLANG_COMMON_FLAGS}")
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(NOT CMAKE_CXX_COMPILER_VERSION LESS 4.8 AND SOCI_ASAN)
set(SOCI_GCC_CLANG_COMMON_FLAGS "${SOCI_GCC_CLANG_COMMON_FLAGS} -fsanitize=address")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SOCI_GCC_CLANG_COMMON_FLAGS} ")
if (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros")
endif()
endif()
else()
message(WARNING "Unknown toolset - using default flags to build SOCI")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SOCI_WERROR_OPTION}")

View File

@@ -1,101 +0,0 @@
################################################################################
# SociDependencies.cmake - part of CMake configuration of SOCI library
#
# Based on BoostExternals.cmake from CMake configuration for Boost
################################################################################
# Copyright (C) 2010 Mateusz Loskot <mateusz@loskot.net>
# Copyright (C) 2009 Troy Straszheim
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
# Macros in this module:
#
# soci_backend - defines a database backend for SOCI library
#
################################################################################
#
# List of SOCI dependncies
#
set(SOCI_CORE_DEPENDENCIES
Threads
Boost)
set(SOCI_BACKENDS_DB_DEPENDENCIES
MySQL
ODBC
Oracle
PostgreSQL
SQLite3
Firebird
DB2)
set(SOCI_ALL_DEPENDENCIES
${SOCI_CORE_DEPENDENCIES}
${SOCI_BACKENDS_DB_DEPENDENCIES})
#
# Perform checks
#
colormsg(_HIBLUE_ "Looking for SOCI dependencies:")
macro(boost_external_report NAME)
set(VARNAME ${NAME})
string(TOUPPER ${NAME} VARNAMEU)
set(VARNAMES ${ARGV})
list(REMOVE_AT VARNAMES 0)
# Test both, given original name and uppercase version too
if(NOT ${VARNAME}_FOUND AND NOT ${VARNAMEU}_FOUND)
colormsg(_RED_ "WARNING: ${NAME} libraries not found, some features will be disabled.")
endif()
foreach(variable ${VARNAMES})
if(${VARNAMEU}_FOUND)
boost_report_value(${VARNAMEU}_${variable})
elseif(${VARNAME}_FOUND)
boost_report_value(${VARNAME}_${variable})
endif()
endforeach()
endmacro()
#
# Some externals default to OFF
#
option(WITH_VALGRIND "Run tests under valgrind" OFF)
#
# Detect available dependencies
#
foreach(external ${SOCI_ALL_DEPENDENCIES})
string(TOUPPER "${external}" EXTERNAL)
# For historical reasons we use both WITH_xxx and SOCI_xxx options, and
# setting either of them to e.g. OFF should disable the corresponding
# dependency.
option(WITH_${EXTERNAL} "Attempt to find and configure ${external}" ON)
option(SOCI_${EXTERNAL} "Attempt to build ${external} backend" ON)
if(NOT WITH_${EXTERNAL})
set(disabled_var "WITH")
elseif(NOT SOCI_${EXTERNAL})
set(disabled_var "SOCI")
endif()
if(NOT DEFINED disabled_var)
colormsg(HICYAN "${external}:")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies/${external}.cmake)
else()
set(${EXTERNAL}_FOUND FALSE CACHE BOOL "${external} found" FORCE)
colormsg(HICYAN "${external}:" YELLOW "disabled, since ${disabled_var}_${EXTERNAL}=OFF")
unset(disabled_var)
endif()
if(NOT ${EXTERNAL}_FOUND)
set(SOCI_${EXTERNAL} OFF)
endif()
endforeach()

View File

@@ -1,436 +0,0 @@
################################################################################
# SociUtilities.cmake - part of CMake configuration of SOCI library
#
# Based on BoostUtilities.cmake from CMake configuration for Boost
################################################################################
# Copyright (C) 2007 Douglas Gregor <doug.gregor@gmail.com>
# Copyright (C) 2007 Troy Straszheim
# Copyright (C) 2010-2013 Mateusz Loskot <mateusz@loskot.net>
#
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
################################################################################
# Macros in this module:
#
# list_contains: Determine whether a string value is in a list.
#
# car: Return the first element in a list
#
# cdr: Return all but the first element in a list
#
# parse_arguments: Parse keyword arguments for use in other macros.
#
# soci_check_package_found: Test varname-FOUND for case-insensitive varname
#
################################################################################
# This utility macro determines whether a particular string value
# occurs within a list of strings:
#
# list_contains(result string_to_find arg1 arg2 arg3 ... argn)
#
# This macro sets the variable named by result equal to TRUE if
# string_to_find is found anywhere in the following arguments.
macro(list_contains var value)
set(${var})
foreach (value2 ${ARGN})
if (${value} STREQUAL ${value2})
set(${var} TRUE)
endif (${value} STREQUAL ${value2})
endforeach (value2)
endmacro(list_contains)
# This utility macro extracts the first argument from the list of
# arguments given, and places it into the variable named var.
#
# car(var arg1 arg2 ...)
macro(car var)
set(${var} ${ARGV1})
endmacro(car)
# This utility macro extracts all of the arguments given except the
# first, and places them into the variable named var.
#
# car(var arg1 arg2 ...)
macro(cdr var junk)
set(${var} ${ARGN})
endmacro(cdr)
# The parse_arguments macro will take the arguments of another macro and
# define several variables. The first argument to parse_arguments is a
# prefix to put on all variables it creates. The second argument is a
# list of names, and the third argument is a list of options. Both of
# these lists should be quoted. The rest of parse_arguments are
# arguments from another macro to be parsed.
#
# parse_arguments(prefix arg_names options arg1 arg2...)
#
# For each item in options, parse_arguments will create a variable with
# that name, prefixed with prefix_. So, for example, if prefix is
# MY_MACRO and options is OPTION1;OPTION2, then parse_arguments will
# create the variables MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These
# variables will be set to true if the option exists in the command line
# or false otherwise.
#
# For each item in arg_names, parse_arguments will create a variable
# with that name, prefixed with prefix_. Each variable will be filled
# with the arguments that occur after the given arg_name is encountered
# up to the next arg_name or the end of the arguments. All options are
# removed from these lists. parse_arguments also creates a
# prefix_DEFAULT_ARGS variable containing the list of all arguments up
# to the first arg_name encountered.
macro(parse_arguments prefix arg_names option_names)
set(DEFAULT_ARGS)
foreach(arg_name ${arg_names})
set(${prefix}_${arg_name})
endforeach(arg_name)
foreach(option ${option_names})
set(${prefix}_${option} FALSE)
endforeach(option)
set(current_arg_name DEFAULT_ARGS)
set(current_arg_list)
foreach(arg ${ARGN})
list_contains(is_arg_name ${arg} ${arg_names})
if (is_arg_name)
set(${prefix}_${current_arg_name} ${current_arg_list})
set(current_arg_name ${arg})
set(current_arg_list)
else (is_arg_name)
list_contains(is_option ${arg} ${option_names})
if (is_option)
set(${prefix}_${arg} TRUE)
else (is_option)
set(current_arg_list ${current_arg_list} ${arg})
endif (is_option)
endif (is_arg_name)
endforeach(arg)
set(${prefix}_${current_arg_name} ${current_arg_list})
endmacro(parse_arguments)
# Perform a reverse topological sort on the given LIST.
#
# topological_sort(my_list "MY_" "_EDGES")
#
# LIST is the name of a variable containing a list of elements to be
# sorted in reverse topological order. Each element in the list has a
# set of outgoing edges (for example, those other list elements that
# it depends on). In the resulting reverse topological ordering
# (written back into the variable named LIST), an element will come
# later in the list than any of the elements that can be reached by
# following its outgoing edges and the outgoing edges of any vertices
# they target, recursively. Thus, if the edges represent dependencies
# on build targets, for example, the reverse topological ordering is
# the order in which one would build those targets.
#
# For each element E in this list, the edges for E are contained in
# the variable named ${PREFIX}${E}${SUFFIX}, where E is the
# upper-cased version of the element in the list. If no such variable
# exists, then it is assumed that there are no edges. For example, if
# my_list contains a, b, and c, one could provide a dependency graph
# using the following variables:
#
# MY_A_EDGES b
# MY_B_EDGES
# MY_C_EDGES a b
#
# With the involcation of topological_sort shown above and these
# variables, the resulting reverse topological ordering will be b, a,
# c.
function(topological_sort LIST PREFIX SUFFIX)
# Clear the stack and output variable
set(VERTICES "${${LIST}}")
set(STACK)
set(${LIST})
# Loop over all of the vertices, starting the topological sort from
# each one.
foreach(VERTEX ${VERTICES})
string(TOUPPER ${VERTEX} UPPER_VERTEX)
# If we haven't already processed this vertex, start a depth-first
# search from where.
if (NOT FOUND_${UPPER_VERTEX})
# Push this vertex onto the stack with all of its outgoing edges
string(REPLACE ";" " " NEW_ELEMENT
"${VERTEX};${${PREFIX}${UPPER_VERTEX}${SUFFIX}}")
list(APPEND STACK ${NEW_ELEMENT})
# We've now seen this vertex
set(FOUND_${UPPER_VERTEX} TRUE)
# While the depth-first search stack is not empty
list(LENGTH STACK STACK_LENGTH)
while(STACK_LENGTH GREATER 0)
# Remove the vertex and its remaining out-edges from the top
# of the stack
list(GET STACK -1 OUT_EDGES)
list(REMOVE_AT STACK -1)
# Get the source vertex and the list of out-edges
separate_arguments(OUT_EDGES)
list(GET OUT_EDGES 0 SOURCE)
list(REMOVE_AT OUT_EDGES 0)
# While there are still out-edges remaining
list(LENGTH OUT_EDGES OUT_DEGREE)
while (OUT_DEGREE GREATER 0)
# Pull off the first outgoing edge
list(GET OUT_EDGES 0 TARGET)
list(REMOVE_AT OUT_EDGES 0)
string(TOUPPER ${TARGET} UPPER_TARGET)
if (NOT FOUND_${UPPER_TARGET})
# We have not seen the target before, so we will traverse
# its outgoing edges before coming back to our
# source. This is the key to the depth-first traversal.
# We've now seen this vertex
set(FOUND_${UPPER_TARGET} TRUE)
# Push the remaining edges for the current vertex onto the
# stack
string(REPLACE ";" " " NEW_ELEMENT
"${SOURCE};${OUT_EDGES}")
list(APPEND STACK ${NEW_ELEMENT})
# Setup the new source and outgoing edges
set(SOURCE ${TARGET})
string(TOUPPER ${SOURCE} UPPER_SOURCE)
set(OUT_EDGES
${${PREFIX}${UPPER_SOURCE}${SUFFIX}})
endif(NOT FOUND_${UPPER_TARGET})
list(LENGTH OUT_EDGES OUT_DEGREE)
endwhile (OUT_DEGREE GREATER 0)
# We have finished all of the outgoing edges for
# SOURCE; add it to the resulting list.
list(APPEND ${LIST} ${SOURCE})
# Check the length of the stack
list(LENGTH STACK STACK_LENGTH)
endwhile(STACK_LENGTH GREATER 0)
endif (NOT FOUND_${UPPER_VERTEX})
endforeach(VERTEX)
set(${LIST} ${${LIST}} PARENT_SCOPE)
endfunction(topological_sort)
# Small little hack that tweaks a component name (as used for CPack)
# to make sure to avoid certain names that cause problems. Sets the
# variable named varname to the "sanitized" name.
#
# FIXME: This is a complete hack. We probably need to fix the CPack
# generators (NSIS in particular) to get rid of the need for this.
macro(fix_cpack_component_name varname name)
if (${name} STREQUAL "foreach")
set(${varname} "boost_foreach")
else()
set(${varname} ${name})
endif()
endmacro()
#
# A big shout out to the cmake gurus @ compiz
#
function (colormsg)
string (ASCII 27 _escape)
set(WHITE "29")
set(GRAY "30")
set(RED "31")
set(GREEN "32")
set(YELLOW "33")
set(BLUE "34")
set(MAG "35")
set(CYAN "36")
foreach (color WHITE GRAY RED GREEN YELLOW BLUE MAG CYAN)
set(HI${color} "1\;${${color}}")
set(LO${color} "2\;${${color}}")
set(_${color}_ "4\;${${color}}")
set(_HI${color}_ "1\;4\;${${color}}")
set(_LO${color}_ "2\;4\;${${color}}")
endforeach()
set(str "")
set(coloron FALSE)
foreach(arg ${ARGV})
if (NOT ${${arg}} STREQUAL "")
if (CMAKE_COLOR_DIAGNOSTICS)
set(str "${str}${_escape}[${${arg}}m")
set(coloron TRUE)
endif()
else()
set(str "${str}${arg}")
if (coloron)
set(str "${str}${_escape}[0m")
set(coloron FALSE)
endif()
set(str "${str} ")
endif()
endforeach()
message(STATUS ${str})
endfunction()
# colormsg("Colors:"
# WHITE "white" GRAY "gray" GREEN "green"
# RED "red" YELLOW "yellow" BLUE "blue" MAG "mag" CYAN "cyan"
# _WHITE_ "white" _GRAY_ "gray" _GREEN_ "green"
# _RED_ "red" _YELLOW_ "yellow" _BLUE_ "blue" _MAG_ "mag" _CYAN_ "cyan"
# _HIWHITE_ "white" _HIGRAY_ "gray" _HIGREEN_ "green"
# _HIRED_ "red" _HIYELLOW_ "yellow" _HIBLUE_ "blue" _HIMAG_ "mag" _HICYAN_ "cyan"
# HIWHITE "white" HIGRAY "gray" HIGREEN "green"
# HIRED "red" HIYELLOW "yellow" HIBLUE "blue" HIMAG "mag" HICYAN "cyan"
# "right?")
#
# pretty-prints the value of a variable so that the
# equals signs align
#
function(boost_report_value NAME)
string(LENGTH "${NAME}" varlen)
# LOG
#message(STATUS "boost_report_value: NAME=${NAME} (${varlen})")
#message(STATUS "boost_report_value: \${NAME}=${${NAME}}")
math(EXPR padding_len 40-${varlen})
string(SUBSTRING " "
0 ${padding_len} varpadding)
colormsg("${NAME}${varpadding} = ${${NAME}}")
endfunction()
function(boost_message_value NAME)
string(LENGTH "${NAME}" varlen)
math(EXPR padding_len 40-${varlen})
string(SUBSTRING " "
0 ${padding_len} varpadding)
message(STATUS "${NAME}${varpadding} = ${${NAME}}")
endfunction()
function(trace NAME)
if(BOOST_CMAKE_TRACE)
string(LENGTH "${NAME}" varlen)
math(EXPR padding_len 40-${varlen})
string(SUBSTRING "........................................"
0 ${padding_len} varpadding)
message("${NAME} ${varpadding} ${${NAME}}")
endif()
endfunction()
#
# pretty-prints the value of a variable so that the
# equals signs align
#
function(boost_report_pretty PRETTYNAME VARNAME)
string(LENGTH "${PRETTYNAME}" varlen)
math(EXPR padding_len 30-${varlen})
string(SUBSTRING " "
0 ${padding_len} varpadding)
message(STATUS "${PRETTYNAME}${varpadding} = ${${VARNAME}}")
endfunction()
#
# assert that ARG is actually a library target
#
macro(dependency_check ARG)
trace(ARG)
if (NOT "${ARG}" STREQUAL "")
get_target_property(deptype ${ARG} TYPE)
if(NOT deptype MATCHES ".*_LIBRARY$")
set(DEPENDENCY_OKAY FALSE)
list(APPEND DEPENDENCY_FAILURES ${ARG})
endif()
endif()
endmacro()
#
# Tests package-FOUND for varname in three cases as given, lowercase and
# uppercase.
#
macro(soci_check_package_found NAME SUCCESS)
set(${SUCCESS} FALSE)
set(VARNAME ${NAME})
set(VARNAME_SUCCESS ${${VARNAME}_FOUND})
# Test both, given original name and uppercase version too
if(VARNAME_SUCCESS)
set(${SUCCESS} TRUE)
else()
string(TOUPPER ${NAME} VARNAME)
set(VARNAME_SUCCESS ${${VARNAME}_FOUND})
if(VARNAME_SUCCESS)
set(${SUCCESS} TRUE)
endif()
endif()
#message(STATUS "soci_check_package_found: ${SUCCESS}=${${SUCCESS}}")
endmacro()
#
# Pretty-print of given property of current directory.
#
function(soci_report_directory_property PROPNAME)
get_directory_property(${PROPNAME} ${PROPNAME})
boost_report_value(${PROPNAME})
endfunction()
#
# Scans the current directory and returns a list of subdirectories.
# Author: Robert Fleming
# Source: http://www.cmake.org/pipermail/cmake/2008-February/020114.html
#
# Third parameter is 1 if you want relative paths returned.
# Usage: list_subdirectories(the_list_is_returned_here /path/to/project TRUE)
#
macro(list_subdirectories retval curdir return_relative)
file(GLOB sub-dir RELATIVE ${curdir} *)
set(list_of_dirs "")
foreach(dir ${sub-dir})
if(IS_DIRECTORY ${curdir}/${dir})
if (${return_relative})
set(list_of_dirs ${list_of_dirs} ${dir})
else()
set(list_of_dirs ${list_of_dirs} ${curdir}/${dir})
endif()
endif()
endforeach()
set(${retval} ${list_of_dirs})
endmacro()
#
# Generates output name for given target depending on platform and version.
# For instance, on Windows, libraries get ABI version suffix soci_coreXY.{dll|lib}.
#
function(soci_target_output_name TARGET_NAME OUTPUT_NAME)
if(NOT DEFINED TARGET_NAME)
message(SEND_ERROR "Error, the variable TARGET_NAME is not defined!")
endif()
if(NOT DEFINED ${PROJECT_NAME}_VERSION)
message(SEND_ERROR "Error, the variable ${${PROJECT_NAME}_VERSION} is not defined!")
endif()
# On Windows, ABI version is specified using binary file name suffix.
# On Unix, suffix is empty and SOVERSION is used instead.
if (WIN32)
string(LENGTH "${${PROJECT_NAME}_ABI_VERSION}" abilen)
if(abilen GREATER 0)
set(SUFFIX "_${${PROJECT_NAME}_ABI_VERSION}")
endif()
endif()
set(${OUTPUT_NAME} ${TARGET_NAME}${SUFFIX} PARENT_SCOPE)
endfunction()
# Check if the given linker is supported and use it if it is.
function(soci_use_ld_if_supported ld)
include(CheckCXXCompilerFlag)
set(ld_flag "-fuse-ld=${ld}")
check_cxx_compiler_flag(${ld_flag} can_use_ld)
if (can_use_ld)
add_link_options(${ld_flag})
endif()
endfunction()

View File

@@ -1,62 +0,0 @@
################################################################################
# SociVersion.cmake - part of CMake configuration of SOCI library
################################################################################
# Copyright (C) 2010 Mateusz Loskot <mateusz@loskot.net>
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
################################################################################
# Macros in this module:
#
# soci_version - defines version information for SOCI library
#
################################################################################
# Defines version information for SOCI library
#
# soci_version(MAJOR major_version MINOR minor_version PATCH patch_level)
#
# MAJOR.MINOR version is used to set SOVERSION
#
macro(soci_version)
# get version from soci/version.h
file(
STRINGS
"${PROJECT_SOURCE_DIR}/include/soci/version.h"
_VERSION
REGEX
"#define SOCI_VERSION ([0-9]+)"
)
string(REGEX MATCH "([0-9]+)" _VERSION "${_VERSION}")
math(EXPR ${PROJECT_NAME}_VERSION_MAJOR "${_VERSION} / 100000")
math(EXPR ${PROJECT_NAME}_VERSION_MINOR "${_VERSION} / 100 % 1000")
math(EXPR ${PROJECT_NAME}_VERSION_PATCH "${_VERSION} % 100")
# Set VERSION string
set(${PROJECT_NAME}_VERSION
"${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}")
# Set SOVERSION based on major and minor
set(${PROJECT_NAME}_SOVERSION
"${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}")
# Set ABI version string used to name binary output and, by SOCI loader, to find binaries.
# On Windows, ABI version is specified using binary file name suffix.
# On Unix, suffix ix empty and SOVERSION is used instead.
if (UNIX)
set(${PROJECT_NAME}_ABI_VERSION ${${PROJECT_NAME}_SOVERSION})
elseif(WIN32)
set(${PROJECT_NAME}_ABI_VERSION
"${${PROJECT_NAME}_VERSION_MAJOR}_${${PROJECT_NAME}_VERSION_MINOR}")
else()
message(FATAL_ERROR "Ambiguous target platform with unknown ABI version scheme. Giving up.")
endif()
boost_report_value(${PROJECT_NAME}_VERSION)
boost_report_value(${PROJECT_NAME}_ABI_VERSION)
add_definitions(-DSOCI_ABI_VERSION="${${PROJECT_NAME}_ABI_VERSION}")
endmacro()

View File

@@ -1,13 +0,0 @@
[ODBC]
DRIVER=Microsoft Access Driver (*.mdb, *.accdb)
UID=admin
UserCommitSync=Yes
Threads=3
SafeTransactions=0
PageTimeout=5
MaxScanRows=8
MaxBufferSize=2048
FIL=MS Access
DriverId=25
DefaultDir=@TEST_ACCESS_PATH@\tests\odbc
DBQ=@TEST_ACCESS_PATH@\tests\odbc\soci_test.mdb

View File

@@ -1,4 +0,0 @@
[ODBC]
DRIVER=@MYSQL_DRIVER_NAME@
DATABASE=soci_test
OPTION=0

View File

@@ -1,13 +0,0 @@
set(Boost_FIND_QUIETLY TRUE)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.33.1 COMPONENTS date_time)
if (NOT Boost_DATE_TIME_FOUND)
find_package(Boost 1.33.1)
endif()
set(Boost_RELEASE_VERSION
"${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
boost_external_report(Boost RELEASE_VERSION INCLUDE_DIR LIBRARIES)

View File

@@ -1,5 +0,0 @@
set(DB2_FIND_QUIETLY TRUE)
find_package(DB2)
boost_external_report(DB2 INCLUDE_DIR LIBRARIES)

View File

@@ -1,9 +0,0 @@
option(SOCI_FIREBIRD_EMBEDDED "Use embedded library in Firebird backend" OFF)
boost_report_value(SOCI_FIREBIRD_EMBEDDED)
set(Firebird_FIND_QUIETLY TRUE)
find_package(Firebird)
boost_external_report(Firebird INCLUDE_DIR LIBRARIES VERSION)

View File

@@ -1,5 +0,0 @@
set(MySQL_FIND_QUIETLY TRUE)
find_package(MySQL)
boost_external_report(MySQL INCLUDE_DIR LIBRARIES)

View File

@@ -1,5 +0,0 @@
set(ODBC_FIND_QUIETLY TRUE)
find_package(ODBC)
boost_external_report(ODBC INCLUDE_DIR LIBRARIES)

View File

@@ -1,5 +0,0 @@
set(Oracle_FIND_QUIETLY TRUE)
find_package(Oracle)
boost_external_report(Oracle INCLUDE_DIR LIBRARIES)

View File

@@ -1,5 +0,0 @@
set(PostgreSQL_FIND_QUIETLY TRUE)
find_package(PostgreSQL)
boost_external_report(PostgreSQL INCLUDE_DIRS LIBRARIES VERSION)

View File

@@ -1,5 +0,0 @@
set(SQLite3_FIND_QUIETLY TRUE)
find_package(SQLite3)
boost_external_report(SQLite3 INCLUDE_DIR LIBRARIES)

View File

@@ -1,4 +0,0 @@
set(Threads_FIND_QUIETLY TRUE)
find_package(Threads)
boost_report_value(CMAKE_THREAD_LIBS_INIT)

View File

@@ -1,21 +0,0 @@
if(DL_INCLUDE_DIR)
set(DL_FIND_QUIETLY TRUE)
endif()
find_path(DL_INCLUDE_DIR dlfcn.h)
find_library(DL_LIBRARY NAMES dl)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DL DEFAULT_MSG DL_LIBRARY DL_INCLUDE_DIR)
if(NOT DL_FOUND)
# if dlopen can be found without linking in dl then,
# dlopen is part of libc, so don't need to link extra libs.
include(CheckFunctionExists)
check_function_exists(dlopen DL_FOUND)
set(DL_LIBRARY "")
endif()
set(DL_LIBRARIES ${DL_LIBRARY})
mark_as_advanced(DL_LIBRARY DL_INCLUDE_DIR)

View File

@@ -1,242 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindODBC
--------
Find the ODBC include directory and library.
Use this module by invoking find_package with the form::
.. code-block:: cmake
find_package(ODBC
[REQUIRED] # Fail with error if ODBC is not found
)
On Windows, when building with Visual Studio, this module assumes the ODBC
library is provided by the available Windows SDK.
On Unix, this module allows to search for ODBC library provided by
unixODBC or iODBC implementations of ODBC API.
This module reads hint about location of the config program:
.. variable:: ODBC_CONFIG
Location of odbc_config or iodbc-config program
Otherwise, this module tries to find the config program,
first from unixODBC, then from iODBC.
If no config program found, this module searches for ODBC header
and library in list of known locations.
Imported targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` targets:
.. variable:: ODBC::ODBC
Imported target for using the ODBC library, if found.
Result variables
^^^^^^^^^^^^^^^^
.. variable:: ODBC_FOUND
Set to true if ODBC library found, otherwise false or undefined.
.. variable:: ODBC_INCLUDE_DIRS
Paths to include directories listed in one variable for use by ODBC client.
May be empty on Windows, where the include directory corresponding to the
expected Windows SDK is already available in the compilation environment.
.. variable:: ODBC_LIBRARIES
Paths to libraries to linked against to use ODBC.
May just a library name on Windows, where the library directory corresponding
to the expected Windows SDK is already available in the compilation environment.
.. variable:: ODBC_CONFIG
Path to unixODBC or iODBC config program, if found or specified.
Cache variables
^^^^^^^^^^^^^^^
For users who wish to edit and control the module behavior, this module
reads hints about search locations from the following variables::
.. variable:: ODBC_INCLUDE_DIR
Path to ODBC include directory with ``sql.h`` header.
.. variable:: ODBC_LIBRARY
Path to ODBC library to be linked.
NOTE: The variables above should not usually be used in CMakeLists.txt files!
Limitations
^^^^^^^^^^^
On Windows, this module does not search for iODBC.
On Unix, there is no way to prefer unixODBC over iODBC, or vice versa,
other than providing the config program location using the ``ODBC_CONFIG``.
This module does not allow to search for a specific ODBC driver.
#]=======================================================================]
### Try Windows Kits ##########################################################
if(WIN32)
# List names of ODBC libraries on Windows
set(ODBC_LIBRARY odbc32.lib)
set(_odbc_lib_names odbc32;)
# List additional libraries required to use ODBC library
if(MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(_odbc_required_libs_names odbccp32;ws2_32)
elseif(MINGW)
set(_odbc_required_libs_names odbccp32)
endif()
endif()
### Try unixODBC or iODBC config program ######################################
if (UNIX AND NOT ODBC_CONFIG)
find_program(ODBC_CONFIG
NAMES odbc_config iodbc-config
DOC "Path to unixODBC or iODBC config program")
endif()
if (UNIX AND ODBC_CONFIG)
# unixODBC and iODBC accept unified command line options
execute_process(COMMAND ${ODBC_CONFIG} --cflags
OUTPUT_VARIABLE _cflags OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${ODBC_CONFIG} --libs
OUTPUT_VARIABLE _libs OUTPUT_STRIP_TRAILING_WHITESPACE)
# Collect paths of include directories from CFLAGS
separate_arguments(_cflags NATIVE_COMMAND "${_cflags}")
foreach(arg IN LISTS _cflags)
if("${arg}" MATCHES "^-I(.*)$")
list(APPEND _odbc_include_paths "${CMAKE_MATCH_1}")
endif()
endforeach()
unset(_cflags)
# Collect paths of library names and directories from LIBS
separate_arguments(_libs NATIVE_COMMAND "${_libs}")
foreach(arg IN LISTS _libs)
if("${arg}" MATCHES "^-L(.*)$")
list(APPEND _odbc_lib_paths "${CMAKE_MATCH_1}")
elseif("${arg}" MATCHES "^-l(.*)$")
set(_lib_name ${CMAKE_MATCH_1})
string(REGEX MATCH "odbc" _is_odbc ${_lib_name})
if(_is_odbc)
list(APPEND _odbc_lib_names ${_lib_name})
else()
list(APPEND _odbc_required_libs_names ${_lib_name})
endif()
unset(_lib_name)
endif()
endforeach()
unset(_libs)
endif()
### Try unixODBC or iODBC in include/lib filesystems ##########################
if (UNIX AND NOT ODBC_CONFIG)
# List names of both ODBC libraries, unixODBC and iODBC
set(_odbc_lib_names odbc;iodbc;unixodbc;)
set(_odbc_include_paths
/usr/local/odbc/include)
set(_odbc_lib_paths
/usr/local/odbc/lib)
endif()
# DEBUG
#message("ODBC_CONFIG=${ODBC_CONFIG}")
#message("_odbc_include_hints=${_odbc_include_hints}")
#message("_odbc_include_paths=${_odbc_include_paths}")
#message("_odbc_lib_paths=${_odbc_lib_paths}")
#message("_odbc_lib_names=${_odbc_lib_names}")
### Find include directories ##################################################
find_path(ODBC_INCLUDE_DIR
NAMES sql.h
HINTS ${_odbc_include_hints}
PATHS ${_odbc_include_paths})
if(NOT ODBC_INCLUDE_DIR AND WIN32)
set(ODBC_INCLUDE_DIR "")
endif()
### Find libraries ############################################################
if(NOT ODBC_LIBRARY)
find_library(ODBC_LIBRARY
NAMES ${_odbc_lib_names}
PATHS ${_odbc_lib_paths}
PATH_SUFFIXES odbc)
foreach(_lib IN LISTS _odbc_required_libs_names)
find_library(_lib_path
NAMES ${_lib}
PATHS ${_odbc_lib_paths} # system parths or collected from ODBC_CONFIG
PATH_SUFFIXES odbc)
if (_lib_path)
list(APPEND _odbc_required_libs_paths ${_lib_path})
endif()
unset(_lib_path CACHE)
endforeach()
unset(_odbc_lib_names)
unset(_odbc_lib_paths)
unset(_odbc_required_libs_names)
endif()
### Set result variables ######################################################
set(REQUIRED_VARS ODBC_LIBRARY)
if(NOT WIN32)
list(APPEND REQUIRED_VARS ODBC_INCLUDE_DIR)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ODBC DEFAULT_MSG ${REQUIRED_VARS})
mark_as_advanced(FORCE ODBC_LIBRARY ODBC_INCLUDE_DIR)
if(ODBC_CONFIG)
mark_as_advanced(FORCE ODBC_CONFIG)
endif()
set(ODBC_INCLUDE_DIRS ${ODBC_INCLUDE_DIR})
list(APPEND ODBC_LIBRARIES ${ODBC_LIBRARY})
list(APPEND ODBC_LIBRARIES ${_odbc_required_libs_paths})
### Import targets ############################################################
if(ODBC_FOUND)
if(NOT TARGET ODBC::ODBC)
if(IS_ABSOLUTE "${ODBC_LIBRARY}")
add_library(ODBC::ODBC UNKNOWN IMPORTED)
set_target_properties(ODBC::ODBC PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${ODBC_LIBRARY}")
else()
add_library(ODBC::ODBC INTERFACE IMPORTED)
set_target_properties(ODBC::ODBC PROPERTIES
IMPORTED_LIBNAME "${ODBC_LIBRARY}")
endif()
set_target_properties(ODBC::ODBC PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${ODBC_INCLUDE_DIR}")
if(_odbc_required_libs_paths)
set_property(TARGET ODBC::ODBC APPEND PROPERTY
INTERFACE_LINK_LIBRARIES "${_odbc_required_libs_paths}")
endif()
endif()
endif()
unset(_odbc_required_libs_paths)

View File

@@ -1,191 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindPostgreSQL
# --------------
#
# Find the PostgreSQL installation.
#
# This module defines
#
# ::
#
# POSTGRESQL_LIBRARIES - the PostgreSQL libraries needed for linking
# POSTGRESQL_INCLUDE_DIRS - the directories of the PostgreSQL headers
# POSTGRESQL_LIBRARY_DIRS - the link directories for PostgreSQL libraries
# POSTGRESQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8)
# ----------------------------------------------------------------------------
# History:
# This module is derived from the module originally found in the VTK source tree.
#
# ----------------------------------------------------------------------------
# Note:
# POSTGRESQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
# version mumber of the implementation of PostgreSQL.
# In Windows the default installation of PostgreSQL uses that as part of the path.
# E.g C:\Program Files\PostgreSQL\8.4.
# Currently, the following version numbers are known to this module:
# "14" "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
#
# To use this variable just do something like this:
# set(POSTGRESQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
# before calling find_package(PostgreSQL) in your CMakeLists.txt file.
# This will mean that the versions you set here will be found first in the order
# specified before the default ones are searched.
#
# ----------------------------------------------------------------------------
# You may need to manually set:
# POSTGRESQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.
# POSTGRESQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.
# If FindPostgreSQL.cmake cannot find the include files or the library files.
#
# ----------------------------------------------------------------------------
# The following variables are set if PostgreSQL is found:
# POSTGRESQL_FOUND - Set to true when PostgreSQL is found.
# POSTGRESQL_INCLUDE_DIRS - Include directories for PostgreSQL
# POSTGRESQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# POSTGRESQL_LIBRARIES - The PostgreSQL libraries.
#
# ----------------------------------------------------------------------------
# If you have installed PostgreSQL in a non-standard location.
# (Please note that in the following comments, it is assumed that <Your Path>
# points to the root directory of the include directory of PostgreSQL.)
# Then you have three options.
# 1) After CMake runs, set POSTGRESQL_INCLUDE_DIR to <Your Path>/include and
# POSTGRESQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is
# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path()
# to locate POSTGRESQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file
# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
# 3) Set an environment variable called ${POSTGRESQL_ROOT} that points to the root of where you have
# installed PostgreSQL, e.g. <Your Path>.
#
# ----------------------------------------------------------------------------
set(POSTGRESQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")
set(POSTGRESQL_INCLUDE_DIR_MESSAGE "Set the POSTGRESQL_INCLUDE_DIR cmake cache entry to the ${POSTGRESQL_INCLUDE_PATH_DESCRIPTION}")
set(POSTGRESQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")
set(POSTGRESQL_LIBRARY_DIR_MESSAGE "Set the POSTGRESQL_LIBRARY_DIR cmake cache entry to the ${POSTGRESQL_LIBRARY_PATH_DESCRIPTION}")
set(POSTGRESQL_ROOT_DIR_MESSAGE "Set the POSTGRESQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")
set(POSTGRESQL_KNOWN_VERSIONS ${POSTGRESQL_ADDITIONAL_VERSIONS}
"14" "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
# Define additional search paths for root directories.
set( POSTGRESQL_ROOT_DIRECTORIES
ENV POSTGRESQL_ROOT
${POSTGRESQL_ROOT}
)
foreach(suffix ${POSTGRESQL_KNOWN_VERSIONS})
if(WIN32)
list(APPEND POSTGRESQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
"PostgreSQL/${suffix}/lib")
list(APPEND POSTGRESQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
"PostgreSQL/${suffix}/include")
list(APPEND POSTGRESQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
"PostgreSQL/${suffix}/include/server")
endif()
if(UNIX)
list(APPEND POSTGRESQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
"pgsql-${suffix}/lib")
list(APPEND POSTGRESQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
"pgsql-${suffix}/include")
list(APPEND POSTGRESQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
"postgresql/${suffix}/server"
"pgsql-${suffix}/include/server")
endif()
if(APPLE)
list(APPEND POSTGRESQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
"postgresql@${suffix}")
list(APPEND POSTGRESQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
"postgresql@${suffix}")
endif()
endforeach()
#
# Look for an installation.
#
find_path(POSTGRESQL_INCLUDE_DIR
NAMES libpq-fe.h
PATHS
# Look in other places.
${POSTGRESQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
pgsql
postgresql
include
${POSTGRESQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES}
# Help the user find it if we cannot.
DOC "The ${POSTGRESQL_INCLUDE_DIR_MESSAGE}"
)
# The PostgreSQL library.
set (POSTGRESQL_LIBRARY_TO_FIND pq)
# Setting some more prefixes for the library
set (POSTGRESQL_LIB_PREFIX "")
if ( WIN32 )
set (POSTGRESQL_LIB_PREFIX ${POSTGRESQL_LIB_PREFIX} "lib")
set (POSTGRESQL_LIBRARY_TO_FIND ${POSTGRESQL_LIB_PREFIX}${POSTGRESQL_LIBRARY_TO_FIND})
endif()
function(__postgresql_find_library _name)
find_library(${_name}
NAMES ${ARGN}
PATHS
${POSTGRESQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
lib
${POSTGRESQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES}
# Help the user find it if we cannot.
DOC "The ${POSTGRESQL_LIBRARY_DIR_MESSAGE}"
)
endfunction()
__postgresql_find_library(POSTGRESQL_LIBRARY ${POSTGRESQL_LIBRARY_TO_FIND})
__postgresql_find_library(POSTGRESQL_LIBRARY_DEBUG ${POSTGRESQL_LIBRARY_TO_FIND}d)
get_filename_component(POSTGRESQL_LIBRARY_DIR ${POSTGRESQL_LIBRARY} PATH)
if (POSTGRESQL_INCLUDE_DIR)
# Some platforms include multiple pg_config.hs for multi-lib configurations
# This is a temporary workaround. A better solution would be to compile
# a dummy c file and extract the value of the symbol.
file(GLOB _PG_CONFIG_HEADERS "${POSTGRESQL_INCLUDE_DIR}/pg_config*.h")
foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
if(EXISTS "${_PG_CONFIG_HEADER}")
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
if(pgsql_version_str)
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
"\\1" POSTGRESQL_VERSION_STRING "${pgsql_version_str}")
break()
endif()
endif()
endforeach()
unset(pgsql_version_str)
endif()
# Did we find anything?
# <SOCI>
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
include(FindPackageHandleStandardArgs)
# </SOCI>
find_package_handle_standard_args(PostgreSQL
REQUIRED_VARS POSTGRESQL_LIBRARY POSTGRESQL_INCLUDE_DIR
VERSION_VAR POSTGRESQL_VERSION_STRING)
set(POSTGRESQL_FOUND ${POSTGRESQL_FOUND})
# Now try to get the include and library path.
if(POSTGRESQL_FOUND)
set(POSTGRESQL_INCLUDE_DIRS ${POSTGRESQL_INCLUDE_DIR})
set(POSTGRESQL_LIBRARY_DIRS ${POSTGRESQL_LIBRARY_DIR})
if(POSTGRESQL_LIBRARY AND POSTGRESQL_LIBRARY_DEBUG)
set(POSTGRESQL_LIBRARIES optimized ${POSTGRESQL_LIBRARY} debug ${POSTGRESQL_LIBRARY_DEBUG})
else()
set(POSTGRESQL_LIBRARIES ${POSTGRESQL_LIBRARY})
endif()
set(POSTGRESQL_VERSION ${POSTGRESQL_VERSION_STRING})
endif()
mark_as_advanced(POSTGRESQL_INCLUDE_DIR POSTGRESQL_LIBRARY)

View File

@@ -1,66 +0,0 @@
###############################################################################
# CMake module to search for SQLite 3 library
#
# On success, the macro sets the following variables:
# SQLITE3_FOUND = if the library found
# SQLITE3_LIBRARY = full path to the library
# SQLITE3_LIBRARIES = full path to the library
# SQLITE3_INCLUDE_DIR = where to find the library headers
#
# Copyright (c) 2009 Mateusz Loskot <mateusz@loskot.net>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
###############################################################################
find_path(SQLITE3_INCLUDE_DIR
NAMES sqlite3.h
PATH_PREFIXES sqlite sqlite3
PATHS
/usr/include
/usr/local/include
$ENV{LIB_DIR}/include
$ENV{LIB_DIR}/include/sqlite
$ENV{LIB_DIR}/include/sqlite3
$ENV{ProgramFiles}/SQLite/*/include
$ENV{ProgramFiles}/SQLite3/*/include
$ENV{SystemDrive}/SQLite/*/include
$ENV{SystemDrive}/SQLite3/*/include
$ENV{SQLITE_ROOT}/include
${SQLITE_ROOT_DIR}/include
$ENV{OSGEO4W_ROOT}/include)
set(SQLITE3_NAMES sqlite3_i sqlite3 sqlite3-static)
find_library(SQLITE3_LIBRARY
NAMES ${SQLITE3_NAMES}
PATHS
/usr/lib
/usr/local/lib
$ENV{LIB_DIR}/lib
$ENV{ProgramFiles}/SQLite/*/lib
$ENV{ProgramFiles}/SQLite3/*/lib
$ENV{SystemDrive}/SQLite/*/lib
$ENV{SystemDrive}/SQLite3/*/lib
$ENV{SQLITE_ROOT}/lib
${SQLITE_ROOT_DIR}/lib
$ENV{OSGEO4W_ROOT}/lib)
set(SQLITE3_LIBRARIES
${SQLITE3_LIBRARIES}
${SQLITE3_LIBRARY})
#message(STATUS ${SQLITE3_LIBRARY})
# Handle the QUIETLY and REQUIRED arguments and set SQLITE3_FOUND to TRUE
# if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SQLite3
DEFAULT_MSG
SQLITE3_LIBRARIES
SQLITE3_INCLUDE_DIR)
if(NOT SQLITE3_FOUND)
message(STATUS "SQLite3 not found (SQLITE3_INCLUDE_DIR=${SQLITE3_INCLUDE_DIR}, SQLITE3_LIBRARY=${SQLITE3_LIBRARY}.")
endif()
mark_as_advanced(SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR SQLITE3_LIBRARIES)

View File

@@ -1,3 +0,0 @@
@PACKAGE_INIT@
include(${CMAKE_CURRENT_LIST_DIR}/SOCITargets.cmake)

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@SOCI_PLATFORM_NAME@'">
<LocalDebuggerCommandArguments>@SOCI_TEST_CMD_ARGS@</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,43 @@
include(soci_utils)
# This function extracts the current SOCI version from the version header file
#
# Use as
# soci_parse_version(
# ROOT_DIR <root_dir>
# OUTPUT_VARIABLE <var_name>
# )
# where
# - <root_dir> is the path to SOCI's source tree root directory
# - <var_name> is the name of the variable used to make the parsed version available. This variable
# will contain the version in a cmake-compatible format
function(soci_parse_version)
set(FLAGS "")
set(ONE_VAL_OPTIONS "OUTPUT_VARIABLE" "ROOT_DIR")
set(MULTI_VAL_OPTIONS "")
cmake_parse_arguments(PARSE_VERSION "${FLAGS}" "${ONE_VAL_OPTIONS}" "${MULTI_VAL_OPTIONS}" ${ARGV})
soci_verify_parsed_arguments(
PREFIX "PARSE_VERSION"
FUNCTION_NAME "soci_parse_version"
REQUIRED "OUTPUT_VARIABLE" "ROOT_DIR"
)
set(VERSION_REGEX "^#define[ \\t]*SOCI_VERSION[ \\t]*([0-9]+)")
file(STRINGS "${PARSE_VERSION_ROOT_DIR}/include/soci/version.h" VERSION_LINE
REGEX ${VERSION_REGEX}
LIMIT_COUNT 1
)
if (NOT VERSION_LINE MATCHES "${VERSION_REGEX}")
message(STATUS "${PARSE_VERSION_ROOT_DIR}")
message(FATAL_ERROR "Failed at parsing version from header file")
endif()
set(RAW_VERSION "${CMAKE_MATCH_1}")
math(EXPR MAJOR_VERSION "${RAW_VERSION} / 100000")
math(EXPR MINOR_VERSION "(${RAW_VERSION} / 100) % 1000")
math(EXPR PATCH_VERSION "${RAW_VERSION} % 100")
set("${PARSE_VERSION_OUTPUT_VARIABLE}" "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}" PARENT_SCOPE)
endfunction()

51
cmake/soci_utils.cmake Normal file
View File

@@ -0,0 +1,51 @@
# This function is meant to be called by other cmake functions that use the cmake_parse_arguments function.
# It implements the boilerplate that is associated with validating the parsed arguments (e.g. no unknown arguments used;
# ensuring all required options have been set).
#
# Use as
# soci_verify_parsed_arguments(
# PREFIX <prefix>
# FUNCTION_NAME <name>
# [REQUIRED <option1> <option2> …]
# )
# where
# - <prefix> is the prefix used in the cmake_parse_arguments call that shall be validated
# - <name> is the name of the calling function or macro - this will be part of error mesages
# - <optionN> are names of options **without** the prefix
function(soci_verify_parsed_arguments)
set(FLAGS "")
set(ONE_VAL_OPTIONS "PREFIX" "FUNCTION_NAME")
set(MULTI_VAL_OPTIONS "REQUIRED")
cmake_parse_arguments(VERIFY_PARSED_ARGS "${FLAGS}" "${ONE_VAL_OPTIONS}" "${MULTI_VAL_OPTIONS}" ${ARGV})
# First, verify own arguments
if (DEFINED VERIFY_PARSED_ARGS_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "verify_parsed_arguments - Received unrecognized options: ${VERIFY_PARSED_ARGS_UNPARSED_ARGUMENTS}")
endif()
if (DEFINED VERIFY_PARSED_ARGS_KEYWORDS_MISSING_VALUES)
message(FATAL_ERROR "verify_parsed_arguments - The following options are missing argumens: ${VERIFY_PARSED_ARGS_KEYWORDS_MISSING_VALUES}")
endif()
if (NOT DEFINED VERIFY_PARSED_ARGS_PREFIX)
message(FATAL_ERROR "verify_parsed_arguments - Missing required option 'PREFIX'")
endif()
if (NOT DEFINED VERIFY_PARSED_ARGS_FUNCTION_NAME)
message(FATAL_ERROR "verify_parsed_arguments - Missing required option 'FUNCTION_NAME'")
endif()
# Now start the function's actual job: Verifying a top-level function's call to cmake_parse_arguments
if (DEFINED ${VERIFY_PARSED_ARGS_PREFIX}_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${VERIFY_PARSED_ARGS_FUNCTION_NAME} - Received unrecognized options: ${${PREFIX}_UNPARSED_ARGUMENTS}")
endif()
if (DEFINED ${VERIFY_PARSED_ARGS_PREFIX}_KEYWORDS_MISSING_VALUES)
message(FATAL_ERROR "${VERIFY_PARSED_ARGS_FUNCTION_NAME} - The following options are missing arguments: ${${PREFIX}_KEYWORDS_MISSING_VALUES}")
endif()
if (DEFINED VERIFY_PARSED_ARGS_REQUIRED)
foreach(CURRENT_ARG IN LISTS VERIFY_PARSED_ARGS_REQUIRED)
set(CURRENT_ARG "${VERIFY_PARSED_ARGS_PREFIX}_${CURRENT_ARG}")
if (NOT DEFINED ${CURRENT_ARG})
message(FATAL_ERROR "${VERIFY_PARSED_ARGS_FUNCTION_NAME - Missing required option '${CURRENT_ARG}'")
endif()
endforeach()
endif()
endfunction()

View File

@@ -1,14 +1,2 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2013 Mateusz Loskot <mateusz@loskot.net>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
include_directories(${SOCI_SOURCE_DIR}/include/private)
add_subdirectory(core)
add_subdirectory(backends)

View File

@@ -1,50 +1,41 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2010 Mateusz Loskot
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
colormsg(_HIBLUE_ "Configuring SOCI backend libraries:")
set(SOCI_EMPTY ${PROJECT_IS_TOP_LEVEL} CACHE STRING "Include the 'empty' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'")
# First, we'll investigate what can be found from database engines
foreach(dep ${SOCI_BACKENDS_DB_DEPENDENCIES})
string(TOUPPER ${dep} depUP)
if (WITH_${depUP})
find_package(${dep})
endif()
if(${dep}_FOUND OR ${depUP}_FOUND)
set(${depUP}_FOUND ON)
else()
set(${depUP}_FOUND OFF)
endif()
set(SOCI_HAVE_${depUP} OFF CACHE INTERNAL "${depUP} backend")
set(SOCI_DB2 "AsAvailable" CACHE STRING "Include the 'DB2' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'")
set(SOCI_FIREBIRD "AsAvailable" CACHE STRING "Include the 'Firebird' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'")
set(SOCI_MYSQL "AsAvailable" CACHE STRING "Include the 'MySQL' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'")
set(SOCI_ODBC "AsAvailable" CACHE STRING "Include the 'ODBC' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'")
set(SOCI_ORACLE "AsAvailable" CACHE STRING "Include the 'Oracle' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'")
set(SOCI_POSTGRESQL "AsAvailable" CACHE STRING "Include the 'Postgresql' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'")
set(SOCI_SQLITE3 "AsAvailable" CACHE STRING "Include the 'SQLite3' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'")
set(BACKENDS "empty" "db2" "firebird" "mysql" "odbc" "oracle" "postgresql" "sqlite3")
foreach(CURRENT IN LISTS BACKENDS)
string(TOUPPER "${CURRENT}" CURRENT_UPPER)
# Backwards compatibility with the old cmake setup that used WITH_* variables
# These are now only defined if the user specified them.
if (DEFINED WITH_${CURRENT_UPPER})
message(DEPRECATION "Use of the WITH_${CURRENT_UPPER} option is deprecated - use the new SOCI_${CURRENT_UPPER} instead")
set(SOCI_${CURRENT_UPPER} "${WITH_${CURRENT_UPPER}}" CACHE STRING "")
# Delete the legacy variable from cache
unset(WITH_${CURRENT_UPPER} CACHE)
endif()
if (SOCI_${CURRENT_UPPER} STREQUAL "Enabled")
set(SOCI_${CURRENT_UPPER} ON)
elseif(SOCI_${CURRENT_UPPER} STREQUAL "Disabled")
set(SOCI_${CURRENT_UPPER} OFF)
elseif(SOCI_${CURRENT_UPPER} STREQUAL "AsAvailable")
set(SOCI_${CURRENT_UPPER} ON)
set(SOCI_${CURRENT_UPPER}_AS_AVAILABLE ON CACHE INTERNAL "")
elseif(SOCI_${CURRENT_UPPER} MATCHES "[Oo][Nn]|[Oo][Ff][Ff]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Yy][Ee][Ss]|[Nn][Oo]|[YyNn01]")
# Do nothing - these are already booleans
else()
message(FATAL_ERROR "Unsupported value '${SOCI_${CURRENT_UPPER}}' for option SOCI_${CURRENT_UPPER}")
endif()
if (SOCI_${CURRENT_UPPER})
add_subdirectory(${CURRENT})
endif()
endforeach()
# get all files in backends
file(GLOB backend_dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
# empty backend always on by default
option(SOCI_EMPTY "Build empty backend" ON)
if(SOCI_EMPTY)
set(WITH_EMPTY ON)
set(EMPTY_FOUND ON)
endif()
# enable only found backends
foreach(dir ${backend_dirs})
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt)
string(TOUPPER ${dir} dirUP)
if(${dirUP}_FOUND AND WITH_${dirUP})
add_subdirectory(${dir})
set(SOCI_HAVE_${dirUP} ON CACHE INTERNAL "${dirUP} backend")
endif()
endif()
endif()
endforeach()
message(STATUS "")

View File

@@ -1,14 +1,44 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2011 Denis Chapligin
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
soci_backend(DB2
DEPENDS DB2
DESCRIPTION "SOCI backend for DB2" AUTHORS "Denis Chapligin"
MAINTAINERS "Denis Chapligin")
if (SOCI_DB2_AS_AVAILABLE)
set(REQUIRED_FLAG "")
else()
set(REQUIRED_FLAG "REQUIRED")
endif()
find_package(DB2 ${REQUIRED_FLAG})
if (NOT DB2_FOUND)
message(STATUS "Disabling DB2 backend as the required dependencies were not found")
return()
endif()
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"
)
target_link_libraries(soci_db2_objects PUBLIC DB2::db2)
target_link_libraries(soci_db2_objects PUBLIC soci_core_objects)
target_include_directories(soci_db2_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/private"
"${PROJECT_SOURCE_DIR}/include/soci"
)
if (SOCI_SHARED)
add_library(soci_db2)
target_link_libraries(soci_db2 PUBLIC soci_db2_objects)
add_library(SOCI::shared::DB2 ALIAS soci_db2)
endif()
if (SOCI_STATIC)
add_library(soci_db2_static)
target_link_libraries(soci_db2_static PUBLIC soci_db2_objects)
add_library(SOCI::static::DB2 ALIAS soci_db2_static)
endif()

View File

@@ -1,14 +1,30 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2010 Mateusz Loskot
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
soci_backend(Empty
DESCRIPTION "SOCI backend skeleton for new backends development"
AUTHORS "Maciej Sobczak, Stephen Hutton"
MAINTAINERS "Maciej Sobczak")
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"
)
target_link_libraries(soci_empty_objects PUBLIC soci_core_objects)
target_include_directories(soci_empty_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/private"
"${PROJECT_SOURCE_DIR}/include/soci"
)
if (SOCI_SHARED)
add_library(soci_empty)
target_link_libraries(soci_empty PUBLIC soci_empty_objects)
add_library(SOCI::shared::Empty ALIAS soci_empty)
endif()
if (SOCI_STATIC)
add_library(soci_empty_static)
target_link_libraries(soci_empty_static PUBLIC soci_empty_objects)
add_library(SOCI::static::Empty ALIAS soci_empty_static)
endif()

View File

@@ -1,16 +1,47 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2013 Viacheslav Naydenov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
option(SOCI_FIREBIRD_EMBEDDED "Use the embedded version of Firebird" OFF)
soci_backend(Firebird
DEPENDS Firebird
DESCRIPTION "SOCI backend for Firebird"
AUTHORS "Rafał Bobrowski"
MAINTAINERS "Viacheslav Naydenov")
if (SOCI_FIREBIRD_AS_AVAILABLE)
set(REQUIRED_FLAG "")
else()
set(REQUIRED_FLAG "REQUIRED")
endif()
find_package(Firebird ${REQUIRED_FLAG})
if (NOT Firebird_FOUND)
message(STATUS "Disabling Firebird backend as the required dependencies were not found")
return()
endif()
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"
)
target_link_libraries(soci_firebird_objects PUBLIC Firebird::firebird)
target_link_libraries(soci_firebird_objects PUBLIC soci_core_objects)
target_include_directories(soci_firebird_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/private"
"${PROJECT_SOURCE_DIR}/include/soci"
)
if (SOCI_SHARED)
add_library(soci_firebird)
target_link_libraries(soci_firebird PUBLIC soci_firebird_objects)
add_library(SOCI::shared::Firebird ALIAS soci_firebird)
endif()
if (SOCI_STATIC)
add_library(soci_firebird_static)
target_link_libraries(soci_firebird_static PUBLIC soci_firebird_objects)
add_library(SOCI::static::Firebird ALIAS soci_firebird_static)
endif()

View File

@@ -1,15 +1,45 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2010 Mateusz Loskot
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
soci_backend(MySQL
DEPENDS MySQL
DESCRIPTION "SOCI backend for MySQL"
AUTHORS "Pawel Aleksander Fedorynski"
MAINTAINERS "Pawel Aleksander Fedorynski")
if (SOCI_MYSQL_AS_AVAILABLE)
set(REQUIRED_FLAG "")
else()
set(REQUIRED_FLAG "REQUIRED")
endif()
find_package(MySQL ${REQUIRED_FLAG})
if (NOT MySQL_FOUND)
message(STATUS "Disabling MySQL backend as the required dependencies were not found")
return()
endif()
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"
)
target_link_libraries(soci_mysql_objects PUBLIC MySQL::mysql)
target_link_libraries(soci_mysql_objects PUBLIC soci_core_objects)
target_include_directories(soci_mysql_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/private"
"${PROJECT_SOURCE_DIR}/include/soci"
)
if (SOCI_SHARED)
add_library(soci_mysql)
target_link_libraries(soci_mysql PUBLIC soci_mysql_objects)
add_library(SOCI::shared::MySQL ALIAS soci_mysql)
endif()
if (SOCI_STATIC)
add_library(soci_mysql_static)
target_link_libraries(soci_mysql_static PUBLIC soci_mysql_objects)
add_library(SOCI::static::MySQL ALIAS soci_mysql_static)
endif()

View File

@@ -1,15 +1,44 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2010 Mateusz Loskot
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
soci_backend(ODBC
DEPENDS ODBC
DESCRIPTION "SOCI backend for ODBC"
AUTHORS "Maciej Sobczak, Stephen Hutton, David Courtney"
MAINTAINERS "Vadim Zeitlin, Mateusz Loskot, Maciej Sobczak")
if (SOCI_ODBC_AS_AVAILABLE)
set(REQUIRED_FLAG "")
else()
set(REQUIRED_FLAG "REQUIRED")
endif()
find_package(ODBC ${REQUIRED_FLAG})
if (NOT ODBC_FOUND)
message(STATUS "Disabling ODBC backend as the required dependencies were not found")
return()
endif()
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"
)
target_link_libraries(soci_odbc_objects PUBLIC ODBC::ODBC)
target_link_libraries(soci_odbc_objects PUBLIC soci_core_objects)
target_include_directories(soci_odbc_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/private"
"${PROJECT_SOURCE_DIR}/include/soci"
)
if (SOCI_SHARED)
add_library(soci_odbc)
target_link_libraries(soci_odbc PUBLIC soci_odbc_objects)
add_library(SOCI::shared::ODBC ALIAS soci_odbc)
endif()
if (SOCI_STATIC)
add_library(soci_odbc_static)
target_link_libraries(soci_odbc_static PUBLIC soci_odbc_objects)
add_library(SOCI::static::ODBC ALIAS soci_odbc_static)
endif()

View File

@@ -1,15 +1,46 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2010 Mateusz Loskot
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
soci_backend(Oracle
DEPENDS Oracle
DESCRIPTION "SOCI backend for Oracle 10+"
AUTHORS "Maciej Sobczak, Stephen Hutton"
MAINTAINERS "Maciej Sobczak")
if (SOCI_ORACLE_AS_AVAILABLE)
set(REQUIRED_FLAG "")
else()
set(REQUIRED_FLAG "REQUIRED")
endif()
find_package(Oracle ${REQUIRED_FLAG})
if (NOT Oracle_FOUND)
message(STATUS "Disabling Oracle backend as the required dependencies were not found")
return()
endif()
add_library(soci_oracle_objects OBJECT
"blob.cpp"
"clob.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_objects PUBLIC Oracle::oracle)
target_link_libraries(soci_oracle_objects PUBLIC soci_core_objects)
target_include_directories(soci_oracle_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/private"
"${PROJECT_SOURCE_DIR}/include/soci"
)
if (SOCI_SHARED)
add_library(soci_oracle)
target_link_libraries(soci_oracle PUBLIC soci_oracle_objects)
add_library(SOCI::shared::Oracle ALIAS soci_oracle)
endif()
if (SOCI_STATIC)
add_library(soci_oracle_static)
target_link_libraries(soci_oracle_static PUBLIC soci_oracle_objects)
add_library(SOCI::static::Oracle ALIAS soci_oracle_static)
endif()

View File

@@ -1,32 +1,59 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2010 Mateusz Loskot <mateusz@loskot.net>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
if (SOCI_POSTGRESQL_AS_AVAILABLE)
set(REQUIRED_FLAG "")
else()
set(REQUIRED_FLAG "REQUIRED")
endif()
include(CMakeDependentOption)
find_package(PostgreSQL ${REQUIRED_FLAG})
if (NOT PostgreSQL_FOUND)
message(STATUS "Disabling PostgreSQL backend as the required dependencies were not found")
return()
endif()
option(SOCI_POSTGRESQL_NO_LO64
"Do not use lo_xxx64() functions for compatibility with PostgreSQL < 9.3"
OFF)
OFF
)
if (POSTGRESQL_VERSION VERSION_LESS "9.3.0")
set(SOCI_POSTGRESQL_NO_LO64 ON CACHE BOOL "Avoid using lo_xxx64() functions" FORCE)
endif()
if(SOCI_POSTGRESQL_NO_LO64)
add_definitions(-DSOCI_POSTGRESQL_NO_LO64=1)
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"
)
target_link_libraries(soci_postgresql_objects PUBLIC PostgreSQL::PostgreSQL)
target_link_libraries(soci_postgresql_objects PUBLIC soci_core_objects)
target_include_directories(soci_postgresql_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/private"
"${PROJECT_SOURCE_DIR}/include/soci"
)
if (SOCI_SHARED)
add_library(soci_postgresql)
target_link_libraries(soci_postgresql PUBLIC soci_postgresql_objects)
add_library(SOCI::shared::PostgreSQL ALIAS soci_postgresql)
if (SOCI_POSTGRESQL_NO_LO64)
target_compile_definitions(soci_postgresql INTERFACE SOCI_POSTGRESQL_NO_LO64)
endif()
endif()
if (SOCI_STATIC)
add_library(soci_postgresql_static)
target_link_libraries(soci_postgresql_static PUBLIC soci_postgresql_objects)
add_library(SOCI::static::PostgreSQL ALIAS soci_postgresql_static)
if (SOCI_POSTGRESQL_NO_LO64)
target_compile_definitions(soci_postgresql_static INTERFACE SOCI_POSTGRESQL_NO_LO64)
endif()
endif()
soci_backend(PostgreSQL
DEPENDS PostgreSQL
DESCRIPTION "SOCI backend for PostgreSQL"
AUTHORS "Maciej Sobczak, Stephen Hutton"
MAINTAINERS "Mateusz Loskot")
boost_report_value(SOCI_POSTGRESQL_NO_LO64)

View File

@@ -1,16 +1,45 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2010 Mateusz Loskot <mateusz@loskot.net>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
if (SOCI_SQLITE3_AS_AVAILABLE)
set(REQUIRED_FLAG "")
else()
set(REQUIRED_FLAG "REQUIRED")
endif()
soci_backend(SQLite3
DEPENDS SQLite3
DESCRIPTION "SOCI backend for SQLite 3"
AUTHORS "Maciej Sobczak, Stephen Hutton, David Courtney"
MAINTAINERS "Maciej Sobczak, Mateusz Loskot")
find_package(SQLite3 ${REQUIRED_FLAG})
if (NOT SQLite3_FOUND)
message(STATUS "Disabling SQLite3 backend as the required dependencies were not found")
return()
endif()
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"
)
target_link_libraries(soci_sqlite3_objects PUBLIC SQLite::SQLite3)
target_link_libraries(soci_sqlite3_objects PUBLIC soci_core_objects)
target_include_directories(soci_sqlite3_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/private"
"${PROJECT_SOURCE_DIR}/include/soci"
)
if (SOCI_SHARED)
add_library(soci_sqlite3)
target_link_libraries(soci_sqlite3 PUBLIC soci_sqlite3_objects)
add_library(SOCI::shared::SQLite3 ALIAS soci_sqlite3)
endif()
if (SOCI_STATIC)
add_library(soci_sqlite3_static)
target_link_libraries(soci_sqlite3_static PUBLIC soci_sqlite3_objects)
add_library(SOCI::static::SQLite3 ALIAS soci_sqlite3_static)
endif()

View File

@@ -1,151 +1,64 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2009-2013 Mateusz Loskot <mateusz@loskot.net>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
colormsg(_HIBLUE_ "Configuring SOCI core library:")
find_package(Threads REQUIRED)
include(CMakePackageConfigHelpers)
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-statement.cpp"
"row.cpp"
"rowid.cpp"
"session.cpp"
"soci-simple.cpp"
"statement.cpp"
"transaction.cpp"
"use-type.cpp"
"values.cpp"
)
# Set INCLUDE_DIRECTORIES
get_directory_property(SOCI_CORE_INCLUDE_DIRS INCLUDE_DIRECTORIES)
list(APPEND SOCI_CORE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
set_directory_properties(PROPERTIES
INCLUDE_DIRECTORIES "${SOCI_CORE_INCLUDE_DIRS}")
target_link_libraries(soci_core_objects PRIVATE Threads::Threads)
# Configure backend loader to also use default install directory.
configure_file(soci_backends_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/soci_backends_config.h)
if (SOCI_BOOST)
find_package(Boost REQUIRED)
target_link_libraries(soci_core_objects PUBLIC Boost::boost)
target_compile_definitions(soci_core_objects PUBLIC SOCI_HAVE_BOOST)
# Core source files
file(GLOB SOCI_CORE_HEADERS ${SOCI_SOURCE_DIR}/include/soci/*.h)
file(GLOB SOCI_CORE_SOURCES *.cpp)
# Group source files for IDE source explorers (e.g. Visual Studio)
source_group("Header Files" FILES ${SOCI_CORE_HEADERS})
source_group("Source Files" FILES ${SOCI_CORE_SOURCES})
source_group("CMake Files" FILES CMakeLists.txt)
# Core targets configuration
string(TOLOWER "${PROJECT_NAME}" PROJECTNAMEL)
#this command will update parent scope variable
set(SOCI_CORE_TARGET ${PROJECTNAMEL}_core PARENT_SCOPE)
set(SOCI_CORE_TARGET ${PROJECTNAMEL}_core)
soci_target_output_name(${SOCI_CORE_TARGET} SOCI_CORE_TARGET_OUTPUT_NAME)
#
# Core shared library
#
if (SOCI_SHARED)
add_library(${SOCI_CORE_TARGET} SHARED ${SOCI_CORE_HEADERS} ${SOCI_CORE_SOURCES})
add_library(Soci::core ALIAS ${SOCI_CORE_TARGET})
target_link_libraries(${SOCI_CORE_TARGET} ${SOCI_CORE_DEPS_LIBS})
if(WIN32)
set_target_properties(${SOCI_CORE_TARGET}
PROPERTIES
DEFINE_SYMBOL SOCI_DLL
OUTPUT_NAME "${SOCI_CORE_TARGET_OUTPUT_NAME}"
VERSION ${SOCI_VERSION}
CLEAN_DIRECT_OUTPUT 1)
else()
set_target_properties(${SOCI_CORE_TARGET}
PROPERTIES
VERSION ${SOCI_VERSION}
SOVERSION ${SOCI_SOVERSION}
INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib
CLEAN_DIRECT_OUTPUT 1)
if (TARGET Boost::date_time)
target_link_libraries(soci_core_objects PUBLIC Boost::date_time)
target_compile_definitions(soci_core_objects PUBLIC SOCI_HAVE_BOOST_DATE_TIME)
endif()
target_include_directories(${SOCI_CORE_TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../../include>
$<INSTALL_INTERFACE:include>
)
endif()
# This adds definitions to all build configurations. SOCI_DEBUG_POSTFIX is passed to soci library
add_definitions(-DSOCI_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}soci_"
-DSOCI_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"
-DSOCI_DEBUG_POSTFIX="${CMAKE_DEBUG_POSTFIX}")
target_include_directories(soci_core_objects PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_include_directories(soci_core_objects
PRIVATE
"${PROJECT_SOURCE_DIR}/include/soci"
"${PROJECT_SOURCE_DIR}/include/private"
)
#
# Core static library
#
if (SOCI_STATIC)
set(SOCI_CORE_TARGET_STATIC ${SOCI_CORE_TARGET}_static)
target_compile_definitions(soci_core_objects
PRIVATE
DEFAULT_BACKENDS_PATH="${CMAKE_INSTALL_FULL_LIBDIR}"
# TODO: Configure prefix and suffix properly
SOCI_LIB_PREFIX=""
SOCI_LIB_SUFFIX=""
)
add_library(${SOCI_CORE_TARGET_STATIC} STATIC
${SOCI_CORE_HEADERS} ${SOCI_CORE_SOURCES})
add_library(Soci::core_static ALIAS ${SOCI_CORE_TARGET_STATIC})
# we still need to link against dl if we have it
target_link_libraries (${SOCI_CORE_TARGET_STATIC}
${SOCI_CORE_DEPS_LIBS}
)
set_target_properties(${SOCI_CORE_TARGET_STATIC}
PROPERTIES
OUTPUT_NAME ${SOCI_CORE_TARGET_OUTPUT_NAME}
PREFIX "lib"
CLEAN_DIRECT_OUTPUT 1)
target_include_directories(${SOCI_CORE_TARGET_STATIC}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../../include>
$<INSTALL_INTERFACE:include>
)
endif()
#
# Core installation
#
install(FILES ${SOCI_CORE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECTNAMEL})
if (SOCI_SHARED)
install(TARGETS ${SOCI_CORE_TARGET}
EXPORT SOCI
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
add_library(soci_core SHARED)
target_link_libraries(soci_core PUBLIC soci_core_objects)
add_library(SOCI::shared::core ALIAS soci_core)
endif()
if (SOCI_STATIC)
install(TARGETS ${SOCI_CORE_TARGET_STATIC}
EXPORT SOCI
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
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)
endif()
install(EXPORT SOCI NAMESPACE SOCI:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SOCI FILE SOCITargets.cmake)
configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/resources/SOCIConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/SOCIConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SOCI)
write_basic_package_version_file(SOCIConfigVersion.cmake VERSION ${SOCI_VERSION} COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SOCIConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/SOCIConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SOCI)
#
# Core configuration summary
#
boost_report_value(SOCI_CORE_TARGET)
boost_report_value(SOCI_CORE_TARGET_OUTPUT_NAME)
boost_report_value(SOCI_CORE_DEPS_LIBS)
boost_report_value(SOCI_CORE_INCLUDE_DIRS)
boost_report_value(WITH_BOOST)
soci_report_directory_property(COMPILE_DEFINITIONS)
message(STATUS "")

View File

@@ -17,8 +17,6 @@
#include <stdint.h>
#endif
#include "soci_backends_config.h"
using namespace soci;
using namespace soci::dynamic_backends;

View File

@@ -1,12 +0,0 @@
//
// Copyright (C) 2011 Alex Ott <alexott@gmail.com>
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SOCI_BACKENDS_CONFIG_H
#define SOCI_BACKENDS_CONFIG_H
#define DEFAULT_BACKENDS_PATH "@CMAKE_INSTALL_FULL_LIBDIR@"
#endif // SOCI_BACKENDS_CONFIG_H

View File

@@ -1,34 +0,0 @@
###############################################################################
#
# This file is part of CMake configuration for SOCI library
#
# Copyright (C) 2013 Mateusz Loskot <mateusz@loskot.net>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
###############################################################################
colormsg(_HIBLUE_ "Configuring SOCI tests:")
# This works around a problem when building in C++11 mode with clang (see #984).
add_definitions(-DCATCH_CONFIG_CPP11_NO_SHUFFLE)
if(MSVC)
add_compile_options(/bigobj)
endif()
include_directories(
${SOCI_SOURCE_DIR}/include/private
${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB SOCI_TESTS_COMMON common-tests.h)
add_subdirectory(empty)
add_subdirectory(db2)
add_subdirectory(firebird)
add_subdirectory(mysql)
add_subdirectory(odbc)
add_subdirectory(oracle)
add_subdirectory(postgresql)
add_subdirectory(sqlite3)