This project is proof that I can use CMake to build a DLL and an executable for it. It is inspired by this tutorial for Visual Studio.
Create a build directory and call cmake from there on the command line, indicating where the CMakeLists.txt file is:
CMakeTest\build> cmake ../src -G "Visual Studio 14 2015 Win64"
Change the target build environment as appropriate.
Open the solution file in Visual Studio, and build the ALL_BUILD project.
Before this will run in Visual Studio, fix the following glitches:
-
By default, ALL_BUILD will be the startup project. Right click on the app project and click
Set as Startup Project. -
The app.exe executable depends on the math.dll that we built with ALL_BUILD, but the system doesn't know how to find it. Build the INSTALL project. This will copy app.exe and math.dll to the bin directory in the build folder.
-
Running app.exe through Visual Studio still won't work, because the command is referencing the copy of app.exe in the
app/Debugfolder, rather than the new copy in the bin directory. Right click on the app project, and select Properties -> Debugging. Set the command to..\bin\app.exeand set Command Arguments to some number (e.g. 200).
Now, when you tell Visual Studio to call app.exe, it is able to find math.dll, because there is a copy of it in the same folder.
Be sure to re-run INSTALL after each build. Otherwise, when you run through the IDE, you would be running the previous version of the code in the bin directory, and you will not be able to see the effects of your changes.