When I tried to run cmake
, it did generate a bunch of files but no MakeFile was created.
CMakeLists.txt
PROJECT(main)
CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
AUX_SOURCE_DIRECTORY(. DIR_SRCS)
ADD_EXECUTABLE(main ${DIR_SRCS})
main.c
int main()
{
return 0;
}
After running cmake
in cmd, it gives me this
E:\practiceFolder\cake>cmake .
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18362.
-- The C compiler identification is MSVC 19.21.27702.2
-- The CXX compiler identification is MSVC 19.21.27702.2
-- Check for working C compiler: D:/VisualStudio2019/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: D:/VisualStudio2019/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/VisualStudio2019/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: D:/VisualStudio2019/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: E:/practiceFolder/cake
After that the some files are generated
E:.
│ ALL_BUILD.vcxproj
│ ALL_BUILD.vcxproj.filters
│ CMakeCache.txt
│ CMakeLists.txt
│ cmake_install.cmake
│ main.c
│ main.sln
│ main.vcxproj
│ main.vcxproj.filters
│ ZERO_CHECK.vcxproj
│ ZERO_CHECK.vcxproj.filters
│
└─CMakeFiles
│ cmake.check_cache
│ CMakeOutput.log
│ generate.stamp
│ generate.stamp.depend
│ generate.stamp.list
│ TargetDirectories.txt
│
├─3.16.2
and some other files
Cannot find MakeFile in it. Probably some obvious mistakes here but I just can't find it. I've been stuck here for hours, any help would be appreciated, thank you!
CMake generates a Unix makefile by default when run from the command line in a Unix-like environment. Of course, you can generate makefiles explicitly using the -G option. When generating a makefile, you should also define the CMAKE_BUILD_TYPE variable.
CMake will create makefiles inside many of the folders inside a build directory and you can run make or make -j8 in any of these directories and it will do the right thing. You can even run make in your src tree, but since there is no Makefile in your source tree, only CMakeLists.
Make (or rather a Makefile) is a buildsystem - it drives the compiler and other build tools to build your code. CMake is a generator of buildsystems. It can produce Makefiles, it can produce Ninja build files, it can produce KDEvelop or Xcode projects, it can produce Visual Studio solutions.
In a Unix-like platform, running cmake and then make creates the Makefiles by default. This is not the case on Windows. On Windows, CMake generates an MSVC solution by default. Check for a .sln file in your build directory. If you actually want Makefiles on Windows, add -G "Unix Makefiles" to the cmake line.
On Windows, CMake generates an MSVC solution by default. Check for a .sln file in your build directory. If you actually want Makefiles on Windows, add -G "Unix Makefiles" to the cmake line. If you want to use MSVC as compiler but work on the command line, another option is -G "NMake Makefiles", and calling make after that.
Use CMake and Make, when sh.exe is in PATH on Windows. Use CMake and Make, when sh.exe is in PATH on WindowsJuly 3, 2017. In order to be trapped by this problem your project / environment has to meet following conditions: You need to use Windows. Your project uses make as a base build system. You have available sh.exe as a system command.
If you actually want Makefiles on Windows, add -G "Unix Makefiles" to the cmake line. If you want to use MSVC as compiler but work on the command line, another option is -G "NMake Makefiles", and calling make after that. Make sure to delete your build directory before trying to build a new generator target.
In a Unix-like platform, running cmake
and then make
creates the Makefiles by default. This is not the case on Windows.
On Windows, CMake generates an MSVC solution by default. Check for a .sln
file in your build directory.
If you actually want Makefiles on Windows, add -G "Unix Makefiles"
to the cmake
line.
If you want to use MSVC as compiler but work on the command line, another option is -G "NMake Makefiles"
, and calling make
after that.
Make sure to delete your build directory before trying to build a new generator target. CMake can be touchy about that.
Check cmake --help
for a list of available options. (Especially the generator targets are platform-specific.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With