[CMake] CMake Visual Studio generator not producing "Output Directory" property in VS

Nils Gladitz nilsgladitz at gmail.com
Fri Mar 21 03:35:27 EDT 2014


On 03/20/2014 11:19 PM, Perkins, Jim R CIV NSWC, PCD wrote:
> I am using CMake 2.8.12.2 to create a Visual Studio 12 (2013) project that builds a library (C++).  In my CMake file (an example project for simplicity), I have:

> ADD_LIBRARY(testcmake SHARED ${SRC})
>
> The only thing I cannot get to work is the CMAKE_LIBRARY_OUTPUT_DIRECTORY variable.  No matter what I try (including other possible CMake variables), it does not get translated to the "Output Directory" field in Visual Studio when building a project.  My library is always placed inside of testcmake\build\Debug, when I want it in ${CMAKE_CURRENT_LIST_DIR}.  I can manually change the "Output Directory" inside Visual Studio and the library outputs to the wanted location, but if I ever modify the CMakeLists file it breaks again, so that is not a solution.

To quote the documentation:
"For non-DLL platforms shared libraries are treated as library targets. 
For DLL platforms the DLL part of a shared library is treated as a 
runtime target and the corresponding import library is treated as an 
archive target."

So for windows you might want to look at the related variables 
CMAKE_RUNTIME_OUTPUT_DIRECTORY and CMAKE_ARCHIVE_OUTPUT_DIRECTORY.

For multi-configuration generators (like the Visual Studio generators) a 
configuration dependent directory will get appended automatically (e.g. 
Debug or Release).

If you do not want these you can look at the config specific target 
properties; e.g. RUNTIME_OUTPUT_DIRECTORY_<CONFIG>:
	http://www.cmake.org/cmake/help/git-master/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.html

Nils



More information about the CMake mailing list