1

when I compile libevent using cmake, I found some confusing code as follow:

if (("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR
    ("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang"))
    set(CLANG 1)
endif()
if (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR (${CLANG}))
    set(GNUC 1)
endif()
if (("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") OR (${CLANG}))
    set(MSVC 1)
endif()

I'm really confused about where CMAKE_C_COMPILER_ID get the value, when I print CMAKE_C_COMPILER_ID under centos, it says "GNU" CMAKE_C_COMPILER_ID

could someone give me a help?

Navy
  • 13
  • 2
  • 2
    "where CMAKE_C_COMPILER_ID get the value" - The variable [CMAKE_C_COMPILER_ID](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html) is set at the `project()` call. During this call CMake detects compilers and obtains their properties. Variable `CMAKE_C_COMPILER_ID` contains a property of the C compiler. – Tsyvarev Nov 05 '20 at 10:39
  • yes you're right, a huge thanks for helping. – Navy Nov 05 '20 at 10:53

0 Answers0