mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-23 02:17:33 +00:00
[#3785] Added C++ standard
This commit is contained in:
parent
806e007540
commit
330e6072fc
65
meson.build
65
meson.build
@ -21,7 +21,12 @@ project(
|
|||||||
meson_version: '>=1.1.0',
|
meson_version: '>=1.1.0',
|
||||||
license: 'MPL-2.0',
|
license: 'MPL-2.0',
|
||||||
license_files: ['COPYING'],
|
license_files: ['COPYING'],
|
||||||
default_options: ['b_asneeded=true', 'b_pch=false', 'b_pie=true'],
|
default_options: [
|
||||||
|
'b_asneeded=true',
|
||||||
|
'b_pch=false',
|
||||||
|
'b_pie=true',
|
||||||
|
'warning_level=2',
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cpp = meson.get_compiler('cpp')
|
cpp = meson.get_compiler('cpp')
|
||||||
@ -283,6 +288,43 @@ conf_data.set('HAVE_PGSQL', POSTGRESQL_DEP.found())
|
|||||||
|
|
||||||
#### Compiler Checks
|
#### Compiler Checks
|
||||||
|
|
||||||
|
# The required keyword in cpp.run() is an 1.5.0 feature.
|
||||||
|
result = cpp.run(
|
||||||
|
fs.read('compiler-checks/get-cpp-standard.cc'),
|
||||||
|
name: 'Get cpp standard',
|
||||||
|
)
|
||||||
|
if result.returncode() == 0
|
||||||
|
cpp_standard = result.stdout().strip()
|
||||||
|
else
|
||||||
|
error('C++ standard is unknown')
|
||||||
|
endif
|
||||||
|
message(f'Detected C++ standard (__cplusplus value) is @cpp_standard@.')
|
||||||
|
cpp_std_opt = get_option('cpp_std')
|
||||||
|
no_cpp_std_opt_msg = 'Please set a C++ standard by setting a CXX variable or by passing the -Dcpp_std argument to meson.'
|
||||||
|
cpp_std_opt_msg = f'-Dcpp_std=@cpp_std_opt@ is not enough.'
|
||||||
|
if cpp_standard.version_compare('<201100')
|
||||||
|
msgs = [
|
||||||
|
'Kea requires at least C++11 to build.',
|
||||||
|
'Recommended C++ standard is C++14 but some dependencies require at least C++20',
|
||||||
|
]
|
||||||
|
if cpp_std_opt == 'none'
|
||||||
|
msgs += no_cpp_std_opt_msg
|
||||||
|
else
|
||||||
|
msgs += cpp_std_opt_msg
|
||||||
|
endif
|
||||||
|
error('\n'.join(msgs))
|
||||||
|
endif
|
||||||
|
# Add Botan 3 to this.
|
||||||
|
if NETCONF_DEP.found() and cpp_standard.version_compare('<202000')
|
||||||
|
msgs = ['Netconf dependency requires at least C++20.']
|
||||||
|
if cpp_std_opt == 'none'
|
||||||
|
msgs += no_cpp_std_opt_msg
|
||||||
|
else
|
||||||
|
msgs += cpp_std_opt_msg
|
||||||
|
endif
|
||||||
|
error('\n'.join(msgs))
|
||||||
|
endif
|
||||||
|
|
||||||
result = cpp.run(
|
result = cpp.run(
|
||||||
fs.read('compiler-checks/boost-has-threads.cc'),
|
fs.read('compiler-checks/boost-has-threads.cc'),
|
||||||
dependencies: [boost_dep, threads_dep],
|
dependencies: [boost_dep, threads_dep],
|
||||||
@ -318,7 +360,7 @@ if cpp.has_link_argument('-Wl,--no-undefined')
|
|||||||
args: ['--shared', '-fPIC', '-Wl,--no-undefined'],
|
args: ['--shared', '-fPIC', '-Wl,--no-undefined'],
|
||||||
)
|
)
|
||||||
if not result
|
if not result
|
||||||
ENVIRON_SHLIB_FLAGS += ['b_lundef=false']
|
ENVIRON_SHLIB_FLAGS += 'b_lundef=false'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -473,7 +515,7 @@ else
|
|||||||
endif
|
endif
|
||||||
conf_data.set('PACKAGE_VERSION_TYPE', f'"@package_version_type@"')
|
conf_data.set('PACKAGE_VERSION_TYPE', f'"@package_version_type@"')
|
||||||
|
|
||||||
#### Compiler Flags
|
#### Compiler
|
||||||
|
|
||||||
compile_args = []
|
compile_args = []
|
||||||
link_args = []
|
link_args = []
|
||||||
@ -485,7 +527,7 @@ INSTALL_RPATH = PREFIX / LIBDIR
|
|||||||
BUILD_RPATH = TOP_BUILD_DIR / 'src/lib'
|
BUILD_RPATH = TOP_BUILD_DIR / 'src/lib'
|
||||||
|
|
||||||
if SYSTEM == 'darwin'
|
if SYSTEM == 'darwin'
|
||||||
compile_args += ['-D__APPLE_USE_RFC_3542']
|
compile_args += '-D__APPLE_USE_RFC_3542'
|
||||||
add_project_arguments('-D__APPLE_USE_RFC_3542', language: 'cpp')
|
add_project_arguments('-D__APPLE_USE_RFC_3542', language: 'cpp')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -505,7 +547,7 @@ no_warnings = ['-Wno-sign-compare']
|
|||||||
cxx_id = cpp.get_id()
|
cxx_id = cpp.get_id()
|
||||||
if cxx_id == 'clang' and cpp_args_opt.length() == 0
|
if cxx_id == 'clang' and cpp_args_opt.length() == 0
|
||||||
add_project_arguments('-Qunused-arguments', language: 'cpp')
|
add_project_arguments('-Qunused-arguments', language: 'cpp')
|
||||||
compile_args += ['-Qunused-arguments']
|
compile_args += '-Qunused-arguments'
|
||||||
no_warnings += ['-Wno-unused-variable', '-Wno-unused-parameter']
|
no_warnings += ['-Wno-unused-variable', '-Wno-unused-parameter']
|
||||||
endif
|
endif
|
||||||
if werror_opt
|
if werror_opt
|
||||||
@ -515,7 +557,7 @@ if cpp_args_opt.length() == 0
|
|||||||
foreach warning : warnings
|
foreach warning : warnings
|
||||||
if cpp.has_argument(warning)
|
if cpp.has_argument(warning)
|
||||||
add_project_arguments(warning, language: 'cpp')
|
add_project_arguments(warning, language: 'cpp')
|
||||||
compile_args += [warning]
|
compile_args += warning
|
||||||
else
|
else
|
||||||
message(f'@warning@ is not supported by the compiler')
|
message(f'@warning@ is not supported by the compiler')
|
||||||
endif
|
endif
|
||||||
@ -571,16 +613,7 @@ if result.returncode() == 0
|
|||||||
else
|
else
|
||||||
report_conf_data.set('CXX_VERSION', 'unknown')
|
report_conf_data.set('CXX_VERSION', 'unknown')
|
||||||
endif
|
endif
|
||||||
# The required keyword in cpp.run() is an 1.5.0 feature.
|
report_conf_data.set('CXX_STANDARD', cpp_standard)
|
||||||
result = cpp.run(
|
|
||||||
fs.read('compiler-checks/get-cpp-standard.cc'),
|
|
||||||
name: 'Get cpp standard',
|
|
||||||
)
|
|
||||||
if result.returncode() == 0
|
|
||||||
report_conf_data.set('CXX_STANDARD', result.stdout().strip())
|
|
||||||
else
|
|
||||||
error('Cpp standard is unknown')
|
|
||||||
endif
|
|
||||||
compile_args += cpp_args_opt
|
compile_args += cpp_args_opt
|
||||||
report_conf_data.set('CXX_ARGS', ' '.join(compile_args))
|
report_conf_data.set('CXX_ARGS', ' '.join(compile_args))
|
||||||
report_conf_data.set('LD_ID', cpp.get_linker_id())
|
report_conf_data.set('LD_ID', cpp.get_linker_id())
|
||||||
|
@ -22,7 +22,6 @@ netconf_lib = static_library(
|
|||||||
dependencies: [NETCONF_DEP, CRYPTO_DEP],
|
dependencies: [NETCONF_DEP, CRYPTO_DEP],
|
||||||
include_directories: [include_directories('.')] + INCLUDES,
|
include_directories: [include_directories('.')] + INCLUDES,
|
||||||
link_with: LIBS_BUILT_SO_FAR,
|
link_with: LIBS_BUILT_SO_FAR,
|
||||||
override_options: ['cpp_std=c++20'],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
@ -35,7 +34,6 @@ executable(
|
|||||||
install_rpath: INSTALL_RPATH,
|
install_rpath: INSTALL_RPATH,
|
||||||
build_rpath: BUILD_RPATH,
|
build_rpath: BUILD_RPATH,
|
||||||
link_with: [netconf_lib] + LIBS_BUILT_SO_FAR,
|
link_with: [netconf_lib] + LIBS_BUILT_SO_FAR,
|
||||||
override_options: ['cpp_std=c++20'],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
|
@ -41,7 +41,6 @@ kea_netconf_tests = executable(
|
|||||||
kea_process_testutils_lib,
|
kea_process_testutils_lib,
|
||||||
kea_testutils_lib,
|
kea_testutils_lib,
|
||||||
] + LIBS_BUILT_SO_FAR,
|
] + LIBS_BUILT_SO_FAR,
|
||||||
override_options: ['cpp_std=c++20'],
|
|
||||||
)
|
)
|
||||||
test(
|
test(
|
||||||
'kea-netconf-tests',
|
'kea-netconf-tests',
|
||||||
|
@ -31,7 +31,6 @@ kea_yang_lib = shared_library(
|
|||||||
build_rpath: BUILD_RPATH,
|
build_rpath: BUILD_RPATH,
|
||||||
link_with: LIBS_BUILT_SO_FAR,
|
link_with: LIBS_BUILT_SO_FAR,
|
||||||
version: '72.0.0',
|
version: '72.0.0',
|
||||||
override_options: ['cpp_std=c++20'],
|
|
||||||
)
|
)
|
||||||
LIBS_BUILT_SO_FAR = [kea_yang_lib] + LIBS_BUILT_SO_FAR
|
LIBS_BUILT_SO_FAR = [kea_yang_lib] + LIBS_BUILT_SO_FAR
|
||||||
kea_yang_headers = [
|
kea_yang_headers = [
|
||||||
|
@ -7,6 +7,5 @@ sysrepo_setup_tests = executable(
|
|||||||
'sysrepo_setup_tests.cc',
|
'sysrepo_setup_tests.cc',
|
||||||
dependencies: [NETCONF_DEP, GTEST_DEP],
|
dependencies: [NETCONF_DEP, GTEST_DEP],
|
||||||
include_directories: [include_directories('.')] + INCLUDES,
|
include_directories: [include_directories('.')] + INCLUDES,
|
||||||
override_options: ['cpp_std=c++20'],
|
|
||||||
)
|
)
|
||||||
test('kea-sysrepo-setup-tests', sysrepo_setup_tests)
|
test('kea-sysrepo-setup-tests', sysrepo_setup_tests)
|
||||||
|
@ -34,7 +34,6 @@ kea_yang_tests = executable(
|
|||||||
dependencies: [NETCONF_DEP, GTEST_DEP],
|
dependencies: [NETCONF_DEP, GTEST_DEP],
|
||||||
include_directories: [include_directories('.')] + INCLUDES,
|
include_directories: [include_directories('.')] + INCLUDES,
|
||||||
link_with: [kea_yang_tests_libs] + LIBS_BUILT_SO_FAR,
|
link_with: [kea_yang_tests_libs] + LIBS_BUILT_SO_FAR,
|
||||||
override_options: ['cpp_std=c++20'],
|
|
||||||
)
|
)
|
||||||
test(
|
test(
|
||||||
'kea-yang-tests',
|
'kea-yang-tests',
|
||||||
|
@ -5,7 +5,5 @@ endif
|
|||||||
kea_yang_testutils_lib = static_library(
|
kea_yang_testutils_lib = static_library(
|
||||||
'kea-yang-testutils',
|
'kea-yang-testutils',
|
||||||
'translator_test.cc',
|
'translator_test.cc',
|
||||||
dependencies: [NETCONF_DEP, GTEST_DEP],
|
|
||||||
include_directories: [include_directories('.')] + INCLUDES,
|
include_directories: [include_directories('.')] + INCLUDES,
|
||||||
override_options: ['cpp_std=c++20'],
|
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user