Search code examples
visual-studiocmakevisual-studio-2022

Importing libraries from CMake


I am very, very new to CMake, and I have configured and built a CMake project, but how do I actually import this CMake cache into a visual studio community 2022 project? I apologize for my inexperience, but there is a limited amount of documentation on this subject and most of the information available is made for Linux.


Solution

  • cmake can generate projects and solution for Visual Studio.

    Just start:

    cmake -S PATH_TO_SOURCE_DIR -B PATH_TO_OUTPUT_DIR
    

    PATH_TO_SOURCE_DIR - dir with CMakeLists.txt PATH_TO_OUTPUT_DIR - dir for build results

    After cmake finishes it's work you can find the *.vcxproj and *.sln files in the PATH_TO_OUTPUT_DIR.

    Than just open sln file in Visual Studio.