CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2000
    Location
    Germany
    Posts
    122

    Problem Running CMake on Windows11 with MinGW compiler

    I have trouble making CMake do its thing.

    I have Win11 and am using MinGW for the c++ compiler. I have no Visual Studio.

    --------------------------------------------

    The CMakeLists.txt file is :

    Code:
    set(CMAKE_MAKE_PROGRAM "C:/msys64/mingw64/bin/mingw32-make.exe")
    set(CMAKE_C_COMPILER "C:/msys64/mingw64/bin/gcc.exe")
    set(CMAKE_CXX_COMPILER "C:/msys64/mingw64/bin/g++.exe")
    
    cmake_minimum_required(VERSION 3.0)
    
    project(C:/CMake_Projects/Test1)
    
    add_executable(Test1 test1.cpp)
    ---------------------------------------------

    The batch file I use to start everything is runMakers.bat :

    Code:
    mkdir build
    cd build
    cmake ..
    pause
    -------------------------------------------

    in the runMakers.bat file I have distinctly not put in a run "mingw32-make" command

    However, this is the error I receive when running this :

    C:\CMake_Projects\Test1\build>cmake ..
    -- Building for: NMake Makefiles <----------------------- very strange, I don't have Visula Studio and NMake
    CMake Error at CMakeLists.txt:8 (project):
    Running

    'C:/msys64/mingw64/bin/mingw32-make.exe' '-?'

    failed with:

    C:/msys64/mingw64/bin/mingw32-make.exe: invalid option -- ?

    Usage: mingw32-make [options] [target] ...

    Options:

    -b, -m Ignored for compatibility.
    -B, --always-make Unconditionally make all targets.
    -C DIRECTORY, --directory=DIRECTORY
    Change to DIRECTORY before doing anything.
    -d Print lots of debugging information.
    --debug[=FLAGS] Print various types of debugging information.
    -e, --environment-overrides
    Environment variables override makefiles.
    -E STRING, --eval=STRING Evaluate STRING as a makefile statement.
    -f FILE, --file=FILE, --makefile=FILE
    Read FILE as a makefile.
    -h, --help Print this message and exit.
    -i, --ignore-errors Ignore errors from recipes.
    -I DIRECTORY, --include-dir=DIRECTORY
    Search DIRECTORY for included makefiles.
    -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
    -k, --keep-going Keep going when some targets can't be made.
    -l [N], --load-average[=N], --max-load[=N]
    Don't start multiple jobs unless load is below N.
    -L, --check-symlink-times Use the latest mtime between symlinks and target.
    -n, --just-print, --dry-run, --recon
    Don't actually run any recipe; just print them.
    -o FILE, --old-file=FILE, --assume-old=FILE
    Consider FILE to be very old and don't remake it.
    -O[TYPE], --output-sync[=TYPE]
    Synchronize output of parallel jobs by TYPE.
    -p, --print-data-base Print make's internal database.
    -q, --question Run no recipe; exit status says if up to date.
    -r, --no-builtin-rules Disable the built-in implicit rules.
    -R, --no-builtin-variables Disable the built-in variable settings.
    -s, --silent, --quiet Don't echo recipes.
    --no-silent Echo recipes (disable --silent mode).
    -S, --no-keep-going, --stop
    Turns off -k.
    -t, --touch Touch targets instead of remaking them.
    --trace Print tracing information.
    -v, --version Print the version number of make and exit.
    -w, --print-directory Print the current directory.
    --no-print-directory Turn off -w, even if it was turned on implicitly.
    -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
    Consider FILE to be infinitely new.
    --warn-undefined-variables Warn when an undefined variable is referenced.



    This program built for Windows32

    Report bugs to <bug-make@gnu.org>



    -- Configuring incomplete, errors occurred!

    C:\CMake_Projects\Test1\build>pause

    -------------------------------------------------------------------

    It seems to want to run the mingw32-make.exe by itself and doesn't have the desired paramters.

    Where do I write the parameters "-f makefile-that-cmake-constructed-please"

    Thanks for any tips.
    Klatau Broada Nektau

  2. #2
    Join Date
    Oct 2023
    Posts
    1

    Re: Problem Running CMake on Windows11 with MinGW compiler

    Quote Originally Posted by Albatross View Post
    I have trouble making CMake do its thing.

    I have Win11 and am using MinGW for the c++ compiler. I have no Visual Studio.

    --------------------------------------------

    The CMakeLists.txt file is :

    Code:
    set(CMAKE_MAKE_PROGRAM "C:/msys64/mingw64/bin/mingw32-make.exe")
    set(CMAKE_C_COMPILER "C:/msys64/mingw64/bin/gcc.exe")
    set(CMAKE_CXX_COMPILER "C:/msys64/mingw64/bin/g++.exe")
    
    cmake_minimum_required(VERSION 3.0)
    
    project(C:/CMake_Projects/Test1)
    
    add_executable(Test1 test1.cpp)
    ---------------------------------------------

    The batch file I use to start uno online everything is runMakers.bat :

    Code:
    mkdir build
    cd build
    cmake ..
    pause
    -------------------------------------------

    in the runMakers.bat file I have distinctly not put in a run "mingw32-make" command

    However, this is the error I receive when running this :

    C:\CMake_Projects\Test1\build>cmake ..
    -- Building for: NMake Makefiles <----------------------- very strange, I don't have Visula Studio and NMake
    CMake Error at CMakeLists.txt:8 (project):
    Running

    'C:/msys64/mingw64/bin/mingw32-make.exe' '-?'

    failed with:

    C:/msys64/mingw64/bin/mingw32-make.exe: invalid option -- ?

    Usage: mingw32-make [options] [target] ...

    Options:

    -b, -m Ignored for compatibility.
    -B, --always-make Unconditionally make all targets.
    -C DIRECTORY, --directory=DIRECTORY
    Change to DIRECTORY before doing anything.
    -d Print lots of debugging information.
    --debug[=FLAGS] Print various types of debugging information.
    -e, --environment-overrides
    Environment variables override makefiles.
    -E STRING, --eval=STRING Evaluate STRING as a makefile statement.
    -f FILE, --file=FILE, --makefile=FILE
    Read FILE as a makefile.
    -h, --help Print this message and exit.
    -i, --ignore-errors Ignore errors from recipes.
    -I DIRECTORY, --include-dir=DIRECTORY
    Search DIRECTORY for included makefiles.
    -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
    -k, --keep-going Keep going when some targets can't be made.
    -l [N], --load-average[=N], --max-load[=N]
    Don't start multiple jobs unless load is below N.
    -L, --check-symlink-times Use the latest mtime between symlinks and target.
    -n, --just-print, --dry-run, --recon
    Don't actually run any recipe; just print them.
    -o FILE, --old-file=FILE, --assume-old=FILE
    Consider FILE to be very old and don't remake it.
    -O[TYPE], --output-sync[=TYPE]
    Synchronize output of parallel jobs by TYPE.
    -p, --print-data-base Print make's internal database.
    -q, --question Run no recipe; exit status says if up to date.
    -r, --no-builtin-rules Disable the built-in implicit rules.
    -R, --no-builtin-variables Disable the built-in variable settings.
    -s, --silent, --quiet Don't echo recipes.
    --no-silent Echo recipes (disable --silent mode).
    -S, --no-keep-going, --stop
    Turns off -k.
    -t, --touch Touch targets instead of remaking them.
    --trace Print tracing information.
    -v, --version Print the version number of make and exit.
    -w, --print-directory Print the current directory.
    --no-print-directory Turn off -w, even if it was turned on implicitly.
    -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
    Consider FILE to be infinitely new.
    --warn-undefined-variables Warn when an undefined variable is referenced.



    This program built for Windows32

    Report bugs to <bug-make@gnu.org>



    -- Configuring incomplete, errors occurred!

    C:\CMake_Projects\Test1\build>pause

    -------------------------------------------------------------------

    It seems to want to run the mingw32-make.exe by itself and doesn't have the desired paramters.

    Where do I write the parameters "-f makefile-that-cmake-constructed-please"

    Thanks for any tips.
    In your CMakeLists.txt file, you can specify the generator for CMake using the CMAKE_GENERATOR variable. Since you're using MinGW, you can set it to "MinGW Makefiles" to generate makefiles compatible with MinGW. Modify your CMakeLists.txt file as follows:


    set(CMAKE_MAKE_PROGRAM "C:/msys64/mingw64/bin/mingw32-make.exe")
    set(CMAKE_C_COMPILER "C:/msys64/mingw64/bin/gcc.exe")
    set(CMAKE_CXX_COMPILER "C:/msys64/mingw64/bin/g++.exe")

    cmake_minimum_required(VERSION 3.0)

    project(Test1)

    # Set the generator to MinGW Makefiles
    set(CMAKE_GENERATOR "MinGW Makefiles")

    add_executable(Test1 test1.cpp)
    With this modification, when you run cmake .. in your batch file, it should generate makefiles for MinGW.

  3. #3
    Join Date
    Apr 2000
    Location
    Germany
    Posts
    122

    Re: Problem Running CMake on Windows11 with MinGW compiler

    Thank you for the help. I'll try this out.
    Klatau Broada Nektau

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured