From 7a2a23c51c0bb1193ad8a1baeb4197a477e5b029 Mon Sep 17 00:00:00 2001 From: YayIguess Date: Fri, 3 Oct 2025 19:41:47 -0700 Subject: [PATCH] compile_commands.json --- .gitignore | 1 + CMakeLists.txt | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 77724da..b104992 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ cmake-build-debug/ build/ +.cache/ .idea roms/ diff --git a/CMakeLists.txt b/CMakeLists.txt index bd46da3..832f24d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.25) project(GameBoy++) set(CMAKE_CXX_STANDARD 23) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIRS}) @@ -18,4 +19,14 @@ add_executable(GameBoy++ src/main.cpp src/testing.hpp src/joypad.cpp ) -target_link_libraries(GameBoy++ ${SDL2_LIBRARIES}) \ No newline at end of file +target_link_libraries(GameBoy++ ${SDL2_LIBRARIES}) + +if(CMAKE_EXPORT_COMPILE_COMMANDS) + add_custom_target(copy_compile_commands ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_BINARY_DIR}/compile_commands.json + ${CMAKE_SOURCE_DIR}/compile_commands.json + DEPENDS ${CMAKE_BINARY_DIR}/compile_commands.json + COMMENT "Copying compile_commands.json to project root") +endif() +