Showing posts with label CMake. Show all posts
Showing posts with label CMake. Show all posts

How to use OpenMP with CMake

Hi! Some days have passed since I wrote something on the blog but I've been a little busy. Anyway, here I am again, this time to write about CMake and OpenMP. If you don't know CMake, and don't know how to use it, you may check my previous  tutorial on How to use CMake with OpenCV where I describe the basic steps to get started with CMake.
OpenMP is an API that supports multi-platform shared-memory parallel programming in C/C++ and Fortran. The OpenMP API defines a portable, scalable model with a simple and flexible interface for developing parallel appications on platforms from the desktop to the supercomputer.
After following the steps I described in the post that I previously referred, you'll have to add the following lines to tour CMakeLists.txt file:
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
After inserting these lines you'll be ready to use the OpenMP libraries in your project. That's just it.



Did you find this post helpful? Do you wish to contribute to other projects regarding computer science, electronics, robotics or mechatronics that will be posted in this blog? If you wish to do so, you can donate via paypal using the button below. Thanks! :)
Donate

How to use OpenCV with CMake and Codeblocks on Ubuntu

Continuing the previous posts on How to Install OpenCV 2.3.1 in Ubuntu 11.10 Oneiric Ocelot with Python support and How to use CMake ith OpenCV now I'll show you how to use both OpenCV and CMake with Codeblocks IDE. Codeblocks is an open source, cross platform, free, great C++ IDE built to meet the most demanding needs of users. It is very extensible and fully configurable. I have been using codeblocks for about 2 years and I never felt the need to change to another IDE. It supports debugging and code completion which are very useful features.

How to use CMake with OpenCV

CMake is a cross platform, open-source build system. It consists in a family of tools designed to build, test and package software. It is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates makefiles that can be used in the compiler environment of your choice.

OpenCV is an open-source computer vision library which was already mentioned in this blog (see How to install OpenCV 2.3.1 in Ubuntu 11.10 Oneiric Ocelot with Python support).

This "how to" will guide you through the process of using CMake to compile and build OpenCV projects. It is based on the tutorial made by Damiles but has some minor changes.

top