Author Topic: [Resolved] Using Cmake on Windows 10  (Read 465 times)

Offline Frank_CB

  • Multiple posting newcomer
  • *
  • Posts: 23
[Resolved] Using Cmake on Windows 10
« 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
« Last Edit: December 01, 2018, 06:45:16 pm by Frank_CB »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6368
    • My Best Post
Re: Using Cmake on Windows 10
« Reply #1 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/

Tim S.
« Last Edit: November 10, 2018, 10:14:53 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11279
    • Travis build status
Re: Using Cmake on Windows 10
« Reply #2 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...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Frank_CB

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Using Cmake on Windows 10
« Reply #3 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
  1. Usage
  2.  
  3.   cmake [options] <path-to-source>
  4.   cmake [options] <path-to-existing-build>
  5.   cmake [options] -S <path-to-source> -B <path-to-build>
  6.  
  7. Specify a source directory to (re-)generate a build system for it in the
  8. current working directory.  Specify an existing build directory to
  9. re-generate its build system.
  10.  
  11. Options
  12.   -S <path-to-source>          = Explicitly specify a source directory.
  13.   -B <path-to-build>           = Explicitly specify a build directory.
  14.   -C <initial-cache>           = Pre-load a script to populate the cache.
  15.   -D <var>[:<type>]=<value>    = Create or update a cmake cache entry.
  16.   -U <globbing_expr>           = Remove matching entries from CMake cache.
  17.   -G <generator-name>          = Specify a build system generator.
  18.   -T <toolset-name>            = Specify toolset name if supported by
  19.                                  generator.
  20.   -A <platform-name>           = Specify platform name if supported by
  21.                                  generator.
  22.   -Wdev                        = Enable developer warnings.
  23.   -Wno-dev                     = Suppress developer warnings.
  24.   -Werror=dev                  = Make developer warnings errors.
  25.   -Wno-error=dev               = Make developer warnings not errors.
  26.   -Wdeprecated                 = Enable deprecation warnings.
  27.   -Wno-deprecated              = Suppress deprecation warnings.
  28.   -Werror=deprecated           = Make deprecated macro and function warnings
  29.                                  errors.
  30.   -Wno-error=deprecated        = Make deprecated macro and function warnings
  31.                                  not errors.
  32.   -E                           = CMake command mode.
  33.   -L[A][H]                     = List non-advanced cached variables.
  34.   --build <dir>                = Build a CMake-generated project binary tree.
  35.   --open <dir>                 = Open generated project in the associated
  36.                                  application.
  37.   -N                           = View mode only.
  38.   -P <file>                    = Process script mode.
  39.   --find-package               = Run in pkg-config like mode.
  40.   --graphviz=[file]            = Generate graphviz of dependencies, see
  41.                                  CMakeGraphVizOptions.cmake for more.
  42.   --system-information [file]  = Dump information about this system.
  43.   --debug-trycompile           = Do not delete the try_compile build tree.
  44.                                  Only useful on one try_compile at a time.
  45.   --debug-output               = Put cmake in a debug mode.
  46.   --trace                      = Put cmake in trace mode.
  47.   --trace-expand               = Put cmake in trace mode with variable
  48.                                  expansion.
  49.   --trace-source=<file>        = Trace only this CMake file/module.  Multiple
  50.                                  options allowed.
  51.   --warn-uninitialized         = Warn about uninitialized values.
  52.   --warn-unused-vars           = Warn about unused variables.
  53.   --no-warn-unused-cli         = Don't warn about command line options.
  54.   --check-system-vars          = Find problems with variable usage in system
  55.                                  files.
  56.   --help,-help,-usage,-h,-H,/? = Print usage information and exit.
  57.   --version,-version,/V [<f>]  = Print version number and exit.
  58.   --help-full [<f>]            = Print all help manuals and exit.
  59.   --help-manual <man> [<f>]    = Print one help manual and exit.
  60.   --help-manual-list [<f>]     = List help manuals available and exit.
  61.   --help-command <cmd> [<f>]   = Print help for one command and exit.
  62.   --help-command-list [<f>]    = List commands with help available and exit.
  63.   --help-commands [<f>]        = Print cmake-commands manual and exit.
  64.   --help-module <mod> [<f>]    = Print help for one module and exit.
  65.   --help-module-list [<f>]     = List modules with help available and exit.
  66.   --help-modules [<f>]         = Print cmake-modules manual and exit.
  67.   --help-policy <cmp> [<f>]    = Print help for one policy and exit.
  68.   --help-policy-list [<f>]     = List policies with help available and exit.
  69.   --help-policies [<f>]        = Print cmake-policies manual and exit.
  70.   --help-property <prop> [<f>] = Print help for one property and exit.
  71.   --help-property-list [<f>]   = List properties with help available and
  72.                                  exit.
  73.   --help-properties [<f>]      = Print cmake-properties manual and exit.
  74.   --help-variable var [<f>]    = Print help for one variable and exit.
  75.   --help-variable-list [<f>]   = List variables with help available and exit.
  76.   --help-variables [<f>]       = Print cmake-variables manual and exit.
  77.  
  78. Generators
  79.  
  80. The following generators are available on this platform:
  81.   Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
  82.                                  Optional [arch] can be "Win64" or "ARM".
  83.   Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
  84.                                  Optional [arch] can be "Win64" or "ARM".
  85.   Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
  86.                                  Optional [arch] can be "Win64" or "ARM".
  87.   Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
  88.                                  Optional [arch] can be "Win64" or "ARM".
  89.   Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
  90.                                  Optional [arch] can be "Win64" or "IA64".
  91.   Visual Studio 9 2008 [arch]  = Generates Visual Studio 2008 project files.
  92.                                  Optional [arch] can be "Win64" or "IA64".
  93.   Borland Makefiles            = Generates Borland makefiles.
  94.   NMake Makefiles              = Generates NMake makefiles.
  95.   NMake Makefiles JOM          = Generates JOM makefiles.
  96.   Green Hills MULTI            = Generates Green Hills MULTI files
  97.                                  (experimental, work-in-progress).
  98.   MSYS Makefiles               = Generates MSYS makefiles.
  99.   MinGW Makefiles              = Generates a make file for use with
  100.                                  mingw32-make.
  101.   Unix Makefiles               = Generates standard UNIX makefiles.
  102.   Ninja                        = Generates build.ninja files.
  103.   Watcom WMake                 = Generates Watcom WMake makefiles.
  104.   CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
  105.   CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
  106.   CodeBlocks - NMake Makefiles JOM
  107.                                = Generates CodeBlocks project files.
  108.   CodeBlocks - Ninja           = Generates CodeBlocks project files.
  109.   CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  110.   CodeLite - MinGW Makefiles   = Generates CodeLite project files.
  111.   CodeLite - NMake Makefiles   = Generates CodeLite project files.
  112.   CodeLite - Ninja             = Generates CodeLite project files.
  113.   CodeLite - Unix Makefiles    = Generates CodeLite project files.
  114.   Sublime Text 2 - MinGW Makefiles
  115.                                = Generates Sublime Text 2 project files.
  116.   Sublime Text 2 - NMake Makefiles
  117.                                = Generates Sublime Text 2 project files.
  118.   Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  119.   Sublime Text 2 - Unix Makefiles
  120.                                = Generates Sublime Text 2 project files.
  121.   Kate - MinGW Makefiles       = Generates Kate project files.
  122.   Kate - NMake Makefiles       = Generates Kate project files.
  123.   Kate - Ninja                 = Generates Kate project files.
  124.   Kate - Unix Makefiles        = Generates Kate project files.
  125.   Eclipse CDT4 - NMake Makefiles
  126.                                = Generates Eclipse CDT 4.0 project files.
  127.   Eclipse CDT4 - MinGW Makefiles
  128.                                = Generates Eclipse CDT 4.0 project files.
  129.   Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  130.   Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
  131.  
  132.  
  133.  
