Open remymuller opened 6 years ago
You can cheat a bit like that.
In all your librairies do that
# Juce
IF(NOT DEFINED JUCE_LIBRARIES)
find_package(JUCE REQUIRED
COMPONENTS
juce_audio_basics # put all required module for the whole project here
)
target_link_libraries(MyLibrary PRIVATE ${JUCE_LIBRARIES})
ENDIF()
target_include_directories(MyLibrary PRIVATE ${JUCE_INCLUDES})
Not perfect but it does the job
Many thanks! That works!
The only caveat would be that the top-level project needs to list the subset of all JUCE modules required by the sub-modules, as there is no collection of required modules upfront, but given there are not too many, I easily can live with that!
Maybe this is already the issue I was about to file, so let me ask the question like this:
I have a multi-library JUCE project (e.g. you can look at https://github.com/christofmuc/juce-spectroscope19-ci which is public), and compile a few libraries as static link libraries. These libraries use JUCE. With the current find_package() in my CMakeLists for the static library I do
This will work nicely, but obviously the juce CPP files are now part of this library project and will be compiled and linked into this library. As the main project is also JUCE-based, I do in the top-level CMakeLists:
which will again add the JUCE cpp files to the executable. Surprisingly, this works despite the same files from juce being present multiple times to the linker, and actually sometimes in some rebuild situations the linker fails with duplicate symbols. But it is not efficient, as I have the JUCE cpp files everywhere.
I would like to only use the JUCE Header generation and set the appropriate target_compile_options, but the variables JUCE_INCLUDE_DIR etc. are not populated. I must be missing something obvious?
I must admit I did not get the comment about the "merge" target that is in the FindJUCE.cmake file.