[Cmake] Re: windows .lib .dll output dirs

Clinton Stimpson clinton at elemtech.com
Fri Sep 3 12:55:58 EDT 2004


I found a solution to my problem.  CMake has no support for this, but I 
was able to add post build commands that had the same effect.  If anyone 
is interested.  It uses visual studio macros so it automatically takes 
care of by debug vs. release libs and also that my debug libs and "_d" 
postfixes.


MACRO(SET_LIBRARY_OUTPUTS target outputdir)
IF(UNIX)
SET(LIBRARY_OUTPUT_PATH "${outputdir}"/bin)
ELSE(UNIX)
ADD_CUSTOM_COMMAND(TARGET "${target}"
                   POST_BUILD
                   COMMAND ${CMAKE_COMMAND}
                   ARGS -E copy $\(TargetPath\) "${outputdir}"/bin)

ADD_CUSTOM_COMMAND(TARGET "${target}"
                   POST_BUILD
                   COMMAND ${CMAKE_COMMAND}
                   ARGS -E copy $\(TargetDir\)/$\(TargetName\).lib 
"${outputdir}"/lib)
ENDIF(UNIX)
ENDMACRO(SET_LIBRARY_OUTPUTS)


Clint


Clinton Stimpson wrote:

> I have a tree like this...
>
> topdir/
>    lib/
>    bin/
>
> and I want all .lib files to be put in the lib directory and all .dll 
> files in the bin directory (both release and debug).
> SET(CMAKE_DEBUG_POSTFIX "_d")  so all my debug libs are postfixed with 
> _d.
>
> If I use
> SET(LIBRARY_OUTPUT_PATH ${MYPROJ_BINARY_DIR}/bin)
> then it works fine on Unix.
>
> But on Windows with project files, I get  topdir/bin/Debug and 
> topdir/bin/Release and the libraries go in there.
> I don't want Debug and Release subdirectories.
>
> Any ideas?
>
> Thanks,
> Clint
>
>



More information about the Cmake mailing list