Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
/build/camitk-9Ht7pk/camitk-6.0.0/sdk/libraries/extensiongenerator/CMakeProjectManager.h

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.

CMakeProjectManager manager(camitkFileFullPath);
// connect signals to follow progress
connect(&manager, &CMakeProjectManager::stageStarted, this, [ = ](const QString & stage) {
std::cout << "Starting stage \"" << stage << "\"..." << std::endl;
});
connect(&manager, &CMakeProjectManager::stageFinished, this, [ = ](const QString & stage, bool success, const QString & output) {
std::cout << "Stage \"" << stage << "\" finished." << std::endl;
std::cout << "Status: " << ((success) ? "[OK]" : "[FAILED]") << std::endl;
std::cout << "Output:\n" << output << std::endl;
});
connect(&manager, &CMakeProjectManager::allStagesFinished, this, [ = ](bool status) {
std::cout << "Stage \"" << stage << "\" finished." << std::endl;
std::cout << "Status: " << ((success) ? "[OK]" : "[FAILED]") << std::endl;
});
// starts the stages
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)
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#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) // This macro makes the enum available to the meta-object system
CMakeProjectManager(const QString& camitkFilePath, QObject* parent = nullptr);
void setStages(QList<CMakeProjectManagerStage> stagesToPerform);
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 // __CMAKE_PROJECT_MANAGER__
#define CAMITKEXTENSIONGENERATOR_EXPORT
Definition CamiTKExtensionGeneratorAPI.h:33
Definition PersistenceManager.h:30