Использование cmake в Linux

603
Widgeteye The Terrible

Я не люблю cmake. Теперь, когда это сказано, вот вопрос;

1) Как настроить конфигурацию с помощью cmake? Использование make Все, что необходимо, - это настроить --help, чтобы получить команды для правильной настройки конфигурации перед запуском make. Как это сделать с помощью cmake или вообще возможно?

2) Используя make, я могу создать установочный пакет для моего дистрибутива, используя make DESTDIR = / directory / build / install, и файлы устанавливаются в / directory / build, затем я легко захожу в / build и создаю пакет для установки программы и удаление позже при необходимости, но с помощью cmake я не вижу способа сделать это, и программа не может быть удалена.

Я предполагаю, что есть способ сделать эти вещи, я просто еще не нашел их. Спасибо

1

1 ответ на вопрос

2
brm

Suppose you've extracted some source package project-1.0.0.tar.gz which has created a directory with a similar name. When I use cmake, I typically create a directory called build in which the .o files etc will be stored, so as not to contaminate the source directory:

/home/user/project-1.0.0> mkdir build /home/user/project-1.0.0> cd build 

From that directory, I then execute ccmake (that's with two c's) which is the ncurses interface to the cmake configuration. Since you have to specify where the main CMakeLists.txt is, in this example the command would be

/home/user/project-1.0.0/build> ccmake .. 

That starts the user interface which initially won't show anything.

Then you need to press 'c' (configure) to let cmake start figuring things out. When this is done, you should see several cmake variable names appear, together with their value. You probably won't need to change them, I typically only fill in the CMAKE_BUILD_TYPE variable and set it to release (for more optimized compiler settings)

You'll need to press 'c' at least one more time (possibly more, depending on what the cmake script does), until all the * before the values of the variables are gone. Then, you can press 'g' to generate the makefiles.

When the makefiles are created, everything probably works as you expect. You can do make, make install, make install DESTDIR=/my/new/dest/dir.

Apart from the ncurses user interface, there also exists a Qt based user interface.

Похожие вопросы