CMake错误“找不到目标向其添加属性” [英] CMake error "Can not find target to add properties to"

查看:603
本文介绍了CMake错误“找不到目标向其添加属性”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的CMakeLIsts.txt文件中,我这样写:

In my CMakeLIsts.txt file I write this:

set(LIBHELLO_SRC hello.c)
set_target_properties(hello_static PROPERTIES OUTPUT_NAME "hello")
get_target_property(OUTPUT_VALUE hello_static OUTPUT_NAME)
message(STATUS "This is the hello_static OUTPUT_NAME:"${OUTPUT_VALUE})

当我运行 cmake 时,它显示错误消息:

When I run cmake, it shows the error message:

set_target_properties Can not find target to add properties to: hello_static


推荐答案

要使代码正常工作, hello_static 必须是CMake目标的名称;通过 add_executable添加的内容 例如code> add_library 命令。

For your code to work, hello_static must be the name of a CMake target; something which is added via the add_executable or add_library commands for example.

这与您的项目名称无关。

This is unrelated to the name of your project.

似乎您缺少以下内容:

add_library(hello_static ${LIBHELLO_SRC})

将直接放置在

set(LIBHELLO_SRC hello.c)

这篇关于CMake错误“找不到目标向其添加属性”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