I’m adding a sub-folder for test files to my main project. The sub-folder has its own CMakeLists.txt file which adds the tests. But in those files in the sub-directory, I can’t include the normal JuceHeader.h.
// all the usual juce CMake setup here
Thanks reuk, it’s working now. I’m still struggling to get CTests working though, since main() never seems to get called for some reason. Does anyone have any examples up on github of using CMake, CTest and juce::UnitTestRunner?
I ended up abandoning CTests and just running tests within my app’s native environment. My app has its own console, so it seemed to make sense. The basic idea was to bundle all of my code minus the JUCEApplication class into a new library (let’s call it CoreLibrary). Then I have two new CMake targets which link CoreLibrary. Both of them have a different JUCEApplication class and main() function, one to load the normal app and the other to load the testing variation. This actually compiles; however, it throws Intellisense off completely, and my error console is littered with errors because it thinks it doesn’t recognize JUCE. Even though these error messages are “wrong”, it makes it difficult for me to proceed, because finding the real errors is now next to impossible.
I know that this is a really boring post, and also that my code is really messy (the only approach I know with CMake is to hack at it until it work). But would someone mind taking a quick look over my code and giving me some feedback? I’m not even sure if it’s a problem with my CMake setup or if it’s a bug with Visual Studio, so it’s really hard to me to find help about this online.
project(CoreLibrary) # Am I right to have a new project() call here?
# all my files.,.
# all my files again...