From 3df49dc7b1517109ef198177f541e24bc61fefea Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 1 Oct 2011 19:09:24 +0200 Subject: [PATCH] fix #12392: handle CMAKE_CXX_COMPILER_ARG1 for Eclipse projects CMAKE_CXX/C_COMPILER_ARG1 have to be used for finding the include dirs and builtin macros, so Eclipse can do code completion Alex --- ...ratorDetermineCompilerMacrosAndIncludeDirs.cmake | 4 +++- Source/cmExtraEclipseCDT4Generator.cxx | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake index 55c37c209..1b4532deb 100644 --- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake +++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake @@ -25,10 +25,12 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines IF (${_lang} STREQUAL "c++") SET(_compilerExecutable "${CMAKE_CXX_COMPILER}") + SET(_arg1 "${CMAKE_CXX_COMPILER_ARG1}") ELSE () SET(_compilerExecutable "${CMAKE_C_COMPILER}") + SET(_arg1 "${CMAKE_C_COMPILER_ARG1}") ENDIF () - EXECUTE_PROCESS(COMMAND ${_compilerExecutable} -v -E -x ${_lang} -dD dummy + EXECUTE_PROCESS(COMMAND ${_compilerExecutable} ${_arg1} -v -E -x ${_lang} -dD dummy WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles ERROR_VARIABLE _gccOutput OUTPUT_VARIABLE _gccStdout ) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 1dd9bf33d..7beffdcf2 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -987,17 +987,26 @@ void cmExtraEclipseCDT4Generator // we need the "make" and the C (or C++) compiler which are used, Alex std::string make = makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::string compiler = makefile.GetSafeDefinition("CMAKE_C_COMPILER"); + std::string arg1 = makefile.GetSafeDefinition("CMAKE_C_COMPILER_ARG1"); if (compiler.empty()) { compiler = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER"); + arg1 = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER_ARG1"); } if (compiler.empty()) //Hmm, what to do now ? { compiler = "gcc"; } - // the following right now hardcodes gcc behaviour :-/ + std::string compilerArgs = + "-E -P -v -dD ${plugin_state_location}/${specs_file}"; + if (!arg1.empty()) + { + arg1 += " "; + compilerArgs = arg1 + compilerArgs; + } + fout << "\n" "