How do I check with CMake whether I'm configuring a Visual Studio solution for e.g. Windows 7 or Windows 8?
Is there any way to do this?
C++ CMake tools for Windows is installed as part of the Desktop development with C++ and Linux Development with C++ workloads. Both C++ CMake tools for Windows and Linux Development with C++ are required for cross-platform CMake development.
To check if cmake is installed in your windows PC using command line, try to run the cmake command in a prompt: if you have the error you quoted in your question, it's not installed. Note that it doesn't mean cmake isn't effectively installed.
Running CMake for Windows / Microsoft Visual C++ (MSVC)Run cmake-gui.exe, which should be in your Start menu under Program Files, there may also be a shortcut on your desktop, or if you built from source, it will be in the build directory.
You can use CMAKE_SYSTEM_NAME
and CMAKE_SYSTEM_VERSION
## Check for Windows ##
if( WIN32 ) # true if windows (32 and 64 bit)
## Check for Version ##
if( ${CMAKE_SYSTEM_VERSION} EQUAL 6.1 ) # Windows 7
# Do something here
elseif( ${CMAKE_SYSTEM_VERSION} EQUAL 6.2 ) # Windows 8
# Do something here
else() # Some other Windows
# Do something here
endif()
endif()
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