FindJUCE.cmake:无法为导入的目标“juce_core”指定源

Posted

技术标签:

【中文标题】FindJUCE.cmake:无法为导入的目标“juce_core”指定源【英文标题】:FindJUCE.cmake: Cannot specify sources for imported target “juce_core” 【发布时间】:2020-10-09 11:52:24 【问题描述】:

我正在尝试编译 hello world 程序。我使用了这个链接提供的 CMakeList:https://github.com/remymuller/juce-cmake

我不知道这些错误是什么意思以及如何解决它们。请帮忙。

CMakeLists.txt

$ cat CMakeLists.txt 
cmake_minimum_required(VERSION 3.0)

project(HelloWorld)

set(CMAKE_MODULE_PATH $CMAKE_MODULE_PATH "/home/sulakshana/Documents/evon/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)

我用过这个.cmake:https://github.com/remymuller/juce-cmake/blob/master/cmake/FindJUCE.cmake

文件夹结构:

这里juce-cmake是上面链接仓库的克隆:

$ ls
Builds  juce-cmake  JuceLibraryCode  NewProject.jucer  Source

CMakeLists.txt 的位置:

/Builds/LinuxMakefile$ ls
build  buildCMake  CMakeLists.txt  Makefile

错误:

$ 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".

【问题讨论】:

【参考方案1】:

此模块依赖于 CMake 3.11 中添加的功能。确保您至少拥有该版本。

最后一组错误是因为你只复制了FindJUCE.cmake文件,而没有复制它附带的FindJuceTemplates目录。我建议将整个存储库克隆/下载到您的工作目录(或将其添加为 Git 子模块),然后将其包含在内。您可能需要将CMAKE_MODULE_PATH 指向子目录。

【讨论】:

谢谢。 FindJuceTemplates 目录在我的计算机上的位置应该在哪里?靠近 .cmake 文件? 您应该按原样克隆 github.com/remymuller/juce-cmake 存储库,或者将其下载为 zip 并解压缩。在这两种情况下,结果都应该是项目中的一个新目录。 我已经编辑了这个问题。请看一下。它仍然无法正常工作。请提供一些启示。 我想你的意思是上传你的项目目录的截图?它不见了。此外,在对 CMake 进行如此彻底的更改时,最好丢弃构建目录中的文件并重新运行 cmake ..

以上是关于FindJUCE.cmake:无法为导入的目标“juce_core”指定源的主要内容,如果未能解决你的问题,请参考以下文章

Neo4j - 无法使用 neo4j-import 导入

SVN:无法连接主机“localhost”:由于目标机器积极拒绝,无法连接

Sqoop 增量导入“无法将文件附加到目标目录”

更改部署目标后无法再将应用模块导入单元测试

突出显示未使用的变量和导入无法正常工作

将测试从一个单元测试目标导入另一个