CMake指定目标的链接选项,有三种方案 方案一 通过target_link_options来设置,(version 3.13.以上) add_executable(mymathApp mymathApp.cc)target_link_op
CMake指定目标的链接选项,有三种方案
方案一
通过target_link_options来设置,(version 3.13.以上)
add_executable(mymathApp mymathApp.cc)target_link_options(mymathApp PRIVATE -wl,-shared,-z,noexecstack)
方案二
通过目标的属性来设置
set_target_properties( PROPERTIES LINK_OPTIONS "-wl,-z,-relro" )
或者
set_target_properties( PROPERTIES LINK_FLAGS "-wl,-z,-relro" )
方案三
set(LINK_FLAGS)
## The options for the shared libraryset(LINK_FLAGS "-rdynamic -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") ## the actual options for GCcset(CMAKE_C_FLAGS "-fsigned-char ${COMPILE_FLAGS}")set(CMAKE_C_FLAGS_DEBUG "-g")set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") ## The linker optionsset(CMAKE_SHARED_LINKER_FLAGS "${LINK_FLAGS}")set(CMAKE_EXE_LINKER_FLAGS "${LINK_FLAGS}")
参考:
CMake 指定目标的链接选项_icbm的博客-CSDN博客_cmake添加链接选项
Gcc链接选项_jiang010的博客-CSDN博客_gcc 链接选项
来源地址:https://blog.csdn.net/sinat_31608641/article/details/128635869
--结束END--
本文标题: CMake 指定链接选项
本文链接: https://lsjlt.com/news/394858.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-04-01
2024-04-03
2024-04-03
2024-01-21
2024-01-21
2024-01-21
2024-01-21
2023-12-23
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0