Ссылка на репозиторий, с которым работал в домашнем задании
Homework
Представьте, что вы стажер в компании "Formatter Inc.".
Задание 1
Вам поручили перейти на систему автоматизированной сборки CMake. Исходные файлы находятся в директории formatter_lib. В этой директории находятся файлы для статической библиотеки formatter. Создайте CMakeList.txt в директории formatter_lib, с помощью которого можно будет собирать статическую библиотеку formatter.
Задание 2
У компании "Formatter Inc." есть перспективная библиотека, которая является расширением предыдущей библиотеки. Т.к. вы уже овладели навыком созданием CMakeList.txt для статической библиотеки formatter, ваш руководитель поручает заняться созданием CMakeList.txt для библиотеки formatter_ex, которая в свою очередь использует библиотеку formatter.
Задание 3
Конечно же ваша компания предоставляет примеры использования своих библиотек. Чтобы продемонстрировать как работать с библиотекой formatter_ex, вам необходимо создать два CMakeList.txt для двух простых приложений:
hello_world, которое использует библиотеку formatter_ex;
solver, приложение которое испольует статические библиотеки formatter_ex и solver_lib.
Удачной стажировки!
P.S. Хочется верить, что стажировка прошла успешно
$ mkdir homework3
$ cd homework3
$ git clone https://github.com/tp-labs/lab03.git .
Cloning into '.'...
remote: Enumerating objects: 91, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 91 (delta 23), reused 21 (delta 21), pack-reused 61 (from 1)
Receiving objects: 100% (91/91), 1.02 MiB | 3.87 MiB/s, done.
Resolving deltas: 100% (41/41), done.
$ git remote remove origin
$ git remote add origin https://github.com/Medvud/homework3.git
$ git remote -v
origin https://github.com/Medvud/homework3.git (fetch)
origin https://github.com/Medvud/homework3.git (push)
$ cd formatter_lib
$ vim CMakeLists.txt
Собственно, с помощью vim, блокнота и интернета я пытался собирать проект по частям, ниже прикреплю файл с фейловыми сборками, после которых я шел переделывать CMake листы. Ошибки были начиная от множественного подключения одной и той же дирректории в одну "цепь", ну и куда без опечаток.В финале, когда уже CMake листы были доделаны и работали, вызывалась ошибка, когда компилятор не понимал что такое std::sqrtf, я позволил себе исправить эту функцию на std::sqrt. Немного фейлов
Успех:
$ rm -rf _build
$ cmake -H. -B _build
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at formatter_lib/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Deprecation Warning at formatter_ex_lib/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Deprecation Warning at solver_lib/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Deprecation Warning at hello_world_application/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Deprecation Warning at solver_application/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- Configuring done (3.5s)
-- Generating done (0.0s)
-- Build files have been written to: /home/mvtop/homework3/_build
$ cmake --build _build
[ 10%] Building CXX object formatter_lib/CMakeFiles/formatter.dir/formatter.cpp.o
[ 20%] Linking CXX static library libformatter.a
[ 20%] Built target formatter
[ 30%] Building CXX object formatter_ex_lib/CMakeFiles/formatter_ex.dir/formatter_ex.cpp.o
[ 40%] Linking CXX static library libformatter_ex.a
[ 40%] Built target formatter_ex
[ 50%] Building CXX object solver_lib/CMakeFiles/solver.dir/solver.cpp.o
[ 60%] Linking CXX static library libsolver.a
[ 60%] Built target solver
[ 70%] Building CXX object hello_world_application/CMakeFiles/hello_world.dir/hello_world.cpp.o
[ 80%] Linking CXX executable hello_world
[ 80%] Built target hello_world
[ 90%] Building CXX object solver_application/CMakeFiles/equation.dir/equation.cpp.o
[100%] Linking CXX executable equation
[100%] Built target equation
Проверки работоспособности кода:
$ ./_build/hello_world_application/hello_world
-------------------------
hello, world!
-------------------------
$ ./_build/solver_application/equation
3
4
5
-------------------------
error: discriminant < 0
-------------------------
$ ./_build/solver_application/equation
1
2
1
-------------------------
x1 = -1.000000
-------------------------
-------------------------
x2 = -1.000000
-------------------------
$ ./_build/solver_application/equation
1
5
4
-------------------------
x1 = -4.000000
-------------------------
-------------------------
x2 = -1.000000
-------------------------
Пушим в удаленный репозиторий
$ git remote -v
origin https://github.com/Medvud/homework3.git (fetch)
origin https://github.com/Medvud/homework3.git (push)
$ git add .
$ git commit -m"added cmake"
[master b65519d] added cmake
109 files changed, 6422 insertions(+), 39 deletions(-)
create mode 100644 _build/CMakeCache.txt
create mode 100644 _build/CMakeFiles/3.28.3/CMakeCCompiler.cmake
create mode 100644 _build/CMakeFiles/3.28.3/CMakeCXXCompiler.cmake
create mode 100755 _build/CMakeFiles/3.28.3/CMakeDetermineCompilerABI_C.bin
create mode 100755 _build/CMakeFiles/3.28.3/CMakeDetermineCompilerABI_CXX.bin
create mode 100644 _build/CMakeFiles/3.28.3/CMakeSystem.cmake
create mode 100644 _build/CMakeFiles/3.28.3/CompilerIdC/CMakeCCompilerId.c
create mode 100755 _build/CMakeFiles/3.28.3/CompilerIdC/a.out
create mode 100644 _build/CMakeFiles/3.28.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
create mode 100755 _build/CMakeFiles/3.28.3/CompilerIdCXX/a.out
create mode 100644 _build/CMakeFiles/CMakeConfigureLog.yaml
create mode 100644 _build/CMakeFiles/CMakeDirectoryInformation.cmake
create mode 100644 _build/CMakeFiles/Makefile.cmake
create mode 100644 _build/CMakeFiles/Makefile2
create mode 100644 _build/CMakeFiles/TargetDirectories.txt
create mode 100644 _build/CMakeFiles/cmake.check_cache
create mode 100644 _build/CMakeFiles/progress.marks
create mode 100644 _build/Makefile
create mode 100644 _build/cmake_install.cmake
create mode 100644 _build/formatter_ex_lib/CMakeFiles/CMakeDirectoryInformation.cmake
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/DependInfo.cmake
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/build.make
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/cmake_clean.cmake
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/cmake_clean_target.cmake
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/compiler_depend.make
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/compiler_depend.ts
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/depend.make
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/flags.make
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/formatter_ex.cpp.o
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/formatter_ex.cpp.o.d
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/link.txt
create mode 100644 _build/formatter_ex_lib/CMakeFiles/formatter_ex.dir/progress.make
create mode 100644 _build/formatter_ex_lib/CMakeFiles/progress.marks
create mode 100644 _build/formatter_ex_lib/Makefile
create mode 100644 _build/formatter_ex_lib/cmake_install.cmake
create mode 100644 _build/formatter_ex_lib/libformatter_ex.a
create mode 100644 _build/formatter_lib/CMakeFiles/CMakeDirectoryInformation.cmake
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/DependInfo.cmake
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/build.make
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/cmake_clean.cmake
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/cmake_clean_target.cmake
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/compiler_depend.make
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/compiler_depend.ts
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/depend.make
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/flags.make
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/formatter.cpp.o
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/formatter.cpp.o.d
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/link.txt
create mode 100644 _build/formatter_lib/CMakeFiles/formatter.dir/progress.make
create mode 100644 _build/formatter_lib/CMakeFiles/progress.marks
create mode 100644 _build/formatter_lib/Makefile
create mode 100644 _build/formatter_lib/cmake_install.cmake
create mode 100644 _build/formatter_lib/libformatter.a
create mode 100644 _build/hello_world_application/CMakeFiles/CMakeDirectoryInformation.cmake
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/DependInfo.cmake
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/build.make
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/cmake_clean.cmake
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/compiler_depend.make
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/compiler_depend.ts
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/depend.make
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/flags.make
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/hello_world.cpp.o
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/hello_world.cpp.o.d
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/link.txt
create mode 100644 _build/hello_world_application/CMakeFiles/hello_world.dir/progress.make
create mode 100644 _build/hello_world_application/CMakeFiles/progress.marks
create mode 100644 _build/hello_world_application/Makefile
create mode 100644 _build/hello_world_application/cmake_install.cmake
create mode 100755 _build/hello_world_application/hello_world
create mode 100644 _build/solver_application/CMakeFiles/CMakeDirectoryInformation.cmake
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/DependInfo.cmake
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/build.make
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/cmake_clean.cmake
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/compiler_depend.make
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/compiler_depend.ts
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/depend.make
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/equation.cpp.o
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/equation.cpp.o.d
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/flags.make
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/link.txt
create mode 100644 _build/solver_application/CMakeFiles/equation.dir/progress.make
create mode 100644 _build/solver_application/CMakeFiles/progress.marks
create mode 100644 _build/solver_application/Makefile
create mode 100644 _build/solver_application/cmake_install.cmake
create mode 100755 _build/solver_application/equation
create mode 100644 _build/solver_lib/CMakeFiles/CMakeDirectoryInformation.cmake
create mode 100644 _build/solver_lib/CMakeFiles/progress.marks
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/DependInfo.cmake
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/build.make
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/cmake_clean.cmake
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/cmake_clean_target.cmake
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/compiler_depend.make
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/compiler_depend.ts
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/depend.make
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/flags.make
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/link.txt
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/progress.make
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/solver.cpp.o
create mode 100644 _build/solver_lib/CMakeFiles/solver.dir/solver.cpp.o.d
create mode 100644 _build/solver_lib/Makefile
create mode 100644 _build/solver_lib/cmake_install.cmake
create mode 100644 _build/solver_lib/libsolver.a
create mode 100644 formatter_ex_lib/CMakeLists.txt
create mode 100644 formatter_lib/CMakeLists.txt
create mode 100644 hello_world_application/CMakeLists.txt
create mode 100644 solver_application/CMakeLists.txt
create mode 100644 solver_lib/CMakeLists.txt
$ git push origin master
Enumerating objects: 134, done.
Counting objects: 100% (134/134), done.
Delta compression using up to 16 threads
Compressing objects: 100% (116/116), done.
Writing objects: 100% (129/129), 66.62 KiB | 3.33 MiB/s, done.
Total 129 (delta 48), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (48/48), completed with 1 local object.
To https://github.com/Medvud/homework3.git
94afc96..b65519d master -> master