I am trying to use some C++ code in my JUCE project which has a number of cpp files, a compile.sh file and two shell scripts for running the code.
Would it be possible to run compile.sh as a Post-Build Shell Script and then run the executable files from my JUCE project using ChildProcess and the two shell scripts?
Ideally, I would like to simply download the folder and include it in my JUCE project folder, create the necessary executables at compile time and access them at run time. However, I am not sure if this is possible or where the executables will be stored.
A better solution would be to make a library out of the files in the project, submit a PR to the original authors, and then integrate that library in your JUCE project.
Shouldn’t be too hard - would just need to use some kind of macro to guard the inclusion of main(), add the .cpp files to an EXTRA_SOURCES-style definition in your JUCE Project, and then just build it in.
(EDIT: removed incorrect assessment of sources that could be used as modules)
… so it really depends what functionality you want to include in your JUCE project - it may very well be the case that you can simply include the AlignmentTool project sources as a submodule in your main JUCE project, and compile/link the relevant sources directly.
AlignmentTool is a very interesting project, btw! Would be cool to see it turned into a more functional library that other JUCE devs could include …
I took your advice and started exploring how best to make a library out of the files in the project. Since all the .cpp files include a main() function I decided to add them as executables to a CMakeLists.txt file in the AlignmentTool folder.
Obviously this approaches means migrating the project from the Projucer to CMake. Before I do this I was wondering if this seemed like a reasonable approach? Also, I know this is not quite the same as creating a library but was influenced by a this StackOverflow post and decided to try something similar.
If possible could you elaborate on how you might go about using a macro to guard against the inclusion of main() should I want to create a library instead?
I’m glad you are interested in the AlignmentTool! Happy to share the library with other JUCE devs if I find a portable solution.