• apt安装
    1
    2
    3
    sudo apt install -y cmake
    # check for version
    cmake --version
  • 指定版本安装
    1
    2
    3
    wget -q -O cmake-linux.sh https://github.com/Kitware/CMake/releases/download/v3.19.6/cmake-3.19.6-Linux-x86_64.sh
    sh cmake-linux.sh -- --skip-license --prefix=$MY_INSTALL_DIR
    rm cmake-linux.sh

CMakeLists.txt windows

window下使用Qt cmake工程,使用的代码中有lf结尾的文件,编译是的头文件和源文件链接失败问题,在cmake文件中添加:

1
2
3
4
5
6
if (MSVC)
add_compile_options($<$<C_COMPILER_ID:MSVC>:/utf-8>)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/utf-8>)
add_compile_options(/FS)
add_compile_options(-bigobj)
endif()