CMake issue with header only modules

I’m a bit of a CMake novice, so I could be entirely wrong about any of this.

We’re working on a project which uses an internal module which is header only.

In my CMakeLists.txt, I added


My module is located at the correct directory, where it contains only <module_name>.h and a few files which contain tests for the module (which is another JUCE cmake project using JUCE unit tests).

When I add the module in my project’s CMakeLists, this error occurs:

CMake Error at JUCE/extras/Build/CMake/JUCEUtils.cmake:359 (list):
  list sub-command REMOVE_ITEM requires two or more arguments.
Call Stack (most recent call first):
  JUCE/extras/Build/CMake/JUCEUtils.cmake:555 (_juce_module_sources)
  CMakeLists.txt:74 (juce_add_module)

This turns out to be here

if(NOT module_files_to_build STREQUAL "")
    list(REMOVE_ITEM headers ${module_files_to_build})

So I called message() to check the contents of module_files_to_build. For this module it was empty, so I’m not sure why it got into this if block.

In any case, this was solved by adding an empty file called <module_name>.cpp to the module header’s directory.

Again, not sure if this is something obviously wrong with this module or something wrong with juce_add_module, but it’s worth noting that this module made it in to my Projucer based projects just fine, so if there’s something wrong with the module it might be good to enforce in both places.

My solution for these issues so far is to create an empty my_module.cpp

That’s what I did too, but I’m wondering if it should be patched.

Thanks for reporting, the issue should be resolved by this patch:


Thanks for the quick one!