0

I'm trying to use clang with CMake. Here's my Dockerfile. You can see that I did not install build-essentials, only clang, because I dont want GNU compilers to be made default.

My Dockerfile:

FROM ubuntu:bionic

WORKDIR /home/project

RUN export DEBIAN_FRONTEND=noninteractive && apt-get update\
    && apt-get install -y clang wget

RUN wget https://github.com/Kitware/CMake/releases/download/v3.18.0-rc2/cmake-3.18.0-rc2-Linux-x86_64.sh && ls

RUN mkdir -p /usr/local/cmake \
&& chmod +x cmake-3.18.0-rc2-Linux-x86_64.sh \
&& ./cmake-3.18.0-rc2-Linux-x86_64.sh --skip-license --prefix=/usr/local/cmake

ENV PATH="/usr/local/cmake/bin:${PATH}"

CMakeLists.txt

cmake_minimum_required (VERSION 3.10)
project(libsmoltcp_cpp LANGUAGES CXX)

Here's what I get when running cmake .:

root@275dbeaae123:/home/project# cmake .
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "/home/project/CMakeFiles/CMakeOutput.log".

In update-alternatives there's just clang:

root@275dbeaae123:/home/project# update-alternatives --config cc
There is only one alternative in link group cc (providing /usr/bin/cc): /usr/bin/clang
Nothing to configure.
PPP
  • 1,279
  • 1
  • 28
  • 71
  • 1
    `sudo apt install make` ? – Eric Backus Jun 30 '20 at 02:54
  • 1
    clang alone also won't work. You'd need libc++. Better to tell cmake what to use when you invoke cmake, than to do any of this. You're trying to sidestep cmake's big advantage. – sweenish Jun 30 '20 at 04:24
  • @sweenish the two options I have are: using an override file: https://stackoverflow.com/a/7032021/6655884 which does not look nice, and updating the alternatives: https://stackoverflow.com/a/12843988/6655884 which is not scriptable – PPP Jun 30 '20 at 04:47
  • 1
    @LucasZanella: What about **fixing the first error message** `CMake was unable to find a build program corresponding to "Unix Makefiles"`? It is noted in your title and completely **unrelated** to clang. Please, in the question post concentrate on a **single problem**. And make sure you have no other problems, especially ones which could affect on the original one. (Without `make` as a build utility checking the compiler has no sense). – Tsyvarev Jun 30 '20 at 07:30
  • "Which does not look nice" is a really poor excuse. If you're going to ignore cmake's biggest strength, it's not going to be elegant. Personally, I alias the cmake command on my machine. – sweenish Jun 30 '20 at 13:21

1 Answers1

0

It seems your CMake configuration is generating Makefiles that should be run with make but it isn't installed. Install make.

The second issue could be you have configured C language:

update-alternatives --config cc

And may need to configure C++ language:

update-alternatives --set g++ /usr/bin/clang
Manuel
  • 2,526
  • 1
  • 13
  • 17