# install works only for RUNTIME

**URL:** https://discourse.cmake.org/t/install-works-only-for-runtime/2438
**Category:** Usage
**Tags:** os:windows
**Created:** [December 29, 2020, 2:34am UTC](https://discourse.cmake.org/t/install-works-only-for-runtime/2438 "2020-12-29T02:34:00Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![aopaw](https://discourse.cmake.org/user_avatar/discourse.cmake.org/aopaw/32/1051_2.png) [@aopaw](https://discourse.cmake.org/u/aopaw)
#### Post date: [December 29, 2020, 2:34am UTC](https://discourse.cmake.org/t/install-works-only-for-runtime/2438/1 "2020-12-29T02:34:00Z")

</div>

Hello,  
I try to solve generating 3rd-party .dll files to the executable folder or install folder with install(TARGETS). The install works only for RUNTIME but not for LIBRARY others. Here is my code:

```cmake
INSTALL(TARGETS ${PROJECT_NAME} 
    RUNTIME DESTINATION ${CMAKE_INSTALL_PATH}/bin
    LIBRARY DESTINATION ${CMAKE_INSTALL_PATH}/lib
    ARCHIVE DESTINATION ${CMAKE_INSTALL_PATH}/lib
    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PATH}/include
    PRIVATE_HEADER DESTINATION ${CMAKE_INSTALL_PATH}/include)

```

After compilation of the project, a folder named install comes out correctly under the ${CMAKE\_INSTALL\_PATH} and also a subdirectory bin shown there with an executable file inside but nothing else was found.

```auto
4>------ Rebuild All started: Project: INSTALL, Configuration: Debug Win32 ------
4> -- Install configuration: "Debug"
4> -- Installing: D:/win32/Project/source/../install/bin/Prjoect.exe
========== Rebuild All: 4 succeeded, 0 failed, 0 skipped ==========

```

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [December 29, 2020, 5:30am UTC](https://discourse.cmake.org/t/install-works-only-for-runtime/2438/2 "2020-12-29T05:30:29Z")

</div>

You wouldn’t normally add the `${CMAKE_INSTALL_PATH}` prefix to the various destinations.

There isn’t enough information here to know what the cause could be. Please post a complete, minimal project which someone else can use to reproduce the problem on their machine. Cut down your real project as far as you can, removing anything that isn’t relevant to the issue you are seeing.

---

<div class="post-metadata">

### Author: ![aopaw](https://discourse.cmake.org/user_avatar/discourse.cmake.org/aopaw/32/1051_2.png) [@aopaw](https://discourse.cmake.org/u/aopaw)
#### Post date: [December 29, 2020, 6:09am UTC](https://discourse.cmake.org/t/install-works-only-for-runtime/2438/3 "2020-12-29T06:09:13Z")

</div>

Thanks for reply, @craig.scott. Later, I modified it as shown below.

```cmake
     # Install
    if(MSVC)
     set(CMAKE_INSTALL_PATH ${PROJECT_SOURCE_DIR}/../install CACHE STRING "installation path")
     message(${CMAKE_INSTALL_PATH})
    endif()
     set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/../install)
     message(${CMAKE_INSTALL_PREFIX})

    INSTALL(TARGETS ${PROJECT_NAME} 
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    )

    INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/include DESTINATION ${CMAKE_INSTALL_PATH})

```

This modification gives a bin folder and an include folder in the “install” one. It still failed to generate lib folder and anything related to that. The project is very simple. The tree structure looks like

```
\source 
       \include 
            \header.h
       \src 
            \header.cpp
            \main.cpp
      \CMakeLists.txt

```

and a

```
\build

```

It is the same level for source, build and install.  
In CMakeLists.txt, there are few libraries and can be found correctly during configuration of cmake-gui. OpenCV is shown here as an example

```cmake
    # opencv 
    set(CMAKE_PREFIX_PATH "D:/opencv343")
    find_package(OpenCV REQUIRED)
    message(${OpenCV_INCLUDE_DIRS})
    message(${OpenCV_LIBS})

    # Update LIBRARIES variable
    LIST(APPEND LIBRARIES
    ${OpenCV_LIBS})

    # include
    include_directories(
    ${PROJECT_SOURCE_DIR}/include
    )

    # source
    aux_source_directory(${PROJECT_SOURCE_DIR}/src SRCFILES)

    # Executable
    add_executable(${PROJECT_NAME} ${SRCFILES})
    target_link_libraries(${PROJECT_NAME} ${LIBRARIES})

```

and then they are only codes given at the beginning of my post.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [December 29, 2020, 6:34am UTC](https://discourse.cmake.org/t/install-works-only-for-runtime/2438/4 "2020-12-29T06:34:04Z")

</div>

The only target you are installing is an executable. If you are expecting the OpenCV libraries to be installed as well, you have to install those yourself. I’d recommend you checkout the CMake docs for the `file(GET_RUNTIME_DEPENDENCIES)` command for that.

This would have been easier if you had provided a complete `CMakeLists.txt` rather than making others piece one together from fragments.

---

<div class="post-metadata">

### Author: ![aopaw](https://discourse.cmake.org/user_avatar/discourse.cmake.org/aopaw/32/1051_2.png) [@aopaw](https://discourse.cmake.org/u/aopaw)
#### Post date: [December 29, 2020, 6:36am UTC](https://discourse.cmake.org/t/install-works-only-for-runtime/2438/5 "2020-12-29T06:36:48Z")

</div>

I found this before having my post. Is there a version limitation in using this command. Thanks.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [December 29, 2020, 6:38am UTC](https://discourse.cmake.org/t/install-works-only-for-runtime/2438/6 "2020-12-29T06:38:18Z")

</div>

`file(GET_RUNTIME_DEPENDENCIES)` is available with CMake 3.16 or later.

---

<div class="post-metadata">

### Author: ![aopaw](https://discourse.cmake.org/user_avatar/discourse.cmake.org/aopaw/32/1051_2.png) [@aopaw](https://discourse.cmake.org/u/aopaw)
#### Post date: [December 29, 2020, 6:41am UTC](https://discourse.cmake.org/t/install-works-only-for-runtime/2438/7 "2020-12-29T06:41:13Z")

</div>

😂 I don’t want to update my cmake which has been used since 2017.
