cmake how to make the build final execute file to another directory

Allow me:

current directory: /home/jian/helloc/cmake_begin/step1

cd …/step1

then it will return the same directory.

Current CMakeLists.txt

cmake_minimum_required(VERSION 3.10)


add_executable(tutorial101 tutorial.c)

cmake ../step1
cmake --build .

then It will generate a executable file then I do 


will print out hello world.

I think you’re looking for CMAKE_RUNTIME_OUTPUT_DIRECTORY.