Set variable used by Project command according to current architecture.

My project definition expect different set of languages according to architecture (macOS or Windows).

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
    project(myProj CXX OBJC OBJCXX)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
    project(myProj CXX)
endif()

However, it looks like the CMAKE_SYSTEM_NAME is only defined after the project command. like in this sample code, only the second message will show valid arch.

message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
project(myProj)
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")

Any idea how to fetch the running arch before the project is defined ?

You cannot get this information before project(0 because this variable is computed as part of this command.
But you can use enable_language() command after project() to activate languages.