cmake 区分操作系统

区分系统

if (CMAKE_HOST_WIN32)
    set(WINDOWS 1)
elseif (CMAKE_HOST_APPLE)
    set(MACOS 1)
elseif (CMAKE_HOST_UNIX)
    set(LINUX 1)
endif ()

 

实际工作

if (MACOS)
    message("配置MACOS VCPKG 路径")
    include_directories(/Users/maohuawei/dev/vcpkg/installed/x64-osx/include)
    link_directories(/Users/maohuawei/dev/vcpkg/installed/x64-osx/lib)
elseif (WINDOWS)
     message("配置WINDOWS VCPKG 路径")
    include_directories(D:/Local/vcpkg/installed/x64-windows/include)
    link_directories(D:/Local/vcpkg/installed/x64-windows/lib)
elseif (LINUX)
    message("配置LINUX VCPKG 路径")
    include_directories(/home/dev/Desktop/vcpkg/installed/x64-linux/include)
    link_directories(/home/dev/Desktop/vcpkg/installed/x64-linux/lib)
endif ()

LINUX平台判断

if(UNIX AND NOT APPLE)
    set(LINUX 1)
endif(UNIX AND NOT APPLE)

MACOS 平台

APPLE

WINDOWS 平台

WIN32
上一篇:《阿里巴巴Java开发手册v1.2》解析(编程规约篇)


下一篇:阿里巴巴Java开发手册———个人追加的见解和补充(一)