[CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Michael Stürmer
I have found some topics related to my issue on the web, but none so far helped 
me to fix it:
 
I use Visual Studio 2010 on Windows 7 64Bit.
 
During my build, all binaries are collected in one folder, which makes it 
easier for me to debug the project. But to be able to run the program actually, 
I have to copy several dlls (like Qt, openCV etc.) into the folder for the 
program to find them. Putting the libraries in the system path is not an option 
for me, as I switch between 32- and 64-bit on the same system.
 
I managed to locate the folder where the dlls are (using some CMake-Variables) 
and using a custom command like
 
ADD_CUSTOM_COMMAND( TARGET CopyDlls POST_BUILD
COMMAND copy "${DLL_3RD}/*.dll"  
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$"
COMMENT "copying dlls ."
)
 
This copies ALL dlls from the ${DLL_3RD} folder to the binary folder, for Qt 
that would be the relase as well as the debug libraries.
 
Now my question:
 
I would like to only copy those dlls I need, i.e. I have to determine somehow 
if I'm in debug or release mode and select the appropriate libraries by adding 
"d" for debug versions. For openCV I need "opencv_core231.dll" in release and 
"opencv_core231d.dll" in debug mode. Does anyone have a 
solution/workaround/idea for this problem?
 
Best regards,
Michael--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Hauke Heibel
Hi Michael,

What I do is running a custom command which itself executes a CMake
script. Usually similar to

add_custom_command(TARGET CopyDlls
  COMMAND ${CMAKE_COMMAND}
-DMSVC_BUILD_CONFIG_DIR=${CMAKE_CFG_INTDIR}
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
-P "/yourCopyDlls.cmake"
  VERBATIM
)

In the "yourCopyDlls.cmake", you can GLOB your DLLs with or without
the "d" postfix depending on MSVC_BUILD_CONFIG_DIR. You can now even
copy additional files such as e.g. PDB files.

HTH,
Hauke

2012/1/9 Michael Stürmer :
> I have found some topics related to my issue on the web, but none so far
> helped me to fix it:
>
>
>
> I use Visual Studio 2010 on Windows 7 64Bit.
>
>
>
> During my build, all binaries are collected in one folder, which makes it
> easier for me to debug the project. But to be able to run the program
> actually, I have to copy several dlls (like Qt, openCV etc.) into the folder
> for the program to find them. Putting the libraries in the system path is
> not an option for me, as I switch between 32- and 64-bit on the same system.
>
>
>
> I managed to locate the folder where the dlls are (using some
> CMake-Variables) and using a custom command like
>
>
>
> ADD_CUSTOM_COMMAND( TARGET CopyDlls POST_BUILD
>
>     COMMAND copy “${DLL_3RD}/*.dll”
>  “${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$”
>
>     COMMENT “copying dlls …”
>
>     )
>
>
>
> This copies ALL dlls from the ${DLL_3RD} folder to the binary folder, for Qt
> that would be the relase as well as the debug libraries.
>
>
>
> Now my question:
>
>
>
> I would like to only copy those dlls I need, i.e. I have to determine
> somehow if I’m in debug or release mode and select the appropriate libraries
> by adding “d” for debug versions. For openCV I need “opencv_core231.dll” in
> release and “opencv_core231d.dll” in debug mode. Does anyone have a
> solution/workaround/idea for this problem?
>
>
>
> Best regards,
>
> Michael
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Michael Stürmer
Hello Hauke,

thanks for the answer! I already got some workaround which is very similar to 
your suggestion: as I have this problem only in windows/msvc mode I use a 
batch-script now which takes the $ variable as an argument. 
Within the bat-script I check the content of %, i.e. 
"Release","Debug" etc. and set some batch-variables appropriately. I don't like 
it very much but it works.

-Ursprüngliche Nachricht-
Von: Hauke Heibel [mailto:hauke.hei...@googlemail.com] 
Gesendet: Montag, 9. Januar 2012 15:45
An: Michael Stürmer
Cc: cmake@cmake.org
Betreff: Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

Hi Michael,

What I do is running a custom command which itself executes a CMake
script. Usually similar to

add_custom_command(TARGET CopyDlls
  COMMAND ${CMAKE_COMMAND}
-DMSVC_BUILD_CONFIG_DIR=${CMAKE_CFG_INTDIR}
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
-P "/yourCopyDlls.cmake"
  VERBATIM
)

In the "yourCopyDlls.cmake", you can GLOB your DLLs with or without
the "d" postfix depending on MSVC_BUILD_CONFIG_DIR. You can now even
copy additional files such as e.g. PDB files.

HTH,
Hauke

2012/1/9 Michael Stürmer :
> I have found some topics related to my issue on the web, but none so far
> helped me to fix it:
>
>
>
> I use Visual Studio 2010 on Windows 7 64Bit.
>
>
>
> During my build, all binaries are collected in one folder, which makes it
> easier for me to debug the project. But to be able to run the program
> actually, I have to copy several dlls (like Qt, openCV etc.) into the folder
> for the program to find them. Putting the libraries in the system path is
> not an option for me, as I switch between 32- and 64-bit on the same system.
>
>
>
> I managed to locate the folder where the dlls are (using some
> CMake-Variables) and using a custom command like
>
>
>
> ADD_CUSTOM_COMMAND( TARGET CopyDlls POST_BUILD
>
>     COMMAND copy "${DLL_3RD}/*.dll"
>  "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$"
>
>     COMMENT "copying dlls ."
>
>     )
>
>
>
> This copies ALL dlls from the ${DLL_3RD} folder to the binary folder, for Qt
> that would be the relase as well as the debug libraries.
>
>
>
> Now my question:
>
>
>
> I would like to only copy those dlls I need, i.e. I have to determine
> somehow if I'm in debug or release mode and select the appropriate libraries
> by adding "d" for debug versions. For openCV I need "opencv_core231.dll" in
> release and "opencv_core231d.dll" in debug mode. Does anyone have a
> solution/workaround/idea for this problem?
>
>
>
> Best regards,
>
> Michael
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread John Drescher
2012/1/9 Hauke Heibel :
> Hi Michael,
>
> What I do is running a custom command which itself executes a CMake
> script. Usually similar to
>
> add_custom_command(TARGET CopyDlls
>  COMMAND ${CMAKE_COMMAND}
>        -DMSVC_BUILD_CONFIG_DIR=${CMAKE_CFG_INTDIR}
>        -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
>        -P "/yourCopyDlls.cmake"
>  VERBATIM
> )
>
> In the "yourCopyDlls.cmake", you can GLOB your DLLs with or without
> the "d" postfix depending on MSVC_BUILD_CONFIG_DIR. You can now even
> copy additional files such as e.g. PDB files.
>

Thanks for sharing this. I use cmake generate a batch file (using
FILE(append ...) ) that calls cmake -E copy_if_different for each
file. then add this as a custom target however your method looks much
cleaner..


John
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Michael Jackson
I was going to chime in with my own macro:

# 
#-- Copy all the Qt4 dependent DLLs into the current build directory so that
#-- one can debug an application or library that depends on Qt4 libraries.
macro (CMP_COPY_QT4_RUNTIME_LIBRARIES QTLIBLIST)
#message(STATUS "CMP_COPY_QT4_RUNTIME_LIBRARIES")
if (MSVC)
if (DEFINED QT_QMAKE_EXECUTABLE)
set(TYPE "d")
FOREACH(qtlib ${QTLIBLIST})
GET_FILENAME_COMPONENT(QT_DLL_PATH_tmp ${QT_QMAKE_EXECUTABLE} 
PATH)
message(STATUS "Generating Copy Rule for Qt Debug DLL Library 
${QT_DLL_PATH_tmp}/${qtlib}d4.dll")  
add_custom_target(ZZ_${qtlib}-Debug-Copy ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different 
${QT_DLL_PATH_tmp}/${qtlib}${TYPE}4.dll
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/ 
COMMENT "Copying ${qtlib}${TYPE}4.dll to 
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/")
message(STATUS "Generating Copy Rule for Qt Release DLL Library 
${QT_DLL_PATH_tmp}/${qtlib}d4.dll")  
add_custom_target(ZZ_${qtlib}-Release-Copy ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different 
${QT_DLL_PATH_tmp}/${qtlib}4.dll
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/ 
COMMENT "Copying ${qtlib}4.dll to 
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/")
  
ENDFOREACH(qtlib)
endif(DEFINED QT_QMAKE_EXECUTABLE)
endif()
endmacro()

The only issue I really have with this is that this macro requires there to be 
BOTH debug and Release libraries available and will copy BOTH no matter which 
configuration is being built. I am thinking that the "yourCopyDlls.cmake" could 
be auto generated based on what the programmer says they need and then do the 
appropriate copy. I may look into this today. Thanks for sharing.
___
Mike JacksonPrincipal Software Engineer
BlueQuartz SoftwareDayton, Ohio
mike.jack...@bluequartz.net  www.bluequartz.net

On Jan 9, 2012, at 9:51 AM, John Drescher wrote:

> 2012/1/9 Hauke Heibel :
>> Hi Michael,
>> 
>> What I do is running a custom command which itself executes a CMake
>> script. Usually similar to
>> 
>> add_custom_command(TARGET CopyDlls
>>  COMMAND ${CMAKE_COMMAND}
>>-DMSVC_BUILD_CONFIG_DIR=${CMAKE_CFG_INTDIR}
>>-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
>>-P "/yourCopyDlls.cmake"
>>  VERBATIM
>> )
>> 
>> In the "yourCopyDlls.cmake", you can GLOB your DLLs with or without
>> the "d" postfix depending on MSVC_BUILD_CONFIG_DIR. You can now even
>> copy additional files such as e.g. PDB files.
>> 
> 
> Thanks for sharing this. I use cmake generate a batch file (using
> FILE(append ...) ) that calls cmake -E copy_if_different for each
> file. then add this as a custom target however your method looks much
> cleaner..
> 
> 
> John
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Hauke Heibel
On Mon, Jan 9, 2012 at 4:11 PM, Michael Jackson
 wrote:
> The only issue I really have with this is that this macro requires there to 
> be BOTH debug and Release libraries available and will copy BOTH no matter 
> which configuration is being built. I am thinking that the 
> "yourCopyDlls.cmake" could be auto generated based on what the programmer 
> says they need and then do the appropriate copy.

I experienced the exact same problem in the beginning - both libraries
had to be available. IIRC, passing ${CMAKE_CFG_INTDIR} to the script
allowed me to overcome this issue. The script does not even need to be
auto-generated. I am using one and the same script for all build
types.

- Hauke
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Michael Hertling
On 01/09/2012 10:05 AM, Michael Stürmer wrote:
> I have found some topics related to my issue on the web, but none so far 
> helped me to fix it:
>  
> I use Visual Studio 2010 on Windows 7 64Bit.
>  
> During my build, all binaries are collected in one folder, which makes it 
> easier for me to debug the project. But to be able to run the program 
> actually, I have to copy several dlls (like Qt, openCV etc.) into the folder 
> for the program to find them. Putting the libraries in the system path is not 
> an option for me, as I switch between 32- and 64-bit on the same system.
>  
> I managed to locate the folder where the dlls are (using some 
> CMake-Variables) and using a custom command like
>  
> ADD_CUSTOM_COMMAND( TARGET CopyDlls POST_BUILD
> COMMAND copy "${DLL_3RD}/*.dll"  
> "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$"
> COMMENT "copying dlls ."
> )
>  
> This copies ALL dlls from the ${DLL_3RD} folder to the binary folder, for Qt 
> that would be the relase as well as the debug libraries.
>  
> Now my question:
>  
> I would like to only copy those dlls I need, i.e. I have to determine somehow 
> if I'm in debug or release mode and select the appropriate libraries by 
> adding "d" for debug versions. For openCV I need "opencv_core231.dll" in 
> release and "opencv_core231d.dll" in debug mode. Does anyone have a 
> solution/workaround/idea for this problem?
>  
> Best regards,
> Michael

Perhaps, you might perform a temporary installation for debugging
purposes and use the BundleUtilities for this installation only:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(P C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")
ADD_EXECUTABLE(main main.c)
INSTALL(TARGETS main DESTINATION bin)
INSTALL(CODE "
IF(CMAKE_INSTALL_PREFIX STREQUAL \"${CMAKE_BINARY_DIR}/debuginstall\")
MESSAGE(\"Use BundleUtilities here\")
ENDIF()
")

If you specify ${CMAKE_BINARY_DIR}/debuginstall as CMAKE_INSTALL_PREFIX,
the BundleUtilities are included - if you replace the MESSAGE() command,
of course - and should do the job. Otherwise, i.e. with different CMAKE_
INSTALL_PREFIX, the installation runs as usual. In this way, you do not
need an installation component or the like to have CMake recognize your
special debugging installation. The downside is that you've to rebuild
the project with the final CMAKE_INSTALL_PREFIX when performing the
"real" installation, but usually, you do this anyway in order to
switch from the debug configuration to the release one.

Regards,

Michael
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Julien Malik

Hi,

Did you try FixupBundle from the BundleUtilities module ?

I use it on windows, at install time, to copy all the dll required by an 
executable, just next to the executable.
Very usefull to generate a standalone installer. The good thing is that 
it introspects your executable (via the windows equivalent of ldd), and 
copy all that is needed, and only what is needed.
No need to maintain any list of DLL, they just need to be accessible in 
the PATH at the time FixupBundle is called.


I guess you can plug a call to it in a POST_BUILD step, and that it 
would automatically copy the right flavor (debug/release) of DLL.


Regards,
Julien


Le 09/01/2012 10:05, Michael Stürmer a écrit :


I have found some topics related to my issue on the web, but none so 
far helped me to fix it:


I use Visual Studio 2010 on Windows 7 64Bit.

During my build, all binaries are collected in one folder, which makes 
it easier for me to debug the project. But to be able to run the 
program actually, I have to copy several dlls (like Qt, openCV etc.) 
into the folder for the program to find them. Putting the libraries in 
the system path is not an option for me, as I switch between 32- and 
64-bit on the same system.


I managed to locate the folder where the dlls are (using some 
CMake-Variables) and using a custom command like


ADD_CUSTOM_COMMAND( TARGET CopyDlls POST_BUILD

COMMAND copy "${DLL_3RD}/*.dll" 
 "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$"


COMMENT "copying dlls ..."

)

This copies ALL dlls from the ${DLL_3RD} folder to the binary folder, 
for Qt that would be the relase as well as the debug libraries.


Now my question:

I would like to only copy those dlls I need, i.e. I have to determine 
somehow if I'm in debug or release mode and select the appropriate 
libraries by adding "d" for debug versions. For openCV I need 
"opencv_core231.dll" in release and "opencv_core231d.dll" in debug 
mode. Does anyone have a solution/workaround/idea for this problem?


Best regards,

Michael


--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread David Cole
2012/1/9 Michael Stürmer :
> I have found some topics related to my issue on the web, but none so far
> helped me to fix it:
>
>
>
> I use Visual Studio 2010 on Windows 7 64Bit.
>
>
>
> During my build, all binaries are collected in one folder, which makes it
> easier for me to debug the project. But to be able to run the program
> actually, I have to copy several dlls (like Qt, openCV etc.) into the folder
> for the program to find them. Putting the libraries in the system path is
> not an option for me, as I switch between 32- and 64-bit on the same system.
>
>
>
> I managed to locate the folder where the dlls are (using some
> CMake-Variables) and using a custom command like
>
>
>
> ADD_CUSTOM_COMMAND( TARGET CopyDlls POST_BUILD
>
>     COMMAND copy “${DLL_3RD}/*.dll”
>  “${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$”
>
>     COMMENT “copying dlls …”
>
>     )
>
>
>
> This copies ALL dlls from the ${DLL_3RD} folder to the binary folder, for Qt
> that would be the relase as well as the debug libraries.
>
>
>
> Now my question:
>
>
>
> I would like to only copy those dlls I need, i.e. I have to determine
> somehow if I’m in debug or release mode and select the appropriate libraries
> by adding “d” for debug versions. For openCV I need “opencv_core231.dll” in
> release and “opencv_core231d.dll” in debug mode. Does anyone have a
> solution/workaround/idea for this problem?
>
>
>
> Best regards,
>
> Michael
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

Have a look at the CMake modules BundleUtilities and GetPrerequisites:

  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:BundleUtilities
  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:GetPrerequisites


HTH,
David
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Michael Stürmer
Awesome! Sometimes you just need to know what's already available to solve your 
problems in a very elegant way. I'll have a look at these bundles and probably 
switch to them instead of maintaining my own stuff!

-Ursprüngliche Nachricht-
Von: David Cole [mailto:david.c...@kitware.com] 
Gesendet: Montag, 9. Januar 2012 17:05
An: Michael Stürmer
Cc: cmake@cmake.org
Betreff: Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012/1/9 Michael Stürmer :
> I have found some topics related to my issue on the web, but none so far
> helped me to fix it:
>
>
>
> I use Visual Studio 2010 on Windows 7 64Bit.
>
>
>
> During my build, all binaries are collected in one folder, which makes it
> easier for me to debug the project. But to be able to run the program
> actually, I have to copy several dlls (like Qt, openCV etc.) into the folder
> for the program to find them. Putting the libraries in the system path is
> not an option for me, as I switch between 32- and 64-bit on the same system.
>
>
>
> I managed to locate the folder where the dlls are (using some
> CMake-Variables) and using a custom command like
>
>
>
> ADD_CUSTOM_COMMAND( TARGET CopyDlls POST_BUILD
>
>     COMMAND copy "${DLL_3RD}/*.dll"
>  "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$"
>
>     COMMENT "copying dlls ."
>
>     )
>
>
>
> This copies ALL dlls from the ${DLL_3RD} folder to the binary folder, for Qt
> that would be the relase as well as the debug libraries.
>
>
>
> Now my question:
>
>
>
> I would like to only copy those dlls I need, i.e. I have to determine
> somehow if I'm in debug or release mode and select the appropriate libraries
> by adding "d" for debug versions. For openCV I need "opencv_core231.dll" in
> release and "opencv_core231d.dll" in debug mode. Does anyone have a
> solution/workaround/idea for this problem?
>
>
>
> Best regards,
>
> Michael
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

Have a look at the CMake modules BundleUtilities and GetPrerequisites:

  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:BundleUtilities
  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:GetPrerequisites


HTH,
David

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread John Drescher
> Awesome! Sometimes you just need to know what's already available to solve 
> your problems in a very elegant way. I'll have a look at these bundles and 
> probably switch to them instead of maintaining my own stuff!
>

Same here. I have spent a few hours writing scripts that keep a list
of necessary dlls. This approach is much cleaner.



John
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread Hauke Heibel
2012/1/9 Michael Stürmer :
> Awesome! Sometimes you just need to know what's already available to solve 
> your problems in a very elegant way. I'll have a look at these bundles and 
> probably switch to them instead of maintaining my own stuff!

When looking at the initial problem, I am pretty much convinced that
you need a combination of your own script and GetPrerequisites since
you want to copy to your run-time output directory - and there to
specific sub-directories depending on the build type.

It may well be that I have overseen some functionality in those new modules ...

- Hauke
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-09 Thread David Cole
2012/1/9 Hauke Heibel :
> 2012/1/9 Michael Stürmer :
>> Awesome! Sometimes you just need to know what's already available to solve 
>> your problems in a very elegant way. I'll have a look at these bundles and 
>> probably switch to them instead of maintaining my own stuff!
>
> When looking at the initial problem, I am pretty much convinced that
> you need a combination of your own script and GetPrerequisites since
> you want to copy to your run-time output directory - and there to
> specific sub-directories depending on the build type.
>
> It may well be that I have overseen some functionality in those new modules 
> ...
>
> - Hauke

BundleUtilities, on Windows, should copy dlls to be in the same
directory as the executable being analyzed... So, as long as the exe
is in the right directory when fixup_bundle is called on it, then the
dlls will get copied into that same directory.


Cheers,
David
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-10 Thread Ben Medina
I'd guess the performance of fixup_bundle will be a big pitfall if
you're planning on doing this after every build.

An entirely different approach is to configure a Visual Studio .user
file to set the PATH environment variable (not setting it globally;
just for debugging your app from within VS). You still have to track
which directories to add to the PATH, but this approach has worked
flawlessly for us (across multiple versions of VS, as well as 32- and
64-bit configs).

On Mon, Jan 9, 2012 at 8:41 AM, David Cole  wrote:
> 2012/1/9 Hauke Heibel :
>> 2012/1/9 Michael Stürmer :
>>> Awesome! Sometimes you just need to know what's already available to solve 
>>> your problems in a very elegant way. I'll have a look at these bundles and 
>>> probably switch to them instead of maintaining my own stuff!
>>
>> When looking at the initial problem, I am pretty much convinced that
>> you need a combination of your own script and GetPrerequisites since
>> you want to copy to your run-time output directory - and there to
>> specific sub-directories depending on the build type.
>>
>> It may well be that I have overseen some functionality in those new modules 
>> ...
>>
>> - Hauke
>
> BundleUtilities, on Windows, should copy dlls to be in the same
> directory as the executable being analyzed... So, as long as the exe
> is in the right directory when fixup_bundle is called on it, then the
> dlls will get copied into that same directory.
>
>
> Cheers,
> David
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-10 Thread Michael Jackson
I am VERY interested in how you did this. Did you have CMake write a file for 
you? Do you have some code to share by any chance? 

Thanks
--
Mike Jackson 

On Jan 10, 2012, at 3:17 PM, Ben Medina wrote:

> I'd guess the performance of fixup_bundle will be a big pitfall if
> you're planning on doing this after every build.
> 
> An entirely different approach is to configure a Visual Studio .user
> file to set the PATH environment variable (not setting it globally;
> just for debugging your app from within VS). You still have to track
> which directories to add to the PATH, but this approach has worked
> flawlessly for us (across multiple versions of VS, as well as 32- and
> 64-bit configs).
> 
> On Mon, Jan 9, 2012 at 8:41 AM, David Cole  wrote:
>> 2012/1/9 Hauke Heibel :
>>> 2012/1/9 Michael Stürmer :
 Awesome! Sometimes you just need to know what's already available to solve 
 your problems in a very elegant way. I'll have a look at these bundles and 
 probably switch to them instead of maintaining my own stuff!
>>> 
>>> When looking at the initial problem, I am pretty much convinced that
>>> you need a combination of your own script and GetPrerequisites since
>>> you want to copy to your run-time output directory - and there to
>>> specific sub-directories depending on the build type.
>>> 
>>> It may well be that I have overseen some functionality in those new modules 
>>> ...
>>> 
>>> - Hauke
>> 
>> BundleUtilities, on Windows, should copy dlls to be in the same
>> directory as the executable being analyzed... So, as long as the exe
>> is in the right directory when fixup_bundle is called on it, then the
>> dlls will get copied into that same directory.
>> 
>> 
>> Cheers,
>> David
>> --
>> 
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at 
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Please keep messages on-topic and check the CMake FAQ at: 
>> http://www.cmake.org/Wiki/CMake_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-10 Thread John Drescher
On Tue, Jan 10, 2012 at 3:17 PM, Ben Medina  wrote:
> I'd guess the performance of fixup_bundle will be a big pitfall if
> you're planning on doing this after every build.
>

One other approach is not making it a post build step but a custom
target that the user can build only when needed. This custom build
step will copy the dlls like the post build step did.

John
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-10 Thread Robert Dailey
He probably just uses a project.vcproj.user file, and uses the
configure_file() command on it to fill in command arguments, environment
variables, etc etc.

I've done this before and it works fantastically, although I have never
tried it to force the EXE to search for my DLL files without copying them.
Good idea though, if it works!

-
Robert Dailey


On Tue, Jan 10, 2012 at 2:29 PM, Michael Jackson <
mike.jack...@bluequartz.net> wrote:

> I am VERY interested in how you did this. Did you have CMake write a file
> for you? Do you have some code to share by any chance?
>
> Thanks
> --
> Mike Jackson 
>
> On Jan 10, 2012, at 3:17 PM, Ben Medina wrote:
>
> > I'd guess the performance of fixup_bundle will be a big pitfall if
> > you're planning on doing this after every build.
> >
> > An entirely different approach is to configure a Visual Studio .user
> > file to set the PATH environment variable (not setting it globally;
> > just for debugging your app from within VS). You still have to track
> > which directories to add to the PATH, but this approach has worked
> > flawlessly for us (across multiple versions of VS, as well as 32- and
> > 64-bit configs).
> >
> > On Mon, Jan 9, 2012 at 8:41 AM, David Cole 
> wrote:
> >> 2012/1/9 Hauke Heibel :
> >>> 2012/1/9 Michael Stürmer :
>  Awesome! Sometimes you just need to know what's already available to
> solve your problems in a very elegant way. I'll have a look at these
> bundles and probably switch to them instead of maintaining my own stuff!
> >>>
> >>> When looking at the initial problem, I am pretty much convinced that
> >>> you need a combination of your own script and GetPrerequisites since
> >>> you want to copy to your run-time output directory - and there to
> >>> specific sub-directories depending on the build type.
> >>>
> >>> It may well be that I have overseen some functionality in those new
> modules ...
> >>>
> >>> - Hauke
> >>
> >> BundleUtilities, on Windows, should copy dlls to be in the same
> >> directory as the executable being analyzed... So, as long as the exe
> >> is in the right directory when fixup_bundle is called on it, then the
> >> dlls will get copied into that same directory.
> >>
> >>
> >> Cheers,
> >> David
> >> --
> >>
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >>
> >> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.cmake.org/mailman/listinfo/cmake
> > --
> >
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.cmake.org/mailman/listinfo/cmake
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-11 Thread Eric Noulard
2012/1/11 Robert Dailey :
> He probably just uses a project.vcproj.user file, and uses the
> configure_file() command on it to fill in command arguments, environment
> variables, etc etc.
>
> I've done this before and it works fantastically, although I have never
> tried it to force the EXE to search for my DLL files without copying them.

All of this may be worth a new Wiki entry, since those questions have popped-up
several on the list.


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Copying of 3rd party DLLs in a POST-BUILD step

2012-01-11 Thread Ben Medina
Yes, that's exactly it. I'll try to add something to the wiki.

On Wed, Jan 11, 2012 at 6:01 AM, Eric Noulard  wrote:
> 2012/1/11 Robert Dailey :
>> He probably just uses a project.vcproj.user file, and uses the
>> configure_file() command on it to fill in command arguments, environment
>> variables, etc etc.
>>
>> I've done this before and it works fantastically, although I have never
>> tried it to force the EXE to search for my DLL files without copying them.
>
> All of this may be worth a new Wiki entry, since those questions have 
> popped-up
> several on the list.
>
>
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake