CMake version in CLion not updating - cmake

I cloned a project from my teacher, and I wanted to run it on CLion. However, I noticed an error:
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.14 or higher is required. You are running version 3.13.2
I configured a new CMake debugger in CLion, but I still keep getting the error.
I have a new version of CMake installed:
When I install a new CMake version in cygwin, CLion returns this:
Does anyone know what I am missing or doing wrong?

It sounds like you want CLion to use your newest version of CMake (instead of the bundled 3.13.2 version). To do that, you must add a new Toolchain (see here) or modify an existing one (see here):
On Windows CLion, navigate to File > Settings > Build, Execution, Deployment > Toolchains, and choose the toolchain you want to modify.
At the CMake: section, select a custom CMake installation by choosing the path to your custom CMake executable (likely a bin folder).
Click OK to save your changes.

Eventually, I solved the problem by installing a new version of CMake inside the cygwin installer. I also updated CLion, because I had the 2018 version and that version only supports CMake versions up to and including 3.13. After updating CLion to the 2019 version, it supported CMake versions up to and including 3.15. Because the CMake version 3.16 is pretty recently released. CLion automatically takes the maximum supported version, which in this case is the 3.15. The minimum version in de CMakeLists.txt was 3.14, so 3.15 worked fine.

Related

Use Doxygen 1.9 (built from source) in CMake

I am not that much sound in CMake and which leads to me in this issue. I am trying to use Doxygen in a project using CMake. Previously, I have used Doxygen version 1.8.11 which was installed from Ubuntu package manager. I have simply followed the following command to install Doxygen
sudo apt-get install doxygen
And in the project in CMakeLists.txt file I have included
find_package(Doxygen REQUIRED)
Everything works flawlessly.
But now for a specific reason I have to upgrade my Doxygen version which is not available in Ubuntu package manager, that's why I have built the binary by following this. The downloaded Doxygen Source directory and my project directory are not the same.
My query is how can I tell CMake to search for this newly installed/build Doxygen?
Still, I am finding the version of Doxygen is 1.8.11
I am using Ubuntu 16.04, cmake version 3.19.0-rc3

How to build CLion based CMake Project with custom Toolchain from Command Line

