Commit 6908e473 authored by ArnaudD-FR's avatar ArnaudD-FR Committed by adesmier

Specify definitions in soci-config.h

 * replace all commmand line definition as -DHAS_BOOST, -DHAS_SQLITE3 by
   soci-config.h
parent a3e3f967
......@@ -93,12 +93,13 @@ if(Boost_FOUND)
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY COMPILE_DEFINITIONS)
list(APPEND SOCI_COMPILE_DEFINITIONS "HAVE_BOOST=1")
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})
list(APPEND SOCI_COMPILE_DEFINITIONS "HAVE_BOOST_DATE_TIME=1")
set(SOCI_HAVE_BOOST_DATE_TIME ON)
endif()
list(APPEND SOCI_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
......@@ -108,8 +109,14 @@ if(Boost_FOUND)
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}
......@@ -133,12 +140,22 @@ set(LIBDIR ${SOCI_LIBDIR} CACHE PATH "The directory to install libraries into.")
set(DATADIR "share" CACHE PATH "The directory to install data files into.")
set(INCLUDEDIR "include" CACHE PATH "The directory to install includes into.")
###############################################################################
# Configuration files
###############################################################################
set(CONFIG_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
install(DIRECTORY ${CONFIG_INCLUDE_DIR}/soci DESTINATION ${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)
include_directories(${SOCI_SOURCE_DIR}/include ${CONFIG_INCLUDE_DIR})
add_subdirectory(src)
if(SOCI_TESTS)
......@@ -163,5 +180,24 @@ if(SOCI_TESTS)
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 "")
......@@ -22,7 +22,6 @@ macro(soci_backend_deps_found NAME DEPS SUCCESS)
# Determine required dependencies
set(DEPS_INCLUDE_DIRS)
set(DEPS_LIBRARIES)
set(DEPS_DEFS)
set(DEPS_NOT_FOUND)
# CMake 2.8+ syntax only:
......@@ -40,7 +39,6 @@ macro(soci_backend_deps_found NAME DEPS SUCCESS)
list(APPEND DEPS_INCLUDE_DIRS ${${DEPU}_INCLUDE_DIRS})
endif()
list(APPEND DEPS_LIBRARIES ${${DEPU}_LIBRARIES})
list(APPEND DEPS_DEFS HAVE_${DEPU}=1)
endif()
endforeach()
......@@ -51,7 +49,6 @@ macro(soci_backend_deps_found NAME DEPS SUCCESS)
else()
set(${NAME}_DEPS_INCLUDE_DIRS ${DEPS_INCLUDE_DIRS})
set(${NAME}_DEPS_LIBRARIES ${DEPS_LIBRARIES})
set(${NAME}_DEPS_DEFS ${DEPS_DEFS})
set(${SUCCESS} True)
endif()
......
......@@ -5,14 +5,15 @@
#include "into-type.h"
#include "into.h"
#include "soci-backend.h"
#include <soci/soci-config.h>
#include "use-type.h"
#include "use.h"
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
# include <boost/fusion/algorithm/iteration/for_each.hpp>
# include <boost/mpl/bool.hpp>
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
#include <vector>
namespace soci
......@@ -35,15 +36,15 @@ public:
template <typename T, typename Indicator>
void exchange(use_container<T, Indicator> const &uc)
{
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
exchange_(uc, (typename boost::fusion::traits::is_sequence<T>::type *)NULL);
#else
exchange_(uc, NULL);
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
}
private:
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
template <typename T, typename Indicator>
struct use_sequence
{
......@@ -91,7 +92,7 @@ private:
boost::fusion::for_each(uc.t, use_sequence<T, details::no_indicator>(*this));
}
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
template <typename T, typename Indicator>
void exchange_(use_container<T, Indicator> const &uc, ...)
......@@ -125,15 +126,15 @@ public:
template <typename T, typename Indicator>
void exchange(into_container<T, Indicator> const &ic)
{
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
exchange_(ic, (typename boost::fusion::traits::is_sequence<T>::type *)NULL);
#else
exchange_(ic, NULL);
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
}
private:
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
template <typename T, typename Indicator>
struct into_sequence
{
......@@ -180,7 +181,7 @@ private:
{
boost::fusion::for_each(ic.t, into_sequence<T, details::no_indicator>(*this));
}
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
template <typename T, typename Indicator>
void exchange_(into_container<T, Indicator> const &ic, ...)
......
......@@ -10,4 +10,9 @@
#include "soci/soci-platform.h"
//
// SOCI has been build with support for:
//
@CONFIGURED_VARIABLES@
#endif // SOCICONFIG_H_INCLUDED
......@@ -9,7 +9,7 @@
#define SOCI_H_INCLUDED
// namespace soci
#include "soci/soci-platform.h"
#include "soci/soci-config.h"
#include "soci/backend-loader.h"
#include "soci/blob.h"
#include "soci/blob-exchange.h"
......
......@@ -21,6 +21,7 @@ foreach(dep ${SOCI_BACKENDS_DB_DEPENDENCIES})
else()
set(${depUP}_FOUND OFF)
endif()
set(SOCI_HAVE_${depUP} OFF CACHE INTERNAL "${depUP} backend")
endforeach()
# get all files in backends
......@@ -40,6 +41,7 @@ foreach(dir ${backend_dirs})
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()
......
......@@ -10,7 +10,7 @@
#include "soci/soci.h"
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
// explicitly pull conversions for Boost's optional, tuple and fusion:
#include <boost/version.hpp>
#include "soci/boost-optional.h"
......@@ -19,7 +19,7 @@
#if defined(BOOST_VERSION) && BOOST_VERSION >= 103500
#include "soci/boost-fusion.h"
#endif // BOOST_VERSION
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
#include "soci-compiler.h"
......@@ -2877,7 +2877,7 @@ TEST_CASE_METHOD(common_tests, "Dynamic binding with rowset", "[core][dynamic][t
}
}
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
// test for handling NULL values with boost::optional
// (both into and use)
......@@ -3214,7 +3214,7 @@ TEST_CASE_METHOD(common_tests, "NULL with optional", "[core][boost][null]")
}
}
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
// connection and reconnection tests
TEST_CASE_METHOD(common_tests, "Connection and reconnection", "[core][connect]")
......@@ -3282,7 +3282,7 @@ TEST_CASE_METHOD(common_tests, "Connection and reconnection", "[core][connect]")
}
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
TEST_CASE_METHOD(common_tests, "Boost tuple", "[core][boost][tuple]")
{
......@@ -3634,7 +3634,7 @@ TEST_CASE_METHOD(common_tests, "Boost date", "[core][boost][datetime]")
}
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
// connection pool - simple sequential test, no multiple threads
TEST_CASE_METHOD(common_tests, "Connection pool", "[core][connection][pool]")
......
......@@ -16,7 +16,7 @@
using namespace soci;
using namespace soci::tests;
#ifdef HAVE_BOOST
#ifdef SOCI_HAVE_BOOST
// It appears later versions of GCC arent happy with this - to be fixed properly
#if (__GNUC__ == 4 && (__GNUC_MINOR__ > 6)) || (__clang__ == 1)
#include <boost/optional.hpp>
......@@ -31,7 +31,7 @@ namespace boost {
}
}
#endif
#endif // HAVE_BOOST
#endif // SOCI_HAVE_BOOST
std::string connectString;
backend_factory const &backEnd = *soci::factory_odbc();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment