Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can cmake and netbeans play nice?

I'm working on a big project, some might say awesome.

The project is being developed in c++ with cmake and netbeans. Everything is working fine except from the fact that every time I do updates to the project, add or remove source files, netbeans runs cmake and adds a new project to 'projects' list. This is somewhat annoying since i tend to do this alot.

Is there a smart way to make sure netbeans does not create new projects every time a sub directory is added?

like image 362
Martin Kristiansen Avatar asked Jul 07 '11 09:07

Martin Kristiansen


People also ask

What is CMake good for?

CMake handles the difficult aspects of building software such as cross-platform builds, system introspection, and user customized builds, in a simple manner that allows users to easily tailor builds for complex hardware and software systems.

Is CMake faster than make?

CMake does a two-step build: it generates a low-level build script in ninja or make or many other generators, and then you run it. All the shell script pieces that are normally piled into Makefile are only executed at the generation stage. Thus, CMake build can be orders of magnitude faster.

Do I need Visual Studio for CMake?

CMake project files (such as CMakeLists. txt ) are consumed directly by Visual Studio for the purposes of IntelliSense and browsing. cmake.exe is invoked directly by Visual Studio for CMake configuration and build.

Is CMake only for C++?

Starting with just C/C++ project support, modern CMake now supports languages like Fortran, C# and CUDA. Over the years a lot of open source projects migrated from Makefile based build system to CMake.


2 Answers

Good news!

As of NetBeans 6.8, CMake is handled gracefully, just like any other configure script:

  1. Make a new "C/C++ Application from existing sources".
  2. Specify the directory of the project (where CMakeLists.txt resides).
  3. In the "Select configuration mode", select "Automatic".

And NetBeans will run cmake to build the Makefile when it's necessary
(or when you click "Reconfigure project").

See the original thread on the NetBeans forums for more info.

like image 124
Alba Mendez Avatar answered Sep 18 '22 12:09

Alba Mendez


CMake-bases projects work perfect with NetBeans.

Variation to jmendeth answer:

  1. Create a new C/C++ Project with Existing Sources
  2. Set the projects path (= directory of main CMakeLists.txt)
  3. At Select Configuration mode set Custom
  4. Click Next
  5. Select Run Configure Script in Subfolder (the default folder is build)
  6. If you don't have further settings, click Next until you can click finish
  7. Click Finish, Cmake will run and build your project

This way is a bit longer then the automatic one, however in practice it's just setting of two ticks.

The advantage and hence the reason for the additional expenses: CMake will now put all it's local cache files in a subfolder (build) and keep them separate at one place - not mixing them with your other project stuff.

This keeps a clean project structure, since those files are just for your project and created by each configure run.

And as an extra: If you have to delete the CMake cache manually - this happens sometimes - there's one single directory where everything is in.

Side note:

Since NetBeans 8.0 there's syntax coloring for all CMake files.

like image 45
ollo Avatar answered Sep 21 '22 12:09

ollo