Skip to content

Commit

Permalink
CMake: Allow build tree to be used as a pseudo-install-tree
Browse files Browse the repository at this point in the history
Once JUCE has been built, you can use the following line to include
the targets from the build tree (replace `JUCE_BUILD_DIR` as
appropriate).
```
include("${JUCE_BUILD_DIR}/JUCEExportConfig.cmake")
```
  • Loading branch information
reuk committed Apr 20, 2020
1 parent 167397a commit 0b4089c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
15 changes: 14 additions & 1 deletion CMakeLists.txt
Expand Up @@ -80,11 +80,24 @@ set(JUCE_INSTALL_DESTINATION "lib/cmake/JUCE-${JUCE_VERSION}" CACHE STRING
"The location, relative to the install prefix, where the JUCE config file will be installed")

install(EXPORT JUCE NAMESPACE juce:: DESTINATION "${JUCE_INSTALL_DESTINATION}")

set(JUCE_EXPORT_FILE_NAME "JUCE.cmake")
set(UTILS_INSTALL_DIR "${JUCE_INSTALL_DESTINATION}")
set(JUCEAIDE_PATH "${JUCE_TOOL_INSTALL_DIR}/${JUCE_JUCEAIDE_NAME}")
configure_package_config_file("${JUCE_CMAKE_UTILS_DIR}/JUCEConfig.cmake.in"
"${JUCE_BINARY_DIR}/JUCEConfig.cmake"
PATH_VARS UTILS_INSTALL_DIR JUCEAIDE_PATH
INSTALL_DESTINATION "${JUCE_INSTALL_DESTINATION}")

set(JUCE_EXPORT_FILE_NAME "JUCEBuildTree.cmake")
export(EXPORT JUCE NAMESPACE juce:: FILE "${JUCE_EXPORT_FILE_NAME}")
set(UTILS_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extras/Build/CMake")
get_target_property(JUCEAIDE_PATH juceaide IMPORTED_LOCATION)
configure_package_config_file("${JUCE_CMAKE_UTILS_DIR}/JUCEConfig.cmake.in"
"${JUCE_BINARY_DIR}/JUCEExportConfig.cmake"
PATH_VARS UTILS_INSTALL_DIR JUCEAIDE_PATH
INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
INSTALL_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")

install(FILES "${JUCE_BINARY_DIR}/JUCEConfigVersion.cmake"
"${JUCE_BINARY_DIR}/JUCEConfig.cmake"
"${JUCE_CMAKE_UTILS_DIR}/LaunchScreen.storyboard"
Expand Down
16 changes: 3 additions & 13 deletions extras/Build/CMake/JUCEConfig.cmake.in
Expand Up @@ -20,24 +20,14 @@

@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/JUCE.cmake")

get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/@JUCE_EXPORT_FILE_NAME@")

if(NOT TARGET juce::juceaide)
add_executable(juce::juceaide IMPORTED)
set_target_properties(juce::juceaide PROPERTIES
IMPORTED_LOCATION "${_IMPORT_PREFIX}/@JUCE_CMAKE_BINARY_BUILDER_NAME@")
IMPORTED_LOCATION "@PACKAGE_JUCEAIDE_PATH@")
endif()

set(_IMPORT_PREFIX)

check_required_components("@PROJECT_NAME@")

include("${CMAKE_CURRENT_LIST_DIR}/JUCEUtils.cmake")
include("@PACKAGE_UTILS_INSTALL_DIR@/JUCEUtils.cmake")
3 changes: 1 addition & 2 deletions extras/Build/juceaide/CMakeLists.txt
Expand Up @@ -85,6 +85,5 @@ else()
install(PROGRAMS "${imported_location}" DESTINATION "${JUCE_TOOL_INSTALL_DIR}")

get_filename_component(binary_name "${imported_location}" NAME)
set(JUCE_CMAKE_BINARY_BUILDER_NAME "${JUCE_TOOL_INSTALL_DIR}/${binary_name}"
CACHE INTERNAL "The name of the juceaide program")
set(JUCE_JUCEAIDE_NAME "${binary_name}" CACHE INTERNAL "The name of the juceaide program")
endif()

0 comments on commit 0b4089c

Please sign in to comment.