Redirect exe files into bin directory
已回答
Hi! I have a project that as 2 sub folders. One is Leetcode which just has a bunch of C++ files. They all compile and run but one annoying thing is that CMAKELIST.TXT creates exe files for each c++ source files when it builds and run.

It can get very long because I just have many C+++ source files.
Im trying to redirect these exe files into a bin folder under LeetCode by editing my CMakeList.txt but it's not working
This is what my project structure looks like:

CMakeList.txt
cmake_minimum_required(VERSION 3.27)
project(Coding_Challanges)
set(CMAKE_CXX_STANDARD 17)
function(add_leetcode_executable name)
add_executable(${name} LeetCode/${name}.cpp)
set_target_properties(${name} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/LeetCode
)
endfunction()
add_subdirectory(LeetCode/Hello)
add_leetcode_executable(assignCookies)
请先登录再写评论。
Hi Mariana!
When executable targets are built by means of CMake, they are by default generated in the
cmake-build-***
directory.However, those .exe files in your screenshots look as if you're running your source files as single files (as described in https://www.jetbrains.com/help/clion/run-single-file.html). I.e., as if you're building/running them via run/debug configurations of the type “C/C++ File” and not “CMake Application”.
If you want such files to be generated into a specific folder, you need to modify the "Working directory" field of the corresponding run/debug configuration of the type “C/C++ File” (for example, the
numberStudentUnableEat.cpp
configuration) inRun | Edit Configurations...
.Also, feel free to comment or upvote the related feature request - CPP-34788. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.