-2

I downloaded this Celero library to test my sorting algorithms.

I saw there were sample demos .cpp file with a CMakeLists.txt.

I read about how this works and I think running cmake . makes a Makefile according to the CMakeLists.txt, but when I am inside the demo folder

Celero-master\experiments\DemoSimple

And I run this command I get error

CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
  cmake_minimum_required() should be called prior to this top-level project()
  call.  Please see the cmake-commands(7) manual for usage documentation of
  both commands.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Selecting Windows SDK version  to target Windows 6.2.9200.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error in CMakeLists.txt:
  No CMAKE_C_COMPILER could be found.



CMake Error in CMakeLists.txt:
  No CMAKE_CXX_COMPILER could be found.


CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.26)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

I added these to top of CMakeLists:

set(CMAKE_CXX_COMPILER "D:/Downloads/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/bin/g++.exe")
set(CMAKE_C_COMPILER "D:/Downloads/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/bin/gcc.exe")

...but I still get the same error.

How do build demos from the Celero project?

EDIT 1:

After running cmake . from root I get this error

-- Selecting Windows SDK version  to target Windows 6.2.9200.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: D:Downloads/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/bin/gcc.exe
-- Check for working C compiler: D:Downloads/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/bin/gcc.exe - broken
CMake Error at C:/Program Files/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/share/cmake-3.26/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "D:Downloads/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/bin/gcc.exe" 

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/HomePC/Desktop/New folder (2)/Celero-master/Celero-master/CMakeFiles/CMakeScratch/TryCompile-60nkgv

    Run Build Command(s):D:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_25446.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n && MSBuild version 17.5.1+f6fdcf537 for .NET Framework
    Build started 5/24/2023 12:47:30 AM.
    Included response file: D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.rsp

    Project "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\cmTC_25446.vcxproj" on node 1 (default targets).
    PrepareForBuild:
      Creating directory "cmTC_25446.dir\Debug\".
    D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(499,5): warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found. [C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\cmTC_25446.vcxproj]
      Creating directory "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\Debug\".
      Creating directory "cmTC_25446.dir\Debug\cmTC_25446.tlog\".
    InitializeBuildStatus:
      Creating "cmTC_25446.dir\Debug\cmTC_25446.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.   
    ClCompile:
      D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\CL.exe /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_25446.dir\Debug\\" /Fd"cmTC_25446.dir\Debug\vc143.pdb" /external:W1 /Gd /TC /errorReport:queue "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\testCCompiler.c"
      Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32216.1 for x64
      testCCompiler.c
      Copyright (C) Microsoft Corporation.  All rights reserved.
      cl /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_25446.dir\Debug\\" /Fd"cmTC_25446.dir\Debug\vc143.pdb" /external:W1 /Gd /TC /errorReport:queue "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\testCCompiler.c"
    Link:
      D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\Debug\cmTC_25446.exe" /INCREMENTAL /ILK:"cmTC_25446.dir\Debug\cmTC_25446.ilk" /NOLOGO /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"C:/Users/HomePC/Desktop/New folder (2)/Celero-master/Celero-master/CMakeFiles/CMakeScratch/TryCompile-60nkgv/Debug/cmTC_25446.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Users/HomePC/Desktop/New folder (2)/Celero-master/Celero-master/CMakeFiles/CMakeScratch/TryCompile-60nkgv/Debug/cmTC_25446.lib" /MACHINE:X64 cmTC_25446.dir\Debug\testCCompiler.obj
    LINK : fatal error LNK1104: cannot open file 'kernel32.lib' [C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\cmTC_25446.vcxproj]
    Done Building Project "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\cmTC_25446.vcxproj" (default targets) -- FAILED.

    Build FAILED.

    "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\cmTC_25446.vcxproj" (default target) (1) ->
    (PrepareForBuild target) ->
      D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(499,5): warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found. [C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\cmTC_25446.vcxproj]


    "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\cmTC_25446.vcxproj" (default target) (1) ->
    (Link target) ->
      LINK : fatal error LNK1104: cannot open file 'kernel32.lib' [C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-60nkgv\cmTC_25446.vcxproj]

        1 Warning(s)
        1 Error(s)

    Time Elapsed 00:00:00.63





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


