Meson 在调试模式下编译子项目
Meson compiling subprojects in debug mode
我有一个父项目和一个使用介子的子项目。遗憾的是,该子项目仅在发布模式下构建。但是,即使我使用 --reconfigure 将父项目设置为调试并使用配置检查构建类型是调试,似乎没有为子项目定义 NDEBUG 宏,这导致它编译失败。
有没有办法为子项目启用调试构建?
父代码段:
project(
'SdfParametrization',
'cpp',
version: '0.0.1',
license: 'GPL',
default_options : [
'cpp_std=c++20',
'default_library=static',
'optimization=3',
'b_ndebug=true'])
add_global_arguments(
'-DVULKAN_HPP_NO_EXCEPTIONS',
'-DVULKAN_HPP_TYPESAFE_CONVERSION',
'-DNDEBUG',
'-Wno-unused-function',
'-fdiagnostics-color=always',
'--coverage',
language : 'cpp')
add_global_link_arguments(
'-lgcov',
'-lubsan',
'-ldl',
'-lvulkan',
language : 'cpp')
cpp = meson.get_compiler('cpp')
neverengine_proj = subproject('neverengine', default_options:['buildtype=debugoptimized'])
neverengine_dep = neverengine_proj.get_variable('core_never_engine_dep')
executable('sdf_parameterization', 'ray_tracing.cpp', dependencies:[neverengine_dep])
子片段:
project(
'NeverEngine',
'cpp',
version: '0.0.1',
license: 'GPL',
default_options : [
'cpp_std=c++20',
'default_library=static',
'optimization=3'])
if not meson.is_subproject()
add_global_arguments(
'-DVULKAN_HPP_NO_EXCEPTIONS',
'-DVULKAN_HPP_TYPESAFE_CONVERSION',
'-Wno-unused-function',
'-fdiagnostics-color=always',
'-fsanitize=undefined',
'--coverage',
language : 'cpp')
add_global_link_arguments(
'-lgcov',
'-lubsan',
language : 'cpp')
endif
cpp = meson.get_compiler('cpp')
external_include_dirs = [
'libraries/Eigen/',
'libraries/imgui/',
'libraries/incbin/']
sources = files(
'Src/Engine/Animation/Animation.cpp',
'Src/Engine/Animation/AnimationMesh.cpp',
'Src/Engine/Animation/GltfLib.cpp',
'Src/Engine/Animation/GltfLoaders.cpp',
'Src/Engine/Animation/Image/CpuImage.cpp',
'Src/Engine/Animation/NumericIntegration.cpp',
'Src/Engine/Animation/SpringMass.cpp',
'Src/Engine/DataSanitation/AttributeInputSanitation.cpp',
'Src/Engine/DynamicLoading/DynamicLoader.cpp',
'Src/Engine/EmbeddedShaders/EmbeddedShaders.cpp',
'Src/Engine/GUI/Guizmo3D.cpp',
'Src/Engine/GUI/_imgui.cpp',
'Src/Engine/GUI/imgui_bridge.cpp',
'Src/Engine/Geometry/DualContouring.cpp',
'Src/Engine/Geometry/GeometryUtils.cpp',
'Src/Engine/Geometry/HMesh.cpp',
'Src/Engine/Geometry/HeatGeodesics.cpp',
'Src/Engine/Geometry/MatrixMesh.cpp',
'Src/Engine/Geometry/MeshGradient.cpp',
'Src/Engine/Geometry/MeshUtils.cpp',
'Src/Engine/Geometry/Parametrics.cpp',
'Src/Engine/Geometry/SdfFramework.cpp',
'Src/Engine/Geometry/Subdivision.cpp',
'Src/Engine/Helpers/EigenHelpers.cpp',
'Src/Engine/Helpers/FlotingPointArithmetic.cpp',
'Src/Engine/Helpers/MiscUtils.cpp',
'Src/Engine/Helpers/NumberTheory.cpp',
'Src/Engine/Helpers/VectorManipulation.cpp',
'Src/Engine/Helpers/log.cpp',
'Src/Engine/Noise/Noise.cpp',
'Src/Engine/Renderer/Camera/Camera.cpp',
'Src/Engine/Renderer/IO/GLFW_tools.cpp',
'Src/Engine/Renderer/IO/InputHandler.cpp',
'Src/Engine/Renderer/IO/Window.cpp',
'Src/Engine/Renderer/Renderer.cpp',
'Src/Engine/Renderer/Rendering/Effects.cpp',
'Src/Engine/Renderer/Rendering/Gallery.cpp',
'Src/Engine/Renderer/Rendering/RenderTargetStorage.cpp',
'Src/Engine/Renderer/Rendering/RenderingTechniques.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/HardwareInterface.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/Image.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/Memory.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/RenderTarget.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/RenderingPipeline.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/ShaderProgram.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/Utils.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VkExtensionsStubs.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VulkanBuffer.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VulkanDebugging.cpp',
'Src/Engine/Renderer/Scribe/Scribe.cpp',
'Src/Engine/Shared/Shared.cpp')
external_incs = include_directories(external_include_dirs, is_system : true)
internal_incs = include_directories(['Src/Engine/', 'build/'])
all_includes = []
all_includes += external_incs
all_includes += internal_incs
pkg = import('pkgconfig')
linked_dependencies = []
linked_dependencies += dependency('vulkan', include_type : 'system')
linked_dependencies += dependency('vulkan-memory-allocator', include_type : 'system')
linked_dependencies += dependency('glfw3', include_type : 'system')
linked_dependencies += dependency('threads', include_type : 'system')
linked_dependencies += dependency('zlib', include_type : 'system')
linked_dependencies += dependency('shaderc_static', include_type : 'system')
linked_dependencies += dependency('freetype2', include_type : 'system')
linked_dependencies += dependency('stb', include_type : 'system')
linked_dependencies += dependency('tinygltf', include_type : 'system')
pre_target = custom_target(
'Preprocess',
output : [
'UniformObjects.cpp',
'UniformObjects.hpp'],
build_always_stale : true,
command : ['python3', '../Scripts/preprocessing.py'])
sources += pre_target
core_lib = library('CoreNeverEngine',
sources,
include_directories : all_includes,
dependencies : linked_dependencies,
build_by_default : true)
pkg.generate(core_lib)
example_path_template = 'Src/examples/@0@/@1@.cpp'
examples = [
'base_example',
'disk_terrain',
'example2',
'gaussian_subdivision',
'gltf_loading',
'heat_geodesics',
'implicit_functions',
'mesh_matrices',
'ray_tracing',
'sponza_scene',
'spring_mass',
'terrain_generation']
foreach example : examples
tokens = example.split('_')
camel_case_name = ''
foreach word : tokens
lower_case = word[0]
upper_case = lower_case.to_upper()
camel_case_name += upper_case + word
camel_case_name = camel_case_name.replace(upper_case + lower_case, upper_case)
endforeach
path = example_path_template.format(camel_case_name, example)
target = executable(camel_case_name, [path],
include_directories : all_includes,
link_with : core_lib,
dependencies : [linked_dependencies])
endforeach
linked_dependencies += dependency('gtest')
geometry_test_files = [
'Src/Engine/Geometry/tests/GeometryTests.cpp',
'Src/Engine/Geometry/tests/TestsGeometryUtils_hpp.cpp',
'Src/Engine/Geometry/GeometryUtils.cpp',
'Src/Engine/Helpers/log.cpp',
]
test = executable(
'GeometryTests',
geometry_test_files,
include_directories : all_includes,
dependencies : linked_dependencies,
link_args : ['-fprofile-arcs', '-ftest-coverage'],
cpp_args : ['-fprofile-arcs', '-ftest-coverage'])
test('GeometryTests', test)
vulkan_test_files = [
'Src/Engine/Renderer/Rendering/VulkanLayer/tests/VulkanLayerTests.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/tests/TestsHardwareInterface_cpp.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/tests/TestsHardwareInterface_hpp.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VulkanDebugging.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VkExtensionsStubs.cpp',
'Src/Engine/Helpers/log.cpp',
]
test = executable(
'VulkanTests',
vulkan_test_files,
include_directories : all_includes,
dependencies : linked_dependencies,
link_args : ['-fprofile-arcs', '-ftest-coverage'],
cpp_args : ['-fprofile-arcs', '-ftest-coverage'])
test('VulkanTests', test)
目前不支持此功能,正如您从 table of core options, only 3 options are settable per subproject as of now: werror and default_library (since 0.54.0) and warning_level (since 0.56.0). And below in Specifying options per subproject 中看到的那样,您可以找到更多详细信息,例如关于申请顺序
我还从问题 Subproject default_options are ignored one of the main contributor says 的讨论中发现:
Right now only a couple of options are allowed on a per-project basis:
default_library, werror (and one more I can't remember off the top of
my head). We keep adding more over time, but other ones are ignored,
yes.
我有一个父项目和一个使用介子的子项目。遗憾的是,该子项目仅在发布模式下构建。但是,即使我使用 --reconfigure 将父项目设置为调试并使用配置检查构建类型是调试,似乎没有为子项目定义 NDEBUG 宏,这导致它编译失败。
有没有办法为子项目启用调试构建?
父代码段:
project(
'SdfParametrization',
'cpp',
version: '0.0.1',
license: 'GPL',
default_options : [
'cpp_std=c++20',
'default_library=static',
'optimization=3',
'b_ndebug=true'])
add_global_arguments(
'-DVULKAN_HPP_NO_EXCEPTIONS',
'-DVULKAN_HPP_TYPESAFE_CONVERSION',
'-DNDEBUG',
'-Wno-unused-function',
'-fdiagnostics-color=always',
'--coverage',
language : 'cpp')
add_global_link_arguments(
'-lgcov',
'-lubsan',
'-ldl',
'-lvulkan',
language : 'cpp')
cpp = meson.get_compiler('cpp')
neverengine_proj = subproject('neverengine', default_options:['buildtype=debugoptimized'])
neverengine_dep = neverengine_proj.get_variable('core_never_engine_dep')
executable('sdf_parameterization', 'ray_tracing.cpp', dependencies:[neverengine_dep])
子片段:
project(
'NeverEngine',
'cpp',
version: '0.0.1',
license: 'GPL',
default_options : [
'cpp_std=c++20',
'default_library=static',
'optimization=3'])
if not meson.is_subproject()
add_global_arguments(
'-DVULKAN_HPP_NO_EXCEPTIONS',
'-DVULKAN_HPP_TYPESAFE_CONVERSION',
'-Wno-unused-function',
'-fdiagnostics-color=always',
'-fsanitize=undefined',
'--coverage',
language : 'cpp')
add_global_link_arguments(
'-lgcov',
'-lubsan',
language : 'cpp')
endif
cpp = meson.get_compiler('cpp')
external_include_dirs = [
'libraries/Eigen/',
'libraries/imgui/',
'libraries/incbin/']
sources = files(
'Src/Engine/Animation/Animation.cpp',
'Src/Engine/Animation/AnimationMesh.cpp',
'Src/Engine/Animation/GltfLib.cpp',
'Src/Engine/Animation/GltfLoaders.cpp',
'Src/Engine/Animation/Image/CpuImage.cpp',
'Src/Engine/Animation/NumericIntegration.cpp',
'Src/Engine/Animation/SpringMass.cpp',
'Src/Engine/DataSanitation/AttributeInputSanitation.cpp',
'Src/Engine/DynamicLoading/DynamicLoader.cpp',
'Src/Engine/EmbeddedShaders/EmbeddedShaders.cpp',
'Src/Engine/GUI/Guizmo3D.cpp',
'Src/Engine/GUI/_imgui.cpp',
'Src/Engine/GUI/imgui_bridge.cpp',
'Src/Engine/Geometry/DualContouring.cpp',
'Src/Engine/Geometry/GeometryUtils.cpp',
'Src/Engine/Geometry/HMesh.cpp',
'Src/Engine/Geometry/HeatGeodesics.cpp',
'Src/Engine/Geometry/MatrixMesh.cpp',
'Src/Engine/Geometry/MeshGradient.cpp',
'Src/Engine/Geometry/MeshUtils.cpp',
'Src/Engine/Geometry/Parametrics.cpp',
'Src/Engine/Geometry/SdfFramework.cpp',
'Src/Engine/Geometry/Subdivision.cpp',
'Src/Engine/Helpers/EigenHelpers.cpp',
'Src/Engine/Helpers/FlotingPointArithmetic.cpp',
'Src/Engine/Helpers/MiscUtils.cpp',
'Src/Engine/Helpers/NumberTheory.cpp',
'Src/Engine/Helpers/VectorManipulation.cpp',
'Src/Engine/Helpers/log.cpp',
'Src/Engine/Noise/Noise.cpp',
'Src/Engine/Renderer/Camera/Camera.cpp',
'Src/Engine/Renderer/IO/GLFW_tools.cpp',
'Src/Engine/Renderer/IO/InputHandler.cpp',
'Src/Engine/Renderer/IO/Window.cpp',
'Src/Engine/Renderer/Renderer.cpp',
'Src/Engine/Renderer/Rendering/Effects.cpp',
'Src/Engine/Renderer/Rendering/Gallery.cpp',
'Src/Engine/Renderer/Rendering/RenderTargetStorage.cpp',
'Src/Engine/Renderer/Rendering/RenderingTechniques.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/HardwareInterface.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/Image.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/Memory.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/RenderTarget.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/RenderingPipeline.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/ShaderProgram.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/Utils.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VkExtensionsStubs.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VulkanBuffer.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VulkanDebugging.cpp',
'Src/Engine/Renderer/Scribe/Scribe.cpp',
'Src/Engine/Shared/Shared.cpp')
external_incs = include_directories(external_include_dirs, is_system : true)
internal_incs = include_directories(['Src/Engine/', 'build/'])
all_includes = []
all_includes += external_incs
all_includes += internal_incs
pkg = import('pkgconfig')
linked_dependencies = []
linked_dependencies += dependency('vulkan', include_type : 'system')
linked_dependencies += dependency('vulkan-memory-allocator', include_type : 'system')
linked_dependencies += dependency('glfw3', include_type : 'system')
linked_dependencies += dependency('threads', include_type : 'system')
linked_dependencies += dependency('zlib', include_type : 'system')
linked_dependencies += dependency('shaderc_static', include_type : 'system')
linked_dependencies += dependency('freetype2', include_type : 'system')
linked_dependencies += dependency('stb', include_type : 'system')
linked_dependencies += dependency('tinygltf', include_type : 'system')
pre_target = custom_target(
'Preprocess',
output : [
'UniformObjects.cpp',
'UniformObjects.hpp'],
build_always_stale : true,
command : ['python3', '../Scripts/preprocessing.py'])
sources += pre_target
core_lib = library('CoreNeverEngine',
sources,
include_directories : all_includes,
dependencies : linked_dependencies,
build_by_default : true)
pkg.generate(core_lib)
example_path_template = 'Src/examples/@0@/@1@.cpp'
examples = [
'base_example',
'disk_terrain',
'example2',
'gaussian_subdivision',
'gltf_loading',
'heat_geodesics',
'implicit_functions',
'mesh_matrices',
'ray_tracing',
'sponza_scene',
'spring_mass',
'terrain_generation']
foreach example : examples
tokens = example.split('_')
camel_case_name = ''
foreach word : tokens
lower_case = word[0]
upper_case = lower_case.to_upper()
camel_case_name += upper_case + word
camel_case_name = camel_case_name.replace(upper_case + lower_case, upper_case)
endforeach
path = example_path_template.format(camel_case_name, example)
target = executable(camel_case_name, [path],
include_directories : all_includes,
link_with : core_lib,
dependencies : [linked_dependencies])
endforeach
linked_dependencies += dependency('gtest')
geometry_test_files = [
'Src/Engine/Geometry/tests/GeometryTests.cpp',
'Src/Engine/Geometry/tests/TestsGeometryUtils_hpp.cpp',
'Src/Engine/Geometry/GeometryUtils.cpp',
'Src/Engine/Helpers/log.cpp',
]
test = executable(
'GeometryTests',
geometry_test_files,
include_directories : all_includes,
dependencies : linked_dependencies,
link_args : ['-fprofile-arcs', '-ftest-coverage'],
cpp_args : ['-fprofile-arcs', '-ftest-coverage'])
test('GeometryTests', test)
vulkan_test_files = [
'Src/Engine/Renderer/Rendering/VulkanLayer/tests/VulkanLayerTests.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/tests/TestsHardwareInterface_cpp.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/tests/TestsHardwareInterface_hpp.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VulkanDebugging.cpp',
'Src/Engine/Renderer/Rendering/VulkanLayer/VkExtensionsStubs.cpp',
'Src/Engine/Helpers/log.cpp',
]
test = executable(
'VulkanTests',
vulkan_test_files,
include_directories : all_includes,
dependencies : linked_dependencies,
link_args : ['-fprofile-arcs', '-ftest-coverage'],
cpp_args : ['-fprofile-arcs', '-ftest-coverage'])
test('VulkanTests', test)
目前不支持此功能,正如您从 table of core options, only 3 options are settable per subproject as of now: werror and default_library (since 0.54.0) and warning_level (since 0.56.0). And below in Specifying options per subproject 中看到的那样,您可以找到更多详细信息,例如关于申请顺序
我还从问题 Subproject default_options are ignored one of the main contributor says 的讨论中发现:
Right now only a couple of options are allowed on a per-project basis: default_library, werror (and one more I can't remember off the top of my head). We keep adding more over time, but other ones are ignored, yes.