I've only worked with CMake in conjunction with the CLion IDE but I'm aware that CMake projects can be built on the command line completely without the IDE with the CMake build system only.
Now I have some more complex CLion projects for which I created a custom toolchain and various profiles through the CLion menus (File -> Settings -> Build, Execution, Deployment --> Toolchain / CMake). I want to switch to building these projects through Gitlab CI without CLion. But how do I start a CMake build on the command line in on a build VM without CLion installed that uses the toolchain and profiles that I created in the CLion GUI?
The desired settings to reproduce are:
Using a custom gcc cross compiler for all profiles
Dependent on the profile:
passing various CMake variables (like -DMY_VAR=FOO) to my CMakeLists
choosing a debug or release build as build type
In CLion I have one custom toolchain with the special gcc and four profiles with different settings, all using this toolchain.
Does CLion generate a toolchain file somewhere in the background that I could just use (didn't find any so far) or do I need to write my own toolchain file and pass it to cmake?

Build configuration error using Android NDK

There is a build configuration error (Gradle sync failed) starting a new simple Android project using IntelliJ IDEA and the installed Android SDK (API 28) to include C++ support.
If I can remember, it worked when first installed, but now any attempt to compile and build the project using the IntelliJ GUI fail. LLDB, CMake and NDK are all installed correctly in the correct folders and the local.properties file references the location of the SDK and NDK.
All attempts to refresh linked C++ projects or clear caches (invalidate caches/restart) make no difference.
CMake_server_log.txt suggests:
CMAKE SERVER: CMake Error: CMake was unable to find a build program
corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You
probably need to select a different build tool.
Build output (edited to remove path):
Cause: executing external native build for cmake CMakeLists.txt
There appears to be a lack of configuration to complete the build or missing PATH or ENVIRONMENT variable. Should I manually try to change this or add some extra code to the build.gradle or CMakeLists.txt? There is the ninja application in the cmake bin directory.
Even importing other NDK sample projects fail (after downloading any required dependencies e.g. Gradle version).
Reinstalling LLDB, CMake and the NDK via SDK Tools do not solve the issue either.
I get the impression that I need to completely uninstall IntelliJ IDEA on Windows and remove any remaining folders/files associated with it, before reinstalling it. That would be a shame as IntelliJ IDEA works for other type of Android projects not requiring native C++ support.

What is the best multiplattform IDE to use with CMAKE?

I'm trying to set up a multiplattform project using CMake, so its easy to setup on any PC.
Basicly the CMAKE script sets up all settings for the projects and finds all libraries automatically.
But after trying a few IDE's like codeblocks and eclipse it seams like CMake integration in these is pretty lackluster.
Does anybody have a few recommendations for better IDE's?
They should have an included debugger and code completion and should be easy to setup on windows and linux.
Have a look at clion, that fully integrates CMake, but I dislike the editor, not really user friendly.
Starting with version 2.6.0 CMake includes a generator for Eclipse CDT 4.0 or newer. It works together with the Makefile generators (i.e. "Unix Makefiles", "MinGW Makefiles", "MSYS Makefiles", and maybe "NMake Makefiles"). This generator creates a set of .project/.cproject files that can be imported in Eclipse using File > Import > Existing Eclipse project.
https://cmake.org/Wiki/Eclipse_CDT4_Generator

gradle doesn't work in Intellij - problems with JAVA_HOME

I can run gradle from a command line to see its version.
I can run, compile and debug a grails app in IntelliJ (version 10.0 or version 10.2)
I installed the IntelliJ Gradle Plugin.
Whenever I try to do anything with gradle from within Intellij I get an error as follows:
Executing command: "tasks"
Failed to connect to gradle process for command 'tasks'
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.0\jre
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
But in my environment I have JAVA_HOME set to the proper JDK in a different directory. Plus when I look in IntelliJ for the project, it also shows the JDK in the proper JDK location. I cannot find anything that attempts to point the JDK to the Intellij JRE location.
Any ideas please?
IntelliJ uses its own jre.
to force IntelliJ to use it, you need to set the environment variable IDEA_JDK to point to your JDK.
then simply restart intellij and gradle gui plugin should now work.
Man I had so much trouble with this as well, and I don't remember having this much trouble before. I think they changed something. Here are the incantations which got it working for me on Mac OS X 10.11.5, both with Java and Gradle on IntelliJ 2016.1
Here's the summary: install the latest Java JDK from Oracle, add the java_home value to $JAVA_HOME and set that value to $IDEA_HOME (IntelliJ's variable for defining which JDK to use), install gradle (optional) using homebrew, then define the project SDK in IntelliJ.
Here it is broken down from the very beginning of a clean install:
1. Download Java from Oracle's Download Page
2. Use homebrew to install gradle
IntelliJ ships with its own version of Gradle, so this is really optional, and is helpful if you want to use Gradle outside of IntelliJ.
`brew update && brew install gradle`
3. Set the env variables
Paste the following into ~/.profile. These values will work regardless of which version of java or gradle you have installed. Don't set the GRADLE_HOME if you didn't install the standalone gradle.
export JAVA_HOME=$(/usr/libexec/java_home)
export IDEA_JDK=$JAVA_HOME
export GRADLE_HOME=/usr/local/opt/gradle/libexec
4. Set the environment variable to occur at application launch so that IntelliJ sees is using OS X's launchctl program:
launchctl setenv JAVA_HOME $(/usr/libexec/java_home)
5. Define the project SDK
Use the project settings window in IntelliJ to define the project SDK (I don't see this option anywhere else in the global IntelliJ preferences window, this has to be done in the project settings).
6. Wait for the indexes to update, then close and re-open IntelliJ. You should now be able to build the program.
if you are using Intellij version 10.x you should not install any Plugin to run a gradle script.
All you have to do is to go to the Gradle setup (File -> Settings -> Gradle) and set the Gradle Home folder (the location of your Gradle installation, eg. C:\tools\gradle).
You should be able to select a Gradle build file and run it.
Point your JAVA_HOME to JDK, not to JRE.
I think this error might be caused by an install bug with IntelliJ IDEA. When I look at the installed folder referred to in the error message on my filesystem:
C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.0\jre
I see the jre folder but then another jre folder beneath that one which contains the bin and lib folders of the jre:
jre
jre
bin
lib
I copied bin and lib up a level into the first jre folder, and that fixed this error for me.