CLion 和 CMake:只构建一个没有可执行文件的库? [英] CLion and CMake: only building a library without an executable?
本文介绍了CLion 和 CMake:只构建一个没有可执行文件的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在没有可执行文件的情况下仅使用 clion 构建静态库?CMakeLists.txt 是什么样的?(没有add_executable
)
How to only build a static library with clion without having an executable?
How does the CMakeLists.txt look like? (without add_executable
)
更新:如果我不向 Clion 添加可执行文件,我有一个错误,需要可执行文件.
Update: If I don't add executable to Clion, I have an error, that an executable is required.
这里是我的 CMakeLists.txt.
推荐答案
这是一个老问题.但我会将您的问题的答案添加为对其他人的帮助.您需要将 add_executable
替换为 add_library
This is an old question. But I'll add the answer to your question as a help for other people. You need to replace your add_executable
with add_library
add_library(target_name source_files)
这篇关于CLion 和 CMake:只构建一个没有可执行文件的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文