Search code examples
msbuildcmakevisual-studio-2015appveyor

Build VS 2015 solution with [CMake / Command Line]


So far this is my command line to start a Cmake build:

cmake .. --build .. -DCMAKE_BUILD_TYPE:STRING=release

This is good and works, and it generates a

Project.sln

and

tests/ProjectTests.sln

solution files.

I could open solution files with visual studio and build them and run tests from Visual Studio, however I'm running the script from a Continuos Integration server and hence I need to also start the build and run the tests from command line: how can I do that?


I need to

  1. Build the library (Project.sln)
  2. Build the test executable (tests/ProjectTests.sln)
  3. Run the tests (calling CTest from the same folder in wich Tests.exe is located)

Until now I tried to build using the command

msbuild Infectorpp2.sln

But that is failing (error log just to long to post), if that can helps here's the script on github. The main problem is that I'm not able to finally generate the Tests.exe file, once that is done calling CTest on it is trivial. Thanks in advance.


Solution

  • As mentioned in the documentation, the general syntax for building a target (i.e. after generating the .sln files with cmake -G) using CMake is:

    cmake --build . [--config <config>] [--target <target>] [-- -i]
    

    It will invoke the appropriate compiler/toolchain commands for you.

    See cmake(1) for the full list of arguments accepted by the cmake command.