0

I'm running cmake on win10 WSL with ubuntu20.04, apt-get installed cmake and used the simpliest CMakeLists.txt as below:

cmake_minimum_required(VERSION 3.4)
project(my)
add_executable(testConst01 testConst.c01)

Run mkdir build; cd build; cmake ../my it will give a bunch of error:

CMake Error at /usr/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 9.4.0
CMake Error at /usr/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 9.4.0
CMake Error at /usr/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/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/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/my/build/CMakeFiles/CMakeOutput.log".
See also "/mnt/d/my/build/CMakeFiles/CMakeError.log".

Then I run cmake the second time, everything become ok, and make command will generate all I wanted. Then I rm -fr the build dir, do the job again. First time it fails and second time it succeeds. Always like this.

I took a look at the CMakeOutput.log and CMakeError.log file, didn't find any real error message either.

What is the cause of this problem, how to fix it? Thanks!

Troskyvs
  • 7,537
  • 7
  • 47
  • 115

1 Answers1

1

Finnaly I found this was WSL config issue, not cmake problem, as stated in this thread:

Every call to configure_file fails on WSL: configure_file Problem configuring file

Step to fix: In wsl command line window, sudo vi /etc/wsl.conf add these lines:

options = "metadata"
enabled = true

Then close all wsl windows.

Then in cmd.exe or powershell, restart my linux instance. E.g. I'm using Ubuntu20.04 I'll wsl -t Ubuntu20.04

Then run my cmake job, everything is OK now.

Troskyvs
  • 7,537
  • 7
  • 47
  • 115