Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Integrate a CMake Project with GYP-Based Libraries

Tags:

c++

build

cmake

gyp

I've been building cross-platform applications using C++ and CMake. Unfortunately many libraries do not include CMake project descriptions. For example Google supported projects frequently use GYP.

Here are some of the approaches I've taken for this problem:

  1. Find a CMake project description for the library on the web
  2. Write a project description using CMake

Finding or writing CMakeLists.txt descriptions for libraries is a maintenance problem. As the library is updated, so too must my CMake description. Also the project files created by the library's authors are more likely to be correct.

How specifically should I integrate GYP projects into my CMake-based software? Is duplicating the project description in CMake the best approach, or is there some feature of CMake that I am missing?

What are some of the general approaches to dealing with this class of problems in CMake? What about libraries that include a set of project files for various platforms/IDEs? Does CMake provide a way to integrate these projects into mine?

like image 306
Kevin Avatar asked Mar 06 '14 02:03

Kevin


People also ask

How do I add a library to CMake project?

To add a library in CMake, use the add_library() command and specify which source files should make up the library. Rather than placing all of the source files in one directory, we can organize our project with one or more subdirectories. In this case, we will create a subdirectory specifically for our library.

What does Add_subdirectory do in CMake?

Add a subdirectory to the build. Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.

Does CMake include GCC?

a. This "cmake and make" stuffs actually use g++ / gcc in its implementation.

What is CMakeLists txt?

CMakeLists. txt file contains a set of directives and instructions describing the project's source files and targets (executable, library, or both). When you create a new project, CLion generates CMakeLists. txt file automatically and places it in the project root directory.


1 Answers

Use the ExternalProject module

http://www.cmake.org/cmake/help/v3.0/module/ExternalProject.html

like image 140
steveire Avatar answered Oct 11 '22 20:10

steveire