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添加可执行文件, b 错误,需要可执行文件。
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屋!
查看全文