Clion Changelog

 

CLion uses CMake as the build system of projects, so you can use the CMake generator to manage your requirements in your CLion project.

  1. Clion Change C++ Version
  2. Clion Change Toolchain
  3. Clion Change Project Root
Clion
  1. 5.51.0: New: Properties can now be overridden for the bundled Google/Sun configurations (#497). 5.51.0: Fixed: Added a couple of missing DTDs to the resolver.
  2. CLion requires a CMakeLists.txt file as a project file, which is problematic for Godot because it uses the SCons buildsystem instead of CMake. However, there is a CMakeLists.txt configuration for Android Studio which can also be used by CLion. From the CLion's welcome window choose the option to import an existing project.
  3. Go to Run - Edit Configuration in the CLion menu and paste the output obtained above into the Program arguments for myproject. LDLIBRARYPATH must be in the form like a following. Again, the exact path may differ depending on the project location.

Just include the conanbuildinfo.cmake this way:

If the conanbuildinfo.cmake file is not found, it will print a warning message in the Messages console of your CLion IDE.

CLion will reload your CMake project and you will be able to see a Warning in the console, because the conanbuildinfo.cmake file still doesn’t exists: 4. Create a conanfile.txt with all your requirements and use the cmake generator.

Using packages in a CLion project¶

Let see an example of how to consume Conan packages in a CLion project. We are going to require and usethe zlib conan package.

Changelog
  1. Create a new CLion project
  1. Edit the CMakeLists.txt file and add the following lines:

3. CLion will reload your CMake project and you will be able to see a Warning in the console, because theconanbuildinfo.cmake file still doesn’t exist:

4. Create a conanfile.txt with all your requirements and use the cmake generator. In this case we onlyrequire the zlib library from a Conan package:

5. Now you can run conan install for debug in the cmake-build-debug folder to install your requirements andgenerate the conanbuildinfo.cmake file there:

Clion Change C++ Version

6. Repeat the last step if you have the release build types configured in your CLion IDE, but change the build_typesetting accordingly:

  1. Now reconfigure your CLion project. The Warning message is not shown anymore:

8. Open the library.cpp file and include zlib.h. If you follow the link, you can see that CLion automaticallydetects the zlib.h header file from the local Conan cache.

  1. Build your project normally using your CLion IDE:
Changelog

You can check a complete example of a CLion project reusing conan packages in this github repository: lasote/clion-conan-consumer.

Creating Conan packages in a CLion project¶

Now we are going to see how to create a Conan package from the previous library.

  1. Create a new CLion project
  1. Edit the CMakeLists.txt file and add the following lines:
  1. Create a conanfile.py file. It’s recommended to use the conan new command.

Edit the conanfile.py:

  • We are removing the source method because we have the sources in the same project; so we can use theexports_sources.
  • In the package_info method, adjust the library name. In this case our CMakeLists.txt creates a target library calledmylibrary.
  • Adjust the CMake helper in the build() method. The cmake.configure() doesn’t need to specify the source_folder, becausewe have the library.* files in the root directory.
  • Adjust the copy function calls in the package method to ensure that all your headers and libraries are copied to the Conan package.
  1. To build your library with CLion, follow the guide of Using packages from step 5.

5. To package your library, use the conan export-pkg command passing the used build-folder. Itwill call your package() method to extract the artifacts and push the Conan package to the localcache:

  1. Now you can upload it to a Conan server if needed:

8. If you would like to see how the package looks like before exporting it to the local cache (conan export-pkg)you can use the conan package command to create the package in a local directory:

Clion Change Toolchain

If we list the mypackage folder we can see:

  • A lib folder containing our library
  • A include folder containing our header files
  • A conaninfo.txt and conanmanifest.txt conan files, always present in all packages.

Clion Change Project Root

You can check a full example of a CLion project for creating a Conan package in this github repository: lasote/clion-conan-package.