JUCE not found - CMakeLists.txt

I think I don’t know what I am doing w.r.t JUCE installation and compilation.

I downloaded this zip file: juce-6.0.3-linux.zip. Unzipped it and found Projucer executable file and executed it. That’s all I did.

Now my intention is to get a basic hello world program running with a CMakeList. Though an official CMakeList project was pointed out in my other thread but still let me first continue with old cmakelist project which I was using: https://github.com/remymuller/juce-cmake/

This is my folder structure:

/helloworld/NewProject$ ls
buildCMake  Builds  CMakeLists.txt  juce-cmake  JuceLibraryCode  NewProject.jucer  Source

Here juce-cmake is the project of the CMakeList repo that I am using:- https://github.com/remymuller/juce-cmake/

Here Source directory contains the helloworld program shown by the Projucer’.

Here ‘CMakeList.txt’ is as follows:

cmake_minimum_required(VERSION 3.0)

project(HelloWorld)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/home/xyz/Documents/abc/work/juce/helloworld/NewProject/juce-cmake/cmake")

find_package(JUCE REQUIRED COMPONENTS 
		juce_core
		juce_data_structures
		juce_events
		juce_graphics
		juce_gui_basics
		juce_gui_extra
)

set(SOURCES
	Source/Main.cpp
	Source/MainComponent.h
	Source/MainComponent.cpp
)

add_executable(${PROJECT_NAME} ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true)
target_link_libraries(${PROJECT_NAME} ${JUCE_LIBRARIES})
source_group(Source FILES ${SOURCES})

When I run this CMakeLists.txt from buildCMake dir, this is the error that I get:

-- 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 juce-cmake/cmake/FindJUCE.cmake:443 (message):
  JUCE not found.
Call Stack (most recent call first):
  CMakeLists.txt:7 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/xyz/Documents/abc/work/juce/helloworld/NewProject/buildCMake/CMakeFiles/CMakeOutput.log".

It is saying JUCE not found.. Does this mean that JUCE has not been installed? What am I supposed to do to solve this error?

please use the official JUCE
as you don’t use juce-cmake like that

Then what is the way to use juce-cmake? I am asking this because I don’t know how to use the official cmake yet.

I just want to get something up and running.

Secondly, even when I run the default make, it throws following errors:

/helloworld/NewProject/Builds/LinuxMakefile$ make
Compiling Main.cpp
In file included from ../../Source/Main.cpp:10:0:
../../Source/MainComponent.h:10:31: error: ‘juce’ has not been declared
 class MainComponent  : public juce::Component
                               ^~~~
../../Source/MainComponent.h:10:37: error: expected ‘{’ before ‘Component’
 class MainComponent  : public juce::Component
                                     ^~~~~~~~~
../../Source/MainComponent.h:12:1: error: expected primary-expression before ‘public’
 public:
 ^~~~~~
../../Source/MainComponent.h:12:1: error: expected ‘}’ before ‘public’
../../Source/MainComponent.h:15:30: error: expected constructor, destructor, or type conversion before ‘;’ token
     ~MainComponent() override;
                              ^
../../Source/MainComponent.h:18:17: error: variable or field ‘paint’ declared void
     void paint (juce::Graphics&) override;
                 ^~~~
../../Source/MainComponent.h:18:17: error: ‘juce’ has not been declared
../../Source/MainComponent.h:18:32: error: expected primary-expression before ‘)’ token
     void paint (juce::Graphics&) override;
                                ^
../../Source/MainComponent.h:19:20: error: virt-specifiers in ‘resized’ not allowed outside a class definition
     void resized() override;
                    ^~~~~~~~
../../Source/MainComponent.h:21:1: error: expected unqualified-id before ‘private’
 private:
 ^~~~~~~
../../Source/MainComponent.h:27:1: error: expected declaration before ‘}’ token
 };
 ^
Makefile:86: recipe for target 'build/intermediate/Debug/Main_90ebc5c2.o' failed
make: *** [build/intermediate/Debug/Main_90ebc5c2.o] Error 1

This makes me think that there is some problem regarding JUCE installation. I haven’t changed the Source files in anyway to cause this.

juce-cmake was made because there used to be no official cmake in Juce.

Just check the official cmake examples

1 Like

Thank you for pointing that out.

Am I supposed to get clone that folder and execute CMakeLists.txt? I hope it is that simple.

juste do a git clone of the whole Juce, apply cmake on this folder and voila

1 Like

I am getting hopeful now. Thank you. You have been helpful.