GithubHelp home page GithubHelp logo

Build Orcania with CMake about orcania HOT 20 CLOSED

silvioprog avatar silvioprog commented on July 24, 2024
Build Orcania with CMake

from orcania.

Comments (20)

silvioprog avatar silvioprog commented on July 24, 2024 1

Sure. :-) I'm leaving home now, but as soon as possible I'll show you the tools I've been using and how I created my CMake buildings. :-)

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024 1

Hello dude, glad you like it! :-)

You are right, and we need to check other required headers too (string.h, stdarg.h etc.). I'm going to upgrade it in the CMakeLists.txt ...

Regarding JANSSONFLAG, I'm going to check original Makefile to migrate it to CMake's option, so the users cmake -DU_DISABLE_JANSSON=ON .. like this. :-)

from orcania.

babelouest avatar babelouest commented on July 24, 2024

I can imagine your distress :)

I think that having a CMake building system is a good idea, especially for multiple platform compilation. This was mentioned in babelouest/ulfius#23 for example

Also, having like one library libulfius-V.dll that will include Orcania and Yder would be better, especially for those who need only Ulfius

I don't know if I will keep both build systems (Makefile and CMake) or just keep CMake eventually but we're not there yet.

Can you help me implementing the CMake system buuilding for Orcania/Yder/Ulfius? I'm not familiar with CMake yet.

from orcania.

babelouest avatar babelouest commented on July 24, 2024

Again, there's no rush on this, I prefer using as much time as we need to make a clean and nice install for new platforms.

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

I'm back. :-)

Regarding building systems, I used a lot autotools (influenced by MHD) in some libraries I've maintained, but these days I got big problems to do simple things, for example: downloading and using third party libraries. I also used a lot GIT sub-modules, but it isn't safe to use unstable version of any library, then I decided to use their stable version. CMake offer a builtin feature to download files in build time, so we can download the stable version (eg. MHD from its FTP, libjwt from its release etc.) of all our third party libraries and make local cache improving the building speed in next builds. Anyway, before someone throws me a mouse, I have nothing against autotools, I like it, even being so difficult to use, but for new projects I'm totally inclined to use CMake. :-)
Some references I've found that we could use besides cmake doc: libvnc cmake file; third party examples; StackOverflow reference; step-by-step articles etc.

About IDEs, I don't know how I would manage coding, building, debugging and profiling C projects without a good IDE. Before, I used CodeLite, Eclipse, CodeBlocks, NetBeans, Visual Studio, Emacs etc., but, after tested JetBrains' CLion, I left all other C IDEs. :-) CLion is a paid tool, but since it was built with open source projects, the JetBrains offers a free version of CLion for students or open source projects, with same features of the paid version (the company that I work got the paid version, so I compared it with a student version that I used some time ago and I checked they are same), it has also community support. I strongly recommend you to test it. See its main window on my Xubuntu and some commented features below:

00

Importing a C project to CLion and creating its initial CMake:

01

it will ask about the project sources:

02

03

after done, we can build, debug and check memory leaks (with button to run our project with valgrind).

Also, CLion offers some fixes before building a project, i.e at design time, take a look at I'm editing Orcania in it:

01

so, when we click on these bands, we are jumped to the source editor:

02

that offers the Alt+F12 option:

03

suggesting possible corrections:

04

or

05

without any building, all at design time. :-) ( sorry for many pictures ^^' )

I've used other CLion's features like builtin CMake code completion, Doxygen/markdown support, GIT/.ignore plugin, performance testing plugin and more.

The only thing that could sounds unfamiliar is because CLion uses the Google C/C++ code style by default (that is adopted by NodeJS's libuv too), but you can easily configure it to use others or your own code style.

Edit: we need to check the ExternalProject_Add() option showed in this article. It seems a nice option to use with lib MHD and libjwt. :-)

from orcania.

babelouest avatar babelouest commented on July 24, 2024

Thanks @silvioprog ,

I suggest we complete Orcania's CMake and MinGW patches before finishing Yder's, anyway Orcania is the lower-level library and has no dependencies on my other libraries, I think it's the best starting point to improve Ulfius' building system.

Concerning CLion, it seems an interesting tool but that's not relevant in Orania issues, I'd prefer the issues to focus on issues and not spread to other discussions, otherwise it will be harder to follow and if we have to go back in the future, it will be harder to understant what data is relevant or not.

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

I suggest we complete Orcania's CMake and MinGW patches before finishing Yder's, anyway Orcania is the lower-level library and has no dependencies on my other libraries, I think it's the best starting point to improve Ulfius' building system.

Done. Finally Orcania can be built with CMake! :-)

