I am using CMake to build an application made up of a dozen projects. We use CMake to automatically generate solutions for x86, x64, and both Visual Studio 2005 and Visual Studio 2010.
Here is an idea of our organisation:
- a.lib, which has no dependency
- b.lib, which has no dependency
- c.lib, which depends on a and b
- d.exe, which depends on c
Each project lies in its own subdirectory and has its own CMakeLists.txt
file. In order to keep track of the library/DLL file generated for our different platforms, we automatically post-fix each library/DLL file with _x86/_x64 and _vc80/_vc100 (e.g., a_x86_vc100.lib), and with an _d for debug (e.g., a_x86_vc100_d.lib).
In the CMakeLists.txt
files, I use target_link_libraries to link each target with the corresponding libraries, for instance:
TARGET_LINK_LIBRARIES( c debug a_${VS}_${PLATFORM}d optimized a${VS_DIR}${PLATFORM} debug b${VS}_${PLATFORM}d optimized b${VS_DIR}_${PLATFORM})
In Visual Studio, the different "Project Dependencies" between the various projects do not appear. I wonder if there is something I miss, or if it is simply not compatible with our library post-fix.
If they are all in the same project, which I think that they are, you only need to specify the target name and the debug/release will be handled for you. I think that you are linking to the actual library file instead of the target.
Try:
That is it!