Skip to content

Commit

Permalink
limit the generation of compile_commands.json to Unix Makefiles and N…
Browse files Browse the repository at this point in the history
…inja generators only

	modified:   CMakeLists.txt
  • Loading branch information
Sajid Ali committed Aug 10, 2023
1 parent 9b8b6a3 commit 9c98645
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ cmake_minimum_required(VERSION 3.20.0)
project(ImpactX VERSION 23.06)

# generate compile_commands.json
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# and place it in the source directory https://stackoverflow.com/a/60910583
add_custom_target(
copy-compile-commands ALL
${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/compile_commands.json ${PROJECT_SOURCE_DIR})
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" OR ${CMAKE_GENERATOR} STREQUAL
"Ninja")
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# and place it in the source directory https://stackoverflow.com/a/60910583
add_custom_target(
copy-compile-commands ALL
${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/compile_commands.json ${PROJECT_SOURCE_DIR})
endif()
endif()

include(${ImpactX_SOURCE_DIR}/cmake/ImpactXFunctions.cmake)
Expand Down

0 comments on commit 9c98645

Please sign in to comment.