[CLion] How to create separate CMAKE/GTest Application run configurations for Debug and Release targets.

已回答

I have a project which has two CMake targets, one for Debug and another to build in Release.

Since CLion creates two separate folders namely, cmake_build_debug and cmake_build_release in that case, I was wondering how to add the path to this folder in my CMake/GTest application run configuration so that LD_LIBRARY_PATH(for instance) is properly set.

 

I tried adding a template like the following but did not really work. Seems like CONFIG_NAME does not really make a difference.

```

<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test_my_package" type="CMakeGoogleTestRunConfigurationType" factoryName="Google Test" REDIRECT_INPUT="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="test_ws" TARGET_NAME="test_my_package" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="test_ws" RUN_TARGET_NAME="test_my_package" TEST_MODE="SUITE_TEST">
<envs>
<env name="LD_LIBRARY_PATH" value="$PROJECT_DIR$/.clion/cmake_build_debug/devel/lib:/opt/ros/melodic/lib" />
</envs>
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
<option name="BeforeTestRunTask" enabled="true" />
</method>
</configuration>
<configuration default="false" name="test_my_package" type="CMakeGoogleTestRunConfigurationType" factoryName="Google Test" REDIRECT_INPUT="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="test_ws" TARGET_NAME="test_my_package" CONFIG_NAME="Release" RUN_TARGET_PROJECT_NAME="test_ws" RUN_TARGET_NAME="test_my_package" TEST_MODE="SUITE_TEST">
<envs>
<env name="LD_LIBRARY_PATH" value="$PROJECT_DIR$/.clion/cmake_build_release/devel/lib:/opt/ros/melodic/lib" />
</envs>
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
<option name="BeforeTestRunTask" enabled="true" />
</method>
</configuration>

</component>

```

 

Is this possible in CLion 2020.2? Thank you!

0

Hello!

For now it's possible to use macros only in the "Program Arguments" and "Working Directory" fields of the following configuration types:

  • CMake Application
  • Custom Build Application
  • Gradle Native Application

Details - https://blog.jetbrains.com/clion/2020/03/clion-2020-1-eap-input-redirection-config-macros/#macros_variables_in_configurations

Feel free to comment or upvote https://youtrack.jetbrains.com/issue/CPP-19798 and https://youtrack.jetbrains.com/issue/CPP-21743. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.

0

请先登录再写评论。