Import non-cmake GitHub project in CLion - c++

Checking CLion help https://www.jetbrains.com/help/clion/2016.2/importing-existing-non-cmake-project.html I see how to import a non-CMake project into CLion.
And I'm also able to clone a project from GitHub https://www.jetbrains.com/help/clion/2016.2/cloning-a-repository-from-github.html
The project https://github.com/quickfix/quickfix uses ./bootstrap and ./configure to setup a makefile.
What I'd like to do is import that makefile into my CLion project and build and run from that. Is this possible?

While it is possible to "import a project" that's not CMake-based into your CLion project, CLion does not itself directly support using Makefiles as an origination point for a project yet. I know that this is something that has been wanted by many people, and as far as I know, the creators of CLion are at some point planning to integrate some support for this.
In the meantime, however, there is no handy way to do this directly. CMake is a build system configurator, in that it generates its own set of Makefiles to build everything, based on the things you write in your CMakeLists.txt file.
Your best bet, should you want to use the quickfix lib in a project of yours, is to learn the CMake process for building an external dependency, and then linking it to your project. A good blog post on such a thing can be found here. If you simply want to work on changes to it in CLion for your own convenience, but keep the original build files, you could just have CLion generate its own little CMakeLists.txt file for the purposes of importing and color-coding everything, and then set your debug config, etc to point to the binaries generated by running make in the command line.
Long story short, there's no easy way to do what you are talking about directly, but depending on your intended purpose, there are a couple of alternate paths to a similar end. Hope this helps!

Support for Makefiles has been added to CLion, however, the feature is (as of writing) still in early development.
This feature allows for a CLion project to be created by selecting File > Open from the main menu and then selecting the top level Makefile for the project.
More details of the feature can be found here: https://www.jetbrains.com/help/clion/makefiles-support.html

Related

Export Eclipse Compiler to cmd

I try to compile an eclipse-project written in c++ which is building a .so-File. Now i try to build the project without an IDE. I tried it with MinGW but the created .so doesn't work. I think there are used some special packages but how can I get the information's.
Is there a way to Export the build settings and import them into MinGW?
How can i else set the compiler?
This is the ToolChainEditor which i would recreat in MinGW.
You can't import a configuration into mingw, but you can tell mingw where to find a configuration of sorts.
Eclipse can be configured to generate a makefile (At least as recent as Neon). Select your project and use the main menu to navigate Project->Properties->C/C++ Build->Tool Chain Editor. Set the "Current builder" to Gnu Make Builder and build the project.
In the generated folder where you would find the finished executable you will find three more files: makefile, objects.mk and sources.mk and can use the make utility that often comes with mingw. It can also be downloaded separately if you have to.
From the command line, enter the folder and type make. Magic will happen. If you want to know more about the magic, make is a very deep topic well worth learning, even if only as a gateway drug to more modern build systems that descended from it.

CMake "make install" or including a library in windows

I'm trying to create an Open Source C++ project. I want it to be as easy to build as possible, but at the same time cross platform.
I don't need gui or heavy libraries like boost or Qt, so I've settled on using GitHub, CMake, and LibSourcey.
My problem is, I can't find a way to make my project easy to build in windows, which is my development environment.
How can I "make install" a library in Windows for use in my project? Do I even have to install it in windows?
Is it possible to download, build, and link it automatically?
On windows, besides an installer, I also want to make a portable version, so don't want any hard coded library paths.
I assume, on some platforms, like Linux, libraries are built separably and packaged up by maintainers. So I shouldn't just bundle up my own copies.
So, my question is:
How can I set up a project that is cross platform and easy to build, and what are the best practices?
You can create git submodule in your git repo with path for example
contrib/LibSourcery and url to github repo of LibSourcery, because of LibSourcery uses cmake you just
need add such line into your CMakeLists.txt: add_subdirectory(contrib/LibSourcery)
So person who want to use your code, just do git clone --recursive url
to get all of your code and dependencies, after that it run cmake -G, to create project for IDE of his choice (including MSVC++ of course),
open project in IDE and press build button, that's all.
Use babun. It's a wrapper for cygwin and it works perfectly for everything I need, even compiling with cmake.
Alternatively, you could use premake, which uses lua as a config system and works fine on windows.
There is no elegant cross-platform way, since the idea of "make install" doesn't exist on Windows, therefore the use of cmake install is undefined there. For something which is supposed to help cross-platform, I feel this is a deficiency w cmake.
My solution is to write a custom _INSTALL which takes the same args as cmake install and then on Linux it just calls install, and on Windows it does an add_command which does a post-build copy to the install paths, which accomplishes the same thing. Basically, _INSTALL behaves the way you expect a cross-platform install command to behave. Can share my _INSTALL func if there is interest.
_INSTALL is placed nto a Helper.cmake, and included in all my CMakeList.txt for my projects, so all I need to do is call it and the generated lib/inc files magically appear for both win and linux.
You can use vcpkg, an open source package manager for c and c++. It allows to easily download and compile libraries and then use find_package from within CMake like you would on linux. It's very easy to use. It even provides hints as to how to alter your cmake file to use the libraries.
I started by installing packages with the command line, and then wondered why they wouldn't show up in visual studio. But I realized that it would download 32 bit libraries by default. Use .\vcpkg install <libname>:x64-windows if you need the 64 bit libraries.
After running the integrate command, you will need to delete any cmake caches to have MSVS use the new toolchain.

