Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <iostream>
00019 #include <string>
00020
00021 #include <stdlib.h>
00022
00023 #include <itksys/SystemTools.hxx>
00024
00025 int mitkExternalToolsTest(int argc, char* argv[])
00026 {
00027 return EXIT_SUCCESS;
00028
00029
00030 std::cout << "Got " << argc << " parameters" << std::endl;
00031 if ( argc == 5 )
00032 {
00033
00034
00035
00036 std::string cmakeBinary = argv[1];
00037 std::string cmakeGenerator = argv[2];
00038 std::string mitkBinaryDirectory = argv[3];
00039 std::string sourceDirectory = argv[4];
00040
00041
00042 std::cout << "Calling CMake as '" << cmakeBinary << "'" << std::endl;
00043 std::cout << "Calling CMake for generator '" << cmakeGenerator << "'" << std::endl;
00044 std::cout << "MITK was compiled in '" << mitkBinaryDirectory << "'" << std::endl;
00045 std::cout << "Configuring project in '" << sourceDirectory << "'" << std::endl;
00046
00047 if( itksys::SystemTools::ChangeDirectory(mitkBinaryDirectory.c_str()) != 0 )
00048 {
00049 std::cerr << "Couldn't change to MITK build dir. See output above." << std::endl;
00050 return EXIT_FAILURE;
00051 }
00052
00053 std::string oneCommandlineQuote("\"");
00054
00055 std::string commandline( oneCommandlineQuote );
00056 commandline += cmakeBinary;
00057 commandline += oneCommandlineQuote;
00058
00059 commandline += " -G ";
00060 commandline += oneCommandlineQuote;
00061 commandline += cmakeGenerator;
00062 commandline += oneCommandlineQuote;
00063
00064 commandline += " -DMITK_DIR:PATH=";
00065
00066 commandline += oneCommandlineQuote;
00067 commandline += mitkBinaryDirectory;
00068 commandline += oneCommandlineQuote;
00069 commandline += " ";
00070 commandline += oneCommandlineQuote;
00071 commandline += sourceDirectory;
00072 commandline += oneCommandlineQuote;
00073
00074 std::cout << "Calling system() with '"
00075 << commandline
00076 << "'"
00077 << std::endl;
00078
00079 int returnCode = system(commandline.c_str());
00080
00081 std::cout << "system() returned " << returnCode << std::endl;
00082
00083 if (returnCode != 0)
00084 {
00085 std::cerr << "Configure FAILED. See output above." << std::endl;
00086 return EXIT_FAILURE;
00087 }
00088
00089
00090
00091 #ifdef WIN32
00092 #else
00093 commandline = "make";
00094
00095
00096
00097 if (returnCode != 0)
00098 {
00099 std::cout << "make returned " << returnCode << std::endl;
00100 std::cerr << "Building the project FAILED. See output above." << std::endl;
00101 return EXIT_FAILURE;
00102 }
00103
00104 #endif
00105
00106
00107
00108 return returnCode;
00109 }
00110 else
00111 {
00112 std::cout << "Invoke this test with three parameters:" << std::endl;
00113 std::cout << " 1. CMake binary including necessary path" << std::endl;
00114 std::cout << " 2. CMake generator name" << std::endl;
00115 std::cout << " 3. MITK binary path (top-level directory)" << std::endl;
00116 std::cout << " 4. Source directory containing CMakeLists.txt" << std::endl;
00117 return EXIT_FAILURE;
00118 }
00119 }
00120