I want to detect if the CMakeLists.txt is being summoned inside an MSYS2 environment/shell:

$ uname MSYS_NT-10.0-18363

from here I have tried:

cmake_minimum_required(VERSION 3.10) project(test_cmake) if(MSYS) # yes I have also tried MSYS2 with the same result! message("This is MSYS") else() message("This is not MSYS") endif()

which returns the same result This is not MSYS both in Windows cmd and MSYS2 shell. I'm not actually surprised because MSYS2 and MSYS are two different beasts! Also from here, I tried:

message(${CMAKE_SYSTEM_NAME})

which both in cmd and MSYS2 returns Windows ! I would appreciate it if you could help me know how I can detect if the cmake command is being run from inside an MSYS2 shell. Thanks for your support in advance.

P.S.1. As a personal note for myself, this and this seem like good sources to look into.

P.S.2 Strangely enough the command

message(${CMAKE_HOST_SYSTEM_NAME})