5

I've just built and installed cmake 3.16 on a fresh WSL install (Ubuntu18.04 LTS). I then created a default hello world project

(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest$ tree .
.
├── CMakeLists.txt
└── main.cpp
//CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(ATest)

set(CMAKE_CXX_STANDARD 14)

add_executable(ATest main.cpp)
//main.cpp
#include <iostream>

#include <string>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

And then tried to build:

(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest$ mkdir build
(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest$ cd build/
(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest/build$ cmake ..

And I get the following.

CMake Error at /usr/local/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:185 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- The C compiler identification is GNU 10.1.0
CMake Error at /usr/local/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:212 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- The CXX compiler identification is GNU 10.1.0
CMake Error at /usr/local/share/cmake-3.16/Modules/CMakeDetermineCXXCompiler.cmake:210 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /usr/local/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:80 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/local/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake:73 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "/mnt/d/ATest/build/CMakeFiles/CMakeOutput.log".
See also "/mnt/d/ATest/build/CMakeFiles/CMakeError.log".
(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest/build$

I originally tried cmake 3.15 but upgraded to see if it was a version problem, given this, I don't this it is. I've also tried g++-7 and g++-9 which behave the same.

Does anybody know what might be going on here? Thanks.

CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
  • Definitely not a GCC problem, it doesn't get that far. WSL suggests that the CMakeListst.txt fle may be in DOS format (CRLF), not Unix. `dos2unix CMakeLists.txt` would fix that. – MSalters Jul 13 '20 at 15:50
  • I wouldn't have thought of that. I tried running `dos2unix CMakeLists.txt` and rebuilding from clean build directory and I got the same problem. – CiaranWelsh Jul 13 '20 at 15:59
  • 2
    Googling the issue led me to this [post](https://github.com/microsoft/WSL/issues/4257#issuecomment-507799403) describing a similar problem with a potential solution. – Kevin Jul 13 '20 at 16:02

2 Answers2

7
  1. Create a file named wsl.conf in /etc/ with the following text:
# /etc/wsl.conf
[automount]
options = "metadata"
enabled = true
  1. Reboot wsl:

wsl.exe -t Ubuntu // (or other e.g. Debian)

Sources:

Peter
  • 2,796
  • 1
  • 17
  • 29
0

I was able to fix the above error by running the following commands in order:

% cd build
% cmake -B . -S ..
% cmake --build .

This solution is taken from here.

atluutran
  • 81
  • 1
  • 4