diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-09-20 17:15:56 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-09-20 17:15:56 (GMT) |
commit | 157e2b4ac3a067107561d4ccc2b08ea3555cce44 (patch) | |
tree | af1a9357c08c2b99ebeabd787e3b5f19bb56e062 /Source/cmTryCompileCommand.cxx | |
parent | 92714311c992a924a249bf9f27820f0512af7013 (diff) | |
download | CMake-157e2b4ac3a067107561d4ccc2b08ea3555cce44.zip CMake-157e2b4ac3a067107561d4ccc2b08ea3555cce44.tar.gz CMake-157e2b4ac3a067107561d4ccc2b08ea3555cce44.tar.bz2 |
Add option of TRY_COMPILE to store the output of compilation so that if the output fails you can display it or store it in the file
Diffstat (limited to 'Source/cmTryCompileCommand.cxx')
-rw-r--r-- | Source/cmTryCompileCommand.cxx | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 9e243a5..cf54a09 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -33,7 +33,8 @@ int cmTryCompileCommand::CoreTryCompileCode( std::string tmpString; // do we have a srcfile signature - if (argv.size() == 3 || argv[3] == "CMAKE_FLAGS" || argv[3] == "COMPILE_DEFINITIONS") + if (argv.size() == 3 || argv[3] == "CMAKE_FLAGS" || argv[3] == "COMPILE_DEFINITIONS" || + argv[3] == "OUTPUT_VARIABLE") { srcFileSignature = true; } @@ -44,7 +45,8 @@ int cmTryCompileCommand::CoreTryCompileCode( { if (argv[i] == "CMAKE_FLAGS") { - for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS"; + for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" && + argv[i] != "OUTPUT_VARIABLE"; ++i) { cmakeFlags.push_back(argv[i]); @@ -53,6 +55,23 @@ int cmTryCompileCommand::CoreTryCompileCode( } } + // look for OUTPUT_VARIABLE and store them + std::string outputVariable; + for (i = 3; i < argv.size(); ++i) + { + if (argv[i] == "OUTPUT_VARIABLE") + { + if ( argv.size() <= (i+1) ) + { + cmSystemTools::Error( + "OUTPUT_VARIABLE specified but there is no variable"); + return -1; + } + outputVariable = argv[i+1]; + break; + } + } + // look for COMPILE_DEFINITIONS and store them std::vector<std::string> compileFlags; for (i = 3; i < argv.size(); ++i) @@ -66,7 +85,8 @@ int cmTryCompileCommand::CoreTryCompileCode( "COMPILE_FLAGS specified on a srcdir type TRY_COMPILE"); return -1; } - for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS"; + for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" && + argv[i] != "OUTPUT_VARIABLE"; ++i) { compileFlags.push_back(argv[i]); @@ -144,12 +164,18 @@ int cmTryCompileCommand::CoreTryCompileCode( } } + std::string output; // actually do the try compile now that everything is setup int res = mf->TryCompile(sourceDirectory, binaryDirectory, - projectName, targetName, &cmakeFlags); + projectName, targetName, &cmakeFlags, &output); // set the result var to the return value to indicate success or failure mf->AddDefinition(argv[0].c_str(), (res == 0 ? "TRUE" : "FALSE")); + + if ( outputVariable.size() > 0 ) + { + mf->AddDefinition(outputVariable.c_str(), output.c_str()); + } // if They specified clean then we clean up what we can if (srcFileSignature && clean) |