CMake Roundtrip Workflow

I understand that CMake enables a project to be easily built in a variety of compiler/IDE environments. I have experienced this for myself and was amazed when CMake produced a working, buildable Xcode project for me from some open source project (cool!)
But what I don't understand is how you properly update the CMake system after you have made significant changes to the project that CMake created for you.
For example I am envisioning a workflow in which the project should be kept portable via CMake. So I create a clone of a github project, use CMake to create my XCode project, and then go to work implementing some new feature or bug fix. Perhaps these changes are non-trivial and affect build.
After these changes are complete I want to push the code base back to github. What happens now? Must all of the CMake files be updated by hand to reflect all of the work that I've done? Or is there some equally magical feature to update the CMake files with the changes that were implemented in XCode (or Visual Studio, or some other supported IDE/compiler combo)?
What is the general "Roundtrip" workflow with CMake and how efficient is it?
The point is that you change your project by changing the CMake configuration files themselves. It could be that you'll find some other tool which manages cmake projects, which will make changes to your cmake files. In the example you mention, you have to check if XCode is modifying your cmake files.
You have to commit all the necessary modifications you do to your cmake files, and your build program (make, ninja, or any other) will run cmake every time the cmake project files are touched.
Advanced note: if you use the command file with globbing instructions to get the list of your sources files, you might be interested to read Getting cmake to run before building after pulling from git

Using biicode and clion?

Is there an easy way to use clion (e.g. debugging) in a c++ project using biicode as construction tool?
In fact, both systems work with cmake, but biicode generates CMakeLists.txt that clion doesn't seem to understand (the one located in blocks/ nor the temporary one in cmake/).
Right now I could only work by using biicode self-generated CMakeLists.txt for regular builds, and a hand-crafted CMakeLists.txt to compile within clion. However duplicating the description of the construction does not sound like a good idea.
I guess some elaborated dark scripting could be done (I am pretty new to cmake), but I'm just playing around and I don't think it is worthwhile to do it or ask for it.
Has anyone tried to use clion and biicode? Is clion fully supporting cmake yet? Is biicode using internal code that fully cmake-compliant tools won't understand? Am I missing some silly idea?
Currently it is not possible. Unfortunately both biicode and CLion use cmake and use different conventions about the project layout/structure, and at the moment they are simply incompatible.
The good news are that the people at CLion are helping a lot to figure out the best solution so hopefully this will be fixed soon.
EDIT 19-Feb-2015: Now biicode 2.4.1 and last CLion EAP are compatible. You can open an existing biicode project in CLion using these steps:
CLion->Open project, navigate to your biicode project/cmake/ folder and open it (where the CMakeLists.txt lives)
CLion->Change project root, select your main biicode project folder.
Then you should be able to build and run your targets.
It can be convenient to check in Settings->Build, Execution, Deployment->CMake, "Automatically reload CMake on editing".
And remember, if you change your project, add or remove files, main executables, add or remove dependencies, to run $ bii cpp:configure so the whole project is updated
Now biicode and CLion work fully with each other. Here's a guide from biicode docs to use CLion.
Biicode has been replaced by Conan.io, which is far easier to use with CLion.

Cmake support in Eclipse

According to this, I have 3 options to use cmake in Eclipse CDT for C++. None of them works.
The first is because I use out-of-source builds and the limitations of the generator is so lame. Also, it uses a hardcoded Eclipse project template, so it is fragile like hell. The second is the poor man's version of cmake support. It does not add any value to Eclipse, really. The third one simply does not work. I can't make an existing cmake project. I can create a new one, but not opening an existing one. Also, the cmake properties in the project properties windows throw an exception and that's it. Does not even show up.
Is there any GOOD support in Eclipse for cmake? Or any other powerful IDE? Like adding the CmakeList.txt and the corresponding project is created? I am mainly interested in having the proper include paths and the global make targets based on the cmake files. And of course it would be nice to have syntax colored editing of cmake files, etc.
We successfully use both Eclipse CDT and Qt Creator with a large CMake based project.
For Eclipse, we usually use option two exactly as described. There is also a CMake Eclipse plug-in called CMake Editor for syntax highlighting and command completion.
Personally, I am using QtCreator. It has quite good CMake support and is very fast. You should initially configure your project with the CMake GUI (using the Make or NMake Generator) and then open your top-level CMakeLists.txt file in QtCreator and point it to your already configured binary directory.
Have you taken a look at Qt Creator? It might have the features you are looking for.
I use CMake GUI for generating CDT project or Unix makefiles and then import it via Eclipse.
Also I use KDevelop 4 because it simply opens CMake projects and tightly integrates CMake support.
Congratulations, CLion http://www.jetbrains.com/clion/ new C++ IDE with CMake well integrated. See its features https://www.youtube.com/watch?feature=player_embedded&v=MY_Z90Tj6is
I tried all three and have found option 2 to be the only useful one. Option 1, the cmake CDT generator, is useless. I cannot get option 3 to work either.
Yes, option 2 is the "poor man's version" insofar as you must follow a series of steps when setting up a new project, rather than pressing a single button. But I have had good success with it for many projects in the past year. Like you, I always do out of source builds.
Also, to get syntax coloring of CMake files, use the excellent CMakeEd plugin for eclipse. It's beautiful.
CDT has official CMake support plugin currently. You can find through Help->Install menu of Eclipse.