-- Configuring incomplete, errors occurred!
PS C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master> cmake .
-- Selecting Windows SDK version  to target Windows 6.2.9200.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: D:Downloads/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/bin/gcc.exe
-- Check for working C compiler: D:Downloads/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/bin/gcc.exe - broken
CMake Error at C:/Program Files/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/share/cmake-3.26/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "D:Downloads/winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-16.0.0-mingw-w64msvcrt-10.0.0-r5/mingw64/bin/gcc.exe" 

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/HomePC/Desktop/New folder (2)/Celero-master/Celero-master/CMakeFiles/CMakeScratch/TryCompile-nfx358
    
    Run Build Command(s):D:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_5c4b2.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n && MSBuild version 17.5.1+f6fdcf537 for .NET Framework
    Build started 5/24/2023 12:52:38 AM.
    Included response file: D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.rsp

    Project "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx358\cmTC_5c4b2.vcxproj" on node 1 (default targets).
    PrepareForBuild:
      Creating directory "cmTC_5c4b2.dir\Debug\".
    D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(499,5): warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found. [C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx358\cmTC_5c4b2.vcxproj]
      Creating directory "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx358\Debug\".
      Creating directory "cmTC_5c4b2.dir\Debug\cmTC_5c4b2.tlog\".
    InitializeBuildStatus:
      Creating "cmTC_5c4b2.dir\Debug\cmTC_5c4b2.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.   
    ClCompile:
      D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\CL.exe /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_5c4b2.dir\Debug\\" /Fd"cmTC_5c4b2.dir\Debug\vc143.pdb" /external:W1 /Gd /TC /errorReport:queue "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx358\testCCompiler.c"
      Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32216.1 for x64
      testCCompiler.c
      Copyright (C) Microsoft Corporation.  All rights reserved.
      cl /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_5c4b2.dir\Debug\\" /Fd"cmTC_5c4b2.dir\Debug\vc143.pdb" /external:W1 /Gd /TC /errorReport:queue "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx358\testCCompiler.c"
    Link:
      D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx358\Debug\cmTC_5c4b2.exe" /INCREMENTAL /ILK:"cmTC_5c4b2.dir\Debug\cmTC_5c4b2.ilk" /NOLOGO /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"C:/Users/HomePC/Desktop/New folder (2)/Celero-master/Celero-master/CMakeFiles/CMakeScratch/TryCompile-nfx358/Debug/cmTC_5c4b2.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Users/HomePC/Desktop/New folder (2)/Celero-master/Celero-master/CMakeFiles/CMakeScratch/TryCompile-nfx358/Debug/cmTC_5c4b2.lib" /MACHINE:X64 cmTC_5c4b2.dir\Debug\testCCompiler.obj
    LINK : fatal error LNK1104: cannot open file 'kernel32.lib' [C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx358\cmTC_5c4b2.vcxproj]
    Done Building Project "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx358\cmTC_5c4b2.vcxproj" (default targets) -- FAILED.

    Build FAILED.

    "C:\Users\HomePC\Desktop\New folder (2)\Celero-master\Celero-master\CMakeFiles\CMakeScratch\TryCompile-nfx35


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


-- Configuring incomplete, errors occurred!
genpfault
  • 51,148
  • 11
  • 85
  • 139
  • `Celero-master\experiments\DemoSimple` This is part of your problem. Run CMake from the root folder and not a subfolder. The CMakeLists.txt in the root folder has the cmake_minimum_required() on line 24: [https://github.com/DigitalInBlue/Celero/blob/master/CMakeLists.txt#LL24C1-L24C38](https://github.com/DigitalInBlue/Celero/blob/master/CMakeLists.txt#LL24C1-L24C38) – drescherjm May 23 '23 at 19:15
  • Read the warnings in the output. Since you didn't add the `project()` command, CMake just assumes there is one at the top of the `CMakeLists.txt` file, i.e. before you set the compiler variables. It's bad practice to define them in your `CMakeLists.txt` anyways. Use a toolchain file for this purpose instead. – fabian May 23 '23 at 19:17
  • @drescherjm I ran from root, still does not work. – Parth Sharma May 23 '23 at 19:19
  • put (move) your new problem into a new question post. And please _research first_ to see if it has already been asked before. – starball May 23 '23 at 19:31
  • The new problem should have duplicates. My advice is to use msys2 to install MinGW instead and run CMake from the mingw64 terminal as this seems to cause me the least amount of problems. With that said I primarily use as a software developer is msvc in Visual Studio. My MinGW experience is mostly limited to helping others and small projects at home. – drescherjm May 23 '23 at 19:44
  • `LINK : fatal error LNK1104: cannot open file 'kernel32.lib'` -> https://stackoverflow.com/questions/39514632/error-cannot-open-file-kernel32-lib. And MinGW compiler, as you tried to specify, will never work with Visual Studio. For use that compiler you need to choose "MinGW Makefiles" [CMake generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) – Tsyvarev May 23 '23 at 21:00

1 Answers1

1

You're trying to configure a buildsystem from an individual example's CMakeLists.txt, but from looking at the CMakeLists.txt you're trying to use as a project configuration, it wasn't written to be that way. It looks like it was written so that you generate a buildsystem for the CMakeLists.txt at the root of the repo, and then you build the experiment targets.

See also the line in the root CMakeLists.txt (https://github.com/DigitalInBlue/Celero/blob/master/CMakeLists.txt) that says option(CELERO_ENABLE_EXPERIMENTS "Set to ON to automatically build all examples." OFF), and the line that does add_subdirectory(experiments).

In https://github.com/DigitalInBlue/Celero/blob/master/experiments/CMakeLists.txt, it only adds individual experiment subdirectories if you set the CELERO_ENABLE_EXPERIMENTS option to ON. So you need to set it to ON (you can do that in your configure command with -D (-DCELERO_ENABLE_EXPERIMENTS=ON)).

https://github.com/DigitalInBlue/Celero/blob/master/experiments/DemoSimple/CMakeLists.txt has SET(PROJECT_NAME CeleroDemo-Simple) and add_executable(${PROJECT_NAME} ..., so once you've generated the root buildsystem, you can do cmake --build <build_dir> --target CeleroDemo-Simple.

starball
  • 20,030
  • 7
  • 43
  • 238