I'm working on a big project, some might say awesome.
The 开发者_Python百科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?
Good news!
As of NetBeans 6.8, CMake is handled gracefully, just like any other configure
script:
- Make a new "C/C++ Application from existing sources".
- Specify the directory of the project (where
CMakeLists.txt
resides). - 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.
CMake-bases projects work perfect with NetBeans.
Variation to jmendeth answer:
- Create a new
C/C++ Project with Existing Sources
- Set the projects path (= directory of main
CMakeLists.txt
) - At
Select Configuration mode
setCustom
- Click
Next
- Select
Run Configure Script in Subfolder
(the default folder isbuild
) - If you don't have further settings, click
Next
until you can click finish - 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.
I was getting this error : "failed to start cmake: No such file or directory"
I had to NetBeans -> Preferences -> C/C++ (Build Tools) -> set the CMake Command to /opt/local/bin/cmake .
I am using Cmake, netbeans and SVN with a large c++ project, with no problem.
I usually configure the project with the option "c++ with existing sources" and select the makefile genereted by cmake so netbeans don't know which make tool I am using. Then select only the folders with the sources you need to work on.
Every time you update the sources you must update your Makefile (and the Netbeans Project will update the sources too) running cmake so you can do it manually or just in the build command of the project: "cmake .. && make" (thats tricky but it works fine). Hope to be useful.
精彩评论