The two that reference NMake(used by Windows) both generate similar error logs.
The error and output logs follow:
Error-
Code: HTML5
  1. Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
  2. Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
  3. Build flags: /DWIN32;/D_WINDOWS;/W3
  4. Id flags:  
  5.  
  6. The output was:
  7. 2
  8. Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
  9. Copyright (C) Microsoft Corporation.  All rights reserved.
  10.  
  11. CMakeCCompilerId.c
  12. Microsoft (R) Incremental Linker Version 14.15.26732.1
  13. Copyright (C) Microsoft Corporation.  All rights reserved.
  14.  
  15. /out:CMakeCCompilerId.exe
  16. CMakeCCompilerId.obj
  17. LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'
  18.  
  19.  
  20. Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
  21. Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
  22. Build flags:
  23. Id flags:  
  24.  
  25. The output was:
  26. 2
  27. Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
  28. Copyright (C) Microsoft Corporation.  All rights reserved.
  29.  
  30. CMakeCXXCompilerId.cpp
  31. Microsoft (R) Incremental Linker Version 14.15.26732.1
  32. Copyright (C) Microsoft Corporation.  All rights reserved.
  33.  
  34. /out:CMakeCXXCompilerId.exe
  35. CMakeCXXCompilerId.obj
  36. LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'
  37.  
  38.  
  39. Determining if the C compiler works failed with the following output:
  40. Change Dir: C:/Users/Frank/CMakeDemo/build/CMakeFiles/CMakeTmp
  41.  
  42. Run Build Command:"nmake" "/nologo" "cmTC_8f82e\fast"
  43.         "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
  44.  
  45. Building C object CMakeFiles/cmTC_8f82e.dir/testCCompiler.c.obj
  46.  
  47.         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
  48.  
  49. testCCompiler.c
  50.  
  51. Linking C executable cmTC_8f82e.exe
  52.  
  53.         "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
  54.  
  55. 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:
  56. The system cannot find the file specifiedNMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
  57.  
  58. Stop.
  59.  
  60. 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'
  61.  
  62. Stop.
  63.  
  64.  
