简体   繁体   中英

CMake generating VS project files in the files with the CMakeLists.txt folders

I'm trying to learn CMake and am struggling to achieve the project layout that I'm used to making with visual studio.

I want to achieve something like the following directory structure, where the .vcxproj and.sln are generated by CMake

Root
    CMakeLists.txt
    MySolution.sln

    ProjectOne
        CMakeLists.txt
        ProjectOne.vcxproj
        someSourceFile1.h
        someSourceFile1.cpp

    ProjectTwo
        CMakeLists.txt
        ProjectTwo.vcxproj
        someSourceFile2.h
        someSourceFile2.cpp

    Binaries
       Platform
          Debug
              ProjectOne.exe
              ProjectTwo.dll

          Release
             ProjectOne.exe
             ProjectTwo.dll

All the tutorials I seem to find seem to give an Examples where the structure turns out something like this:

Root
   Source
      CMakeLists.txt

      ProjectOne
        CMakeLists.txt
        someSourceFile1.h
        someSourceFile1.cpp

      ProjectTwo
        CMakeLists.txt
        someSourceFile2.h
        someSourceFile2.cpp

    Build
       MySolution.sln
       ProjectTwo.vcxproj
       ProjectOne.vcxproj
      
       Platform
          Debug
              ProjectOne.exe
              ProjectTwo.dll

          Release
              ProjectOne.exe
              ProjectTwo.dll
              

Using commands like

mkdir Build
cd build
CMake ..\Source
CMake --Build .

Notable I have not added ALL_BUILD.vcxproj and ZERO_CHECK.vcxproj that get generated, which I am yet to understand my need for.

  • Is there just a command I'm missing in the CMakeList.txt to do this?
  • Is there a reason I shouldn't lay my project out the way I want to?

Doing some more research I have stumbled across this post (linked below), which I think answers my question.

I am simply doing the wrong thing, as CMake is meant for distribution builds, not development builds.

Visual Studio puts new files into wrong directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM