So, I am starting out with CLion. And I have a project where I managed to store the .cpp
and .h
files in a folder under the working directory called src
. However, I am unable to get the linker's generated output (the executable file) in a separate folder, let's say bin
under the working directory.
For reference, the file structure of the project that I am seeking is:
- Working Directory
- make-build-debug
- CMakeLists.txt
- src
- example.cpp
- example.h
- bin
- example (example.out)
Platform Specification:
- OS: macOS 13.4.1
- CLion Version: 2023.1.4
CMakeLists.txt:
cmake_minimum_required(VERSION 3.25)
project(Password_Manager_CPP)
set(CMAKE_C_STANDARD 11)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
include_directories(.)
add_executable(Password_Manager_CPP
src/PasswordManager.cpp src/PasswordDriver.cpp src/PasswordManager.h)
For example, if you have a file example.cpp
, and you compile it using the command: g++ example.cpp -o example
. I want the UNIX Exec file, example
, to be stored in the bin folder.
I tried out some potential solutions on the internet. I looked into YouTube, Google, forums, and even StackOverflow. However, I could not find a solution that sufficed my needs.