FIX: fix the problem where a target is a single character and nmake gets confused and add a test for it
This commit is contained in:
parent
43bc8a0d63
commit
040f776885
|
@ -426,15 +426,18 @@ bool cmSystemTools::RunSingleCommand(
|
||||||
{
|
{
|
||||||
verbose = false;
|
verbose = false;
|
||||||
}
|
}
|
||||||
|
std::string argsTemp;
|
||||||
|
std::string program;
|
||||||
|
cmSystemTools::SplitProgramFromArgs(command, program, argsTemp);
|
||||||
|
std::vector<cmStdString> args = cmSystemTools::ParseArguments(argsTemp.c_str());
|
||||||
|
|
||||||
std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
|
if(program.size() < 1)
|
||||||
|
|
||||||
if(args.size() < 1)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const char*> argv;
|
std::vector<const char*> argv;
|
||||||
|
argv.push_back(program.c_str());
|
||||||
for(std::vector<cmStdString>::const_iterator a = args.begin();
|
for(std::vector<cmStdString>::const_iterator a = args.begin();
|
||||||
a != args.end(); ++a)
|
a != args.end(); ++a)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys)
|
||||||
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
|
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
|
||||||
LINK_LIBRARIES(${COMPLEX_LIBS})
|
LINK_LIBRARIES(${COMPLEX_LIBS})
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(A A.cxx)
|
||||||
ADD_EXECUTABLE(complex complex)
|
ADD_EXECUTABLE(complex complex)
|
||||||
ADD_EXECUTABLE(complex.file complex.file.cxx)
|
ADD_EXECUTABLE(complex.file complex.file.cxx)
|
||||||
IF (UNIX)
|
IF (UNIX)
|
||||||
|
|
|
@ -111,6 +111,34 @@ int main()
|
||||||
lib += CMAKE_INTDIR;
|
lib += CMAKE_INTDIR;
|
||||||
lib += "/";
|
lib += "/";
|
||||||
#endif
|
#endif
|
||||||
|
std::string exe = lib;
|
||||||
|
|
||||||
|
// Test a single character executable to test a: in makefiles
|
||||||
|
exe += "A";
|
||||||
|
exe += cmSystemTools::GetExecutableExtension();
|
||||||
|
int ret;
|
||||||
|
std::string errorMessage;
|
||||||
|
if(cmSystemTools::RunSingleCommand(exe.c_str(), 0, &ret))
|
||||||
|
{
|
||||||
|
if(ret != 10)
|
||||||
|
{
|
||||||
|
errorMessage += exe;
|
||||||
|
errorMessage += " did not return 10";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorMessage += exe;
|
||||||
|
errorMessage += ": failed to run.";
|
||||||
|
}
|
||||||
|
if(errorMessage.size())
|
||||||
|
{
|
||||||
|
cmFailed(errorMessage.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("run Single Character executable A returned 10 as expected.");
|
||||||
|
}
|
||||||
|
|
||||||
lib += cmDynamicLoader::LibPrefix();
|
lib += cmDynamicLoader::LibPrefix();
|
||||||
lib += "CMakeTestModule";
|
lib += "CMakeTestModule";
|
||||||
|
|
|
@ -11,7 +11,7 @@ LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys)
|
||||||
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
|
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
|
||||||
LINK_LIBRARIES(${COMPLEX_LIBS})
|
LINK_LIBRARIES(${COMPLEX_LIBS})
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(A A.cxx)
|
||||||
ADD_EXECUTABLE(complex complex)
|
ADD_EXECUTABLE(complex complex)
|
||||||
ADD_EXECUTABLE(complex.file complex.file.cxx)
|
ADD_EXECUTABLE(complex.file complex.file.cxx)
|
||||||
IF (UNIX)
|
IF (UNIX)
|
||||||
|
|
|
@ -111,6 +111,34 @@ int main()
|
||||||
lib += CMAKE_INTDIR;
|
lib += CMAKE_INTDIR;
|
||||||
lib += "/";
|
lib += "/";
|
||||||
#endif
|
#endif
|
||||||
|
std::string exe = lib;
|
||||||
|
|
||||||
|
// Test a single character executable to test a: in makefiles
|
||||||
|
exe += "A";
|
||||||
|
exe += cmSystemTools::GetExecutableExtension();
|
||||||
|
int ret;
|
||||||
|
std::string errorMessage;
|
||||||
|
if(cmSystemTools::RunSingleCommand(exe.c_str(), 0, &ret))
|
||||||
|
{
|
||||||
|
if(ret != 10)
|
||||||
|
{
|
||||||
|
errorMessage += exe;
|
||||||
|
errorMessage += " did not return 10";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorMessage += exe;
|
||||||
|
errorMessage += ": failed to run.";
|
||||||
|
}
|
||||||
|
if(errorMessage.size())
|
||||||
|
{
|
||||||
|
cmFailed(errorMessage.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("run Single Character executable A returned 10 as expected.");
|
||||||
|
}
|
||||||
|
|
||||||
lib += cmDynamicLoader::LibPrefix();
|
lib += cmDynamicLoader::LibPrefix();
|
||||||
lib += "CMakeTestModule";
|
lib += "CMakeTestModule";
|
||||||
|
|
|
@ -11,7 +11,7 @@ LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys)
|
||||||
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
|
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
|
||||||
LINK_LIBRARIES(${COMPLEX_LIBS})
|
LINK_LIBRARIES(${COMPLEX_LIBS})
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(A A.cxx)
|
||||||
ADD_EXECUTABLE(complex complex)
|
ADD_EXECUTABLE(complex complex)
|
||||||
ADD_EXECUTABLE(complex.file complex.file.cxx)
|
ADD_EXECUTABLE(complex.file complex.file.cxx)
|
||||||
IF (UNIX)
|
IF (UNIX)
|
||||||
|
|
|
@ -111,6 +111,34 @@ int main()
|
||||||
lib += CMAKE_INTDIR;
|
lib += CMAKE_INTDIR;
|
||||||
lib += "/";
|
lib += "/";
|
||||||
#endif
|
#endif
|
||||||
|
std::string exe = lib;
|
||||||
|
|
||||||
|
// Test a single character executable to test a: in makefiles
|
||||||
|
exe += "A";
|
||||||
|
exe += cmSystemTools::GetExecutableExtension();
|
||||||
|
int ret;
|
||||||
|
std::string errorMessage;
|
||||||
|
if(cmSystemTools::RunSingleCommand(exe.c_str(), 0, &ret))
|
||||||
|
{
|
||||||
|
if(ret != 10)
|
||||||
|
{
|
||||||
|
errorMessage += exe;
|
||||||
|
errorMessage += " did not return 10";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorMessage += exe;
|
||||||
|
errorMessage += ": failed to run.";
|
||||||
|
}
|
||||||
|
if(errorMessage.size())
|
||||||
|
{
|
||||||
|
cmFailed(errorMessage.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("run Single Character executable A returned 10 as expected.");
|
||||||
|
}
|
||||||
|
|
||||||
lib += cmDynamicLoader::LibPrefix();
|
lib += cmDynamicLoader::LibPrefix();
|
||||||
lib += "CMakeTestModule";
|
lib += "CMakeTestModule";
|
||||||
|
|
Loading…
Reference in New Issue