cmake

如何彻底清除cmake产生的缓存
cmake并没有提供类似于



cmake clean



这样的方式来让我们清除产生的缓存,但是它编译的缓存(*.cmake, Makefile,CmakeCache.txt,



CMakeFiles目录)会遍布各个目录。



解决方法:
在根部目录下建立一个build目录,然后在build目录中编译即可。



#mkdir build
#cd build
#${path}/cmake
这样,产生的缓存都在build目录下了。



在下一次编译之前,只要先删除build下的内容即可,可以做成一个脚本,避免重复操作。



错误:
删除cmake缓冲后可能会出现错误:could not load cache



解决方法:reload cmake project即可



例:Clion->File->Reload CMake Project
https://zhuanlan.zhihu.com/p/67022315

CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。他能够输出各种各样的makefile或者project文件,能测试编译器所支持的C++特性,类似UNIX下的automake。



CMake 使用方法
CMake的所有的语句都写在一个叫:CMakeLists.txt的文件中。当CMakeLists.txt文件确定后,可以用ccmake命令对相关 的变量值进行配置。这个命令必须指向CMakeLists.txt所在的目录。配置完成之后,应用cmake命令生成相应的makefile(在Unix like系统下)或者 project文件(指定用window下的相应编程工具编译时)。



其基本操作流程为:


$> ccmake directory
$> cmake directory
$> make



在mac上
#/Applications/CMake.app/Contents/bin/ccmake
#/Applications/CMake.app/Contents/bin/cmake
#make



其中directory为CMakeList.txt所在目录;
第一条语句用于配置编译选项,如VTK_DIR目录 ,一般这一步不需要配置,直接执行第二条语句即可,但当出现错误时,这里就需要认为配置了,这一步才真正派上用场;
第二条命令用于根据CMakeLists.txt生成Makefile文件;
第三条命令用于执行Makefile文件,编译程序,生成可执行文件;



CMake的执行就是这么简单,其难点在于如何编写CMakeLists.txt文件,下面结合例子简单介绍CMakeLists.txt的编写,看下面这个CMakeLists.txt



#project name
PROJECT(test_math)
#head file path
INCLUDE_DIRECTORIES(
include
)
#source directory
AUX_SOURCE_DIRECTORY(src DIR_SRCS)
#set environment variable
SET(TEST_MATH
${DIR_SRCS}
)
#set extern libraries
SET(LIBRARIES
libm.so
)
#add executable file
ADD_EXECUTABLE(../bin/bin ${TEST_MATH})
#add link library
TARGET_LINK_LIBRARIES(../bin/bin ${LIBRARIES})



或者用下面这个CMakeLists.txt
#project name

PROJECT(test_math)



add_definitions(“-Wall -lpthread -g”)



#head file path

INCLUDE_DIRECTORIES(

include

)



#source directory

AUX_SOURCE_DIRECTORY(src DIR_SRCS)



#set environment variable

SET(TEST_MATH

${DIR_SRCS}

)



#set extern libraries

SET(LIBRARIES

libm.so

)



set output binary path


SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)



SET(FS_BUILD_BINARY_PREFIX “Yfs”)



#add executable file

ADD_EXECUTABLE(${FS_BUILD_BINARY_PREFIX}sqrt ${TEST_MATH})



#add link library

TARGET_LINK_LIBRARIES(${FS_BUILD_BINARY_PREFIX}sqrt ${LIBRARIES})



https://www.cnblogs.com/lidabo/p/7359422.html



https://blog.csdn.net/mart1nn/article/details/82021747



https://blog.csdn.net/netnote/article/details/4051620



关于Mac安装PHP相关扩展出现Zend/zend_config.h缺失的问题记录
In file included from /usr/include/php/main/php.h:35:



/usr/include/php/Zend/zend.h:51:11: fatal error: ‘zend_config.h‘ file not found



include


      ^ 1 error generated.


make: *** [redis.lo] Error 1



I finally managed to install xdebug. In fact, I had to install Xcode developer tool and then copy the files from/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/php into /Applications/MAMP/bin/php/php5.4.4/include and then it worked !
于是在Xcode对应的目录看了看,确实有类似的目录存在。
拷贝至相应的目录后,编译安装通过
https://www.php.cn/php-weizijiaocheng-326060.html



cmake 编译php7



$ ./buildconf –force /编译执行前检查相关依赖
$ ./configure –prefix=/usr/local/php-7.0.20 –with-config-file-path=/usr/local/php-7.0.20/etc/ –enable-fpm –with-fpm-user=www-data –with-fpm-group=www-data –with-mysql-sock –with-mysqli –with-pdo-mysql –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-libxml-dir=/usr –disable-rpath –enable-bcmath –enable-shmop –enable-inline-optimization –with-curl –enable-mbregex –enable-mbstring –enable-ftp –with-gd –enable-gd-native-ttf –enable-soap –without-pear –with-gettext –disable-fileinfo –enable-maintainer-zts –disable-debug –enable-shared –enable-opcache –enable-pdo –with-iconv –with-mcrypt –with-mhash –with-openssl –enable-xml –with-xmlrpc –with-libxml-dir –enable-pcntl –enable-sysvmsg –enable-sysvsem –enable-sysvshm –with-zlib –enable-zip –without-sqlite3 –without-pdo-sqlite –with-libdir=/lib/x86_64-linux-gnu –with-jpeg-dir=/usr/lib –with-apxs2=/usr/bin/apxs2 –enable-cgi –enable-wddx –with-zlib-dir –with-bz2 –enable-session –enable-exif /配置开启 php-fpm支持,–enable-fpm;开启多线程支持 –enable-maintainer-zts;开启线程安全以及其他模块



https://blog.csdn.net/orangesuan/article/details/73909857



./configure –with-php-config=/usr/bin/php-config
https://www.erro.com.cn/index/index/detail/id/51.html



https://www.cnblogs.com/jkko123/p/10790427.html


Category linux