# Unknown CMake command "juce\_add\_gui\_app"

**URL:** <https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175>\
**Category:** General JUCE discussion\
**Created:** [October 12, 2020, 8:33am UTC](https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175 "2020-10-12T08:33:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aquariusgirl](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aquariusgirl](https://forum.juce.com/u/aquariusgirl)\
**Post date:** [October 12, 2020, 8:33am UTC](https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175/1 "2020-10-12T08:33:09Z")

</div>

Well, I have progressed now with the official CMake project of JUCE.  
I cloned this whole directory: [https://github.com/juce-framework/JUCE](https://github.com/juce-framework/JUCE)

I went inside:

```
.../temp/JUCE/examples/CMake/GuiApp$ ls
build CMakeLists.txt MainComponent.cpp MainComponent.h Main.cpp

```

I made that `build` directory for executing `cmake`.

Executing the cmake is resulting in following error:

```
.../temp/JUCE/examples/CMake/GuiApp/build$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:39 (juce_add_gui_app):
  Unknown CMake command "juce_add_gui_app".

-- Configuring incomplete, errors occurred!
See also "/home/xyz/Documents/abc/work/juce/temp/JUCE/examples/CMake/GuiApp/build/CMakeFiles/CMakeOutput.log".

```

Was I supposed to change something in the CMakeList.txt? Please guide about how to get rid of `Unknown CMake command "juce_add_gui_app".` .

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [October 12, 2020, 9:12am UTC](https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175/2 "2020-10-12T09:12:23Z")

</div>

There are instructions for building the GuiApp example in `examples/CMake/GuiApp/CMakeLists.txt`.

If you’re building the GuiApp example from inside JUCE (as you’ve attempted here), you’ll need to run cmake from the top level of the repo, like so:

```auto
cmake . -B cmake-build-dir -D JUCE_BUILD_EXAMPLES=ON
cmake --build cmake-build-dir --target GuiApp

```

However, if you’re starting a new JUCE project, it’s recommended to copy the whole GuiApp folder to a new location outside the repo, and then to use `add_subdirectory(path/to/JUCE)` to point the project to a copy of JUCE.

---

<div class="post-metadata">

**Author:** ![aquariusgirl](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aquariusgirl](https://forum.juce.com/u/aquariusgirl)\
**Post date:** [October 12, 2020, 10:35am UTC](https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175/3 "2020-10-12T10:35:51Z")

</div>

Am thankful for your patience. I am not well versed with CMake yet.

I ran `cmake . -B cmake-build-dir -D JUCE_BUILD_EXAMPLES=ON` in the top level directory of the repository. It complained about missing ‘webkit2gtk-4.0’ , ‘gtk±x11-3.0’, and ‘alsa’.

Is it important to have these dependencies? Are they optional?

Secondly, where am I supposed to run the second command? `cmake --build cmake-build-dir --target GuiApp`?

I ran it in the top level repo’ build dir like this: `cmake .. --build cmake-build-dir --target ../examples/CMake/GuiApp`

It said:

`CMake Error: The source "/home/xyz/Documents/abc/work/juce/temp/JUCE/examples/CMake/GuiApp/CMakeLists.txt" does not match the source "/home/xyz/Documents/abc/work/juce/temp/JUCE/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.`

Running it in the `JUCE/examples/CMake/` repo complains about `Unknown CMake command "juce_add_gui_app"`.

Where am I supposed to run the second command?

---

<div class="post-metadata">

**Author:** ![aquariusgirl](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aquariusgirl](https://forum.juce.com/u/aquariusgirl)\
**Post date:** [October 12, 2020, 10:43am UTC](https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175/4 "2020-10-12T10:43:20Z")

</div>

Besides what I wrote in the above post, I have also enabled `find_package(JUCE CONFIG REQUIRED)` in th GuiApp’s CMakeList.txt.

Now the innermost cmake says:

```
CMake Error at CMakeLists.txt:25 (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.

```

should I have done this?

I have added `list(APPEND CMAKE_PREFIX_PATH "/home/xyz/Documents/abc/work/juce/temp/JUCE/")`

That doesn’t seem to help though.

---

<div class="post-metadata">

**Author:** ![aquariusgirl](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aquariusgirl](https://forum.juce.com/u/aquariusgirl)\
**Post date:** [October 12, 2020, 12:19pm UTC](https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175/5 "2020-10-12T12:19:07Z")

</div>

Again a change:

I cleaned the build folders and started again:

This time 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

```

I am supposed to put this path in CMAKE\_PREFIX\_PATHS?

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [October 12, 2020, 12:28pm UTC](https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175/6 "2020-10-12T12:28:22Z")

</div>

To resolve the missing packages, you should install `libwebkit2gtk-4.0-dev` and `libasound2-dev`:

```auto
sudo apt install libwebkit2gtk-4.0-dev libasound2-dev

```

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

- Copy the GuiApp folder to a new location.
- In the GuiApp CMakeLists that you copied, replace the `add_subdirectory(JUCE)` line with `add_subdirectory("/home/xyz/Documents/abc/work/juce/temp/JUCE" JUCE)`, replacing the path with the real location of the JUCE repo on your system.
- From the GuiApp folder that you copied, run
  - `cmake . -B cmake-build-dir`
    - This will create a build tree folder named `cmake-build-dir`

  - `cmake --build cmake-build-dir`
    - This will build all targets in the `cmake-build-dir` folder.

---

<div class="post-metadata">

**Author:** ![aquariusgirl](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aquariusgirl](https://forum.juce.com/u/aquariusgirl)\
**Post date:** [October 12, 2020, 1:58pm UTC](https://forum.juce.com/t/unknown-cmake-command-juce-add-gui-app/42175/7 "2020-10-12T13:58:10Z")

</div>

I am utterly thankful for the patience that you have shown here.  
I followed all your steps and this time there were no errors.

I found the executable in the build directory and I ran it successfully.  
Now I hope to speed up towards writing/learning coding.
