# teaching machines

## Project configuration

While waiting to hear back from ORSP, we are taking the time to find a sustainable solution for managing our project across multiple platforms and machines. We really want to share code without emailing it. We also want to avoid fiddling with Visual Studio as much as possible. For this, we’ve chosen to use TortoiseSVN and CMake.

Here are the steps we take to set up a new Windows machine and a Visual Studio project:

### Setup

1. Install TortoiseSVN.
2. Right-click on the directory where you’d like to check out the code repository. Choose SVN Checkout. Enter https://host:port/svn/otolith/trunk for the URL. Hit OK. Wait for the files to download. Since I included OpenCV in the project itself, it will take a couple of years to grab everything.
3. Install CMake.
4. Run CMake from the start menu. Enter the checked out trunk directory as the source directory. Enter a build directory outside the source directory. Hit Configure. Choose Visual Studio 10, native compilers. Hit Generate. Close CMake.
5. The build directory contains OTOLITH.sln, your Visual Studio solution file. Open it.
6. There’s a project listed for every component of the OpenCV library, plus for all of our stuff. In order to switch back and forth between these, right-click on the solution node in the Solution Explorer, choose Set Startup Projects, and select Current Selection under Common Properties, Startup Project.
7. Switch to Release mode. This step shouldn’t be necessary, but staying in Debug mode produces a “This application could not start properly” error message.
8. Select your project and run it. It’ll build all the OpenCV stuff and any of our code that we’ve registered with CMake.

### Workflow

1. Right-click on the checkout directory and SVN Update.
2. Edit code, add files, tweak CMakeLists.txt.
3. Right-click on the checkout directory and SVN Commit.

add_executable(my_executable source1.cpp source2.cpp ...)
target_link_libraries(my_executable \${OpenCV_LIBS})

### Adding source files to executable/project

1. Either in Visual Studio:
1. Expand the project in Visual Studio.
2. Right-click on Source Files and choose Add.
3. Pick the file type.
4. Change the location to your directory in the checkout folder.  By default it places the new file in the build directory.

or in Windows Explorer:

1. Create the file in your directory.
2. In Windows Explorer, right-click on the new file and Add it with TortoiseSVN. (Don’t forget to commit when done!)
3. Augment the executable dependencies in the appropriate add_executable call in CMakeLists.txt.