# Correctly locating target output file in multi config builds.

**URL:** https://discourse.cmake.org/t/correctly-locating-target-output-file-in-multi-config-builds/10913
**Category:** Code
**Created:** [May 28, 2024, 1:09am UTC](https://discourse.cmake.org/t/correctly-locating-target-output-file-in-multi-config-builds/10913 "2024-05-28T01:09:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![marksibly](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marksibly/32/4303_2.png) [@marksibly](https://discourse.cmake.org/u/marksibly)
#### Post date: [May 28, 2024, 1:09am UTC](https://discourse.cmake.org/t/correctly-locating-target-output-file-in-multi-config-builds/10913/1 "2024-05-28T01:09:22Z")

</div>

Hi,

I have a cmake project that generates an output file that I want to install.

For ‘single config’ builds (eg: makefile/ninja builds) the target output file is simply located in the ${CMAKE\_CURRENT\_BINARY\_DIR}, but for ‘multi config’ builds (eg: msvc) the target is located in a Debug or Release subdirectory.

I also need to the rename the target in a specific way as it’s a python module so I am confused about how to go about locating the correct output file to install.

Here’s the bit of my CMakeLists.txt that declares the python module target, using the SWIG output:

```auto
add_library(libsgd_python SHARED sgd_wrap.c)

target_include_directories(libsgd_python PRIVATE ${Python_INCLUDE_DIRS})

target_link_libraries(libsgd_python PRIVATE libsgd ${Python_LIBRARIES})

set_target_properties(libsgd_python PROPERTIES OUTPUT_NAME _sgd)

set_target_properties(libsgd_python PROPERTIES PREFIX "")

if(SGD_OS_WINDOWS)
	set_target_properties(libsgd_python PROPERTIES SUFFIX .pyd)
	set(OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/_sgd.pyd)
else()
	set(OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/_sgd.so)
endif()

install(FILES ${OUTPUT_FILE} ${CMAKE_CURRENT_BINARY_DIR}/sgd.py ${CMAKE_CURRENT_SOURCE_DIR}/helloworld.py DESTINATION python)

```

How do I compute the correct the right ${OUTPUT\_FILE} in a way that works with both single and multi config builds?

Bye,  
Mark

---

<div class="post-metadata">

### Author: ![marksibly](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marksibly/32/4303_2.png) [@marksibly](https://discourse.cmake.org/u/marksibly)
#### Post date: [May 28, 2024, 1:48am UTC](https://discourse.cmake.org/t/correctly-locating-target-output-file-in-multi-config-builds/10913/2 "2024-05-28T01:48:21Z")

</div>

OK, I got it working by changing the install to a normal TARGETS install and using RUNTIME so I only install the dll, eg:

```auto
install(TARGETS libsgd_python RUNTIME DESTINATION python)

```
