其他分享
首页 > 其他分享> > cmake 区分操作系统

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

标签:cmake,操作系统,区分,x64,installed,vcpkg,LINUX,include,directories
来源: https://www.cnblogs.com/songhaibin/p/13878714.html