cmake

CMake构建项目级编译环境

妖精的绣舞 提交于 2020-01-26 01:04:06
开始之前 参与到一个项目时,往往因为需求而去快速Get某些技能,并将之应用到实际的项目中,慢慢的对这些知识越来越熟悉,有时候准备把Get到的这些知识记录下来,但静下来想想要把这些知识点写全也不太容易,而且自我感觉应该不会忘的,所以把笔记的事情没当回事。时间一天天过去,当我们参与到其他项目之中,开始了新的关键技术分析和概要设计,当初Get到的那些技能由于不经常使用而慢慢退化,当某个时间点再次需要这些技能时,开始在大脑中搜索,what fuck???除了有个概念,什么都记不起来,那些之前踩过的坑,又会再踩一遍,那些曾经困惑的知识点,又会再次感到困惑,天道好轮回,苍天绕过谁啊!!!CMake有很多人在用,现在Github上大部分工程都支持CMake编译,当我自己构建工程时还是遇到过很多问题,但能搜索到的知识点还是太少,只能去研究cmake的官方英文文档,所以这里把重要的知识点记录一下。 背景 项目工程目录介绍 工程目录树如下图所示,微服务的项目工程结构,common目录是多个服务(services)公共的依赖,services目录主要存放多个服务,包括服务1(service1)、服务2(service2)、… 服务n,每个单服务就是一个应用,意味着均可编译产生一个可执行程序。service1的子目录包含头文件目录inc和源文件目录src以及用于单元测试的test目录

docker 操作记录-1

旧巷老猫 提交于 2020-01-25 21:54:04
docker操作记录(Ubuntu-16.04环境) Xshell 6 (Build 0115) Copyright (c) 2002 NetSarang Computer, Inc. All rights reserved. Type `help' to learn how to use Xshell prompt. [C:\~]$ Connecting to 192.168.114.130:22... Connection established. To escape to local shell, press Ctrl+Alt+]. Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-70-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage * Overheard at KubeCon: "microk8s.status just blew my mind". https://microk8s.io/docs/commands#microk8s.status 13 个可升级软件包。 10 个安全更新。

cmake: make_directory in built time

大城市里の小女人 提交于 2020-01-25 15:40:09
问题 I have this code that runs during configuration time: if (NOT EXISTS "${PROJECT_BINARY_DIR}/tmpdir/") file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/tmpdir/") message ("Generating tmpdir directory") endif () How do I implement the above code but in build time? 回答1: How do I implement the above code but in build time? It depends on when you exactly need this directory. For instance if you need it before executable foo compiled, you can use add_custom_target and add_dependencies: add_custom_target

cmake: make_directory in built time

此生再无相见时 提交于 2020-01-25 15:38:34
问题 I have this code that runs during configuration time: if (NOT EXISTS "${PROJECT_BINARY_DIR}/tmpdir/") file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/tmpdir/") message ("Generating tmpdir directory") endif () How do I implement the above code but in build time? 回答1: How do I implement the above code but in build time? It depends on when you exactly need this directory. For instance if you need it before executable foo compiled, you can use add_custom_target and add_dependencies: add_custom_target

POCO libraries: MinGW (MSYS2) compilation has generated libPocoDataODBC.dll with missing entry points (Poco::Data::ODBC::Connector::registerConnector)

依然范特西╮ 提交于 2020-01-25 09:28:14
问题 I have succeeded compiling POCO libraries with MinGW64 (MSYS2). To build it, I installed Windows SDK and added to the PATH environment the path to mc.exe , so I executed: pacman -S mingw-w64-x86_64-cmake # Get POCO git clone -b master https://github.com/pocoproject/poco.git # set Windows SDK to the PATH export PATH="/c/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64:$PATH" # Prepare compilation cd poco /mingw64/bin/cmake -G "MSYS Makefiles" .. # Compile make The compilation succeeded

problem in installing dlib module for anaconda on mac os

女生的网名这么多〃 提交于 2020-01-25 09:18:06
问题 Im trying to install dlib on my mac os, I used anaconda and the picture below is an error occurred when i attempted to install the module. I did install cmake, but it still failed. Thank you in advance for helpiing me to figuring this out, cheers. 回答1: Dlib is support with python 3.6 to 3.7.0 version s.Try to install the dlib in anaconda prompt by following command., step 1: conda create -n env_name python=3.7.0 step 2: conda activate env_name step 3: conda install -c conda-forge dlib=19.17

Linux下__attribute__((visibility ("default")))的使用

倖福魔咒の 提交于 2020-01-25 08:58:58
在Linux下动态库(.so)中,通过GCC的C++ visibility属性可以控制共享文件导出符号。在GCC 4.0及以上版本中,有个visibility属性,可见属性可以应用到函数、变量、模板以及C++类。 限制符号可见性的原因:从动态库中尽可能少地输出符号是一个好的实践经验。输出一个受限制的符号会提高程序的模块性,并隐藏实现的细节。动态库装载和识别的符号越少,程序启动和运行的速度就越快。导出所有符号会减慢程序速度,并耗用大量内存。 “default”:用它定义的符号将被导出,动态库中的函数默认是可见的。”hidden”:用它定义的符号将不被导出,并且不能从其它对象进行使用,动态库中的函数是被隐藏的。default意味着该方法对其它模块是可见的。而hidden表示该方法符号不会被放到动态符号表里,所以其它模块(可执行文件或者动态库)不可以通过符号表访问该方法。 要定义GNU属性,需要包含__attribute__和用括号括住的内容。可以将符号的可见性指定为visibility(“hidden”),这将不允许它们在库中被导出,但是可以在源文件之间共享。实际上,隐藏的符号将不会出现在动态符号表中,但是还被留在符号表中用于静态链接。 导出列表由编译器在创建共享库的时候自动生成,也可以由开发人员手工编写。导出列表的原理是显式地告诉编译器可以通过外部文件从对象文件导出的符号是哪些

Cmake cannot run shell command

二次信任 提交于 2020-01-25 08:53:08
问题 Let's assume we have a project with some subdirectories and we need to generate .cpp and .h files in one of its subdirectories. True fact: if we run a command (without < and >) in that directory, it generates valid files. So how to do the same using cmake? Cmake has add_custom_command, but it does nothing, so we cannot use it. execute_process is better because it runs something, but in a wrong way. execute_process(COMMAND "protoc -I=\".\" --cpp_out=\".\" protocol.proto" WORKING_DIRECTORY $

Protocol Buffer with CMakeLists

天涯浪子 提交于 2020-01-25 07:01:24
问题 I have a project which has src , include and some older folders under its parent dictory. I created a folder called proto , which has my VisionData.proto in it. I want to generate the expected output files, however it doesn't work. I looked at the official site of it and did whatever they wrote there, but still no luck. Here is my CMakeLists: cmake_minimum_required(VERSION 2.8.3) project(uwsim_imgproc) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) set(LIBRARY_OUTPUT_PATH ${PROJECT

Compiling Google test with Mingw-w64

妖精的绣舞 提交于 2020-01-25 04:16:25
问题 I'm trying to compile Google Test with Mingw-w64 in a Windows 10 machine but I always get the error: C:\git\tdd\googletest>cmake CMakeLists.txt -G "MinGW Makefiles" CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a