Τρίτη 15 Σεπτεμβρίου 2020

CMake in Apache NetBeans

 How to use CMake in Apache NetBeans

As of this writing, the C/C++ plugin for NetBeans has not yet been donated to Apache by Oracle. However, you can still download and install the plugin.

  1. Navigate to Tools -> Plugins, click on Settings tab and add the following update center if not already added: NetBeans 8.2 Plugin Portal, URL: http://updates.netbeans.org/netbeans/updates/8.2/uc/final/distribution/catalog.xml.gz.
  2.  Click on Available Plugins tab and select the C/C++ plugin and click on Install.

If you run Apache NetBeans with JDK 14, then the installation will fail: 

The Plugin Installer found problem timeout of loading C/C++ Repository[org.netbeans.modules.cnd.repository/1.32.6.1] while install the following plugins)

You may check which JDK version you are running Apache NetBeans by clicking on Help -> About (Windows, Linux) or NetBeans -> About (MacOSX). This depends on the default JDK on your system, or if you have set netbeans_jdkhome in etc/netbeans.conf file to JDK 14. In that case, a solution is provided by this link:

  1. Copy pack200(.exe) and unpack200(.exe) to jdk-14/bin from a previous JDK version.

 Assuming that cmake is already installed in your system, before you are able to use it in NetBeans, you need to first set it up:

  1. Click on Tools -> Options (Windows, Linux) or NetBeans -> Preferences (MacOSX) and then on C/C++ button and select the Build Tools tab.
  2. Fill in the CMake Command: with the path of cmake in your system (e.g. /usr/lib/cmake)
  3. Click OK

 Assuming that you have already created the CMakeLists.txt file inside the folder of your C/C++ project: 

  1. Select File -> New Project, then the C/C++ category and then the Project: C/C++ Project with Existing Sources
  2. Specify the folder that contains existing sources and leave the rest settings the default, i.e. checked Use Build Analyzer and Automatic configuration mode. The Next button is enabled, which means by clicking it, NetBeans runs the cmake command to generate the Makefile and builds the project automatically.