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

查看:55
本文介绍了如何从 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 必须在 IDL 文件更改时运行如果我向项目添加了新的源文件,则需要 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天全站免登陆