This example shows how to set up a cmake project and one of its targets. Then the target is watched for source changes and rebuild if needed.
#include <siplasplas/cmake/project.hpp>
#include <siplasplas/reflection/dynamic/runtimeloader.hpp>
#include <iostream>
{
public:
void onBuildStarted(const std::string& target)
{
std::cout << "Building " << target << "...\n";
}
void onBuildFinished(const std::string& target, bool successful)
{
if(successful)
{
std::cout << target << " successfully built.\n";
}
else
{
std::cout << target << " build failed.\n";
}
}
void stdoutLineFromBuildJob(const std::string& target, const std::string& line)
{
std::cout << line << "\n";
}
void reloadBinary(const std::string& binary)
{
std::cout << "Reloading " << binary << " symbols...\n";
}
private:
cpp::dynamic_reflection::RuntimeLoader _runtimeLoader;
};
int main()
{
const std::string& targetName = "pluginexample";
CMakeProgress cmakeProgress;
auto& target = project.
addTarget(targetName);
{
std::cout << targetName << " build finished!!! (successful=" << std::boolalpha << successful << ")\n";
});
while(true)
{
cmakeProgress.poll();
}
}