From 18d2d2ba6af6ac76e4714fae2737a55d223716f8 Mon Sep 17 00:00:00 2001 From: giskard Date: Tue, 21 May 2024 06:00:28 +0800 Subject: [PATCH] cmake: macro-prefix-map, compile_commands.json (#338) * cmake: position independent build for `__FILE__` * cmake: generate compile_commands.json, coder-friendly --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9246428..cfab691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ project(hyprlock ) set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") +set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) message(STATUS "Configuring hyprlock in Debug with CMake") @@ -27,7 +28,10 @@ include(GNUInstallDirs) # configure set(CMAKE_CXX_STANDARD 23) add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value - -Wno-missing-field-initializers -Wno-narrowing) + -Wno-missing-field-initializers -Wno-narrowing) + +# position independent build: __FILE__ +add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=) # dependencies message(STATUS "Checking deps...")