通过cmake和Visual Studio在一个解决方案中进行多个项目 [英] Several projects in one solution with cmake and visual studio

查看:279
本文介绍了通过cmake和Visual Studio在一个解决方案中进行多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio 2010解决方案,其中包含5个项目,两个库和三个应用程序(取决于这些库)。我现在想将构建系统迁移到CMake(也可以在Linux下编译)。

I have a Visual Studio 2010 solution with 5 projects in it, two libraries and three applications (that depend on the libraries). I would now like to migrate the build system to CMake (to also be able to compile under Linux).

我已经找到了如何编写CMakeLists.txt的方法。为一个项目创建一个.sln文件,然后在VS中编译该文件。但是,我找不到解决方案来在CMake文件中指定每个单独的项目,然后自动让CMake创建其中包含这5个项目的VS .sln。

I've already found out how to write a CMakeLists.txt for one project and create a .sln file out of it that compiles in VS. However, I can't find a solution to specify in a CMake file each individual projects and then automatically let CMake create a VS .sln with those 5 projects in it.

我必须如何构造项目和CMakelist才能完成此任务?

How do I have to structure my projects and CMakelists to accomplish this?

推荐答案

对于每个库,调用 add_library ,针对每个应用程序调用 add_executable

For each library, call add_library, for each application call add_executable.

这篇关于通过cmake和Visual Studio在一个解决方案中进行多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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