diff options
author | mrsmidge <smidge@xsco.net> | 2020-08-16 21:30:58 +0100 |
---|---|---|
committer | mrsmidge <smidge@xsco.net> | 2020-08-16 21:30:58 +0100 |
commit | 401794f3a1a0581ab131ad704598664ab0d70fcb (patch) | |
tree | 3792e13aff77a38bfb8dd9d572bec2087377f192 | |
parent | 7880bfe9cbcfda05a38a74e6a53f1ce5e8cc8b6d (diff) |
Introduce build-time generated config.hpp file
Both meson and CMake build detect support for std::optional<T> or its
experimental equivalent.
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | include/djinterop/config.hpp.in (renamed from include/djinterop/config.hpp) | 6 | ||||
-rw-r--r-- | include/djinterop/meson.build | 20 | ||||
-rw-r--r-- | include/meson.build | 4 | ||||
-rw-r--r-- | meson.build | 2 |
5 files changed, 41 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ea07846..73d9df2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ # The meson/ninja build should be preferred in all other cases. # cmake_minimum_required(VERSION 3.10) -project(libdjinterop VERSION 0.11.0) +project(libdjinterop VERSION 0.12.0) # Require C++17 set(CMAKE_CXX_STANDARD 17) @@ -18,6 +18,14 @@ find_package(SQLite3 3.11.0 REQUIRED) # Require zlib >= 1.2.8 find_package(ZLIB 1.2.8 REQUIRED) +# Generate config.hpp based on build-time environment. +include(CheckIncludeFileCXX) +CHECK_INCLUDE_FILE_CXX(optional DJINTEROP_STD_OPTIONAL) +CHECK_INCLUDE_FILE_CXX(experimental/optional DJINTEROP_STD_EXPERIMENTAL_OPTIONAL) +configure_file( + include/djinterop/config.hpp.in + include/djinterop/config.hpp) + add_library( djinterop src/djinterop/enginelibrary/el_crate_impl.cpp @@ -50,6 +58,7 @@ target_include_directories( ${SQLite3_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ext/sqlite_modern_cpp + ${CMAKE_CURRENT_BINARY_DIR}/include include src) target_link_libraries( @@ -60,7 +69,7 @@ target_link_libraries( install(TARGETS djinterop DESTINATION lib) install(FILES include/djinterop/album_art.hpp - include/djinterop/config.hpp + ${CMAKE_CURRENT_BINARY_DIR}/include/djinterop/config.hpp include/djinterop/crate.hpp include/djinterop/database.hpp include/djinterop/djinterop.hpp diff --git a/include/djinterop/config.hpp b/include/djinterop/config.hpp.in index 97260cc..b558501 100644 --- a/include/djinterop/config.hpp +++ b/include/djinterop/config.hpp.in @@ -46,4 +46,10 @@ #endif // DJINTEROP_SOURCE #define DJINTEROP_LOCAL DJINTEROP_SYMBOL_LOCAL +// Symbols defined after this point represent the environment at the time +// that this library was built. The environment when this library is used must +// be compatible in order to use the library successfully. +#cmakedefine DJINTEROP_STD_OPTIONAL +#cmakedefine DJINTEROP_STD_EXPERIMENTAL_OPTIONAL + #endif // DJINTEROP_CONFIG_HPP diff --git a/include/djinterop/meson.build b/include/djinterop/meson.build new file mode 100644 index 0000000..c43a0b2 --- /dev/null +++ b/include/djinterop/meson.build @@ -0,0 +1,20 @@ +# Generate config file based on build-time feature detection. +# Note that most build configuration for public headers is handled in the +# parent build file; this file exists solely because the `output` parameter +# of configure_file() does not, at the time of writing (meson 0.55.0), support +# writing the output file to a different directory. +conf_data = configuration_data() +if cpp_compiler.has_header('optional') + conf_data.set10('DJINTEROP_STD_OPTIONAL', true) +endif +if cpp_compiler.has_header('experimental/optional') + conf_data.set10('DJINTEROP_STD_EXPERIMENTAL_OPTIONAL', true) +endif +configure_file( + input: 'config.hpp.in', + output: 'config.hpp', + configuration: conf_data, + format: 'cmake', + install_dir: get_option('includedir') + '/djinterop' +) + diff --git a/include/meson.build b/include/meson.build index ee89840..f43c8e8 100644 --- a/include/meson.build +++ b/include/meson.build @@ -1,6 +1,8 @@ +# Used only to generate config.hpp in the nested include dir. +subdir('djinterop') + djinterop_header_files = [ 'djinterop/album_art.hpp', - 'djinterop/config.hpp', 'djinterop/crate.hpp', 'djinterop/database.hpp', 'djinterop/djinterop.hpp', diff --git a/meson.build b/meson.build index e34ffcb..575e12f 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'djinterop', 'cpp', 'c', - version: '0.11.0', + version: '0.12.0', license: 'LGPL-3.0', default_options: ['cpp_std=c++17', 'default_library=both']) |