I think setting LIBRARY_OUTPUT_PATH instead only works on the libraries you
build. I also need to copy configuration files etc. so ... how about
something like this:
(Note the the explicit specification of "Debug and release in the WIN32
section.)
#-- Start of code --
IF ( WIN32 )
# Only needed for windows.
# Note: We need to copy the dlls to two places in the build tree, namely
# ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}
IF(NOT STATIC_BUILD)
# Find the dlls we need.
FIND_FILE(LIBPQ_DLL libpq.dll PATHS ${POSTGRESQL_LIBRARY_DIRS}
NO_DEFAULT_PATH )
FIND_FILE(LIBPQD_DLL libpqd.dll PATHS ${POSTGRESQL_LIBRARY_DIRS}
NO_DEFAULT_PATH )
FIND_FILE(LIBPQXX_DLL libpqxx.dll PATHS ${LIBPQXX_LIBRARY_DIRS}
NO_DEFAULT_PATH )
FIND_FILE(LIBPQXXD_DLL libpqxxD.dll PATHS ${LIBPQXX_LIBRARY_DIRS}
NO_DEFAULT_PATH )
SET ( ESSENTIAL_FILES ${ESSENTIAL_FILES}
${LIBPQ_DLL}
${LIBPQXX_DLL}
)
SET ( ESSENTIAL_FILES_DEBUG ${ESSENTIAL_FILES_DEBUG}
${LIBPQD_DLL}
${LIBPQXXD_DLL}
)
ENDIF(NOT STATIC_BUILD)
# Copy these files to the build tree.
# We cannot determine whether Release or Debug is being used.
ADD_CUSTOM_TARGET(CopyDllCfg ALL echo "Copying dlls and essential files
...")
FOREACH(file ${ESSENTIAL_FILES_DEBUG})
GET_FILENAME_COMPONENT(fn ${file} NAME)
SET(tgt ${EXECUTABLE_OUTPUT_PATH}/Debug/${fn})
SET(src ${file})
ADD_CUSTOM_COMMAND(
TARGET CopyDllCfg
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different ${src} ${tgt}
COMMENT "source copy dlls and essential files"
)
ENDFOREACH(file)
FOREACH(file ${ESSENTIAL_FILES})
GET_FILENAME_COMPONENT(fn ${file} NAME)
SET(tgt ${EXECUTABLE_OUTPUT_PATH}/Release/${fn})
SET(src ${file})
ADD_CUSTOM_COMMAND(
TARGET CopyDllCfg
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different ${src} ${tgt}
COMMENT "source copy dlls and essential files"
)
ENDFOREACH(file)
ELSE ( WIN32 )
# Copy these files to the build tree.
ADD_CUSTOM_TARGET(CopyCfg ALL echo "Copying dlls and essential files ...")
FOREACH(file ${ESSENTIAL_FILES})
GET_FILENAME_COMPONENT(fn ${file} NAME)
SET(tgt ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${fn})
SET(src ${file})
ADD_CUSTOM_COMMAND(
TARGET CopyCfg
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different ${src} ${tgt}
COMMENT "source copy essential files"
)
ENDFOREACH(file)
ENDIF ( WIN32 )
#-- End of code ---
Regards
Andrew
On 9/18/07, McKay Davis <[EMAIL PROTECTED]> wrote:
>
> I'm experiencing trouble getting cmake to copy DLL files to my executable
> output path in visual studio after the target is built.
>
> It seems that the CMAKE_CFG_INTDIR variable is being expanded to:
> "$"(OutDir)
>
> This causes the .dll files to be copied to the filename '$(OutDir)', not
> into
> the 'Debug' or 'Release' sub-directory as I would expect.
>
> Here is the relevant cmake code:
>
> IF(WIN32)
> FILE(GLOB QT_DLLS "${QT_LIBRARY_DIR}/../bin/*.dll")
>
> GET_FILENAME_COMPONENT(PTHREAD_LIBRARY_DIR "${PTHREAD_LIBRARY}" PATH)
> FILE(GLOB PTHREAD_DLLS "${PTHREAD_LIBRARY_DIR}/*.dll")
>
> SET(DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
>
> FOREACH(DLL_FILENAME ${QT_DLLS} ${PTHREAD_DLLS})
>ADD_CUSTOM_COMMAND(
> TARGET ${PROJECT_NAME}
> POST_BUILD
> COMMAND ${CMAKE_COMMAND} -E copy
> ${DLL_FILENAME} ${DESTINATION}
> VERBATIM)
> MESSAGE(COPY ${DLL_FILENAME} ${DESTINATION})
> ENDFOREACH(DLL_FILENAME)
> ENDIF(WIN32)
>
>
> And here are a few lines from my VC++ buildlog.htm:
>
> "C:\Program Files (x86)\CMake 2.4\bin\cmake.exe" -E copy
> C:/Qt/4.3.1/lib/../bin/QtXml4.dll C:/bin/viewer/"$"(OutDir)
>
> "C:\Program Files (x86)\CMake 2.4\bin\cmake.exe" -E copy
> C:/Qt/4.3.1/lib/../bin/QtXmld4.dll C:/bin/viewer/"$"(OutDir)
>
>
> For some reason either cmake is quoting the $ in the expansion of the
> ${CMAKE_CFG_INTDIR} variable. Does anyone know a fix for this?
>
> -McKay D
>
>
>
>
>
>
>
> Don't let your dream ride pass you by. Make it a reality with Yahoo!
> Autos.
> http://autos.yahoo.com/index.html
>
>
>
> ___
> CMake mailing list
> CMake@cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
--
___
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney 2006 NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake