[CMake] How to invoke a separate build with CMAKE_CUSTOM_TARGET?

Rolf Eike Beer eike at sf-mail.de
Thu May 12 05:33:17 EDT 2011


> Hi,
>
> I'm not sure that I'm on the right path, therfore I will explain what I
> will do. I'm migrating our Linux project to Windows plattforms. Our
> project is build on several modules, which have to create and installed as
> libraries with cmake, some modules have dependencies to other modules. So
> far so good. This works fine on linux and windows.
>
> Now I've implemented several demos for one of those modules. On Linux
> there is no problem, if I've installed the dependencies correctly I could
> build my demo executables and run them directly. But on windows platfforms
> I'm struggling. To run the executables it's required to place the required
> libraries besides the executable or in system32 folder ...
>
> If I install the module dependencies with a cutstom install target to
> system32 folder I could ensure that those libraries could be linked by the
> executable at runtime. So I've got a behaviour like on Linux plattform for
> the module dependencies. But what is the best way to handling the library
> of the actual build? This file is placed to a lib subfolder which is
> differend from the demo executalbes (bin subfolder).

You can install the different "parts" of a library to different folders
(see the documentation of which parts means what). So this may solve your
issue by installing the DLLs to the same place as the executables:

INSTALL(TARGETS mylib
     RUNTIME DESTINATION bin
     LIBRARY DESTINATION lib
     ARCHIVE DESTINATION lib)

Also installing into system32 on Windows usually causes great mess. If the
above doesn't work just try adding your lib directory to the system PATH
before starting your executable.

Eike


More information about the CMake mailing list