All steps below requires at least CMake 3.5.

Building and installing on Debian/Ubuntu from trunk:

git clone https://github.com/silvioprog/orcania.git
cd orcania/
git checkout cmake
mkdir build
cd build/
cmake ..
sudo make install/strip

Additional commands:

  • use sudo make install if you want the debugging version
  • use pkg-config to get library info, e.g: pkg-config liborcania --libs
  • use make test to run all tests
  • use make dist to generate a production tag.gz (we should use it to distribute stable signed sources instead of trunk)
  • use make package to generate .deb/.rpm packages

Building and installing on Windows. Firstly, install MinGW-w64 from msys2.org and all tools you need to build Orcania with CMake:

pacman -S --needed git
pacman -S --needed base-devel
pacman -S --needed mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain
pacman -S --needed mingw-w64-i686-cmake mingw-w64-x86_64-cmake
pacman -S --needed mingw-w64-i686-check mingw-w64-x86_64-check

Now, open the MSYS2 MinGW 32-bit (or MSYS2 MinGW 64-bit for 64 bits) command line and build Orcania for Windows:

git clone https://github.com/silvioprog/orcania.git
cd orcania/
git checkout cmake
mkdir build
cd build/
cmake -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=/mingw32 .. # or /mingw64
make install/strip

If you want the Ocania's DLL file, get it from C:\msys32\mingw32\bin\liborcania-1.dll and enjoy that!

Note: I'm using a temporary unofficial repo/branch, then all steps above may be changed as soon as cmake building was merged to the official trunk. 👍

Edit for Debian/Ubuntu users:

If you get some message "shared 'orcania' library not found", don't worry, just upgrade the libraries cache with sudo ldconfig.

from orcania.

babelouest avatar babelouest commented on July 24, 2024

Hello @silvioprog ,

Thanks a lot for this amazing work! I've tested it on a fresh install and found out that there may be a problem regarding jansson dependency. This library is required for the full version or Orcania but I made it optional in the original Makefile.

The first problem is that the file CMakeLists.txt doesn't check if Jansson (including its header files) is installed, and also, to be compatible with the original Makefile, we should add an option to build Orcania without Jansson.

The way to build Orcania without Jansson in the original Makefile is:

$ make JANSSONFLAG=-DU_DISABLE_JANSSON

from orcania.

babelouest avatar babelouest commented on July 24, 2024

If possible, I'd name the disable jansson option with something more meaningful, something like cmake jansson=off for example...

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

jansson=off sounds good, it will be like this. 😎

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

[sharing] Interesting article: http://voices.canonical.com/jussi.pakkanen/2013/03/26/a-list-of-common-cmake-antipatterns . I'm reading it to apply to Orcania building ...

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

Hi again @babelouest . :-)

I've made many changes and now it supports the following options appended to the cmake ..:

The WITH_JANSSON=ON will declare the define USE_JANSSON internally using jansson library. BUILD_TESTING=ON will enable all supported tests. The Orcania's building auto detects which libraries are available in the system enabling/disabling these options automatically, so I think it may work fine in a fresh system.

from orcania.

babelouest avatar babelouest commented on July 24, 2024

You're awesome!

One last change and I think we'll be ready to merge, can you set the parameter -DBUILD_TESTING to OFF by default? So check won't be necessary for normal everyday install.

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

Done! 👍 😎 👍

from orcania.

babelouest avatar babelouest commented on July 24, 2024

Like a boss

from orcania.

babelouest avatar babelouest commented on July 24, 2024

Can you send a Pull Request to the my branch?

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

Sure. 😃 I'm going to send it ...

from orcania.

babelouest avatar babelouest commented on July 24, 2024

Thanks, as I said in the pull request, there are too much changes for a new feature that shouldn't require that much.

The way I see Orcania and all my other tools is that they are fitted for Makefile first. Using other build tools is OK as long as it doesn't change the library intent: to be available on small and embedded devices, without huge dependencies.

I hope the changes I require are OK to you.

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

Hello dude. I'm going to do the changes as requested, but they are really required to compile with -Wall/-Wextra/-Werror (could you try to compile with these options?). Regarding makefiles I just deleted it because your previous comment about removing them, but they will be restored. :-) Regarding O_EXTERN I'll try to explain at #11 (comment) .

from orcania.

silvioprog avatar silvioprog commented on July 24, 2024

Done in a new temporary fork/branch: https://github.com/silvioprog/orcania/commits/cmake . 😎

from orcania.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.