Hello,

Perhaps you can start by not using the .bat scripts and using the .exe instead. You can run cmake from a visual studio environment, and instead of invoking a visual studio environment for each command.

And to build from your script:
cmake --build .

Regards,

Juan


On 9/19/19 12:59 PM, Joao Pedro Abreu De Souza wrote:
Now, with this toolchain file:
-----start of toolchain file-------
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR "x86")
set(CMAKE_SYSTEM_VERSION 1)

# Microsoft MSVC compiler
#set(CMAKE_C_COMPILER cl.exe)
#set(CMAKE_CXX_COMPILER cl.exe)

set(CMAKE_C_COMPILER "${CMAKE_CURRENT_SOURCE_DIR}/ninja-core-lib/toolchains/cl.bat")
set(CMAKE_CXX_COMPILER "${CMAKE_C_COMPILER}")

# Unfortunatly CMake doesn't seem to know anything about the MSVC compiler,
# so tell CMake that cl.exe supports C99
set(CMAKE_C_COMPILE_FEATURES c_std_99)


set(CMAKE_C_FLAGS_INIT   "/arch:SSE2 ${_MP_FLAG} /EHsc")
set(CMAKE_CXX_FLAGS_INIT "/arch:SSE2 ${_MP_FLAG}")



#set(CMAKE_STATIC_LINKER link.exe)
#set(CMAKE_LINKER link.exe)
#set(CMAKE_SHARED_LINKER link.exe)

set(CMAKE_STATIC_LINKER "${CMAKE_CURRENT_SOURCE_DIR}/ninja-core-lib/toolchains/link.bat")
set(CMAKE_LINKER ${CMAKE_STATIC_LINKER})
set(CMAKE_SHARED_LINKER ${CMAKE_STATIC_LINKER})


set(CMAKE_AR ${CMAKE_LINKER})

set(CMAKE_C_COMPILER_ID "porquePreciseiDeUmBat")
-----stop of toolchain file-------

using this cl.bat
----start of cl.bat---------
pushd
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsamd64_x86.bat"
popd
cl.exe %*
----stop of cl.bat---------

and link.bat in the same spirit but with link.exe instead of cl.exe, I can execute cmake, ninja, but the main.exe don't are on build/src/main


When I look on CMakeError.log on build directory, can look

-------start of CMakeError.log--------------------------
C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles>more CMakeError.log Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Compilation of the C compiler identification source "CMakeCCompilerId.c" did not produce an executable in "C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CompilerIdC".

Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler":

C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles\3.15.3\CompilerIdC>pushd

C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles\3.15.3\CompilerIdC>"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsamd64_x86.bat"
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.16
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64_x86'
Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler":

C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles\3.15.3\CompilerIdC>pushd

C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles\3.15.3\CompilerIdC>"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsamd64_x86.bat"
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.16
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64_x86'
Detecting C compiler ABI info failed to compile with the following output:
Change Dir: C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_8a08d && [1/2] Building C object CMakeFiles\cmTC_8a08d.dir\CMakeCCompilerABI.c.obj

C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles\CMakeTmp>pushd

C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles\CMakeTmp>"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsamd64_x86.bat"
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.16
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64_x86'
[2/2] Linking C executable cmTC_8a08d.exe

C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles\CMakeTmp>pushd

C:\Users\jpabreu\Desktop\testCMAKE\build_Win32_normal\CMakeFiles\CMakeTmp>"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsamd64_x86.bat"
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.16
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64_x86'


Cannot copy output executable
   ''
to destination specified by COPY_FILE:
'C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/3.15.3/CMakeDetermineCompilerABI_C.bin'
Unable to find the executable at any of:
C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/CMakeTmp/cmTC_8a08d.exe C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/CMakeTmp/Debug/cmTC_8a08d.exe C:/Users/jpabreu/Desktop/testCMAKE/build_Win32_normal/CMakeFiles/CMakeTmp/Development/cmTC_8a08d.exe
-------stop of CMakeError.log--------------------------

I am not understanding the last error. All this files are my (are under Users/jpabreu), so I don't think that may be permission problems.

Em qui, 19 de set de 2019 às 14:02, Gonzalo Garramuño <ggarr...@gmail.com <mailto:ggarr...@gmail.com>> escreveu:


    El 17/9/19 a las 16:46, fdk17 escribió:

    I personally never seen anyone try to use the Ninja generator via
    command line CMake and use the cl.exe compiler.
    I've only seen that using Visual Studio to open a CMakeLists.txt
    file it can produce a Ninja project.  But even MS documentation
    states that it doesn't always work.

    I use it just like that.  I open a .bat file that calls vsvars with
    the right settings and then calls msys bash. Find it below:


    @echo off

    call "C:/Program Files (x86)/Microsoft Visual Studio
    14.0/VC/vcvarsall.bat" amd64 8.1
    C:
    C:\MinGW\msys\1.0\msys.bat -rxvt

    Then I call cmake and ninja with a bash script (both are in the bash
    PATH).  Find it attached.


    --

    Gonzalo Garramuño

--
    Powered by www.kitware.com <http://www.kitware.com>

    Please keep messages on-topic and check the CMake FAQ at:
    http://www.cmake.org/Wiki/CMake_FAQ

    Kitware offers various services to support the CMake community. For
    more information on each offering, please visit:

    CMake Support: http://cmake.org/cmake/help/support.html
    CMake Consulting: http://cmake.org/cmake/help/consulting.html
    CMake Training Courses: http://cmake.org/cmake/help/training.html

    Visit other Kitware open-source projects at
    http://www.kitware.com/opensource/opensource.html

    Follow this link to subscribe/unsubscribe:
    https://cmake.org/mailman/listinfo/cmake



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to