[SOLVED] Build Juce targets only once/ or fix somehow rebuild for single file. (cmake doesn't see my changes)


I have the situation when cmake doesn’t see my changes in .h files. And app just running without any changes. I have to run “clean” before the each build. Not sure why this is happening. (My sources is basically only .h files without .cpp files. because I’m tired of duplicating the same method names in two files) p.s. this even happens if I use .cpp files. (I use CLion IDE)

So my question is if I can exclude somehow JUCE files from the cmake clean, so it will not generate each time the same mm.o files and just used the old one?

Project rebuild takes a long time and it becomes difficult to debug something in real time.
especially hard is building on these files:
[ 94%] Building CXX object CMakeFiles/APP.dir/Users/xxxx/Documents/GitHub/MyApp1/JuceLibraryCode/include_juce_gui_extra.mm.o
[ 97%] Building CXX object CMakeFiles/APP.dir/Users/xxxx/Documents/GitHub/MyApp1/JuceLibraryCode/include_juce_opengl.mm.o

Please help! I didn’t find this thread on the forum, but if I missed something or there is a setting in Projucer. Let me know.


Doing a clean build every time seems like a general misconfiguration in your project and excluding the JUCE sources does not seem like a solution to that from my point of view. How do you add your source files to your CMake project? Did you know that you can also pass header files to target_sources? Maybe that will do the trick.

@PluginPenguin Thanks for reply. This happens for me even with new empty project. Yes, I know about target_sources, but I’m using projucer to generate a cmake txt file. So any manual changes will be lost after I make some changes in projucer.


That CLion exporter is now deprecated. I suggest to try the JUCE6 native CMake support.

@eyalamir sorry, not sure how do to this. There is no way to create it in the Projucer.

The native CMake support does not require the Projucer. You just create a CMakeLists.txt file which can open directly in CLion, and you can also use to generate projects to other IDEs as well.

Here are some examples:

@eyalamir I do not quite understand what the difference will be. Currently the Projucer generates CMakeLists.txt and the CLion just opens it fine. I just have a checkbox checked - import settings from exporter: Mac OS X or Windows :: Blocks

I would not really like to do it manually just would like it to be generated by one button itself. In addition, I use very heavily Projucer, adding new files, binary data, etc. BTW, @ToJuce That was actually the reason why I started using Juce. Because you click one button and it just opens and work anywhere. Now it seems not user-friendly. With other frameworks I spend a months… and days to get it work. Any reason why the CLion is now deprecated?

The difference is, those generated Projucer->CMake files were not good and had bugs in them, which is one reason why the JUCE team dropped them.

I used to use CLion with the generated files and switched to the manual files, because of similar problems. The native CMake files supports all the features you like in the Projucer, like BinaryData.

P.S. In CLion you want to make sure you’re using the Visual Studio toolchain (with either Clang or MSVC compilers) and not Cygwin or MinGW that are buggy.

Looks like I resolved this issue by removing target_include_directories(…)

That strange. I was just trying to create an alternative <MyAppHeader.h> like Juce have. and inside this file I used most frequent libraries. But then without the “Clean” the whole project seems to be just being cached and even if I remove all files in the project, the app still running without any changes :slight_smile:

So I have now to write relative url to include my global in this way: “…/…/…/src/common/MyAppHeader.h”

or use include_directories() instead of target_include_directories()