redguardtoo / cpputils-cmake

Easy real time C++ syntax check and intellisense if you use CMake
196 stars 28 forks source link

Flags like -std=c++11 is missed #64

Open ecnewbie opened 8 years ago

ecnewbie commented 8 years ago

Hi, Chen bin,

I'm using cpputils-cmake now. And I found that some c++ flags like -std=c++11 was missed.

I think it is caused by the cppcm-trim-compiling-flags function. And I've tried to fix it by seperating the queried-c-defines variable into "-I"s and other flags, then concat those flags to the c-defines variable, and it works. There may be a better way to fix it.

Thanks! P.S. I am not familiar with elisp, issues or where to send a bug report yet.

Here is the bug report:

You can run the command `eval-expression' with M-:
t
cppcm-reload-all called
cppcm-get-dirs called
cppcm-query-var-from-last-matched-line called [2 times]
(cppcm-get-dirs)=(t nil /home/zhang/demo/build/ /home/zhang/demo) [2 times]
cppcm-scan-info-from-cmake called => /home/zhang/demo /home/zhang/demo /home/zhang/demo/build/
CMakeLists.txt=/home/zhang/demo/CMakeLists.txt
possible-targets=((add_executable example))
cppcm-handle-one-executable called => /home/zhang/demo /home/zhang/demo/build/ /home/zhang/demo (add_executable example)
cppcm--guess-dir-containing-cmakelists-dot-txt called => /home/zhang/demo
cppcm--guess-dir-containing-cmakelists-dot-txt: dir=/home/zhang/demo
flag-make=/home/zhang/demo/build/CMakeFiles/example.dir/flags.make
cppcm-proj-max-dir-level called => /home/zhang/demo/build/ (add_executable example)
cppcm-guess-exe-full-path: type=add_executable
cppcm-guess-exe-full-path: tgt=(add_executable example)
cppcm-guess-exe-full-path: exe-dir=/home/zhang/demo/build/
cppcm-guess-exe-full-path: cppcm-cmake-target-regex=^ *[^#]* *\(add_executable\|add_library\) *( *\([^ ]+\)
cppcm-guess-exe-full-path: base-exe-name=/home/zhang/demo/build/libexample
exe-full-path=/home/zhang/demo/build/example
cppcm-trim-compiling-flags called => -std=c++11
tks=(-std=c++11)
queried-c-flags=CXX_FLAGS =   -std=c++11
is-c=CXX
c-flags=
queried-c-defines=CXX_FLAGS =   -std=c++11
creating Makefile for flymake: /home/zhang/demo/Makefile
cppcm-scan-info-from-cmake called => /home/zhang/demo /home/zhang/demo/src /home/zhang/demo/build/
cppcm-set-c-flags-current-buffer called
cppcm--guess-dir-containing-cmakelists-dot-txt called => nil
cppcm--guess-dir-containing-cmakelists-dot-txt: dir=/home/zhang/demo/
c-compiling-flags-list=( )
cppcm-include-dirs=(-I"/home/zhang/demo/src/")
ac-clang-flags=(-I/home/zhang/demo/src/)
company-clang-arguments=(-I/home/zhang/demo/src/)
flycheck-clang-include-path=(/home/zhang/demo/src/)
flycheck-clang-definitions=nil
company-c-headers-path-system=(/home/zhang/demo/src/)
flycheck-clang-args = (-I/home/zhang/demo/src/ -I/usr/include/c++/5.2 -I/usr/include/c++/5.2/backward -I/usr/include/x86_64-linux-gnu/c++/5.2 -I/usr/lib/gcc/x86_64-linux-gnu/5.2/include -I/usr/lib/gcc/x86_64-linux-gnu/5.2/include-fixed -I/usr/include -I/usr/include/x86_64-linux-gnu -I/usr/local/include)
cppcm-hash is a variable defined in `cpputils-cmake.el'.
Its value is #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data
              ("/home/zhang/demo/exe-full-path" "/home/zhang/demo/build/example" "/home/zhang/demo/cpp-flags"
               ("" "")))
GNU Emacs 24.5.1
Copyright (C) 2015 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU/Linux.
redguardtoo commented 8 years ago

thanks, I will look into it.

redguardtoo commented 8 years ago

This could be fixed in next version. Could give me a minimum sample?

ecnewbie commented 8 years ago

yes, here is the sample:

project(example)

add_definitions("-std=c++11")

add_executable(example src/main.cpp)