cmake 编译 Cannot specify compile options for target "" which is not built by this project.

时间: 2024-02-16 07:05:20 浏览: 23
这个错误通常是由于在CMakeLists.txt文件中没有正确定义目标项目导致的。请检查您的CMakeLists.txt文件,确保您已正确设置目标项目。您可以通过在CMakeLists.txt文件中使用`add_executable`或`add_library`命令来定义目标项目。例如,如果您想要添加一个可执行文件,您可以使用以下命令: ``` add_executable(my_executable main.cpp) ``` 如果您确认已正确定义了目标项目,则可能是由于其他因素引起的问题。请提供更多上下文和详细信息,以便我能够更好地帮助您解决问题。
相关问题

cmake报错:Cannot specify link libraries for target "hello_lib" which is not built by this project.

这个错误通常是由于在 CMakeLists.txt 文件中的 target_link_libraries() 命令中指定了不存在的库,或者是指定了当前项目并未生成的库。 解决方法如下: 1. 检查 target_link_libraries() 命令中指定的库是否存在,并且是否已经正确地添加到项目中。 2. 确保在 CMakeLists.txt 文件中,先添加并构建需要的库,再将其链接到目标。 比如,假设你的项目包含两个库,一个是 lib1,另一个是 lib2,同时你的项目还生成了可执行文件 hello。那么,在 CMakeLists.txt 文件中,应该按照以下顺序添加和构建库: ``` add_library(lib1 ...) add_library(lib2 ...) add_executable(hello ...) ``` 然后,再将库链接到目标: ``` target_link_libraries(hello lib1 lib2) ``` 这样就能够避免 "Cannot specify link libraries for target" 的错误了。 希望这能帮助你解决问题!

CMake Error at CMakeLists.txt:50 (target_link_libraries): Cannot specify link libraries for target "DesensitiseJNI" which is not built by this project.

这个错误通常是因为在使用 target_link_libraries 命令时,指定了一个不存在的目标。在你的错误信息中,错误提示指出 "DesensitiseJNI" 这个目标不是通过当前项目构建的。 解决这个问题,你需要先确保 "DesensitiseJNI" 这个目标是通过当前项目构建的,如果不是,则需要先将该目标的构建加入到 CMakeLists.txt 文件中。如果 "DesensitiseJNI" 目标确实是由当前项目构建的,那么你需要检查一下 target_link_libraries 命令中是否有拼写错误或者其他的语法错误。 以下是一些可能有用的调试步骤: 1. 检查 CMakeLists.txt 文件中是否有构建 "DesensitiseJNI" 目标的命令,例如 add_library 或 add_executable。 2. 确认你使用的是正确的目标名称。你可以通过命令行输出或者 CMake 编译日志来确定目标名称是否正确。 3. 检查 target_link_libraries 命令是否正确指定了库文件或目标名称。如果有多个库文件或目标名称,需要使用空格或分号来分隔它们。 如果你需要更多的帮助,请提供更多的上下文信息,例如完整的 CMakeLists.txt 文件内容或者更详细的错误信息。

相关推荐

ubuntu16.04运行时报错CMake Error at bobac2_description/CMakeLists.txt:147 (add_dependencies): Cannot add target-level dependencies to non-existent target "bobac2_description_node". The add_dependencies works for top-level logical targets created by the add_executable, add_library, or add_custom_target commands. If you want to add file-level dependencies see the DEPENDS option of the add_custom_target and add_custom_command commands. CMake Error at bobac2_description/CMakeLists.txt:150 (target_link_libraries): Cannot specify link libraries for target "bobac2_description_node" which is not built by this project. -- Configuring incomplete, errors occurred! See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeOutput.log". See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeError.log". Makefile:2796: recipe for target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] Error 1 CMake Error at bobac2_description/CMakeLists.txt:147 (add_dependencies): Cannot add target-level dependencies to non-existent target "bobac2_description_node". The add_dependencies works for top-level logical targets created by the add_executable, add_library, or add_custom_target commands. If you want to add file-level dependencies see the DEPENDS option of the add_custom_target and add_custom_command commands. CMake Error at bobac2_description/CMakeLists.txt:150 (target_link_libraries): Cannot specify link libraries for target "bobac2_description_node" which is not built by this project. -- Configuring incomplete, errors occurred! See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeOutput.log". See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeError.log". Makefile:2796: recipe for target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] Error 1

最新推荐

recommend-type

centos 7 vscode cmake 编译c++工程的教程详解

给大家介绍了centos 7 使用vscode+cmake配置简单c++项目的方法,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧
recommend-type

实例分享cmake编译一个简单c++项目(demo)

下面通过一个小例子来说明cmake编译一个c++项目,生成可执行文件,需要的朋友可以参考下
recommend-type

(cmake最全的书)cmake.pdf

cmake大全,详细介绍了cmake的安装、配置、使用;可谓是不可多得好书,网上很多只介绍了一部分,这本书从基础到高级,都有介绍
recommend-type

###对华为OD分布式操作系统的详细介绍

华为OD
recommend-type

2110220116吴骏博.py

2110220116吴骏博.py
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【实战演练】MATLAB用遗传算法改进粒子群GA-PSO算法

![MATLAB智能算法合集](https://static.fuxi.netease.com/fuxi-official/web/20221101/83f465753fd49c41536a5640367d4340.jpg) # 2.1 遗传算法的原理和实现 遗传算法(GA)是一种受生物进化过程启发的优化算法。它通过模拟自然选择和遗传机制来搜索最优解。 **2.1.1 遗传算法的编码和解码** 编码是将问题空间中的解表示为二进制字符串或其他数据结构的过程。解码是将编码的解转换为问题空间中的实际解的过程。常见的编码方法包括二进制编码、实数编码和树形编码。 **2.1.2 遗传算法的交叉和
recommend-type

openstack的20种接口有哪些

以下是OpenStack的20种API接口: 1. Identity (Keystone) API 2. Compute (Nova) API 3. Networking (Neutron) API 4. Block Storage (Cinder) API 5. Object Storage (Swift) API 6. Image (Glance) API 7. Telemetry (Ceilometer) API 8. Orchestration (Heat) API 9. Database (Trove) API 10. Bare Metal (Ironic) API 11. DNS
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。