mirror of
https://github.com/reactos/CMake.git
synced 2024-11-23 11:39:48 +00:00
Initialize CMAKE_EXPORT_COMPILE_COMMANDS only if not set already
Also de-duplicate its initialization code. Fixes: #16588
This commit is contained in:
parent
4dc9552686
commit
fe19df49d4
@ -50,15 +50,9 @@ if(CMAKE_GENERATOR MATCHES "Make")
|
|||||||
if(DEFINED CMAKE_TARGET_MESSAGES)
|
if(DEFINED CMAKE_TARGET_MESSAGES)
|
||||||
set_property(GLOBAL PROPERTY TARGET_MESSAGES ${CMAKE_TARGET_MESSAGES})
|
set_property(GLOBAL PROPERTY TARGET_MESSAGES ${CMAKE_TARGET_MESSAGES})
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_GENERATOR MATCHES "Unix Makefiles")
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS "$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}"
|
|
||||||
CACHE BOOL "Enable/Disable output of compile commands during generation."
|
|
||||||
)
|
|
||||||
mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_GENERATOR MATCHES "Ninja")
|
if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS AND CMAKE_GENERATOR MATCHES "Ninja|Unix Makefiles")
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS "$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}"
|
set(CMAKE_EXPORT_COMPILE_COMMANDS "$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}"
|
||||||
CACHE BOOL "Enable/Disable output of compile commands during generation."
|
CACHE BOOL "Enable/Disable output of compile commands during generation."
|
||||||
)
|
)
|
||||||
|
@ -197,6 +197,9 @@ endif()
|
|||||||
add_RunCMake_test(CompilerNotFound)
|
add_RunCMake_test(CompilerNotFound)
|
||||||
add_RunCMake_test(Configure -DMSVC_IDE=${MSVC_IDE})
|
add_RunCMake_test(Configure -DMSVC_IDE=${MSVC_IDE})
|
||||||
add_RunCMake_test(DisallowedCommands)
|
add_RunCMake_test(DisallowedCommands)
|
||||||
|
if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
|
||||||
|
add_RunCMake_test(ExportCompileCommands)
|
||||||
|
endif()
|
||||||
add_RunCMake_test(ExternalData)
|
add_RunCMake_test(ExternalData)
|
||||||
add_RunCMake_test(FeatureSummary)
|
add_RunCMake_test(FeatureSummary)
|
||||||
add_RunCMake_test(FPHSA)
|
add_RunCMake_test(FPHSA)
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/compile_commands.json")
|
||||||
|
set(RunCMake_TEST_FAILED "compile_commands.json not generated")
|
||||||
|
return()
|
||||||
|
endif()
|
3
Tests/RunCMake/ExportCompileCommands/BeforeProject.cmake
Normal file
3
Tests/RunCMake/ExportCompileCommands/BeforeProject.cmake
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
enable_language(C)
|
||||||
|
add_library(empty STATIC empty.c)
|
||||||
|
message(STATUS "CMAKE_EXPORT_COMPILE_COMMANDS='${CMAKE_EXPORT_COMPILE_COMMANDS}'")
|
@ -0,0 +1 @@
|
|||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
3
Tests/RunCMake/ExportCompileCommands/CMakeLists.txt
Normal file
3
Tests/RunCMake/ExportCompileCommands/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.17)
|
||||||
|
project(${RunCMake_TEST} NONE)
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
3
Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake
Normal file
3
Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
run_cmake_with_options(BeforeProject -DCMAKE_PROJECT_INCLUDE_BEFORE=BeforeProjectBEFORE.cmake)
|
0
Tests/RunCMake/ExportCompileCommands/empty.c
Normal file
0
Tests/RunCMake/ExportCompileCommands/empty.c
Normal file
Loading…
Reference in New Issue
Block a user