cmake设定可执行文件的输出目录


ADD_EXECUTABLE(1-1 1-1.c)
ADD_EXECUTABLE(1-2 1-2.c)
ADD_EXECUTABLE(1-3 1-3.c)
ADD_EXECUTABLE(1-4 1-4.c)
ADD_EXECUTABLE(1-5 1-5.c)
ADD_EXECUTABLE(1-6 1-6.c)
ADD_EXECUTABLE(1-7 1-7.c)
ADD_EXECUTABLE(1-8 1-8.c)


#设置属性CMAKE_RUNTIME_OUTPUT_DIRECTORY,控制编译出的可执行文件的输出路径,这里将1.5和1.6这两个elf的输出目录设为了./exercise/
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ./exercise/)
ADD_EXECUTABLE(1.5 ./exercise/1.5.c)
ADD_EXECUTABLE(1.6 ./exercise/1.6.c)



By default the executable file will be created in the build tree directory corresponding to the source tree directory in which the command was invoked. See documentation of the RUNTIME_OUTPUT_DIRECTORY target property to change this location. See documentation of the OUTPUT_NAME target property to change the <name> part of the final file name.


https://cmake.org/cmake/help/v3.0/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html?highlight=runtime_output_directory

RUNTIME_OUTPUT_DIRECTORY

Output directory in which to build RUNTIME target files.

This property specifies the directory into which runtime target files should be built. Multi-configuration generators (VS, Xcode) append a per-configuration subdirectory to the specified directory.

There are three kinds of target files that may be built: archive, library, and runtime. Executables are always treated as runtime targets. Static libraries are always treated as archive targets. Module libraries are always treated as library targets. For non-DLL platforms shared libraries are treated as library targets. For DLL platforms the DLL part of a shared library is treated as a runtime target and the corresponding import library is treated as an archive target. All Windows-based systems including Cygwin are DLL platforms.

This property is initialized by the value of the variable CMAKE_RUNTIME_OUTPUT_DIRECTORY if it is set when a target is created.



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值