Code::Blocks Forums

User forums => Help => Topic started by: Frank_CB on November 09, 2018, 07:45:56 pm

Title: [Resolved] Using Cmake on Windows 10
Post by: Frank_CB on November 09, 2018, 07:45:56 pm
Hello,

Can use Cmake's visual studio generator "Visual Studio 15 2017 Win64" from both the commandline and gui to create a solution (.sln). I can then open either solution in VS15 Community and finish building the executable. Opening either VS .sln in CB 17.12, and adding the appropriate information, I am also able to build the executable with CB.  All the executable(s) run on my 64-bit platform.

But, I am having no luck using the generator for CB ("CodeBlocks - NMake Makefiles").  While it completes from the commandline, opening the .cbp project in CB gives me garbage that references VS. The gui never gets out of the starting blocks.

Is anyone able to use Cmake to successfully generate makefiles and/or CB project file(s) in Windows.  If so, can you provide a reference to documentation the covers the process? Neither CB's forums or wiki do an adequate job in my opinion.

Regards,
Frank
Title: Re: Using Cmake on Windows 10
Post by: stahta01 on November 10, 2018, 08:03:59 am
Did you try using nmake to run the makefile? If not, do so.

Edit: You do know that error messages give information; if you fail to post that information, most people will guess it is likely an user error.

Edit2: Link to docs https://cmake.org/documentation/ (https://cmake.org/documentation/)

Tim S.
Title: Re: Using Cmake on Windows 10
Post by: oBFusCATed on November 10, 2018, 10:28:34 am
Frank_CB: I'm not sure if you're supposed to use this generator. Have you tried to use any of the CodeBlocks based generators? They work well on linux, but I've not tested them on windows...
Title: Re: Using Cmake on Windows 10
Post by: Frank_CB on November 10, 2018, 06:44:44 pm
@Stahta01
NMake is the make utility for Windows. Cmake-gui never makes a makefile.
@oBFusCATed
Cmake Help only shows three possible generators for CB.
Code: html5
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Options
  -S <path-to-source>          = Explicitly specify a source directory.
  -B <path-to-build>           = Explicitly specify a build directory.
  -C <initial-cache>           = Pre-load a script to populate the cache.
  -D <var>[:<type>]=<value>    = Create or update a cmake cache entry.
  -U <globbing_expr>           = Remove matching entries from CMake cache.
  -G <generator-name>          = Specify a build system generator.
  -T <toolset-name>            = Specify toolset name if supported by
                                 generator.
  -A <platform-name>           = Specify platform name if supported by
                                 generator.
  -Wdev                        = Enable developer warnings.
  -Wno-dev                     = Suppress developer warnings.
  -Werror=dev                  = Make developer warnings errors.
  -Wno-error=dev               = Make developer warnings not errors.
  -Wdeprecated                 = Enable deprecation warnings.
  -Wno-deprecated              = Suppress deprecation warnings.
  -Werror=deprecated           = Make deprecated macro and function warnings
                                 errors.
  -Wno-error=deprecated        = Make deprecated macro and function warnings
                                 not errors.
  -E                           = CMake command mode.
  -L[A][H]                     = List non-advanced cached variables.
  --build <dir>                = Build a CMake-generated project binary tree.
  --open <dir>                 = Open generated project in the associated
                                 application.
  -N                           = View mode only.
  -P <file>                    = Process script mode.
  --find-package               = Run in pkg-config like mode.
  --graphviz=[file]            = Generate graphviz of dependencies, see
                                 CMakeGraphVizOptions.cmake for more.
  --system-information [file]  = Dump information about this system.
  --debug-trycompile           = Do not delete the try_compile build tree.
                                 Only useful on one try_compile at a time.
  --debug-output               = Put cmake in a debug mode.
  --trace                      = Put cmake in trace mode.
  --trace-expand               = Put cmake in trace mode with variable
                                 expansion.
  --trace-source=<file>        = Trace only this CMake file/module.  Multiple
                                 options allowed.
  --warn-uninitialized         = Warn about uninitialized values.
  --warn-unused-vars           = Warn about unused variables.
  --no-warn-unused-cli         = Don't warn about command line options.
  --check-system-vars          = Find problems with variable usage in system
                                 files.
  --help,-help,-usage,-h,-H,/? = Print usage information and exit.
  --version,-version,/V [<f>]  = Print version number and exit.
  --help-full [<f>]            = Print all help manuals and exit.
  --help-manual <man> [<f>]    = Print one help manual and exit.
  --help-manual-list [<f>]     = List help manuals available and exit.
  --help-command <cmd> [<f>]   = Print help for one command and exit.
  --help-command-list [<f>]    = List commands with help available and exit.
  --help-commands [<f>]        = Print cmake-commands manual and exit.
  --help-module <mod> [<f>]    = Print help for one module and exit.
  --help-module-list [<f>]     = List modules with help available and exit.
  --help-modules [<f>]         = Print cmake-modules manual and exit.
  --help-policy <cmp> [<f>]    = Print help for one policy and exit.
  --help-policy-list [<f>]     = List policies with help available and exit.
  --help-policies [<f>]        = Print cmake-policies manual and exit.
  --help-property <prop> [<f>] = Print help for one property and exit.
  --help-property-list [<f>]   = List properties with help available and
                                 exit.
  --help-properties [<f>]      = Print cmake-properties manual and exit.
  --help-variable var [<f>]    = Print help for one variable and exit.
  --help-variable-list [<f>]   = List variables with help available and exit.
  --help-variables [<f>]       = Print cmake-variables manual and exit.

