Mateusz Loskot wrote:
I have a CMake-based project which builds several shared libraries and executables. There are various run-time dependencies between those shared libraries and executables.On Windows, I use Visual Studio for development, so I have CMake-generated .sln with projects. loaded into the IDE. I build. Then, I'd like to run one of executables (e.g. test.exe) which links against the DLLs also built by the project. Obviously, it is necessary to deal with the run-time search path. At the moment, I simplify things by outputting all .exe and .dll binaries to common directory, so programs can find required DLLs: set(MYPRJOUTDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MYPRJOUTDIR}) This is also required to launch such executables under debugger. However, I have heard opinions it is some kind of a hack unnatural to CMake. On Linux, I do the same, but I imagine I could make use of rpath [1] as CMake provides some degree of support in this area [2]. On Windows, there is no such concept as rpath. Isolated Applications [3] seems to be the closest idea available there. Is it a good idea to have all-in-one CMAKE_RUNTIME_OUTPUT_DIRECTORY? Is there any CMake best practice for dealing with run-time search path on Windows? For example, automatically setting PATH in project -> Configuration Properties -> Debugging -> Environment. [1] http://en.wikipedia.org/wiki/Rpath [2] http://www.vtk.org/Wiki/CMake_RPATH_handling [3] http://msdn.microsoft.com/en-us/library/aa375190%28VS.85%29.aspx
On Windows, it looks fine to me to have all the DLL's built by the project together with the executable that links against them, in one and the same CMAKE_RUNTIME_OUTPUT_DIRECTORY. The alternative of setting the PATH looks less reliable to me, because the PATH may easily be overruled by other locations (current directory, system directory or Windows directory), depending on that rather complicated "Dynamic-Link Library Search Order" thing, http://msdn.microsoft.com/en-us/site/ms682586 And eventually I guess you don't want your application to depend on the PATH at the end user machine. However, I haven't yet tried to build an "isolated application" according to your reference [3] (http://msdn.microsoft.com/en-us/library/aa375190%28VS.85%29.aspx). Would you recommend doing so?
Kind regards, Niels -- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center -- 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
