How to change the name of the output binary to not be a.out with CMake?

Where can I go to CMakeLists.txt to change the name of the generated file?

-1
source share
2 answers

Here is a simple CMakeLists.txt

cmake_minimum_required(VERSION 2.6 FATAL_ERROR) project(demo) add_executable(hello hello.cpp) 

This CMakeLists.txt compiles the hello.cpp file into an executable file called hello. You can name the executable file any, using the add_executable operator.

 add_executable(<executable-name> <source1> <source2> ...) 
0
source

For the executable, see the target properties OUTPUT_NAME and SUFFIX . The actual exit name if the combination is OUTPUT_NAME . SUFFIX with

Thus, the following example will override both defaults:

 add_executable(a ...) set_target_properties( a PROPERTIES OUTPUT_NAME "myname" SUFFIX ".myext" ) 

Generated myname.myext for target a .

For more details, for example. see adding a program suffix .

0
source

Source: https://habr.com/ru/post/1273553/


All Articles