11

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).

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.

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

Captain Obvlious
  • 19,754
  • 5
  • 44
  • 74
Ela782
  • 5,041
  • 5
  • 53
  • 66
  • 1
    Its not that hard, you have to declare each library and each executable. it can be in separate subdirectories. I recommend looking at some open source projects and their CMake files. (for example [this](https://github.com/madler/zlib/blob/master/CMakeLists.txt) ) – Mohammad Jun 25 '12 at 19:36

2 Answers2

13

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

isanae
  • 3,253
  • 1
  • 22
  • 47
Fraser
  • 74,704
  • 20
  • 238
  • 215
3

Every cmake call to add_library or add_executable creates a new project in your solution.

totowtwo
  • 2,101
  • 1
  • 14
  • 21