cmake

How to differentiate between clang and clang-cl?

佐手、 提交于 2020-12-05 07:03:15
问题 I'm new to CMake and I've run into a little bit of a snag here, wondering if there is an "elegant" solution to this problem, or maybe there's just an easy solution. As an example, for setting up compiler flags I'm doing the following: target_compile_options(${PROJECT_NAME} PUBLIC $<$<CXX_COMPILER_ID:GNU>:"-some_gnu_flag"> $<$<CXX_COMPILER_ID:Clang>:"-some_clang_flag"> $<$<CXX_COMPILER_ID:MSVC>:"/some_msvc_flag"> ) This works perfectly as expected, except for when I try a build using clang-cl

Cross compiling gRPC using cmake

假如想象 提交于 2020-12-04 08:24:57
问题 I'm trying to cross-compile a gRPC using cmake. I actually managed to do it. Unfortunately my method involves tinkering inside CMakeLists.txt. Problem was that, when I was trying to compile gRPC it was using protobuffer he just compiled. It cannot run ARM compiled executables on x86 machine. I managed to compile it by specifying path to protoc and grpc_cpp_plugin manually in gRPCs main CMakeLists.txt. It is dirty and since I would like to include gRPC as submodule I need clean way to do it.

Cross compiling gRPC using cmake

大兔子大兔子 提交于 2020-12-04 08:24:39
问题 I'm trying to cross-compile a gRPC using cmake. I actually managed to do it. Unfortunately my method involves tinkering inside CMakeLists.txt. Problem was that, when I was trying to compile gRPC it was using protobuffer he just compiled. It cannot run ARM compiled executables on x86 machine. I managed to compile it by specifying path to protoc and grpc_cpp_plugin manually in gRPCs main CMakeLists.txt. It is dirty and since I would like to include gRPC as submodule I need clean way to do it.

Cross compiling gRPC using cmake

廉价感情. 提交于 2020-12-04 08:24:18
问题 I'm trying to cross-compile a gRPC using cmake. I actually managed to do it. Unfortunately my method involves tinkering inside CMakeLists.txt. Problem was that, when I was trying to compile gRPC it was using protobuffer he just compiled. It cannot run ARM compiled executables on x86 machine. I managed to compile it by specifying path to protoc and grpc_cpp_plugin manually in gRPCs main CMakeLists.txt. It is dirty and since I would like to include gRPC as submodule I need clean way to do it.

常见的构建系统(Build System)

白昼怎懂夜的黑 提交于 2020-12-02 15:16:19
各种构建系统各有优缺点,需要深入研究和使用才能了解。没有那个是最好的,只有最适合的。一般: 一两个源文件的C++代码,完全没必要用构建系统,直接使用编译器命令直接搞定; 自己用的小项目,直接手动写Makefile即可 大型C++项目建议使用CMake,GNU Build System比较年龄大了,规则有些复杂,写起来没有CMake那么舒服,不能跨平台的话就根本没戏。 比较新的构建系统:SCons、Waf、B2 基于make的构建系统 GNU Make GNU Make 是一个控制源码生成可执行文件或其他文件的工具。需要一个叫Makefile的文件来说明构建的目标和规则。 target: dependencies ... commands ... 意思是:生成target,依赖于dependencies,如果dependencies有修改或者target不存在,就逐个执行下面的commands去生成target。 但是大型的项目中,Makefile文件不可能手工去编写,GNU Build System可以自动生成Makefile文件。主要包含三大模块: Autoconf Automake Libtool 可以从 使用者 和 开发者 两个角度来看: 使用者的角度 GNU Build System为我们提供了源码包编译安装的方式: tar -xvzf package-name

Set CXX-standard to c++17 when combining C++ and CUDA in CMakeLists

ぐ巨炮叔叔 提交于 2020-11-29 19:12:54
问题 According to the documentation of CMake I just have to write project(${PROJECT_NAME} LANGUAGES CUDA CXX) when I would like to combine CUDA-files and native C++-files in one project. Then I do not have to call cuda_add_executable() anymore, but rather add_executable , and CMake should figure out everything on its own. This works fine, unless I would like to specify a standard for C++-code (by using set(CMAKE_CXX_STANDARD 17) ). Then I get the error message Target requires the language dialect

Set CXX-standard to c++17 when combining C++ and CUDA in CMakeLists

限于喜欢 提交于 2020-11-29 19:09:58
问题 According to the documentation of CMake I just have to write project(${PROJECT_NAME} LANGUAGES CUDA CXX) when I would like to combine CUDA-files and native C++-files in one project. Then I do not have to call cuda_add_executable() anymore, but rather add_executable , and CMake should figure out everything on its own. This works fine, unless I would like to specify a standard for C++-code (by using set(CMAKE_CXX_STANDARD 17) ). Then I get the error message Target requires the language dialect

开工第一天,先用Python戴个口罩

本秂侑毒 提交于 2020-11-28 03:08:36
Python实用宝典终于复工啦 (我咸鱼够了) !这些天,令人揪心的肺炎疫情一直闹得沸沸扬扬,口罩也被抢得断货,许多网友朋友们都只能开始给自己的头像戴口罩了 (也挺好,为疫区省点医疗物资) 。 有个朋友(Prodesire)一早就预料到有这种情况,因此ta开发了一个工具,能让大家用一行语句就成功戴上口罩! 1.准备 老规矩,在开工前一定要安装好Python,如果还没安装请看这篇文章:超详细Python安装教程。安装完Python后我们就可以安装Prodesire开发的一个叫做face-mask的模块。 如果你是windows机器,请在 开始—运行 中输入cmd,执行 pip install face-mask 如果你是macOS机器,请command+空格,输入Terminal打开终端,执行 pip install face-mask 如果出现:CMake must be installed to build the following extensions: dlib 这样的错误,请先安装cmake: pip install cmake 2.使用 同样地,打开cmd或终端,输入以下命令,就能在该图片的当前文件夹下生成一张戴着口罩的图片: face-mask 图片路径 比如说宽叔的这张图片: 输入命令 face-mask Downloads/2.jpg 即可生成戴口罩的图片:

Invoke MIDL compiler from CMAKE

拟墨画扇 提交于 2020-11-28 01:54:27
问题 I am going to use MIDL compiler with CMAKE but unable to invoke MIDL compiler from CmakeList That is command which I use to achieve my goal add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/IFace.h ${CMAKE_CURRENT_BINARY_DIR}/GUIDS.c ${CMAKE_CURRENT_BINARY_DIR}/Proxy.c ${CMAKE_CURRENT_BINARY_DIR}/ProxyDll.c COMMAND midl /h IFace.h /iid GUIDS.c /proxy Proxy.c /dlldata ProxyDll.c ${CMAKE_CURRENT_LIST_DIR}/include/Server.idl ) When I build my project there are no files produced by MIDL

树莓派安装OpenCV完整过程

穿精又带淫゛_ 提交于 2020-11-25 07:56:57
1. 配置并更新树莓派系统 sudo raspi-config // 进入后 打开摄像头 、SSH sudo apt - get update sudo apt - get upgrade sudo rpi -update 2. 安装OpenCV的相关工具 sudo apt-get install build-essential cmake git pkg-config 3. 安装OpenCV的图像工具包 sudo apt-get install libjpeg8- dev sudo apt -get install libtiff5- dev sudo apt -get install libjasper- dev sudo apt -get install libpng12-dev 4. 安装视频I/O包 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev 5.安装gtk2.0和优化函数包 sudo apt-get install libgtk2.0- dev sudo apt -get install libatlas-base-dev gfortran 6. 下载OpenCV源码 git clone https://github.com/opencv/opencv.git