siplasplas
A library for C++ reflection and introspection
project.hpp
1 #ifndef SIPLASPLAS_CMAKE_PROJECT_HPP
2 #define SIPLASPLAS_CMAKE_PROJECT_HPP
3 
4 #include <string>
5 #include <siplasplas/signals/emitter.hpp>
6 #include <siplasplas/fswatch/fslistener.hpp>
7 #include <siplasplas/cmake/export.hpp>
8 #include "target.hpp"
9 
43 namespace cpp
44 {
45 
58 class SIPLASPLAS_CMAKE_EXPORT CMakeProject : public SignalEmitter
59 {
60 public:
61 
72  CMakeProject(const std::string& sourceDir, const std::string& binaryDir);
73 
81  void configure();
82 
94  void buildTarget(const std::string& targetName);
95 
111  CMakeTarget& addTarget(const std::string& name);
112 
126  CMakeTarget& addTarget(const CMakeTarget::Metadata& metadata);
127 
140  efsw::WatchID addSourceDirWatch(const std::string& sourceDir);
141 
154  efsw::WatchID addIncludeDirWatch(const std::string& includeDir);
155 
169  efsw::WatchID addBinaryDirWatch(const std::string& binaryDir);
170 
181  void startWatch();
182 
186 
193  void configureFinished(bool successful) {}
194 
200  void buildStarted(const std::string& target) {}
201 
208  void buildFinished(const std::string& target, bool successful) {}
209 
221  void stdoutLine(const std::string& targetName, const std::string& line) {}
223 
233  cpp::FileSystemListener& fileSystemListener();
234 
240  const std::string& sourceDir() const;
241 
247  const std::string& binaryDir() const;
248 
249 private:
250  std::string _sourceDir, _binaryDir;
251  efsw::FileWatcher _fileWatcher;
252  cpp::FileSystemListener _fileListener;
253  std::vector<std::unique_ptr<CMakeTarget>> _targets;
254 };
255 
256 }
257 
258 #include <reflection/include/siplasplas/cmake/project.hpp>
259 
260 #endif // SIPLASPLAS_CMAKE_PROJECT_HPP
Configures and builds an existing CMake project.
Definition: project.hpp:58
Class that can send and receive signals from other emitters.
Definition: emitter.hpp:64
Definition: canary_allocator.hpp:7
void stdoutLine(const std::string &targetName, const std::string &line)
stdout line feed from target build.
Definition: project.hpp:221
void configureFinished(bool successful)
Project configuration has finished.
Definition: project.hpp:193
void buildFinished(const std::string &target, bool successful)
A target build has finished.
Definition: project.hpp:208
void buildStarted(const std::string &target)
A target build started.
Definition: project.hpp:200
Represents a CMake target being watched by a project.
Definition: target.hpp:32
Represents the set of properties that define a target.
Definition: target.hpp:51
File system listener class that notifies filesystem changed through signals.
Definition: fslistener.hpp:41