diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-03-15 01:14:30 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-03-15 01:22:29 +0300 |
commit | 9706320d1321c3e05c9e64340eba7603a7e3dcb3 (patch) | |
tree | 6ec9411382b221068d6b9009f9d419ab4f6c37a6 /docs/cmake.md | |
parent | docs: markdownify (diff) | |
download | cmake-common-9706320d1321c3e05c9e64340eba7603a7e3dcb3.tar.gz cmake-common-9706320d1321c3e05c9e64340eba7603a7e3dcb3.zip |
docs: reflow
Diffstat (limited to '')
-rw-r--r-- | docs/cmake.md | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/docs/cmake.md b/docs/cmake.md index e4724b0..cd8a149 100644 --- a/docs/cmake.md +++ b/docs/cmake.md @@ -13,26 +13,26 @@ Makefile generators ------------------- CMake has a number of "... Makefiles" generators. "Unix Makefiles" uses -gmake/make/smake, whichever is found first, and cc/c++ for compiler -detection ([2][2]). "MinGW Makefiles" looks for mingw32-make.exe in a number of -well-known locations, uses gcc/g++ directly, and is aware of windres ([3][3]). In -addition, "Unix Makefiles" uses /bin/sh as the SHELL value in the Makefile, +gmake/make/smake, whichever is found first, and cc/c++ for compiler detection +([2][2]). "MinGW Makefiles" looks for mingw32-make.exe in a number of +well-known locations, uses gcc/g++ directly, and is aware of windres ([3][3]). +In addition, "Unix Makefiles" uses /bin/sh as the SHELL value in the Makefile, while the MinGW version uses cmd.exe. I don't think it matters on Windows though, since the non-existent /bin/sh is ignored anyway ([4][4]). "NMake Makefiles" is similar, except it defaults to using cl ([5][5]). It's important to _not_ use the -A parameter with any of the Makefile generators - it's an error. This goes for "NMake Makefiles" also. "NMake -Makefiles" doesn't attempt to search for installed Visual Studio compilers, -you need to use it from one of the Visual Studio-provided shells. +Makefiles" doesn't attempt to search for installed Visual Studio compilers, you +need to use it from one of the Visual Studio-provided shells. Visual Studio generators ------------------------ These are special. They ignore the CMAKE_\<LANG\>_COMPILER parameters and use cl by default ([9][9]). They support specifying the toolset to use via the -T -parameter (the "Platform Toolset" value in the project's properties) since -3.18 ([10][10]). The toolset list varies between Visual Studio versions, and I'm +parameter (the "Platform Toolset" value in the project's properties) since 3.18 +([10][10]). The toolset list varies between Visual Studio versions, and I'm too lazy to learn exactly which version supports which toolsets. `cmake --build` uses msbuild with Visual Studio generators. You can pass the @@ -40,8 +40,8 @@ path to a different cl.exe by doing something like msbuild ... /p:CLToolExe=another-cl.exe /p:CLToolPath=C:\parent\dir -It's important that the generators for Visual Studio 2017 or older use -Win32 as the default platform ([12][12]). Because of that, we need to pass the -A +It's important that the generators for Visual Studio 2017 or older use Win32 as +the default platform ([12][12]). Because of that, we need to pass the -A parameter. mingw32-make vs make @@ -51,12 +51,12 @@ No idea what the actual differences are. The explanation in the FAQ ([6][6]) about how GNU make "is lacking in some functionality and has modified functionality due to the lack of POSIX on Win32" isn't terribly helpful. -It's important that you can install either on Windows (`choco install make` -for GNU make and `choco install mingw` to install a MinGW-w64 distribution -with mingw32-make.exe included). Personally, I don't see any difference -between using either make.exe or mingw32-make.exe w/ CMake on Windows. But, -since MinGW-w64 distributions do include mingw32-make.exe and not make.exe, -we'll try to detect that. +It's important that you can install either on Windows (`choco install make` for +GNU make and `choco install mingw` to install a MinGW-w64 distribution with +mingw32-make.exe included). Personally, I don't see any difference between +using either make.exe or mingw32-make.exe w/ CMake on Windows. But, since +MinGW-w64 distributions do include mingw32-make.exe and not make.exe, we'll try +to detect that. Cross-compilation ----------------- @@ -81,18 +81,18 @@ Ubuntu, you need to install the gcc-multilib package. Windows & Clang --------------- -Using Clang on Windows is no easy task, of course. Prior to 3.15, there was -no support for building things using the clang++.exe executable, only -clang-cl.exe was supported ([7][7]). If you specified `-DCMAKE_CXX_COMPILER=clang++`, -CMake would stil pass MSVC-style command line options to the compiler (like -/MD, /nologo, etc.), which clang++ doesn't like ([8][8]). +Using Clang on Windows is no easy task, of course. Prior to 3.15, there was no +support for building things using the clang++.exe executable, only clang-cl.exe +was supported ([7][7]). If you specified `-DCMAKE_CXX_COMPILER=clang++`, CMake +would stil pass MSVC-style command line options to the compiler (like `/MD`, +`/nologo`, etc.), which clang++ doesn't like ([8][8]). So, in summary, you can only use clang++ since 3.15. clang-cl doesn't work with Visual Studio generators unless you specify the proper toolset using the --T parameter. You can set the ClToolExe property using msbuild, but while -that might work in practice, clang-cl.exe needs to map some unsupported -options for everything to work properly. For an example of how this is done, -see the LLVM.Cpp.Common.* files at ([11][11]). +-T parameter. You can set the ClToolExe property using msbuild, but while that +might work in practice, clang-cl.exe needs to map some unsupported options for +everything to work properly. For an example of how this is done, see the +LLVM.Cpp.Common.* files at ([11][11]). I recommend using Clang (either clang-cl or clang++ since 3.15) using the "NMake Makefiles" generator. |