cmake.platform 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
cmake_minimum_required(VERSION 3.16)

MESSAGE("Current system is ${CMAKE_SYSTEM_NAME}")

# init
SET(TD_LINUX FALSE)
SET(TD_WINDOWS FALSE)
SET(TD_DARWIN FALSE)

IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")

    SET(TD_LINUX TRUE)
    SET(OSTYPE "Linux")
    ADD_DEFINITIONS("-DLINUX")

    IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
        SET(TD_LINUX_64 TRUE)
    ELSE ()
        SET(TD_LINUX_32 TRUE)
    ENDIF ()

ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

    SET(TD_DARWIN TRUE)
    SET(OSTYPE "macOS")
    ADD_DEFINITIONS("-DDARWIN")
    IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
        MESSAGE("Current system arch is arm64")
        SET(TD_DARWIN_64 TRUE)
        ADD_DEFINITIONS("-D_TD_DARWIN_64")
    ENDIF ()

    ADD_DEFINITIONS("-DHAVE_UNISTD_H")

ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")

    SET(TD_WINDOWS TRUE)
    SET(OSTYPE "Windows")
    ADD_DEFINITIONS("-DWINDOWS")

    IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
        SET(TD_WINDOWS_64 TRUE)
    	ADD_DEFINITIONS("-D_TD_WINDOWS_64")
    ELSE ()
        SET(TD_WINDOWS_32 TRUE)
    	ADD_DEFINITIONS("-D_TD_WINDOWS_32")
    ENDIF ()
ENDIF()

MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}")
MESSAGE("CXX Compiler ID: ${CMAKE_CXX_COMPILER_ID}")