Generators

The following generators are available on this platform:
  Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
                                 Optional [arch] can be "Win64" or "IA64".
  Visual Studio 9 2008 [arch]  = Generates Visual Studio 2008 project files.
                                 Optional [arch] can be "Win64" or "IA64".
  Borland Makefiles            = Generates Borland makefiles.
  NMake Makefiles              = Generates NMake makefiles.
  NMake Makefiles JOM          = Generates JOM makefiles.
  Green Hills MULTI            = Generates Green Hills MULTI files
                                 (experimental, work-in-progress).
  MSYS Makefiles               = Generates MSYS makefiles.
  MinGW Makefiles              = Generates a make file for use with
                                 mingw32-make.
  Unix Makefiles               = Generates standard UNIX makefiles.
  Ninja                        = Generates build.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
  CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
  CodeBlocks - NMake Makefiles JOM
                               = Generates CodeBlocks project files.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - MinGW Makefiles   = Generates CodeLite project files.
  CodeLite - NMake Makefiles   = Generates CodeLite project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Sublime Text 2 - MinGW Makefiles
                               = Generates Sublime Text 2 project files.
  Sublime Text 2 - NMake Makefiles
                               = Generates Sublime Text 2 project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.
  Kate - MinGW Makefiles       = Generates Kate project files.
  Kate - NMake Makefiles       = Generates Kate project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Eclipse CDT4 - NMake Makefiles
                               = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - MinGW Makefiles
                               = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.


The two that reference NMake(used by Windows) both generate similar error logs.
The error and output logs follow:
Error-
Code: html5
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
Build flags: /DWIN32;/D_WINDOWS;/W3
Id flags: 

The output was:
2
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

CMakeCCompilerId.c
Microsoft (R) Incremental Linker Version 14.15.26732.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:CMakeCCompilerId.exe
CMakeCCompilerId.obj
LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
Build flags:
Id flags: 

The output was:
2
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

CMakeCXXCompilerId.cpp
Microsoft (R) Incremental Linker Version 14.15.26732.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:CMakeCXXCompilerId.exe
CMakeCXXCompilerId.obj
LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'


Determining if the C compiler works failed with the following output:
Change Dir: C:/Users/Frank/CMakeDemo/build/CMakeFiles/CMakeTmp

Run Build Command:"nmake" "/nologo" "cmTC_8f82e\fast"
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64\nmake.exe" -f CMakeFiles\cmTC_8f82e.dir\build.make /nologo -L                  CMakeFiles\cmTC_8f82e.dir\build

Building C object CMakeFiles/cmTC_8f82e.dir/testCCompiler.c.obj

C:\PROGRA~2\MIB055~1\2017\BUILDT~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\cl.exe @C:\Users\Frank\AppData\Local\Temp\nm77A9.tmp

testCCompiler.c

Linking C executable cmTC_8f82e.exe

"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_8f82e.dir --manifests  -- C:\PROGRA~2\MIB055~1\2017\BUILDT~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_8f82e.dir\objects1.rsp @C:\Users\Frank\AppData\Local\Temp\nm78C4.tmp

RC Pass 1: command "rc /foCMakeFiles\cmTC_8f82e.dir/manifest.res CMakeFiles\cmTC_8f82e.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\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64\nmake.exe"' : return code '0x2'

Stop.

Output-
Code: html5
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
Build flags: /DWIN32;/D_WINDOWS;/W3
Id flags: -c

The output was:
0
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

CMakeCCompilerId.c


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.obj"

The C compiler identification is MSVC, found in "C:/Users/Frank/CMakeDemo/build/CMakeFiles/3.13.0-rc2/CompilerIdC/CMakeCCompilerId.obj"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
Build flags:
Id flags: -c

The output was:
0
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

CMakeCXXCompilerId.cpp


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.obj"

The CXX compiler identification is MSVC, found in "C:/Users/Frank/CMakeDemo/build/CMakeFiles/3.13.0-rc2/CompilerIdCXX/CMakeCXXCompilerId.obj"


Hope this helps?!  If I can provide any more information, please ask?

Regards,
Frank
Title: Re: Using Cmake on Windows 10
Post by: oBFusCATed on November 10, 2018, 10:08:16 pm
Here we don't provide support for cmake related problems. You should find such a place... There someone might be able to help you.
Title: Re: Using Cmake on Windows 10
Post by: stahta01 on November 10, 2018, 10:10:14 pm
@Stahta01
NMake is the make utility for Windows. Cmake-gui never makes a makefile.
Usage

So, you not using an CMake that I have used in the past which made makefiles for CB.

Note: I think you are likely very wrong in your opinion; and, not worth my time to try to help.
Partly because I think you need an CMake expert to help you; And, because I see no Code::Blocks problem that I can help you solve.

Tim S.
Title: Re: Using Cmake on Windows 10
Post by: Frank_CB on November 10, 2018, 11:02:37 pm
@oBFusCATed
Thanks for your comments!  Cmake's mailing lists haven't replied yet (and probably never will).
@stahta01
Thanks for your comments.  My opinion about cmake-gui not making making makefiles only pertained to my current problem.

Regards,
Frank
Title: Re: Using Cmake on Windows 10
Post by: Frank_CB on December 01, 2018, 06:42:45 pm
Found a pdf document on Cmake's github site that covers using cmake, ctest and cpack.

Invoking all commands from the correct command prompt window solved all my issues.  The Cmake icon installed by the installer was apparently for a 32-bit machine, not the 64-bit machine I'm using it on.

Regards,
Frank