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
- Install TortoiseSVN.
- 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.
- Install CMake.
- 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.
- The build directory contains OTOLITH.sln, your Visual Studio solution file. Open it.
- 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.
- 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.
- 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
- Right-click on the checkout directory and SVN Update.
- Edit code, add files, tweak CMakeLists.txt.
- Right-click on the checkout directory and SVN Commit.
Adding a new executable
- Open checkout/username/CMakeLists.txt.
- Add some lines like:
add_executable(my_executable source1.cpp source2.cpp ...) target_link_libraries(my_executable ${OpenCV_LIBS})
Adding source files to executable/project
- Either in Visual Studio:
- Expand the project in Visual Studio.
- Right-click on Source Files and choose Add.
- Pick the file type.
- 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:
- Create the file in your directory.
- In Windows Explorer, right-click on the new file and Add it with TortoiseSVN. (Don’t forget to commit when done!)
- Augment the executable dependencies in the appropriate add_executable call in CMakeLists.txt.