Skip to content

Instantly share code, notes, and snippets.

@Aruise
Created June 5, 2019 07:41
Show Gist options
  • Select an option

  • Save Aruise/7ddff385cb3f86d37a5d1b0ba8e16642 to your computer and use it in GitHub Desktop.

Select an option

Save Aruise/7ddff385cb3f86d37a5d1b0ba8e16642 to your computer and use it in GitHub Desktop.
Homework

Homework

Задание 2

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

$ cd formatter_ex
$ cat >> CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 3.4)
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