2

I cloned https://github.com/juce-framework/JUCE

I first uncommented find_package(JUCE) in /GuiApp' CMakeList.txt. Then I ran cmake .. . -B cmake-build-dir -D JUCE_BUILD_EXAMPLES=ON on the top level directory.

It says:

-- Checking for modules 'webkit2gtk-4.0;gtk+-x11-3.0'
--   No package 'webkit2gtk-4.0' found
--   No package 'gtk+-x11-3.0' found
-- Checking for module 'alsa'
--   No package 'alsa' found
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
CMake Error at examples/CMake/GuiApp/CMakeLists.txt:27 (find_package):
  Could not find a package configuration file provided by "JUCE" with any of
  the following names:

    JUCEConfig.cmake
    juce-config.cmake

  Add the installation prefix of "JUCE" to CMAKE_PREFIX_PATH or set
  "JUCE_DIR" to a directory containing one of the above files.  If "JUCE"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

I tried to find where is JUCEConfig.cmake

 /work/juce/temp/JUCE/build$ find . -name JUCEConfig.cmake
./cmake-build-dir/tools/JUCEConfig.cmake

How am I supposed to put this path in CMAKE_PREFIX_PATHS?

Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
  • 1
    Did you also note the comment [beside the line you uncommented](https://github.com/juce-framework/JUCE/blob/master/examples/CMake/GuiApp/CMakeLists.txt#L20-L27)? You should only use that one if you have previously installed JUCE to your system. – Botje Oct 12 '20 at 12:33
  • You did not need to uncomment that line; it is only meant for when you create a new application based on that template. – Botje Oct 12 '20 at 12:36
  • In your [previous question](https://stackoverflow.com/questions/64314319/unknown-cmake-command-juce-add-gui-app) (now deleted) you have tried to build example as --**standalone** project, using the example directory as source directory for CMake. That time you tried to build the example as a **part of** the JUCE. So, what exactly do you want? And please, stop creating and deleting question about the same problem. Instead, edit the old question and update information in it. – Tsyvarev Oct 12 '20 at 13:45
  • @Tsyvarev updating same question is not helpful because the error messages differ after my changes and I try different things to get something working and that results in a different scenario. The topic is same but the problems are not. Secondly, I did not know what I was doing here. All I wanted was to run and see a hello world program. To see how to compile a simple JUCE program with CMakeLists.txt. Now this problem has been solved by the help of a helpful person from JUCE forums. I will write the same answer here itself. – Aquarius_Girl Oct 12 '20 at 14:03

1 Answers1

4

Clone this repository: https://github.com/juce-framework/JUCE

alsa and webkit2gtk are required dependencies which were absent on Ubuntu 18.04 in my computer. You too may have to install as follows:

sudo apt install libwebkit2gtk-4.0-dev libasound2-dev

In the examples/CMake folder in this repository there is a folder called GuiApp.

To build a new GUI App project with JUCE/CMake, do this (starting from scratch):

  1. Copy the GuiApp folder to a new location.

  2. In the GuiApp's CMakeLists.txt that you copied, replace the

    add_subdirectory(JUCE)

with

add_subdirectory("<path_to_JUCE_cloned_repository>" JUCE) 

replacing the path with the real location of the JUCE repository on your system.

  1. From the GuiApp folder that you copied, run

    cmake . -B cmake-build-dir

Above command will create a build tree folder named cmake-build-dir

  1. cmake --build cmake-build-dir

Above command will build all targets in the cmake-build-dir folder.

  1. After successful build, you can run the executable by going in directory:

    cmake-build-dir/GuiAppExample_artefacts/

and issuing ./Gui\ App\ Example. That's the name of the resultant default executable.

Credit: https://forum.juce.com/u/reuk/summary

Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411