FindJUCE.cmake: Cannot specify sources for imported target "juce_core"

I am trying to compile the hello world program. I have used the CMakeList provided by this link: https://github.com/remymuller/juce-cmake

I don’t know what these errors mean and how to solve them. Please help.

CMakeLists.txt

$ cat CMakeLists.txt 
cmake_minimum_required(VERSION 3.0)

project(HelloWorld)

list(APPEND CMAKE_PREFIX_PATH "/home/sulakshana/Documents/evon/work/juce/helloworld/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/home/sulakshana/Documents/evon/work/juce/helloworld/")
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})

I have used this .cmake: https://github.com/remymuller/juce-cmake/blob/master/cmake/FindJUCE.cmake

Errors:

$ cmake ..
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:344 (target_sources):
  Cannot specify sources for imported target "juce_core".
Call Stack (most recent call first):
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:490 (juce_add_module)
  CMakeLists.txt:7 (find_package)


CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:344 (target_sources):
  Cannot specify sources for imported target "juce_data_structures".
Call Stack (most recent call first):
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:490 (juce_add_module)
  CMakeLists.txt:7 (find_package)


CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:344 (target_sources):
  Cannot specify sources for imported target "juce_events".
Call Stack (most recent call first):
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:363 (juce_add_module)
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:490 (juce_add_module)
  CMakeLists.txt:7 (find_package)


CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:344 (target_sources):
  Cannot specify sources for imported target "juce_graphics".
Call Stack (most recent call first):
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:490 (juce_add_module)
  CMakeLists.txt:7 (find_package)


CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:344 (target_sources):
  Cannot specify sources for imported target "juce_gui_basics".
Call Stack (most recent call first):
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:490 (juce_add_module)
  CMakeLists.txt:7 (find_package)


CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:344 (target_sources):
  Cannot specify sources for imported target "juce_gui_extra".
Call Stack (most recent call first):
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:490 (juce_add_module)
  CMakeLists.txt:7 (find_package)


CMake Error: File /home/sulakshana/Documents/evon/work/juce/helloworld/FindJuceTemplates/AppConfig.h.in does not exist.
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:264 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:501 (juce_generate_app_config)
  CMakeLists.txt:7 (find_package)


CMake Error: File /home/sulakshana/Documents/evon/work/juce/helloworld/FindJuceTemplates/JuceHeader.h.in does not exist.
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:283 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:514 (juce_generate_juce_header)
  CMakeLists.txt:7 (find_package)


CMake Error: File /home/sulakshana/Documents/evon/work/juce/helloworld/FindJuceTemplates/include_juce_module.cpp.in does not exist.
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:566 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:7 (find_package)


CMake Error: File /home/sulakshana/Documents/evon/work/juce/helloworld/FindJuceTemplates/include_juce_module.cpp.in does not exist.
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:566 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:7 (find_package)


CMake Error: File /home/sulakshana/Documents/evon/work/juce/helloworld/FindJuceTemplates/include_juce_module.cpp.in does not exist.
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:566 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:7 (find_package)


CMake Error: File /home/sulakshana/Documents/evon/work/juce/helloworld/FindJuceTemplates/include_juce_module.cpp.in does not exist.
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:566 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:7 (find_package)


CMake Error: File /home/sulakshana/Documents/evon/work/juce/helloworld/FindJuceTemplates/include_juce_module.cpp.in does not exist.
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:566 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:7 (find_package)


CMake Error: File /home/sulakshana/Documents/evon/work/juce/helloworld/FindJuceTemplates/include_juce_module.cpp.in does not exist.
CMake Error at /home/sulakshana/Documents/evon/work/juce/helloworld/FindJUCE.cmake:566 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:7 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/sulakshana/Documents/evon/work/juce/helloworld/NewProject/Builds/LinuxMakefile/buildCMake/CMakeFiles/CMakeOutput.log".

You should probably use the official juce cmake now that it is available.

Where can I find it? I request you to give me the link.

I am reading this: https://docs.juce.com/master/tutorial_new_projucer_project.html
Didn’t see any official mention of CMake. Please help.

2 Likes

There’s some brief getting-started steps in the readme here, more comprehensive docs for the full CMake API here, and some examples that you can use as a starting point for new projects here. Also note that all of the programs that ship with JUCE, such as the Projucer and AudioPluginHost, have CMake builds which may be useful examples.

1 Like

The truth is that you type juce cmake on google you don’t hit on those.
There should be maybe a section about this on juce website (not github)

1 Like