[CMake] What do Visual Studio users do so they can run/debug their programs when using 3rd party .dlls?

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Sun May 25 21:30:35 EDT 2014


Hi Eric,

This can be solved using a launcher.

When adding tests, you could use the following syntax:

  add_test(
    NAME NameOfTest
    COMMAND ${TheProject_LAUNCH_COMMAND} $<TARGET_FILE:NameOfTarget>
    --arg1 ...
    )


where

   TheProject_LAUNCH_COMMAND  is a variable pointing to a launcher


There are few options for the launcher, you could:

  (1) configure a .bat or .sh script as it is done in TubeTK. See [1]

or

  (2) use a dedicated "launcher" program as done in Slicer. For example the
CTKAppLauncher. See [2][3] and [4]

        More details:
http://www.commontk.org/index.php/Tools:_Application_launcher


Hth
Jc

[1]
https://github.com/TubeTK/TubeTK/blob/2157c3318aab85ae929a6ee6dce9d3ea2f8eeae7/CMakeLists.txt#L595
[2]
https://github.com/Slicer/Slicer/blob/3c4dc4490488e545c354472521f634a786f121c6/Applications/SlicerApp/CMakeLists.txt#L264
[3]
https://github.com/Slicer/Slicer/blob/3c4dc4490488e545c354472521f634a786f121c6/CMakeLists.txt#L717
[4]
https://github.com/Slicer/Slicer/blob/3c4dc4490488e545c354472521f634a786f121c6/Applications/SlicerApp/Testing/Cpp/CMakeLists.txt#L68



On Fri, May 23, 2014 at 10:48 PM, Michael Jackson <
mike.jackson at bluequartz.net> wrote:

> Eric,
>    For my project I ran into the same problems (
> http://www.github.com/dream3d/DREAM3D) and I chose to solve the issues by
> having CMake setup custom build rules to copy the DLLs into the appropriate
> Debug or Release directory for what I am building. I do this because simply
> adding the directories to the global PATH is a "bad" idea if you have
> multiple versions of a particular 3rd party framework, i.e., 32 bit and 64
> bit Qt or different versions of Qt. In the same "Copy Code" I also setup
> install rules for those libraries, again, based on the type of build being
> performed.
>
>  For packaging CMake has functions available to copy the required MS
> runtime libraries into the final package scheme for you. I use the
> following CMake file to setup my packaging.
> https://github.com/dream3d/DREAM3D/blob/m_develop/Resources/CPack/PackageProject.cmake
>
> For my project all this seems to be working quite well as we don't have
> any issues with our releases. YMMV.
>
> Cheers
> --
> Mike Jackson
>
>
> On May 23, 2014, at 7:23 PM, Eric Wing <ewmailing at gmail.com> wrote:
>
> > My project has lots of 3rd party .dlls. I can build my project just
> > fine with CMake/Visual Studio. But when I try to debug/run within
> > Visual Studio, it fails because my 3rd party .dlls are not in the same
> > directory as where VS generated the .exe.
> >
> > I know I can manually copy all my .dlls and put them in the generated
> > directory, but I was hoping there was a more automatic way to do this,
> > especially since the directory changes when you switch from
> > debug/release/etc.
> >
> >
> > On a similar note, what do you do for packaging/installing? In
> > addition to including the 3rd party dlls, what do you do to include
> > Microsoft required dll's like msvcr*.dll and msvcp*.dll?
> >
> > Thanks,
> > Eric
> > --
> > Beginning iPhone Games Development
> > http://playcontrol.net/iphonegamebook/
> > --
> >
> > Powered by www.kitware.com
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
> >
> > CMake Support: http://cmake.org/cmake/help/support.html
> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
> > CMake Training Courses: http://cmake.org/cmake/help/training.html
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.cmake.org/mailman/listinfo/cmake
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140525/71af7378/attachment-0001.html>


More information about the CMake mailing list