How to change the name of the output binary to not

2019-03-05 05:01发布

Where would I go within CMakeLists.txt in order to change the name of the generated file?

标签: cmake
2条回答
beautiful°
2楼-- · 2019-03-05 05:38

Here's a simple CMakeLists.txt

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(demo)

add_executable(hello hello.cpp)

This CMakeLists.txt compiles a hello.cpp file to an executable named hello. You can name the executable anything by using the add_executable statement.

add_executable(<executable-name> <source1> <source2> ...)
查看更多
beautiful°
3楼-- · 2019-03-05 05:44

For an executable target see target properties OUTPUT_NAME and SUFFIX. The actual output name if a combination of OUTPUT_NAME.SUFFIX with

So the following example would override both defaults:

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

Would generate myname.myext for target a.

For more details e.g. take a look at adding program suffix.

查看更多
登录 后发表回答