cpp-best-practices / cmake_template

CMake for C++ Best Practices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Verify docker scripts

lefticus opened this issue · comments

Docker scripts should be tested and verified. I (@lefticus) don't work with docker and don't have the necessary experience to see if the docker scripts make sense.

Run the docker commands from README_docker.md

Testing

  1. Run docker build -f ./.devcontainer/Dockerfile --tag=my_project:latest . && docker run -it my_project:latest -> Building the base image, seems to work I get into the container and can run g++ --version -> "g++ (Ubuntu 11.1.0-1ubuntu1~20.04) 11.1.0"

  2. Run docker run -it -v ./:/project my_project:latest, then in the docker container:

cd /starter_project
mkdir build
cmake -S . -B ./build
cmake --build ./build

Failed with Error:

[  3%] Linking CXX static library libspdlog.a
[  3%] Built target spdlog
[  5%] Building CXX object src/sample_library/CMakeFiles/sample_library.dir/sample_library.cpp.o
error: optimization flag '-fno-fat-lto-objects' is not supported [clang-diagnostic-ignored-optimization-argument,-warnings-as-errors]
7 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1 warning treated as error
make[2]: *** [src/sample_library/CMakeFiles/sample_library.dir/build.make:76: src/sample_library/CMakeFiles/sample_library.dir/sample_library.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3662: src/sample_library/CMakeFiles/sample_library.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

A script called build_examples.sh is provided to help you to build the example GUI projects in this container.

This seems to be out-dated (?)

Environment:

OS: Garuda Arch Linux (64-Bit) (Linux x64 6.3.1)
Compiler: g++ (13.1.1)
IDE: VSCodium (1.78.2)
docker: Docker version 23.0.6, Docker Compose version 2.17.3