Manage configuration check, CMake configure and build stages from C++ of the given CamiTK file.
Manage configuration check, CMake configure and build stages from C++ of the given CamiTK file The following stages can be performed by calling related applications using QProcess:
- Check_System: check that cmake, camitk-extensiongenerator and camitk-config are found and usable
- Generate_Source_Files: calls camitk-extensiongenerator (first phase with destination dir equals to the CamiTK file path)
- Configure_CMake: run cmake for configuration of the generated source files and creates the build directory
- Build_Project: run "cmake --build build"
- Run_CamiTK_Config: run "camitk-config --config", output can be check for new Standard extension
- Check_Integration: (for Standard extension) check what is build action extensions defined in the CamiTK file were build and properly loaded by camitk-config
- Cleanup: remove temporary directory used during the previous stages
Set the list of stages you want to perform using setStages (default is do them all) and call start(). Each stage will be performed up to the last stage or up to the first one that fails.
Connect your methods to three given signals to follow the status of each stage.
std::cout << "Starting stage \"" << stage << "\"..." << std::endl;
});
std::cout << "Stage \"" << stage << "\" finished." << std::endl;
std::cout << "Status: " << ((success) ? "[OK]" : "[FAILED]") << std::endl;
std::cout << "Output:\n" << output << std::endl;
});
std::cout << "Stage \"" << stage << "\" finished." << std::endl;
std::cout << "Status: " << ((success) ? "[OK]" : "[FAILED]") << std::endl;
});
manager.start();
Definition CMakeProjectManager.h:78
@ Configure_CMake
cmake configure
Definition CMakeProjectManager.h:87
@ Generate_Source_Files
calls camitk-extensiongenerator (fist phase with destination dir equals to the CamiTK file path)
Definition CMakeProjectManager.h:86
@ Build_Project
cmake build
Definition CMakeProjectManager.h:88
@ Check_System
check that cmake, camitk-extensiongenerator and camitk-config are found and usable
Definition CMakeProjectManager.h:85
void allStagesFinished(bool status)
sent when all the stage are finished (with the given overall status)
void stageStarted(const QString &stage)
sent when the given stage is starting
void stageFinished(const QString &stage, bool success, const QString &output)
sent when the given stage is finished (with the given status and output)
#ifndef __CMAKE_PROJECT_MANAGER__
#define __CMAKE_PROJECT_MANAGER__
#include <QObject>
#include <QProcess>
#include <QDir>
Q_OBJECT
public:
enum CMakeProjectManagerStage {
Check_System,
Generate_Source_Files,
Configure_CMake,
Build_Project,
Run_CamiTK_Config,
Check_Integration,
Cleanup
};
Q_ENUM(CMakeProjectManagerStage)
void start();
bool success() const;
QString getCurrentStage() const;
QStringList getStages() const;
QString getStageName(CMakeProjectManagerStage value) const;
signals:
void stageStarted(const QString& stage);
void stageFinished(const QString& stage, bool success, const QString& output);
void allStagesFinished(bool status);
private slots:
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
private:
QString camitkFilePath;
QProcess* currentProcess;
bool status;
QDir sourceDir;
QDir buildDir;
QDir camitkBinDir;
bool isDebug;
int currentStageIndex;
void executeNextStage();
void checkSystem();
void generateSourceFiles();
void configureCMake();
void buildProject();
void runCamiTKConfig();
void checkIntegration();
void cleanup();
};
#endif
#define CAMITKEXTENSIONGENERATOR_EXPORT
Definition CamiTKExtensionGeneratorAPI.h:33
Definition PersistenceManager.h:30