customize workspace.xml cmake settings programmatically from the command line

Answered

In my typical workflow, I am frequently jumping between multiple cross-platform CMake repositories and launch CMake from the command line with a number of standard options geared towards a consistent toolchain oriented layout.

A typical build might look something like this:

launch.sh:

```

CONFIG=Release
TOOLCHAIN=gcc-pic-hid-sections

PROJECT=${PWD}

cmake_args=(
-H${PROJECT}
-B${PROJECT}/_builds/${TOOLCHAIN}-${CONFIG}
-CMAKE_BUILD_TYPE=${CONFIG}
-DCMAKE_TOOLCHAIN_FILE=${POLLY_ROOT}/${TOOLCHAIN}.cmake
-DCMAKE_INSTALL_PREFIX=${PROJECT}/_install/${TOOLCHAIN}
)

cmake ${cmake_args[@]}

```

I'm interested in launching CLion from the command line using this boilerplate configuration and am curious if there is a programmatic way to generate the projects accordingly.

 

I'd like to make a CLion project launcher script as shown below:

 

clion_setup.py:

```

clion_setup.py --toolchain <toolchain> --config Release --home . 

```

 

Is there an API or specification that would allow me to implement the clion_setup.py script (or any scripting language) to create a CLIon project that is compatible with the launch.sh script I outlined above?

I understand these changes can be configured through appropriate fields in the CLion IDE settings, but I change repositories and toolchains frequently enough in a typical workflow that it is cumbersome enough for me to achieve this through the GUI that I often stick with command line development for quick changes.  I would like to put together a process that would give me the benefits of the CLion IDE based development in this context.

 

Any hints or tips for achieving this would be appreciated.

 

 

1
2 comments
Avatar
Permanently deleted user

I have a somewhat similar usecase and it would be great to hear about the possibilites. I'd expect a workflow somewhat similar to working with a Visual Studio CMake generator: Generate with CMake through scripts, and then open these projects with CLion. It would be very, very helpful.

0

Hello!

Looks related to this feature request: https://youtrack.jetbrains.com/issue/CPP-8414. Feel free to comment/upvote it or to create a new one.

For now as a workaround you can edit workspace.xml using a script.

0

Please sign in to leave a comment.