diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1eb94ff11..84d504244 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -53,6 +53,7 @@ LINK_LIBRARIES(CMakeLib) LINK_DIRECTORIES(${CMake_BINARY_DIR}/Sources) ADD_EXECUTABLE(cmake cmakemain) +ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation) ADD_EXECUTABLE(ctest ctest.cxx cmSystemTools.cxx cmRegularExpression.cxx) @@ -66,6 +67,8 @@ IF(BUILD_TESTING) CONFIGURE_FILE( ${CMake_SOURCE_DIR}/Source/cmaketest.h.in ${CMake_BINARY_DIR}/Source/cmaketest.h ESCAPE_QUOTES) + ADD_TEST(DumpDocumentation ${CMake_BINARY_DIR}/Source/DumpDocumentation + ${CMake_BINARY_DIR}/CMakeDoc.html ) ADD_TEST(simple ${CMake_BINARY_DIR}/Source/cmaketest ${CMake_SOURCE_DIR}/Tests/Simple ${CMake_BINARY_DIR}/Tests/Simple simple ) diff --git a/Source/cmDumpDocumentation.cxx b/Source/cmDumpDocumentation.cxx index 51db267ad..77771dd30 100644 --- a/Source/cmDumpDocumentation.cxx +++ b/Source/cmDumpDocumentation.cxx @@ -3,10 +3,20 @@ // #include "cmMakefile.h" -int main() +int main(int ac, char** av) { cmMakefile makefile; - makefile.DumpDocumentationToFile("cmake.txt"); - + const char* outname = "cmake.html"; + if(ac > 1) + { + outname = av[1]; + } + std::ofstream fout(outname); + if(!fout) + { + std::cerr << "failed to open output file: " << outname << "\n"; + return -1; + } + makefile.DumpDocumentationToFile(fout); return 0; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9dd92e838..ee27f5846 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -797,16 +797,9 @@ const char* cmMakefile::GetDefinition(const char* name) return cmCacheManager::GetInstance()->GetCacheValue(name); } -int cmMakefile::DumpDocumentationToFile(const char *fileName) +int cmMakefile::DumpDocumentationToFile(std::ostream& f) { // Open the supplied filename - std::ofstream f; - f.open(fileName, std::ios::out); - - if ( f.fail() ) - { - return 0; - } // Loop over all registered commands and print out documentation const char *name; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c5363d64c..5146f8f99 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -487,7 +487,7 @@ public: * Dump documentation to a file. If 0 is returned, the * operation failed. */ - int DumpDocumentationToFile(const char *fileName); + int DumpDocumentationToFile(std::ostream&); /** * Expand all defined varibles in the string.