diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index a051cb6629..0978d3930d 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -344,6 +344,12 @@ macro(project project_name) # Generate compile_commands.json (needs to come after project call). set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + # If CMAKE_COLOR_DIAGNOSTICS not set in project CMakeLists.txt or in the environment, + # enable it by default. + if(NOT DEFINED CMAKE_COLOR_DIAGNOSTICS AND NOT DEFINED ENV{CMAKE_COLOR_DIAGNOSTICS}) + set(CMAKE_COLOR_DIAGNOSTICS ON) + endif() + # Since components can import third-party libraries, the original definition of project() should be restored # before the call to add components to the build. function(project)