diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index c67f884717..4eec953555 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -115,11 +115,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) { return 0; } - if(this->FileName && strcmp(var, "CMAKE_CURRENT_LIST_FILE") == 0) - { - return this->AddString(this->FileName); - } - else if(this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) + if(this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) { cmOStringStream ostr; ostr << this->FileLine; diff --git a/Tests/MacroTest/CMakeLists.txt b/Tests/MacroTest/CMakeLists.txt index d0220ff926..7ec50c7b7c 100644 --- a/Tests/MacroTest/CMakeLists.txt +++ b/Tests/MacroTest/CMakeLists.txt @@ -86,3 +86,8 @@ ELSE(SOME_CHECK) ENDIF(SOME_CHECK) ADD_EXECUTABLE(MacroTest macroTest.c) + +MACRO(GET_CURRENT_FILE var) + SET(${var} ${CMAKE_CURRENT_LIST_FILE}) +ENDMACRO(GET_CURRENT_FILE) +INCLUDE(context.cmake) diff --git a/Tests/MacroTest/context.cmake b/Tests/MacroTest/context.cmake new file mode 100644 index 0000000000..f4d7035fbc --- /dev/null +++ b/Tests/MacroTest/context.cmake @@ -0,0 +1,10 @@ +GET_CURRENT_FILE(current_file) +IF(NOT "${current_file}" STREQUAL "${CMAKE_CURRENT_LIST_FILE}") + MESSAGE(FATAL_ERROR + "Macro file context is broken. Expected:\n" + " ${CMAKE_CURRENT_LIST_FILE}\n" + "but got:\n" + " ${current_file}\n" + "from the macro." + ) +ENDIF(NOT "${current_file}" STREQUAL "${CMAKE_CURRENT_LIST_FILE}")