CLion build depend targets

2019-05-04 18:34发布

My CLions CMakeLists.txt contains more than 1 target (libraries and depends executables). How can I configure building all targets in one click, instead of choosing target one by one and building them? For example, in Visual Studio I can configure project dependencies and build all solution. CLions "Edit configurations..."->"Before launch:Build" won't work for me.

标签: cmake clion
3条回答
Evening l夕情丶
2楼-- · 2019-05-04 18:53

You can add the command add_dependencies to your CMakeLists.txt, it does what you want:

Make a top-level target depend on other top-level targets to ensure that they build before does.

Then you just need to create a "BUILD_ALL" target that depends on every other target.

查看更多
走好不送
3楼-- · 2019-05-04 18:58

Clion use cmake right? you can directly edit the cmake file. Check add_subdirectory command. http://www.cmake.org/cmake/help/v3.0/command/add_subdirectory.html

查看更多
Lonely孤独者°
4楼-- · 2019-05-04 19:07

Configuring target dependencies works, but it is much easier to add an "all" to CLion's build options.

查看更多
登录 后发表回答