From 3c907f783027328cf90fae45ff51978c1f123418 Mon Sep 17 00:00:00 2001 From: giskard Date: Thu, 16 May 2024 00:13:56 +0800 Subject: [PATCH] build: update meson, cmake setup - meson . fix run_command() check warning . drop lines for compatability, as it's already using c++23 - cmake . generate `compile_commands.json` by default . position independent build: __FILE__ --- CMakeLists.txt | 7 +++++-- meson.build | 21 ++++++--------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43927fbe..858502cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ project(Hyprland set(HYPRLAND_VERSION ${VER}) set(PREFIX ${CMAKE_INSTALL_PREFIX}) set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) -configure_file(hyprland.pc.in hyprland.pc @ONLY) +configure_file(hyprland.pc.in hyprland.pc @ONLY) set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") @@ -90,9 +90,12 @@ include_directories( "protocols/") set(CMAKE_CXX_STANDARD 23) add_compile_definitions(WLR_USE_UNSTABLE) -add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith) +add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value + -Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith + -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=) set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE) +set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) message(STATUS "Checking deps...") diff --git a/meson.build b/meson.build index 9b278198..b7b23470 100644 --- a/meson.build +++ b/meson.build @@ -5,20 +5,9 @@ project('Hyprland', 'cpp', 'c', 'default_library=static', 'optimization=3', 'buildtype=release', - 'debug=false' - # 'cpp_std=c++23' # not yet supported by meson, as of version 0.63.0 - ]) - -# clang v14.0.6 uses C++2b instead of C++23, so we've gotta account for that -# replace the following with a project default option once meson gets support for C++23 -cpp_compiler = meson.get_compiler('cpp') -if cpp_compiler.has_argument('-std=c++23') - add_global_arguments('-std=c++23', language: 'cpp') -elif cpp_compiler.has_argument('-std=c++2b') - add_global_arguments('-std=c++2b', language: 'cpp') -else - error('Could not configure current C++ compiler (' + cpp_compiler.get_id() + ' ' + cpp_compiler.version() + ') with required C++ standard (C++23)') -endif + 'debug=false', + 'cpp_std=c++23', + ]) add_project_arguments( [ @@ -26,9 +15,11 @@ add_project_arguments( '-Wno-unused-value', '-Wno-missing-field-initializers', '-Wno-narrowing', + '-Wno-pointer-arith', ], language: 'cpp') +cpp_compiler = meson.get_compiler('cpp') if cpp_compiler.check_header('execinfo.h') add_project_arguments('-DHAS_EXECINFO', language: 'cpp') endif @@ -65,7 +56,7 @@ if get_option('buildtype') == 'debug' add_project_arguments('-DHYPRLAND_DEBUG', language: 'cpp') endif -version_h = run_command('sh', '-c', 'scripts/generateVersion.sh') +version_h = run_command('sh', '-c', 'scripts/generateVersion.sh', check: true) globber = run_command('find', 'src', '-name', '*.h*', check: true) headers = globber.stdout().strip().split('\n')