xmos / xscope_fileio

FileIO interface over xscope
Other
2 stars 10 forks source link

Host app cmake build step fails on Windows #29

Closed mbanth closed 2 years ago

mbanth commented 2 years ago

The README.rst file suggests using the cmake -G "NMake Makefiles" . command to generate build files for use on Windows. This command fails when run at an XTC command prompt. It fails in a different way when run at a VS command prompt.

Both failure cases occur using cmake v3.22.5. I have not tried this command with another version of cmake.

I used commit ad7cfb6, the current HEAD of develop, of xscope_fileio as of to generate the results shown below.

When run from an XTC command prompt:

C:\Users\michaelb\sandboxes\xscope_fileio\host>cmake -G "NMake Makefiles" .
-- The C compiler identification is MSVC 19.25.28610.4
-- The CXX compiler identification is MSVC 19.25.28610.4
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/michaelb/sandboxes/xscope_fileio/host/CMakeFiles/CMakeTmp

    Run Build Command(s):nmake -f Makefile /nologo cmTC_4e034\fast &&   "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x64\nmake.exe"  -f CMakeFiles\cmTC_4e034.dir\build.make /nologo -L                  CMakeFiles\cmTC_4e034.dir\build
    Building C object CMakeFiles/cmTC_4e034.dir/testCCompiler.c.obj
        "C:\Program Files\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_4e034.dir\testCCompiler.c.obj.d --working-dir=C:\Users\michaelb\sandboxes\xscope_fileio\host\CMakeFiles\CMakeTmp --filter-prefix="Note: including file: " -- "C:\PROGRA~2\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x64\cl.exe" @C:\Users\michaelb\AppData\Local\Temp\nmE3A7.tmp
    testCCompiler.c
    Linking C executable cmTC_4e034.exe
        "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_4e034.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- "C:\PROGRA~2\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x64\link.exe" /nologo @CMakeFiles\cmTC_4e034.dir\objects1.rsp @C:\Users\michaelb\AppData\Local\Temp\nmE406.tmp
    RC Pass 1: command "rc /fo CMakeFiles\cmTC_4e034.dir/manifest.res CMakeFiles\cmTC_4e034.dir/manifest.rc" failed (exit code 0) with the following output:
    The system cannot find the file specifiedNMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
    Stop.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:6 (project)

-- Configuring incomplete, errors occurred!
See also "C:/Users/michaelb/sandboxes/xscope_fileio/host/CMakeFiles/CMakeOutput.log".
See also "C:/Users/michaelb/sandboxes/xscope_fileio/host/CMakeFiles/CMakeError.log".

When run from a VS command prompt:

-- The C compiler identification is MSVC 19.25.28610.4
-- The CXX compiler identification is MSVC 19.25.28610.4
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - 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: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
XSCOPE_ENDPOINT_LIB
    linked by target "xscope_host_endpoint" in directory C:/Users/michaelb/sandboxes/xscope_fileio/host

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.
mbanth commented 2 years ago

Running the SetEnv.bat script at a VS command prompt before attempting the cmake command allows the cmake command to complete successfully:

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools>cd "c:\Program Files (x86)\XMOS\XTC\15.1.4"

c:\Program Files (x86)\XMOS\XTC\15.1.4>SetEnv.bat

c:\Program Files (x86)\XMOS\XTC\15.1.4>cd c:\Users\michaelb\sandboxes\xscope_fileio\host

c:\Users\michaelb\sandboxes\xscope_fileio\host>cmake -G "NMake Makefiles" .
-- The C compiler identification is MSVC 19.25.28610.4
-- The CXX compiler identification is MSVC 19.25.28610.4
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - 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: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/michaelb/sandboxes/xscope_fileio/host

I suspect that the problem lies in the environment variables each type of command prompt terminal creates/alters.

mbanth commented 2 years ago

The attached file compares the PATH variable for a VS command terminal and an XTC command terminal. VS_XTC_Path_Comparison.xlsx

mbanth commented 2 years ago

The pull requests associated with this issue have resolved the problem. Closing as fixed.