I’m a complete CMake newbie and the only reason I’m looking into it is to try and port our plugins to CLAP (hopefully, that’s coming to JUCE soon).
I find CMake to be convoluted and I can’t find an easy way to replicate the current setup we have using Projucer.
Using FRUT I was able to at least in part convert a .jucer file to CMakeLists.txt
However, the folder structure is completely messed up.
A typical plugin file structure for us is something like this:
I can’t find a way to add folders that are outside the plugin repo to the project, it looks like they all need to be inside the plugin repo.
I also can’t find a way to organize the files in folders, instead, the Xcode project generated by CMake has all the .cpp listed in Source Files and all the .h in Header Files:
Xcode is a bit of a special cookie. I’ve abandoned it for CLion, which has fantastic CMake integration, but before that, I spent many hours tweaking it to display JUCE projects decently.
I also can’t find a way to organize the files in folders, instead, the Xcode project generated by CMake has all the .cpp listed in Source Files and all the .h in Header Files
This and the excessive amount of targets are the current problems with Xcode+JUCE. It’s been a while, but here’s what I do in my projects (globs are dead, long live globs!)
# Why yes, we'd like all our Source files to be in our Source dir...
file(GLOB_RECURSE SourceFiles CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Source/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Source/*.h")
target_sources("${PROJECT_NAME}" PRIVATE ${SourceFiles})
# Grab our modules from the Module dir, while we are at it
file(GLOB_RECURSE ModuleFiles CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/modules/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/modules/*.h")
target_sources("${PROJECT_NAME}" PRIVATE ${moduleFiles})
# Our file tree should uhhh, still look like our file tree
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/Source PREFIX "" FILES ${SourceFiles})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/modules PREFIX "" FILES ${ModuleFiles})
Also @benvining is doing a cmake series on the Audio Programmer’s youtube channel right now. (He might show up and say that the CMake devs (still) warn against using globs, even with CONFIGURE_DEPENDS but so far I haven’t run into any real world problems with them).
@audiothing just FYI jatin is working on making the CLAP extensions work with projucer also; he got it working yesterday and we might be able to merge it this weekend (we have mostly documentation work to do).
I’m seeing an incredible amount of warnings (8000+) that I don’t see with the XCode project generated by Projucer (10+). Not a big deal, but it’s annoying. Any flag I should set to avoid that?
@baconpaul yes I sent Jatin an email a few days ago, I look forward to the projucer implementation if it’s stable enough. I still feel like CMake is probably not the best solution for my needs, but I’m also afraid that the Projucer might be abandoned in the future, so I want to try to stay a bit ahead