From ae71c48ffcbfe8ce3437c5d3e41584ed30cb88e3 Mon Sep 17 00:00:00 2001 From: bibo38 Date: Sat, 9 Dec 2017 14:10:58 +0100 Subject: [PATCH 1/2] Now using nullptr in the headers, if it is supported by the compiler --- CMakeLists.txt | 12 +++++++++++- include/SQLiteCpp/Database.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b61d1537..9674dd2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # # Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt # or copy at http://opensource.org/licenses/MIT) -cmake_minimum_required(VERSION 2.8.12) # first version with add_compile_options() +cmake_minimum_required(VERSION 3.1) # first version with the WriteCompilerDetectionHeader module project(SQLiteCpp) message (STATUS "CMake version: ${CMAKE_VERSION}") @@ -168,6 +168,16 @@ source_group(scripts FILES ${SQLITECPP_SCRIPT}) # All includes are relative to the "include" directory include_directories("${PROJECT_SOURCE_DIR}/include") +# Detect some newer C++ features and create a suitable compability header +include(WriteCompilerDetectionHeader) +write_compiler_detection_header( + FILE "${CMAKE_CURRENT_BINARY_DIR}/compability_macros.h" + PREFIX COMPABILITY + COMPILERS GNU Clang MSVC + FEATURES cxx_nullptr +) +include_directories("${CMAKE_CURRENT_BINARY_DIR}") + # add sources of the wrapper as a "SQLiteCpp" static library add_library(SQLiteCpp ${SQLITECPP_SRC} ${SQLITECPP_INC} ${SQLITECPP_DOC} ${SQLITECPP_SCRIPT}) # make the sqlite3 library part of the interface of the SQLiteCpp wrapper itself (the client app does not need to link to sqlite3) diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index e2177c4b..a633b94e 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -11,6 +11,7 @@ #pragma once #include +#include #include @@ -95,7 +96,7 @@ class Database Database(const char* apFilename, const int aFlags = SQLite::OPEN_READONLY, const int aBusyTimeoutMs = 0, - const char* apVfs = NULL); + const char* apVfs = COMPABILITY_NULLPTR); /** * @brief Open the provided database UTF-8 filename. From 2a0d13d2b114c80c0b4aaf08671e5db42cbdcb39 Mon Sep 17 00:00:00 2001 From: bibo38 Date: Sat, 9 Dec 2017 15:08:18 +0100 Subject: [PATCH 2/2] Directly added the generated files to keep the CMake version requirement low --- CMakeLists.txt | 12 +- include/SQLiteCpp/Database.h | 2 +- include/SQLiteCpp/compability_macros.h | 249 +++++++++++++++++++++++++ 3 files changed, 251 insertions(+), 12 deletions(-) create mode 100644 include/SQLiteCpp/compability_macros.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9674dd2a..b61d1537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # # Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt # or copy at http://opensource.org/licenses/MIT) -cmake_minimum_required(VERSION 3.1) # first version with the WriteCompilerDetectionHeader module +cmake_minimum_required(VERSION 2.8.12) # first version with add_compile_options() project(SQLiteCpp) message (STATUS "CMake version: ${CMAKE_VERSION}") @@ -168,16 +168,6 @@ source_group(scripts FILES ${SQLITECPP_SCRIPT}) # All includes are relative to the "include" directory include_directories("${PROJECT_SOURCE_DIR}/include") -# Detect some newer C++ features and create a suitable compability header -include(WriteCompilerDetectionHeader) -write_compiler_detection_header( - FILE "${CMAKE_CURRENT_BINARY_DIR}/compability_macros.h" - PREFIX COMPABILITY - COMPILERS GNU Clang MSVC - FEATURES cxx_nullptr -) -include_directories("${CMAKE_CURRENT_BINARY_DIR}") - # add sources of the wrapper as a "SQLiteCpp" static library add_library(SQLiteCpp ${SQLITECPP_SRC} ${SQLITECPP_INC} ${SQLITECPP_DOC} ${SQLITECPP_SCRIPT}) # make the sqlite3 library part of the interface of the SQLiteCpp wrapper itself (the client app does not need to link to sqlite3) diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index a633b94e..9fd790a8 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -11,7 +11,7 @@ #pragma once #include -#include +#include #include diff --git a/include/SQLiteCpp/compability_macros.h b/include/SQLiteCpp/compability_macros.h new file mode 100644 index 00000000..dadf726e --- /dev/null +++ b/include/SQLiteCpp/compability_macros.h @@ -0,0 +1,249 @@ +// Generated by CMake 3.9.6 using the following commands: +// include(WriteCompilerDetectionHeader) +// write_compiler_detection_header( +// FILE "${CMAKE_CURRENT_BINARY_DIR}/compability_macros.h" +// PREFIX COMPABILITY +// COMPILERS GNU Clang MSVC Intel +// FEATURES cxx_nullptr +// ALLOW_UNKNOWN_COMPILERS +// ALLOW_UNKNOWN_COMPILER_VERSIONS +// ) + +// This is a generated file. Do not edit! + +#ifndef COMPABILITY_COMPILER_DETECTION_H +#define COMPABILITY_COMPILER_DETECTION_H + +#ifdef __cplusplus +# define COMPABILITY_COMPILER_IS_Comeau 0 +# define COMPABILITY_COMPILER_IS_Intel 0 +# define COMPABILITY_COMPILER_IS_PathScale 0 +# define COMPABILITY_COMPILER_IS_Embarcadero 0 +# define COMPABILITY_COMPILER_IS_Borland 0 +# define COMPABILITY_COMPILER_IS_Watcom 0 +# define COMPABILITY_COMPILER_IS_OpenWatcom 0 +# define COMPABILITY_COMPILER_IS_SunPro 0 +# define COMPABILITY_COMPILER_IS_HP 0 +# define COMPABILITY_COMPILER_IS_Compaq 0 +# define COMPABILITY_COMPILER_IS_zOS 0 +# define COMPABILITY_COMPILER_IS_XL 0 +# define COMPABILITY_COMPILER_IS_VisualAge 0 +# define COMPABILITY_COMPILER_IS_PGI 0 +# define COMPABILITY_COMPILER_IS_Cray 0 +# define COMPABILITY_COMPILER_IS_TI 0 +# define COMPABILITY_COMPILER_IS_Fujitsu 0 +# define COMPABILITY_COMPILER_IS_SCO 0 +# define COMPABILITY_COMPILER_IS_AppleClang 0 +# define COMPABILITY_COMPILER_IS_Clang 0 +# define COMPABILITY_COMPILER_IS_GNU 0 +# define COMPABILITY_COMPILER_IS_MSVC 0 +# define COMPABILITY_COMPILER_IS_ADSP 0 +# define COMPABILITY_COMPILER_IS_IAR 0 +# define COMPABILITY_COMPILER_IS_ARMCC 0 +# define COMPABILITY_COMPILER_IS_MIPSpro 0 + +#if defined(__COMO__) +# undef COMPABILITY_COMPILER_IS_Comeau +# define COMPABILITY_COMPILER_IS_Comeau 1 + +#elif defined(__INTEL_COMPILER) || defined(__ICC) +# undef COMPABILITY_COMPILER_IS_Intel +# define COMPABILITY_COMPILER_IS_Intel 1 + +#elif defined(__PATHCC__) +# undef COMPABILITY_COMPILER_IS_PathScale +# define COMPABILITY_COMPILER_IS_PathScale 1 + +#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) +# undef COMPABILITY_COMPILER_IS_Embarcadero +# define COMPABILITY_COMPILER_IS_Embarcadero 1 + +#elif defined(__BORLANDC__) +# undef COMPABILITY_COMPILER_IS_Borland +# define COMPABILITY_COMPILER_IS_Borland 1 + +#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 +# undef COMPABILITY_COMPILER_IS_Watcom +# define COMPABILITY_COMPILER_IS_Watcom 1 + +#elif defined(__WATCOMC__) +# undef COMPABILITY_COMPILER_IS_OpenWatcom +# define COMPABILITY_COMPILER_IS_OpenWatcom 1 + +#elif defined(__SUNPRO_CC) +# undef COMPABILITY_COMPILER_IS_SunPro +# define COMPABILITY_COMPILER_IS_SunPro 1 + +#elif defined(__HP_aCC) +# undef COMPABILITY_COMPILER_IS_HP +# define COMPABILITY_COMPILER_IS_HP 1 + +#elif defined(__DECCXX) +# undef COMPABILITY_COMPILER_IS_Compaq +# define COMPABILITY_COMPILER_IS_Compaq 1 + +#elif defined(__IBMCPP__) && defined(__COMPILER_VER__) +# undef COMPABILITY_COMPILER_IS_zOS +# define COMPABILITY_COMPILER_IS_zOS 1 + +#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800 +# undef COMPABILITY_COMPILER_IS_XL +# define COMPABILITY_COMPILER_IS_XL 1 + +#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800 +# undef COMPABILITY_COMPILER_IS_VisualAge +# define COMPABILITY_COMPILER_IS_VisualAge 1 + +#elif defined(__PGI) +# undef COMPABILITY_COMPILER_IS_PGI +# define COMPABILITY_COMPILER_IS_PGI 1 + +#elif defined(_CRAYC) +# undef COMPABILITY_COMPILER_IS_Cray +# define COMPABILITY_COMPILER_IS_Cray 1 + +#elif defined(__TI_COMPILER_VERSION__) +# undef COMPABILITY_COMPILER_IS_TI +# define COMPABILITY_COMPILER_IS_TI 1 + +#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) +# undef COMPABILITY_COMPILER_IS_Fujitsu +# define COMPABILITY_COMPILER_IS_Fujitsu 1 + +#elif defined(__SCO_VERSION__) +# undef COMPABILITY_COMPILER_IS_SCO +# define COMPABILITY_COMPILER_IS_SCO 1 + +#elif defined(__clang__) && defined(__apple_build_version__) +# undef COMPABILITY_COMPILER_IS_AppleClang +# define COMPABILITY_COMPILER_IS_AppleClang 1 + +#elif defined(__clang__) +# undef COMPABILITY_COMPILER_IS_Clang +# define COMPABILITY_COMPILER_IS_Clang 1 + +#elif defined(__GNUC__) || defined(__GNUG__) +# undef COMPABILITY_COMPILER_IS_GNU +# define COMPABILITY_COMPILER_IS_GNU 1 + +#elif defined(_MSC_VER) +# undef COMPABILITY_COMPILER_IS_MSVC +# define COMPABILITY_COMPILER_IS_MSVC 1 + +#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) +# undef COMPABILITY_COMPILER_IS_ADSP +# define COMPABILITY_COMPILER_IS_ADSP 1 + +#elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) +# undef COMPABILITY_COMPILER_IS_IAR +# define COMPABILITY_COMPILER_IS_IAR 1 + +#elif defined(__ARMCC_VERSION) +# undef COMPABILITY_COMPILER_IS_ARMCC +# define COMPABILITY_COMPILER_IS_ARMCC 1 + +#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) +# undef COMPABILITY_COMPILER_IS_MIPSpro +# define COMPABILITY_COMPILER_IS_MIPSpro 1 + + +#endif + +# if COMPABILITY_COMPILER_IS_GNU + +# if defined(__GNUC__) +# define COMPABILITY_COMPILER_VERSION_MAJOR (__GNUC__) +# else +# define COMPABILITY_COMPILER_VERSION_MAJOR (__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define COMPABILITY_COMPILER_VERSION_MINOR (__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define COMPABILITY_COMPILER_VERSION_PATCH (__GNUC_PATCHLEVEL__) +# endif + +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) +# define COMPABILITY_COMPILER_CXX_NULLPTR 1 +# else +# define COMPABILITY_COMPILER_CXX_NULLPTR 0 +# endif + +# elif COMPABILITY_COMPILER_IS_Clang + +# define COMPABILITY_COMPILER_VERSION_MAJOR (__clang_major__) +# define COMPABILITY_COMPILER_VERSION_MINOR (__clang_minor__) +# define COMPABILITY_COMPILER_VERSION_PATCH (__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define COMPABILITY_SIMULATE_VERSION_MAJOR (_MSC_VER / 100) +# define COMPABILITY_SIMULATE_VERSION_MINOR (_MSC_VER % 100) +# endif + +# if ((__clang_major__ * 100) + __clang_minor__) >= 301 && __has_feature(cxx_nullptr) +# define COMPABILITY_COMPILER_CXX_NULLPTR 1 +# else +# define COMPABILITY_COMPILER_CXX_NULLPTR 0 +# endif + +# elif COMPABILITY_COMPILER_IS_MSVC + + /* _MSC_VER = VVRR */ +# define COMPABILITY_COMPILER_VERSION_MAJOR (_MSC_VER / 100) +# define COMPABILITY_COMPILER_VERSION_MINOR (_MSC_VER % 100) +# if defined(_MSC_FULL_VER) +# if _MSC_VER >= 1400 + /* _MSC_FULL_VER = VVRRPPPPP */ +# define COMPABILITY_COMPILER_VERSION_PATCH (_MSC_FULL_VER % 100000) +# else + /* _MSC_FULL_VER = VVRRPPPP */ +# define COMPABILITY_COMPILER_VERSION_PATCH (_MSC_FULL_VER % 10000) +# endif +# endif +# if defined(_MSC_BUILD) +# define COMPABILITY_COMPILER_VERSION_TWEAK (_MSC_BUILD) +# endif + +# if _MSC_VER >= 1600 +# define COMPABILITY_COMPILER_CXX_NULLPTR 1 +# else +# define COMPABILITY_COMPILER_CXX_NULLPTR 0 +# endif + +# elif COMPABILITY_COMPILER_IS_Intel + + /* __INTEL_COMPILER = VRP */ +# define COMPABILITY_COMPILER_VERSION_MAJOR (__INTEL_COMPILER/100) +# define COMPABILITY_COMPILER_VERSION_MINOR (__INTEL_COMPILER/10 % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define COMPABILITY_COMPILER_VERSION_PATCH (__INTEL_COMPILER_UPDATE) +# else +# define COMPABILITY_COMPILER_VERSION_PATCH (__INTEL_COMPILER % 10) +# endif +# if defined(__INTEL_COMPILER_BUILD_DATE) + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ +# define COMPABILITY_COMPILER_VERSION_TWEAK (__INTEL_COMPILER_BUILD_DATE) +# endif +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define COMPABILITY_SIMULATE_VERSION_MAJOR (_MSC_VER / 100) +# define COMPABILITY_SIMULATE_VERSION_MINOR (_MSC_VER % 100) +# endif + +# if __INTEL_COMPILER >= 1210 && ((__cplusplus >= 201103L) || defined(__INTEL_CXX11_MODE__) || defined(__GXX_EXPERIMENTAL_CXX0X__)) +# define COMPABILITY_COMPILER_CXX_NULLPTR 1 +# else +# define COMPABILITY_COMPILER_CXX_NULLPTR 0 +# endif + +# endif + +# if defined(COMPABILITY_COMPILER_CXX_NULLPTR) && COMPABILITY_COMPILER_CXX_NULLPTR +# define COMPABILITY_NULLPTR nullptr +# else +# define COMPABILITY_NULLPTR 0 +# endif + +#endif + +#endif