[CMake] .dll rpath crutch needed

Michael Wild themiwi at gmail.com
Mon May 16 08:16:59 EDT 2011


On 05/16/2011 02:10 PM, Thomas Sondergaard wrote:
> I've got a project with 21 shared libraries and a number of executables.
> The shared libraries end up in their various directories but on Linux
> not-installed binaries can still be run because the path to the shared
> libraries are "burned in" to the shared libraries and executables as
> rpaths.
> 
> The exact same project build on Windows doesn't work as well because the
> shared libraries are not found. For the short term solution we have
> chosen to set up the PATH variable prior to starting visual studio from
> a command prompt, e.g
> 
> set PATH=%PATH%;C:\path\to\myproject_build\module1\src\Debug
> set PATH=%PATH%;C:\path\to\myproject_build\module2\src\Debug
> set PATH=%PATH%;C:\path\to\myproject_build\module3\src\Debug
> set PATH=%PATH%;C:\path\to\myproject_build\module4\src\Debug
> set PATH=%PATH%;C:\path\to\myproject_build\module5\src\Debug
> set PATH=%PATH%;C:\path\to\myproject_build\module6\src\Debug
> ...
> 
> It would be very handy and get us closer to common behaviour if CMake
> could provide a crutch of some kind in the absence of rpath support in
> Windows .dlls.
> 
> First, it would be handy if the project CMake output included a .cmd
> script for setting all the paths above. This would allow you to start a
> Visual Studio (or Windows SDK) command shell and get the environment
> right by running e.g.
> "C:\path\to\myproject_build\setup_build_paths_debug.cmd".
> 
> You could use the above solution with Visual Studio if you run the
> script before opening visual studio from a command prompt. A supplement
> would be to have CMake generate an appropriate environment setting for
> the debugging section of all executables. This way you can start visual
> studio without any tricks and still get it right most of the time. It
> would also (unlike the former solution) work correctly if you switch
> between build types (e.g Debug, RelWithDbg, Release).
> 
> Does something like this exist? Any alternative solutions out there.
> Obviously I can't be the first cmake user with this problem. I've found
> this stackoverflow question which is related but not identical, but no
> convincing solution:
> 
> http://stackoverflow.com/questions/1005901/how-to-set-path-environment-variable-using-cmake-and-visual-studio-to-run-test
> 
> 
> 
> Thanks,
> 
> Thomas

It would be easier to set CMAKE_RUNTIME_OUTPUT_DIRECTORY on
(WIN32 AND NOT CYGWIN).

My 2c.

Michael


More information about the CMake mailing list