Eclipses 如何支持CMake Project
来源:互联网 发布:spring boot 执行sql 编辑:程序博客网 时间:2024/06/06 07:46
eclipse目前版本(至少时Luna以后的版本)对Cmake有着特殊的支持。如果不用该支持,会导致index不完全,很多地方出现红线无法解析的问题。本文阐述实战中如何对MySQL(AliSQL)进行导入。
MySQL(AliSQL)的版本已经是Cmake。git clone后,进入文件夹:
发现里面有一个build.sh脚本,我们做相应的动作
mkdir bu
./build.sh
之后会在bu下生成一堆目录和文件,里面的.cproject就是cmake为我们生成的eclipse工程文件。之后eclipse打开已有项目文件即可。
让我们看一下build.sh做了什么。下面是build.sh的内内容:
#!/bin/bash## Script for Dev's daily work. It is a good idea to use the exact same# build options as the released version.get_key_value(){ echo "$1" | sed 's/^--[a-zA-Z_-]*=//'}usage(){cat <<EOFUsage: $0 [-t debug|release] [-d <dest_dir>] [-s <server_suffix>] Or $0 [-h | --help] -t Select the build type. -d Set the destination directory. -s Set the server suffix. -h, --help Show this help message.Note: this script is intended for internal use by MySQL developers.EOF}parse_options(){ while test $# -gt 0 do case "$1" in -t=*) build_type=`get_key_value "$1"`;; -t) shift build_type=`get_key_value "$1"`;; -d=*) dest_dir=`get_key_value "$1"`;; -d) shift dest_dir=`get_key_value "$1"`;; -s=*) server_suffix=`get_key_value "$1"`;; -s) shift server_suffix=`get_key_value "$1"`;; -h | --help) usage exit 0;; *) echo "Unknown option '$1'" exit 1;; esac shift done}dump_options(){ echo "Dumping the options used by $0 ..." echo "build_type=$build_type" echo "dest_dir=$dest_dir" echo "server_suffix=$server_suffix"}if test ! -f sql/mysqld.ccthen echo "You must run this script from the MySQL top-level directory" exit 1fibuild_type="debug"dest_dir="/home/michael/install"server_suffix="tb2016"parse_options "$@"dump_options# valgrid is always 0, turn it on when needed.# unit_tests is always 1, if gmock is not found, it will be disabled.if [ x"$build_type" = x"debug" ]; then build_type="Debug" debug=1 debug_sync=1 unit_tests=1 valgrid=0elif [ x"$build_type" = x"release" ]; then build_type="Release" debug=0 debug_sync=0 unit_tests=1 valgrid=0else echo "Invalid build type, it must be \"debug\" or \"release\"." exit 1figmock="./source_downloads/gmock-1.6.0.zip"if [ x"$unit_tests" = x"1" ]; then if [ -f "$gmock" ]; then export WITH_GMOCK=`readlink -f "$gmock"` fifiserver_suffix="-""$server_suffix"# http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html# #option_cmake_build_config# http://dev.mysql.com/doc/refman/5.6/en/compilation-problems.html## From the following two files, we can get the table of CMAKE_BUILD_TYPE# and CFLAGS/CXXFLAGS.# 1. CMakeCache.txt# 2. cmake/build_configurations/compiler_options.cmake## CMAKE_BUILD_TYPE CFLAGS & CXXFLAGS# Debug -g# RelWithDebInfo -O3 -g# MinSizeRel -Os -DNDEBUG# Release -O3 -DNDEBUG#if [ x"$build_type" = x"Release" ]; then # Alibaba use -fno-exceptions -static-libgcc for 5.5, keep it anyway. COMMON_FLAGS="-O3 -g -fexceptions -static-libgcc \-fno-omit-frame-pointer -fno-strict-aliasing" CFLAGS="$COMMON_FLAGS" export CFLAGS # Alibaba use -fno-rtti for 5.5, but unittest/ cannot build in 5.6. CXXFLAGS="$COMMON_FLAGS" export CXXFLAGS # Use gcc instead of g++ or c++ to avoid dependency on libstdc++.so and # libgcc_s.so. # But utilities under extra/ will not build, this is introduced by MySQL # 5.6. # See extra/CMakeList.txt and keyword LINKER_LANGUAGE. # # CXX=gcc # export CXX CC=/opt/rh/devtoolset-2/root/usr/bin/gcc CXX=/opt/rh/devtoolset-2/root/usr/bin/g++ export CC CXXfirm -rf CMakeCache.txt# MyISAM, MERGE, MEMORY, and CSV engines are mandatory, and need not be# installed explicitly.#rm -rf bu#mkdir bu && cd bucd bucmake .. \ -G"Eclipse CDT4 - Unix Makefiles" -DDOWNLOAD_BOOST=0 \ -DWITH_BOOST="../boost" \ -DCMAKE_BUILD_TYPE="$build_type" \ -DSYSCONFDIR="$dest_dir" \ -DCMAKE_INSTALL_PREFIX="$dest_dir" \ -DMYSQL_DATADIR="$dest_dir/data" \ -DWITH_DEBUG=$debug \ -DWITH_DEBUG_SYNC=$debug_sync \ -DWITH_UNIT_TESTS=$unit_tests \ -DWITH_VALGRIND=$valgrid \ -DENABLED_PROFILING=1 \ -DWITH_EXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_SSL=bundled \ -DWITH_ZLIB=bundled \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_EMBEDDED_SERVER=0 \ -DINSTALL_LAYOUT=STANDALONE \ -DWITH_INNODB_MEMCACHED=ON \ -DMYSQL_SERVER_SUFFIX="$server_suffix"# end of file
注意,cmake的参数第一行,我添加的是-G"Eclipse CDT4 - Unix Makefiles",目的就是生成.cproject文件。
进入到eclipse里(我用的时neon版本),加入本工程文件后,eclipse自动完成index,不用任何辅助设置。完美!
阅读全文
0 0
- Eclipses 如何支持CMake Project
- 在eclipses中 如何能创建maven项目
- cmake to visual studio project
- CMake 支持中文
- CMake常见变量——Project和CMake相关信息
- cmake 增加C++11支持
- CMake 编译支持GDB调试
- Eclipse导入CMake生成的eclipse project
- 《CMake实践》笔记一:PROJECT/MESSAGE/ADD_EXECUTABLE
- How to Build a CMake-Based Project
- linux----如何安装cmake
- 如何安装cmake
- 如何安装cmake?
- cmake如何写
- cmd如何执行cmake
- Eclipses中的launch文件
- [9] CMake - 如何高效使用"cmake --help" ?
- 让Java Project支持Groovy
- git add -A 和 git add . 的区别
- TCP拥塞控制慢启动窗口设置===》另外一篇文章
- vue
- JS 中alert总结
- Windows下git修改文件权限
- Eclipses 如何支持CMake Project
- javascript 全局变量是可怕的?
- 深搜倒水问题
- 剑指offer之空格替换java
- css3最新版中文参考手册在线浏览
- 关于SpringMVC的路径问题
- 教你如何用AST语法树对代码“动手脚”
- 欢迎使用CSDN-markdown编辑器
- 基础语法笔记