remymuller / juce-cmake

CMake find module for the JUCE library
MIT License
30 stars 7 forks source link

handle BinaryData inclusion in JuceHeader.h #4

Open remymuller opened 7 years ago

FlorianFranzen commented 5 years ago

I solved this for now by just specifying the JUCE_BINARYDATA_DIR and copying the BinaryData files to the generated ones:

# Make sure binarydata dir is absolute
if(NOT IS_ABSOLUTE "${JUCE_BINARYDATA_DIR}")
    set(JUCE_BINARYDATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${JUCE_BINARYDATA_DIR}")
endif()

# copy excisting BinaryData.h
if(EXISTS "${JUCE_BINARYDATA_DIR}/BinaryData.h" AND 
   EXISTS "${JUCE_BINARYDATA_DIR}/BinaryData.cpp")
    message(STATUS "Using pregenerated BinaryData.h/.cpp")

    set(JUCE_BINARYDATA_H "${JuceLibraryCode}/BinaryData.h")
    set(JUCE_BINARYDATA_CPP "${JuceLibraryCode}/BinaryData.cpp")

    configure_file("${JUCE_BINARYDATA_DIR}/BinaryData.h" 
                   "${JUCE_BINARYDATA_H}"
                   COPYONLY)
    configure_file("${JUCE_BINARYDATA_DIR}/BinaryData.cpp" 
                   "${JUCE_BINARYDATA_CPP}"
                   COPYONLY)

    # This variable is written to JuceHeader.h
    set(JUCE_BINARYDATA_INCLUDES "#include \"BinaryData.h\"")
endif()

JUCE_BINARYDATA_INCLUDES is part of the JuceHeader.h template.

I also added JUCE_BINARYDATA_H and JUCE_BINARYDATA_CPP to JUCE_SOURCES.