Always place try_compile executables predictably (#11724)

Set CMAKE_RUNTIME_OUTPUT_DIRECTORY explicitly in try_compile projects so
that the COPY_FILE feature knows where to look.  This makes the feature
robust against CMAKE_USER_MAKE_RULES_OVERRIDE files that set variables
like CMAKE_RUNTIME_OUTPUT_DIRECTORY or EXECUTABLE_OUTPUT_PATH.
This commit is contained in:
Brad King 2011-01-20 08:08:47 -05:00
parent a5300f1d45
commit 5792d3a38a
1 changed files with 4 additions and 0 deletions

View File

@ -277,6 +277,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
cmakeFlags.push_back(flag); cmakeFlags.push_back(flag);
} }
/* Put the executable at a known location (for COPY_FILE). */
fprintf(fout, "SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
this->BinaryDirectory.c_str());
/* Create the actual executable. */
fprintf(fout, "ADD_EXECUTABLE(cmTryCompileExec \"%s\")\n",source.c_str()); fprintf(fout, "ADD_EXECUTABLE(cmTryCompileExec \"%s\")\n",source.c_str());
fprintf(fout, fprintf(fout,
"TARGET_LINK_LIBRARIES(cmTryCompileExec ${LINK_LIBRARIES})\n"); "TARGET_LINK_LIBRARIES(cmTryCompileExec ${LINK_LIBRARIES})\n");