diff --git a/cmake/modules/OverloadCompilerFlags.cmake b/cmake/modules/OverloadCompilerFlags.cmake index 6ef9b3be0a3480dfdd51b5517f138721a098ea14..b59f10d6a0c49a11a1be0300fa2ca1cfd76e41c7 100644 --- a/cmake/modules/OverloadCompilerFlags.cmake +++ b/cmake/modules/OverloadCompilerFlags.cmake @@ -30,6 +30,20 @@ include_guard(GLOBAL) option(ALLOW_CXXFLAGS_OVERWRITE OFF) option(ALLOW_CFLAGS_OVERWRITE OFF) option(ALLOW_CXXFLAGS_OVERWRITE_FORCE OFF) +option(ALLOW_CXXFLAGS_OVERWRITE_VERBOSE OFF) +option(ALLOW_CFLAGS_OVERWRITE_VERBOSE OFF) + +if( DEFINED ENV{ALLOW_CXXFLAGS_OVERWRITE_VERBOSE} ) + set(ALLOW_CXXFLAGS_OVERWRITE_VERBOSE ON ) +endif() + +if( ALLOW_CXXFLAGS_OVERWRITE_VERBOSE ) + set(ALLOW_CXXFLAGS_OVERWRITE ON) +endif() + +if( ALLOW_CFLAGS_OVERWRITE_VERBOSE ) + set(ALLOW_CFLAGS_OVERWRITE ON) +endif() set(WRITE_CXXFLAGS_COMPILER_SCRIPT FALSE) # write scripts if CMAKE_GENERATOR is Makefiles or if FORCE is on @@ -140,7 +154,12 @@ macro(finalize_compiler_script) set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n if [ \"\$VARNAME\" != \"\" ]; then\n VAR=`\$ENV | \$GREP \$VARNAME`\n if [ \"\$VAR\" != \"\" ]; then") set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n # add variable from environment to flags list\n NEWFLAG=\"-D\$VARNAME=\${!VARNAME}\"\n fi\n fi") set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n FLAGS=\"\$FLAGS \$NEWFLAG\"\ndone") - set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n\$ECHO \"${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS\"") + if( ${COMP} STREQUAL "CXX" AND ALLOW_CXXFLAGS_OVERWRITE_VERBOSE ) + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n\$ECHO \"${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS\"") + endif() + if( ${COMP} STREQUAL "C" AND ALLOW_CFLAGS_OVERWRITE_VERBOSE ) + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n\$ECHO \"${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS\"") + endif() set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nexec ${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS") message("-- Generating ${COMP} compiler script for ${COMP}FLAGS overloading on command line") if( ${COMP} STREQUAL "CXX" )