How do I get CLion to run an install target

前端 未结 2 600
感动是毒
感动是毒 2020-12-10 11:30

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

相关标签:
2条回答
  • 2020-12-10 11:53

    UPDATE: As of 2018.1 EAP, build 181.3741.16, CLion supports running cmake install if your project defines install targets:


    Original Answer:

    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 the make 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.

    Update:

    A more cross-platform technique might be the following:

    add_custom_target(install_${PROJECT_NAME}
                      "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target install
                      DEPENDS ${PROJECT_NAME}
                      COMMENT "Installing ${PROJECT_NAME}")
    
    0 讨论(0)
  • 2020-12-10 12:11

    @maddouri 's comment already addresses your question. Alternatively, Under Settings -> Build, Execution, Deployment -> CMake, you can also set Build Option for Debug or Release build type to something like -j 2 install. With this setting, whenever CLion builds the code, it will install your targets, too!

    0 讨论(0)
提交回复
热议问题