# CMAKE\_XXX\_OUTPUT\_DIRECTORY vs. target properties XXX\_OUTPUT\_DIRECTORY

**URL:** https://discourse.cmake.org/t/cmake-xxx-output-directory-vs-target-properties-xxx-output-directory/4187
**Category:** Usage
**Tags:** comp:msvc, os:windows, gen:ninja
**Created:** [October 1, 2021, 2:05pm UTC](https://discourse.cmake.org/t/cmake-xxx-output-directory-vs-target-properties-xxx-output-directory/4187 "2021-10-01T14:05:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![petermbauer](https://discourse.cmake.org/user_avatar/discourse.cmake.org/petermbauer/32/1839_2.png) [@petermbauer](https://discourse.cmake.org/u/petermbauer)
#### Post date: [October 1, 2021, 2:05pm UTC](https://discourse.cmake.org/t/cmake-xxx-output-directory-vs-target-properties-xxx-output-directory/4187/1 "2021-10-01T14:05:25Z")

</div>

Hello,

my goal is to use the CMAKE\_XXX\_OUTPUT\_DIRECTORY variables to set the default location for the built binaries and use the respective target property XXX\_OUTPUT\_DIRECTORY (e.g. LIBRARY\_OUTPUT\_DIRECTORY) for specific targets to place the respective files in a different location in the build folder. According to the documentation this should work as the values of the global variables are used to set the value of the target property of the targets when they are created so i would guess that changing the property values would reflect in the output path.  
The problem is now that changing the target property has no effect on the output path. Things i already double-checked:

- the value of the property is correctly set, verified using get\_target\_property()
- the name of the target is correct as setting the XXX\_OUTPUT\_NAME works and is reflected in the filename
- if the global variables are not set before, the property works and the output path is correct

what am i missing here?  
thx!

---

<div class="post-metadata">

### Author: ![petermbauer](https://discourse.cmake.org/user_avatar/discourse.cmake.org/petermbauer/32/1839_2.png) [@petermbauer](https://discourse.cmake.org/u/petermbauer)
#### Post date: [October 6, 2021, 7:25am UTC](https://discourse.cmake.org/t/cmake-xxx-output-directory-vs-target-properties-xxx-output-directory/4187/2 "2021-10-06T07:25:51Z")

</div>

to answer my own question: the problem was that also the CMAKE\_LIBRARY\_OUTPUT\_DIRECTORY\_\<BUILD\_TYPE\> was set so the target property LIBRARY\_OUTPUT\_DIRECTORY\_\<BUILD\_TYPE\> had to be set to change to output dir of the target.

---

<div class="post-metadata">

### Author: ![wowengineer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/w/48db29/32.png) [@wowengineer](https://discourse.cmake.org/u/wowengineer)
#### Post date: [January 13, 2022, 6:45am UTC](https://discourse.cmake.org/t/cmake-xxx-output-directory-vs-target-properties-xxx-output-directory/4187/3 "2022-01-13T06:45:42Z")

</div>

> [@petermbauer](#):
>
> get\_target\_property

hi  
I am doing same thing as you. could you tell me how to set the param? I am new, thanks.  
is it: set\_target\_properties(${ENCODER\_X86\_ASM\_LIB\_NAME} PROPERTIES CMAKE\_LIBRARY\_OUTPUT\_DIRECTORY\_\<\> ${PATH}) ?

---

<div class="post-metadata">

### Author: ![petermbauer](https://discourse.cmake.org/user_avatar/discourse.cmake.org/petermbauer/32/1839_2.png) [@petermbauer](https://discourse.cmake.org/u/petermbauer)
#### Post date: [January 13, 2022, 7:39am UTC](https://discourse.cmake.org/t/cmake-xxx-output-directory-vs-target-properties-xxx-output-directory/4187/4 "2022-01-13T07:39:10Z")

</div>

its

```auto
set_target_properties(<target> PROPERTIES LIBRARY_OUTPUT_DIRECTORY <path>)

```

or if you want to set it for all configuration types:

```auto
    if(DEFINED CMAKE_CONFIGURATION_TYPES)
      foreach(config ${CMAKE_CONFIGURATION_TYPES})
        string(TOUPPER ${config} config)
        set_target_properties(<target> PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config} <path>)
      endforeach()
    endif()

```

---

<div class="post-metadata">

### Author: ![wowengineer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/w/48db29/32.png) [@wowengineer](https://discourse.cmake.org/u/wowengineer)
#### Post date: [January 13, 2022, 7:43am UTC](https://discourse.cmake.org/t/cmake-xxx-output-directory-vs-target-properties-xxx-output-directory/4187/5 "2022-01-13T07:43:47Z")

</div>

hi, sorry, I am wrong, I met another issue that: duplicated obj file generated, not lib.  
my question is inside : [Two same output obj generated by VS IDE and CMake command line cause LNK4006 - Code - CMake Discourse](https://discourse.cmake.org/t/two-same-output-obj-generated-by-vs-ide-and-cmake-command-line-cause-lnk4006/4833)

could you take a look? Many thanks!
