Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create compile_commands.json #6

Open
wants to merge 4 commits into
base: generate-asm-ranges
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

# Enable JSON compilation database generation
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Symbolic link to the compile_commands.json in root directory for tools or copy for Windows
if(CMAKE_EXPORT_COMPILE_COMMANDS)
if(WIN32)
# On Windows, instead of creating a symlink, copy the file
add_custom_target(
create_compile_commands_copy ALL
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_SOURCE_DIR}/compile_commands.json
)
else()
# On non-Windows systems, create the symbolic link
add_custom_target(
create_compile_commands_symlink ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_SOURCE_DIR}/compile_commands.json
)
endif()
endif()

# Platform detection
if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
set(WINDOWS TRUE)
Expand Down