bison/flex parser into eclipse - eclipse-cdt

I'm having trouble figuring out how to "merge" two of my projects.
-- I've got a project consisting of a bison/flex parser with its sources and its own makefile.
-- I've got an eclipse project(with its own sources) with a automatic makefile generation on itself.
What I have done so far :
On Eclipse
--click on my project>new Folder>link to folder in FS
--exclude the "main.cc" that is the main for the parser project when it is alone
Now i have access to my parser project files
(cpf.y, token.lex, heading.h, makefile)
Now i would like to add the interesting parts of my own makefile to the auto-generated makefile of my eclipse project ?? (I can't find the right preference location to do that)
Regards

Well in fact the solution is pretty simple :
--right click on the project
--under the c++ Build tag
--uncheck generate automatic makefile
Now the makefile you had will stay and you will be able to modify it without having it overwritten.
The only problem is that you will have to add manually every new file from your eclipse project (ie can't have autogenerate part for the eclipse project and manual part for the parser)

Related

How to create a C++ project in Eclipse CDT using existing source files and an existing CMakeLists.txt?

The title says it all: I have source files and a CMakeLists.txt for an existing C++ project. Now I want to create a project in Eclipse CDT using those files.
I want to be able to build the project with the "build" button from within Eclipse once I'm done, and I want to be able to use GDB.
I've used the CMake option to create Eclipse projects before, but it didn't always work flawlessly and I was told the CMake generator for Eclipse is supposedly outdated.
I know I could just create an empty project and then copy the source files into it, but what about the CMakeLists.txt? I want Eclipse to know how to build the project.
I'm new to Eclipse and there are like fifty ways to start a new project with or without existing source files, so some guidance would be greatly appreciated.

Eclipse CDT build always rebuild all files

I am working with Eclipse Luna with CDT plug-in.
Whenever I build the project it keeps rebuilding all files, even if I just modify specific .cpp file.
I use project -> build project for the build.
I also removed build automatically option (and re-opened eclipse), but it did not solve the problem.
I've searched a lot for similar questions, but found none.
Are you using a manually-managed Makefile project, i.e. one that is not automatically-managed by the CDT plugin? If so, perhaps you could post your Makefile contents here, because there may be issues with the target dependencies in it.
The File | New | C++ Project | Executable option creates a project in which CDT automatically creates and updates the Makefiles itself - in this setup, the dependencies (while not perfect, because there are a few bugs in CDT in this respect) should be managed well enough so that it won't rebuild the entire project just because one file changed.
On the other hand, if you imported an existing project via the menu File | New | Makefile Project with Existing Code (which I didn't previously mention), then you would have had to copy the Makefile from the existing project manually, as CDT doesn't copy it for you, or you would have had to manually create a Makefile.
As I mentioned previously, if you posted your Makefile (feel free to 'sanitise' it by removing any personal information), we might be able to determine why it's rebuilding all files when you've only updated one of them.
I would have posted this as a comment reply to your last comment, #davidgrandson, but apparently there's a fairly short limit on the length of these.

Can a project created with qmake be compiled without using qmake?

I have some source code that was built with qmake. Compiling it is supposed to be done with qmake qmakefile.pro.
I'd like to compile it without using qmake. Is that even possible? What would the steps be?
Edit: Here's the .pro file.
Yes, you can compile files without qmake.
You need to get any specific compiler settings from qmake and convert them to the other compiler as necessary.
Or you can convert the contents of the qmake.pro file into a makefile or your IDE's project settings.
If the qmake.pro is not a human readable text file, you will have to launch qmake and retrieve the settings. Otherwise search for a conversion tool.
While it is technically possible to translate the .pro file into something else, I would not advise it.
Why?
QMake does a lot of work behind the scenes.
In the case of the .pro file you referenced (http://pastebin.com/viv204Fv), QMake is invoking meta-tools (uic, moc) to create the code for the UI and adding build rules to compile it. You will need to manually code those in your build script.
-. QMake also solves issues of choosing the right compiler and linker options (including the right include files). You will need to determine them yourself and add them to your build script.
The project is already using Qt, so why not use Qt's build script generating tool, QMake? If you have installed a Qt development environment, you should already have qmake installed.

Using Cmake with Qt Creator

I would like to use Qt creator and Cmake together (please, don't ask me about my motivation, accept this as a given.)
I successfully set up Qt creator to use cmake "Cmake": see this, this and this documents regarding how I did that.
I successfully create hello world project, but I can't create files in project,
only add existing files to project tree and after that adding it to cmake list.
Standard operation of Qt creator "Add New..." doesn't work and I can't find why.
Is there anybody who uses Qt creator and "Cmake" together? Is the combination actually possible?
Note: I'm using Qt creator v2.4.1.
You can add files using glob expression in your CMakeLists.txt, like this:
file(GLOB SRC . *.cpp)
add_executable (your_exe_name ${SRC})
Cmake will pick your new cpp files next time you run it and QtCreator will show them in the project browser.
Update
This solution may be useful but as noted in comments - this is not a good practice. Every time somebody add new source file and commit changes, you need to rerun cmake to build all the sources. Usually I just touch one of the CMakeLists.txt files if my build is broken after I pool recent changes from repository. After that make will run cmake automatically and I didn't need to run it by hands. Despite of that I think that explicit source lists in CMakeLists.txt is a good thing, they called thing CMake Lists for a reason.
When you add new files in QtCreator using the "New File or Project..." dialog it only creates the files on disk, it doesn't automatically add the files to the CMakeLists.txt. You need to do this by hand by editing the CMakeLists.txt file.
The next time you build the project, CMake will be re-run, and QtCreator will pick up the new files and show them in the project browser.
I solve this problem that I added new files in standard way (CTRL+N), then added needed files in CMakeLists. After that, right click on project in project tree view and choose option Run CMake. After this, files showed in project list tree. Only build was not enough.
I tested here and happened the same behavior because those options you were asking were really disabled.
Use File -> "New File or Project..." or CTRL+N to add new files and after that add to CMakeLists.txt
I'm adding an updated answer for newer versions of QtCreator (4.x, I don't know precisely which release but at least from 4.7). In the Tools > Options... menu, choose the Build & Run section and then the CMake tab. You will see the Adding Files settings, and you can set it to Copy file paths :
This way, when you want to add a new file to your project, in the Project view, right click on the desired CMake Executable/Library's name and select Add New..., go through the Add dialog, and when you'll validate the dialog, QtCreator will open CMakeLists.txt in the Editor view. Finally, paste the content of the clipboard at the end of the corresponding source file list and save CMakeLists.txt. The CMake project will be parsed, and your new file will show up in the Project view.

Custom resource build steps in Eclipse managed project

I know this can be done using a makefile, alas I am not using a makefile, but rather Eclipse's "managed" C++ project. :( In any case, this is what I'm trying to accomplish:
I have a C++ project in Eclipse. I have a number of XML files in this project that specify information about source files that are auto-generated. When the XML files change, I would like a custom tool executed to convert them. The challenges are:
These resources need to be built prior to compiling the project since they specify source and header files used in the compilation.
They should be built only when the XML file is modified (header files are generated, so this is to avoid needless recompilation because a file timestamp changed).
I'd like it included as part of the build process of this project, not a separate project.
I see moving to CMake in the future, but for the time being I am trying to make do.
You can add a pre-build command in Project Properties -> C/C++ Build -> Settings -> Build Steps. This command will be executed before each build.
I'm not aware of a built-in way to get the command to run only when the XML file is modified. If you want that, then instead of making the pre-build command the XML-converting command itself, you can make it a "make" command with a makefile with a single rule whose prerequisite is the XML file and which calls the XML-converting command.