diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index e64ed87f22..219ad48b5c 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -176,6 +176,13 @@ std::string cmFindProgramCommand::FindNormalProgramNamesPerDir() { helper.AddName(*ni); } + + // Check for the names themselves (e.g. absolute paths). + if (helper.CheckDirectory(std::string())) + { + return helper.BestPath; + } + // Search every directory. for (std::vector::const_iterator p = this->SearchPaths.begin(); p != this->SearchPaths.end(); ++p) @@ -200,6 +207,12 @@ std::string cmFindProgramCommand::FindNormalProgramDirsPerName() // Switch to searching for this name. helper.SetName(*ni); + // Check for the name by itself (e.g. an absolute path). + if (helper.CheckDirectory(std::string())) + { + return helper.BestPath; + } + // Search every directory. for (std::vector::const_iterator p = this->SearchPaths.begin(); diff --git a/Tests/RunCMake/find_program/DirsPerName-stdout.txt b/Tests/RunCMake/find_program/DirsPerName-stdout.txt index f763bb0860..dc1c82b5fc 100644 --- a/Tests/RunCMake/find_program/DirsPerName-stdout.txt +++ b/Tests/RunCMake/find_program/DirsPerName-stdout.txt @@ -1 +1,2 @@ -- PROG='[^']*/Tests/RunCMake/find_program/B/testB' +-- PROG_ABS='[^']*/Tests/RunCMake/find_program/A/testA' diff --git a/Tests/RunCMake/find_program/DirsPerName.cmake b/Tests/RunCMake/find_program/DirsPerName.cmake index 54db6ddfb7..6db778d7e3 100644 --- a/Tests/RunCMake/find_program/DirsPerName.cmake +++ b/Tests/RunCMake/find_program/DirsPerName.cmake @@ -4,3 +4,9 @@ find_program(PROG NO_DEFAULT_PATH ) message(STATUS "PROG='${PROG}'") + +find_program(PROG_ABS + NAMES ${CMAKE_CURRENT_SOURCE_DIR}/A/testA + NO_DEFAULT_PATH + ) +message(STATUS "PROG_ABS='${PROG_ABS}'") diff --git a/Tests/RunCMake/find_program/NamesPerDir-stdout.txt b/Tests/RunCMake/find_program/NamesPerDir-stdout.txt index 964e25971e..fd79185ac9 100644 --- a/Tests/RunCMake/find_program/NamesPerDir-stdout.txt +++ b/Tests/RunCMake/find_program/NamesPerDir-stdout.txt @@ -1 +1,2 @@ -- PROG='[^']*/Tests/RunCMake/find_program/A/testA' +-- PROG_ABS='[^']*/Tests/RunCMake/find_program/A/testA' diff --git a/Tests/RunCMake/find_program/NamesPerDir.cmake b/Tests/RunCMake/find_program/NamesPerDir.cmake index 49ce49d84a..5f00a28d0a 100644 --- a/Tests/RunCMake/find_program/NamesPerDir.cmake +++ b/Tests/RunCMake/find_program/NamesPerDir.cmake @@ -4,3 +4,9 @@ find_program(PROG NO_DEFAULT_PATH ) message(STATUS "PROG='${PROG}'") + +find_program(PROG_ABS + NAMES ${CMAKE_CURRENT_SOURCE_DIR}/A/testA NAMES_PER_DIR + NO_DEFAULT_PATH + ) +message(STATUS "PROG_ABS='${PROG_ABS}'")