问题描述
我正在对已经使用CMake的现有项目评估CLion 1.2.1。该项目由几个库模块和单个可执行文件组成。
我有一个安装目标,我用来收集可执行文件和一个配置文件用于调试的文件夹:
...
install(TARGETS $ {PROJECT_NAME} DESTINATION $ {CMAKE_BINARY_DIR} / bin / )
install(FILES config.xml DESTINATION $ {CMAKE_BINARY_DIR} / bin /)
建立在命令行上我只是运行:
make install
pre>
如预期那样构建二进制文件,如果成功则运行上述安装命令。
我的问题是我不能得到CLion运行'安装'目标。我希望能够创建一个新的运行/调试配置,但目标:下拉菜单只包含使用 add_executable()和 add_library()
我也试过在设置对话框的构建选项中添加安装。
解决方案我不认为CLion实现了此功能。但是,您可以通过添加CMake 自定义目标(使用)
add_custom_target(install _ $ {PROJECT_NAME}
$(MAKE)install
DEPENDS $ {PROJECT_NAME}
COMMENT正在安装$ {PROJECT_NAME})
现在,从CLion的targets菜单中创建
install_YOUR_PROJECT_NAME
目标。I'm evaluating CLion 1.2.1 on an existing project which is already using CMake. The project is made up of a few library modules and a single executable.
I have an install target which I use to collect the executable and a configuration file together in a bin folder for debugging:
... install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_BINARY_DIR}/bin/) install(FILES config.xml DESTINATION ${CMAKE_BINARY_DIR}/bin/)
When building on the command line I'd just run:
make install
which as expected builds the binaries and if successful then runs the above install commands.
My problem is that I can't get CLion to run the 'install' target. I expected to be able to create a new Run/Debug configuration but the Target: dropdown only contains those targets added using add_executable() and add_library().
I also tried adding 'install' to the Build options in the Settings dialog. That however runs install for every target now including 'clean' which is not right.
解决方案I don't think that CLion implements this feature yet. However, you can work around this limitation by adding a CMake "custom target" (using
add_custom_target()
) that will execute themake install
command:add_custom_target(install_${PROJECT_NAME} $(MAKE) install DEPENDS ${PROJECT_NAME} COMMENT "Installing ${PROJECT_NAME}")
Now, all you have to do is "build" the
install_YOUR_PROJECT_NAME
target from the "targets" menu in CLion.这篇关于如何让CLion运行安装目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!