CMake-set_property找不到目标xxx.也许它还没有被创建 [英] CMake - set_property could not find TARGET xxx. Perhaps it has not yet been created

查看:151
本文介绍了CMake-set_property找不到目标xxx.也许它还没有被创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,我要做的是使用带有CMakeLists的CMake将现有Windows应用程序移植到Linux,这是我使用vcproj2cmake脚本生成的( https://github.com/sixman9/vcproj2cmake ).

Greetings, what I'm trying to do is to port an existing Windows application to Linux using CMake with CMakeLists, which I generated with the vcproj2cmake Script (https://github.com/sixman9/vcproj2cmake).

使用CMakeLists.txt和CMake,我能够成功地将VS 2005项目移植到VS2010.现在,我尝试将同一VS 2005项目移植到Linux,以便可以使用KDevelope对其进行编辑.

With the CMakeLists.txt and CMake I was able to successfully port a VS 2005 project to VS 2010. Now I try to port the same VS 2005 project to Linux, so that I can edit it with KDevelope.

该项目本身很小,我认为创建一个新项目并复制所有相关文件(如果可行)会更容易,问题是,这不仅是一个项目,而且很多,因此我一直在寻找以尽可能简单的方式移植项目的方法.

The project itself is small and I think it would be easier to just create a new project and copy all relevant files (if that would work), the problem is, that it's not only one project but many, hence I was looking for a way to port a project in an as simple as possible way.

在Linux中,我能够使用vcproj2cmake脚本创建CMakeLists.txt.下一步将是使用CMake创建一个KDevelope项目.这就是我被困住的地方.

In Linux I was able to create a CMakeLists.txt using the vcproj2cmake script. The next step would be creating a KDevelope project using CMake. And this is where I'm stuck.

每次我尝试运行CMake时,都会出现以下错误:

Everytime I try to run CMake I get the following error:

CMake Error at CMakeLists.txt: 196 (set_property) :
set_property could not find TARGET Test_Project. Perhaps it has not yet been
created.
Test_Project: installing /root/Desktop/Test_Project/vs8/CMakeLists. txt rebuilder (watching /root/Desktop/Test_Project/vs8/Test_Project. vcproj)
Configuring incomplete, errors occurred!
See also "/root/Desktop/Test_Project/vs8/CMakeFiles/CMakeOutput.log".

我搜索了很长时间的解决方案或方法,但是我得到的唯一结果是特定于项目的,或者至少我认为是.

I searched for a solution or an approach for quite a time now, but the only results that I get are project-specific, or at least I think they are.

第196行中CMakeLists.txt的内容:

Content of the CMakeLists.txt from line 196:

set_property(TARGET Test_Project PROPERTY PROJECT_LABEL "Test_Project")

v2c_rebuild_on_update(Test_Project "${CMAKE_CURRENT_SOURCE_DIR}/Test_Project.vcproj" ${CMAKE_CURRENT_LIST_FILE} "vcproj2cmake.rb" ".")

include(${V2C_HOOK_POST} OPTIONAL)

也许有更有效的方法将许多项目从Windows移植到Linux,我欢迎任何建议.

Perhaps there are more efficient ways to port many projects form Windows to Linux, I'm open for any suggestion.

推荐答案

在没有项目的情况下很难提供帮助-由于您使用的是第三方工具来转换VC项目,因此您应咨询该工具的作者.:D

It is a bit difficult to help without having your project - since you are using a third party tool to convert a VC project you should ask the author of that tool. :D

如果要维护的项目很多,建议您选择一个可以创建跨平台(Windows/Linux)CMake配置的项目,以供其他项目重复使用.

If you have many projects which you are going to maintain, I suggest that you select one where you can create a cross platform (Windows/Linux) CMake config for which you can reuse for other projects.

对于要构建的所有平台,大多数配置都应该相同-区别应该在于使用哪个生成器以及在最终可执行文件中链接的库(如果要构建的是).运行cmake时指定了生成器.

Most of the config should be the same for all platforms you are building for - the difference should be which generator is used and what libraries to link in the final executable (if you are building one that is). The generator is specified when running cmake.

我认为您应该尝试使用以下结构进行源外构建:

In my opinion you should try an out of source build with the following structure:

/$COMMON_DIR/CMakeLists.txt
/CMakeLists.txt
/src/
/build/
/build/vcX
/build/generate_vcX.bat
/build/linux
/build/generate_linux.sh 

$ COMMON_DIR应该包含您希望所有项目都通用的CMake代码-例如为在/src中搜索文件的模块创建静态库的函数,以及可用于为/src添加可执行文件的函数.特定平台.

$COMMON_DIR should contain the CMake code you expect to be common for all you projects - like a function to create a static library for a module which searches for files in /src and another function which can be used to add an executable for certain platform.

项目根目录(我认为是存储库)中的CMakeLists.txt应该调用$ COMMON_DIR中定义的函数,并可能添加一些项目特定的定义或链接标志.

The CMakeLists.txt in the root of your project (repository, I assume) should call the functions defined in $COMMON_DIR and possibly add some project specific defines or link flags.

这篇关于CMake-set_property找不到目标xxx.也许它还没有被创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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