[CMake] Select CMAKE_LIBRARY_OUTPUT_DIRECTORY_<CONFIG> in a CMakeLists.txt script

Rolf Eike Beer eike at sf-mail.de
Wed Mar 2 03:31:45 EST 2011


> I am defining separate output paths for different configurations:
>
>   CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG    = bin/win32/dbg
>   CMAKE_RUN TIME_OUTPUT_DIRECTORY_RELEASE = bin/win32/opt
>
>   CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG    = lib/win32/dbg
>   CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE  = lib/win32/opt
>
>   CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG    = bin/win32/dbg
>   CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE  = bin/win32/opt
>
> And in Visual Studio the CMake command add_library() command does a fine
> job of choosing between CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG for the Debug
> configuration, and CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE for the Release
> configuration.
>
> I can see how I might use CMAKE_CFG_INTDIR to get the IDE configuration,
> but its value is "Debug" or "Release".  If I were to use
> "lib/win32/${CMAKE_CFG_INTDIR}", I would get "lib/win32/Debug" or
> "lib/win32/Release", which is incorrect.
>
> I can imagine some sort of non-portable solution, but I am wondering if
> there is a standard approach, or an example from which I might draw
> inspiration.
>
> My application is compiling C# within add_custom_command().

Are you searching something like
${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CMAKE_CFG_INTDIR}}?

Eike


More information about the CMake mailing list