Open yfede opened 6 years ago
sounds reasonable, I won't have time to look at this right now, but will try when I get back from vacations.
cool, thanks!
To change the path detection you will just have add additional path hints to the find_path
call for JUCE_ROOT_DIR
.
For example, I just added a JUCE_DIR
variable as a path hint, which then only needs to be set before the call to find_package(JUCE ...)
:
find_path(JUCE_ROOT_DIR
"modules/juce_core/juce_core.h"
HINTS
${JUCE_DIR}
${PROJECT_SOURCE_DIR}/../
${PROJECT_SOURCE_DIR}/JUCE
${CMAKE_CURRENT_LIST_DIR}/../../JUCE
${CMAKE_CURRENT_LIST_DIR}/../JUCE
DOC
"JUCE library directory"
)
You might also noticed I choose to look for modules/juce_core/juce_core.h
instead of the default modules\JUCE Module Format.txt
, as I often delete that file and the header is needed anyway to determine the JUCE version.
@remymuller: Any interested in a pull request for this?
This only works if you want to change the global location of JUCE.
What is required is a more detailed handling of additional search paths in juce_add_module()
, and taking care additional include path are properly added to targets.
I don't have time to test it right now though.
+1 for this feature.
I just had to makeup a small CMakeLists.txt just to include a trivial module. It's possible, but a bit of a pain:
find_package(JUCE REQUIRED
COMPONENTS
juce_core
juce_events
juce_audio_basics
juce_audio_devices
juce_audio_formats
)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/JuceLibraryCode/JuceHeader.h "#include <ff_meters/ff_meters.h>")
include_directories(${CMAKE_CURRENT_LIST_DIR})
set(ff_meters_sources
ff_meters/ff_meters.h
ff_meters/ff_meters_LevelMeter.cpp
ff_meters/ff_meters_LevelMeter.h
<snip more>
)
add_library(ff_meters ${ff_meters_sources})
target_include_directories(ff_meters INTERFACE ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(ff_meters PRIVATE ${JUCE_LIBRARIES})
The main trick is to
Thanks remymuller for the nice juce-cmake, BTW, I explored it a bit today and must say it all works fairly smoothly so far!
Having the possibility to explicitly specify several directories where to look for modules would be appreciated.
Some useful code is now being released by third parties in the form of a JUCE module, or companies are writing their own code to be reused in that form.
That code certainly does not belong inside the "modules" directory of the JUCE repo/submodule one has cloned.
I think that the a config variable MODULES_ROOT_DIRS could be added to contain a list of those rather than having just one JUCE_ROOT_DIR.
That variable could then contain "juce/modules", then "another-lib/modules", etc., and find_package should look in all of them to find a module.