如何从CMake转换为普通的Visual Studio项目? [英] How to transform from CMake to a plain Visual Studio project?

查看:220
本文介绍了如何从CMake转换为普通的Visual Studio项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够CMake构建 HelloWorld示例项目使用 cmakelists.txt >文件并生成Visual Studio项目.

I am able to CMake build this HelloWorld example project using cmakelists.txt file and generate a visual studio project.

project(helloworld LANGUAGES C CXX)
cmake_minimum_required(VERSION 3.5)

find_package(Idlpp-cxx REQUIRED)
if (NOT TARGET CycloneDDS-CXX::ddscxx)
  find_package(CycloneDDS-CXX REQUIRED)
endif()

# Convenience function, provided by the Idlpp-cxx that generates a CMake
# target for the given IDL file. The function calls Idlcpp-cxx to generate
# source files and compiles them into a library.
idl_ddscxx_generate(ddscxxHelloWorldData_lib "HelloWorldData.idl")

add_executable(ddscxxHelloworldPublisher publisher.cpp)
add_executable(ddscxxHelloworldSubscriber subscriber.cpp)

# Link both executables to idl data type library and ddscxx.
target_link_libraries(ddscxxHelloworldPublisher ddscxxHelloWorldData_lib     CycloneDDS-CXX::ddscxx)
target_link_libraries(ddscxxHelloworldSubscriber ddscxxHelloWorldData_lib CycloneDDS-CXX::ddscxx)

set_property(TARGET ddscxxHelloworldPublisher PROPERTY CXX_STANDARD 11)
set_property(TARGET ddscxxHelloworldSubscriber PROPERTY CXX_STANDARD 11)

我需要创建一个没有 cmakelists.txt 和CMake

I need to create the same project without cmakelists.txt and CMake

如何仅使用Visual Studio做到这一点?在Visual Studio中的CMakelists.txt 中定义这些命令的位置,如果我创建一个空的c ++项目

How to do this only using visual studio? where to define those commands in CMakelists.txt in visual studio if I create an empty c++ project

我已经尝试过制作一个空项目.

I have tried this making an empty project.

我不知道如何在VS中执行idl_ddscxx_generate和target_link_libraries....

I don't know how to idl_ddscxx_generate and target_link_libraries perform in VS....

idl_ddscxx_generate必须运行如果我向项目添加了新的源文件,则需要target_link_libraries.

idl_ddscxx_generate has to run if IDL file has changed target_link_libraries is required if I added new source files to the project....

推荐答案

  1. 新建一个空的Visual Studio项目.
  2. 复制除CMake文件之外的所有源文件.
  3. 在Visual Studio项目中执行任何操作.添加文件,目标,依赖项,……如果不确定,请查找CMakeLists.txt文件中写的内容.
  4. 删除原始项目中的所有CMake文件并复制Visual Studio项目文件.
  5. 将这些更改(已删除的CMake文件,添加的VS项目文件)添加到您的Subversion存储库中,也许在其他人可以对其进行测试,报告并改进更改的分支中执行此操作.完成后,合并分支.

可能,添加步骤0 .:了解Visual Studio如何组织其项目.制作教程,接受一些培训.

Probably, add step 0.: Learn how Visual Studio organizes its project. Make a tutorial, take some training.

备注:CMake不管您遇到什么问题,都错过了一些东西.但是您可以稍后找到并恢复您的更改,然后再次选择CMake.

Remark: Whatever your problem is with CMake, you missed something. But you can find this out later and revert your changes and pick up CMake up again.

这篇关于如何从CMake转换为普通的Visual Studio项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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