Output-
Code: HTML5
  1. Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
  2. Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
  3. Build flags: /DWIN32;/D_WINDOWS;/W3
  4. Id flags: -c
  5.  
  6. The output was:
  7. 0
  8. Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
  9. Copyright (C) Microsoft Corporation.  All rights reserved.
  10.  
  11. CMakeCCompilerId.c
  12.  
  13.  
  14. Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.obj"
  15.  
  16. The C compiler identification is MSVC, found in "C:/Users/Frank/CMakeDemo/build/CMakeFiles/3.13.0-rc2/CompilerIdC/CMakeCCompilerId.obj"
  17.  
  18. Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
  19. Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
  20. Build flags:
  21. Id flags: -c
  22.  
  23. The output was:
  24. 0
  25. Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
  26. Copyright (C) Microsoft Corporation.  All rights reserved.
  27.  
  28. CMakeCXXCompilerId.cpp
  29.  
  30.  
  31. Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.obj"
  32.  
  33. The CXX compiler identification is MSVC, found in "C:/Users/Frank/CMakeDemo/build/CMakeFiles/3.13.0-rc2/CompilerIdCXX/CMakeCXXCompilerId.obj"
  34.  
  35.  

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

Regards,
Frank

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11279
    • Travis build status
Re: Using Cmake on Windows 10
« Reply #4 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6368
    • My Best Post
Re: Using Cmake on Windows 10
« Reply #5 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Frank_CB

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Using Cmake on Windows 10
« Reply #6 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

Offline Frank_CB

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Using Cmake on Windows 10
« Reply #7 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