[CMake] Question about install()

Robert Dailey rcdailey at gmail.com
Sun Dec 7 13:02:59 EST 2008


On Sun, Dec 7, 2008 at 7:01 AM, Michael Jackson <mike.jackson at bluequartz.net
> wrote:

> There are a few variables that control where the final executables,
> libraries and archives are created.
>
> CMAKE_RUNTIME_OUTPUT_DIRECTORY
> CMAKE_LIBRARY_OUTPUT_DIRECTORY
> CMAKE_ARCHIVE_OUTPUT_DIRECTORY
>
>        • RUNTIME_OUTPUT_DIRECTORY: Output directory in which to build
> RUNTIME target files.
> This property specifies the directory into which runtime target files
> should be built. There are three kinds of target files that may be built:
> archive, library, and runtime. Executables are always treated as runtime
> targets. Static libraries are always treated as archive targets. Module
> libraries are always treated as library targets. For non-DLL platforms
> shared libraries are treated as library targets. For DLL platforms the DLL
> part of a shared library is treated as a runtime target and the
> corresponding import library is treated as an archive target. All
> Windows-based systems including Cygwin are DLL platforms. This property is
> initialized by the value of the variable CMAKE_RUNTIME_OUTPUT_DIRECTORY if
> it is set when a target is created
>
> So you can do something like:
>
> SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin CACHE PATH
>  "Single Directory for all executables"
>  )
> SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin CACHE PATH
>  "Single Directory for all dynamic Libraries"
>  )
> SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin CACHE PATH
>  "Single Directory for all static Libraries"
>  )
>
> BEFORE any "add_library" or "add_executable" is called. That way all your
> built products will be created in the same directory when being built. Now,
> that assumes that your "couple of dlls" were built by your project. If they
> were NOT built by your project (say for example, Qt libraries) then you will
> want to try something a bit different.
>
> cmake -E can be used to copy files.
>
> You may want to look at the add_custom_command(TARGET ${yourExeTarget}
>                                                POST_BUILD
>                                                COMMAND ${CMAKE_COMMAND} -E
> {path to source dll} {path to dest}
>                                                ..... )
>
> This will probably copy the files _every_ time the target is built although
> I am not sure on that point.
>
> You can look up the help for add_custom_command and see if this will help
> you out.


I tried the following, but it didn't print anything. Are you sure these
variables even exist?

message( "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" )
message( "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" )
message( "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081207/a37a8187/attachment.htm>


More information about the CMake mailing list