区分系统
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