How to Setup CLion

Setting up clion for modifying the libnd4j code base


In order to setup clion, we need to configure the cmake defaults to ensure that tests can be built. Normally this is setup by the libnd4j build script. A general tutorial on how to configure cmake profiles for clion can be found here. When configuring cmake to run, there are generally a few steps to follow.

This will in general include setting up the cmake gtest integration (we use google test for our test suite)

  1. Setup a toolchain. This will depend on your OS. More can be found here. This will cover the compiler, debugger and other needed additional software to enable clion to manage your cmake project.

  2. After configuration, let cmake build/index the files. It takes time to setup the files, auto complete and other expected functionality provided by the IDE. Ensure this is done by keeping an eye on the bottom right of the IDE to ensure all tasks are complete.

  3. After your clion environment is setup, you may put the following cmake configuration for CPU: -DSD_CPU=true -DSD_BUILD_TESTS=true -DSD_X86_BUILD=true -DSD_ALL_OPS=true -DSD_ARCH=x86-64 -DSD_X86_BUILD=true -DSD_SHARED_LIB=true

  4. The above will configure your IDE to build a shared library for intel cpus as well as configure the gtest setup to run. Please ensure that you read about how to configure cmake profiles (as linked above)

  5. Now you should be able to make modifications backed by the IDE. Note that you can also run tests under testscpu/layerstests

  6. In order to run all tests, you may run the AllTests.cpp entry point. In order to run the tests (or even a specific test) just right click on any test and click the green arrow option that appears in the dropdown similar to "Run AllTests.." or something like that. For more information on this, please see here.

  7. When running tests, note that it may take a while. It will build a whole executable compiling the relevant parts of the code base (or if necessary, the whole code base) in order to run the tests.

Last updated