Skip to content

Instantly share code, notes, and snippets.

@Aruise
Created June 11, 2019 09:59
Show Gist options
  • Select an option

  • Save Aruise/045d73ad11536b0870a210e3d8f53c3e to your computer and use it in GitHub Desktop.

Select an option

Save Aruise/045d73ad11536b0870a210e3d8f53c3e to your computer and use it in GitHub Desktop.

Задание 2

У компании "Formatter Inc." есть перспективная библиотека, которая является расширением предыдущей библиотеки. Т.к. вы уже овладели навыком созданием CMakeList.txt для статической библиотеки formatter, ваш руководитель поручает заняться созданием CMakeList.txt для библиотеки formatter_ex, которая в свою очередь использует библиотеку formatter.

$ cd formatter_ex        
$ cat >> CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 3.4)      #выбор версии cmake
project(formatter_ex)
set(CMAKE_CXX_STANDARD 11)               #задаем стандарты
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(formatter_exlib STATIC ${CMAKE_CURRENT_SOURCE_DIR}/formatter_ex.cpp)    #создание статической библиотеки
add_executable(formatter_ex ${CMAKE_CURRENT_SOURCE_DIR}/formatter_ex.cpp)           #создание исполяемого файла 
target_link_libraries(formatter_ex formatter_exlib)       #связывание библиотек
EOF

В formatter_ex.cpp нужно указать путь к файлу formatter.h

$ nano formatter_ex.cpp
#include "../formatter_lib/formatter.h"

Проверка работы. Удаление созданных файлов. Commit, push.

$ cmake . $ make $ cd .. $ git add . $ git commit -m "Создание библиотеки formatter_exlib" $ git push origin master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment