Coder Social home page Coder Social logo

ycm-generator's Introduction

YCM-Generator

This is a script which generates a list of compiler flags from a project with an arbitrary build system. It can be used to:

It works by building the project with a fake toolchain, which simply and filters compiler flags to be stored in the resulting file.

It is reasonably fast, taking ~10 seconds to generate a configuration file for the Linux kernel.

Status

This plugin is in maintenance mode. I am happy to merge PRs and triage bug reports, but am not actively working on it.

Installation

Add NeoBundle 'rdnetto/YCM-Generator' to your vimrc (or the equivalent for your plugin manager).

For vim-plug users, add Plug 'rdnetto/YCM-Generator', { 'branch': 'stable'} to your vimrc.

Alternatively, Arch Linux users can install YCM-Generator using the (unofficial) AUR package.

Usage

Run ./config_gen.py PROJECT_DIRECTORY, where PROJECT_DIRECTORY is the root directory of your project's build system (i.e. the one containing the root Makefile, etc.)

You can also invoke it from within Vim using the :YcmGenerateConfig or :CCGenerateConfig commands to generate a config file for the current directory. These commands accept the same arguments as ./config_gen.py, but do not require the project directory to be specified (it defaults to the current working directory).

Requirements and Limitations

  • Requirements:

    • Python 2
    • Clang
  • Supported build systems:

    • make
    • cmake
    • qmake
    • autotools

Your build system should support specifying the compiler through the CC/CXX environment variables, or not use an absolute path to the compiler.

Some flags present in the resulting configuration file may be mutually exclusive with each other - reading the generated file prior to use is recommended.

The script assumes that executables with the names clang and clang++ exist in your PATH. This has been known to cause issues under Ubuntu, where the C++ compiler may be called clang++-3.6 (see #50).

Documentation & Support

  • run ./config_gen.py --help to see the complete list of supported options.
  • if you receive the error message ERROR: No commands were logged to the build logs, try using the --verbose flag to see any error messages
    • some build systems require certain environment variables to be set. Note that these will not be used by YCM-Generator by default, unless --preserve-environment is used
    • if you open an issue regarding this error message, please include the output when running with --verbose and a link to the project repo (if possible)

Development

Patches are welcome. Please submit pull requests against the develop branch.

Windows support

The script is currently supported under Unices (Linux, NixOS[1], BSD, OS X) only. Implementing Windows support consists of porting the contents of fake-toolchain/Unix. If you are interested in implementing/testing this, please open a pull request.

[1] May require --preserve-environment - see #19

Test Cases

The following projects are used for testing:

Project Build system Notes
Linux kernel Kbuild (Make)
Vim-qt Autotools
Clementine Cmake
ExtPlane Qmake Should be tested with both versions of Qt.
OpenFOAM wmake

License

YCM-Generator is published under the GNU GPLv3.

ycm-generator's People

Contributors

agauniyal avatar aumuell avatar burlog avatar esdrubal avatar frankier avatar handrake0724 avatar iliis avatar mcourteaux avatar pavildon avatar proudzhu avatar rdnetto avatar robertaudi avatar ssfdust avatar the-compiler avatar yamakaky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ycm-generator's Issues

deal with cd during build

Some projects may change directory during build, is it possible to deal with such situation.
For example, https://github.com/xiph/speexdsp, ycm_generator will generate flags like '-I../include' as it change directory to libspeexdsp during build, but it should be '-I./include'.

Boost not found

Hi,
It seems there is a bug when looking for boost. When I try to use config_gen.py on my project I got the issue below.

Script started on Do 25 Feb 2016 11:50:04 CET
$ ~/.vim/bundle/YCM-Generator/config_gen.py  -v .
'/home/daedric/work/perso/commonpp/.ycm_extra_conf.py' already exists. Overwrite? [y/N] y
 Running cmake in '/tmp/tmpQsNyYu'...
$ cmake /home/daedric/work/perso/commonpp
-- The C compiler identification is Clang 3.9.0
-- The CXX compiler identification is Clang 3.9.0
-- Check for working C compiler: /home/daedric/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/daedric/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - failed
-- Check for working CXX compiler: /home/daedric/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++
-- Check for working CXX compiler: /home/daedric/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
-- Setting cmake build type to 'Debug' as none was specified.
-- CMake Version        : 3.2.2
-- commonpp Version     : 0.1.1
-- Build Tests          : ON
-- Build Type           : Debug
-- System               : Linux 4.2.0-30-generic
-- Install Prefix       : /usr
-- Source Directory     : /home/daedric/work/perso/commonpp
-- C++ Compiler ID      : Clang
-- Performing Test HAVE_CPP_VERSION
-- Performing Test HAVE_CPP_VERSION - Success
-- Performing Test HAVE_NOUNUSED_LOCAL_TYPEDEF
-- Performing Test HAVE_NOUNUSED_LOCAL_TYPEDEF - Success
-- Looking for clock_getcpuclockid
-- Looking for clock_getcpuclockid - found
-- Performing Test HAVE_MAKE_UNIQUE
-- Performing Test HAVE_MAKE_UNIQUE - Failed
-- Looking for include file sys/prctl.h
-- Looking for include file sys/prctl.h - found
-- Performing Test HAVE_THREAD_LOCAL_SPECIFIER
-- Performing Test HAVE_THREAD_LOCAL_SPECIFIER - Success
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Found Intel TBB
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28") 
-- checking for module 'hwloc'
--   found hwloc, version 1.11.0
CMake Error at /usr/share/cmake-3.2/Modules/FindBoost.cmake:1202 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.58.0

  Boost include path: /usr/include

  Could not find the following static Boost libraries:

          boost_unit_test_framework
          boost_log
          boost_log_setup
          boost_filesystem
          boost_thread
          boost_system

  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.
Call Stack (most recent call first):
  CMakeLists.txt:128 (find_package)


-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Configuring incomplete, errors occurred!
See also "/tmp/tmpQsNyYu/CMakeFiles/CMakeOutput.log".
See also "/tmp/tmpQsNyYu/CMakeFiles/CMakeError.log".

Running make...
$ make -i -j8
make: *** No targets specified and no makefile found.  Stop.

Cleaning up...

Build completed in 1.4 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /tmp/tmpF7lVGA, C++: /tmp/tmpDkRSie).
Your build system may not be compatible.
$ 

Script done on Do 25 Feb 2016 11:50:49 CET

Please let me know if I can be of any assistance,
Cheers,

Endless loop / fork bomb

Hi, I'm having some trouble while trying to generate the ycm config file for mangos ( https://github.com/mangostwo/server.git ) which is using the ACE C++ framework.
Basically, it start forking until all system resources are exausted.

$ cd /home/al/git/other/mangos-server
$ ~/.vim/bundle/YCM-Generator/config_gen.py . --verbose
Running cmake in '/tmp/tmpjgQglj'...
$ cmake /home/al/git/other/mangos-server
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /home/al/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/al/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/al/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++
-- Check for working CXX compiler: /home/al/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done

This script builds the MaNGOS server.
  Options that can be used in order to configure the process:
    CMAKE_INSTALL_PREFIX    Path where the server should be installed to
    CMAKE_BUILD_TYPE        Sets build type (Release;Debug;...)
    PCH                     Use precompiled headers
    INCLUDE_BINDINGS_DIR    Include a script library in src/bindings/ with the
                            defined name. the name must corespond to the name of
                            the folder and the folder must contain a valid
                            CMakeLists.txt
    ACE_USE_EXTERNAL        Use external ACE
    BUILD_SCRIPTS           Build server scripts content.
    POSTGRESQL              Use PostgreSQL bindings.
  To set an option simply type -D<OPTION>=<VALUE> after 'cmake <srcs>'.
  Also, you can specify the generator with -G. see 'cmake --help' for more details
  For example: cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/opt/mangos

-- Detected 64-bit platform.
-- Found Git: /usr/bin/git  
-- Using mysql-config: /usr/bin/mysql_config
-- Found MySQL library: /usr/lib64/libmysqlclient.so
-- Found MySQL headers: /usr/include/mysql
-- Found OpenSSL library: /usr/lib64/libssl.so
-- Found OpenSSL headers: /usr/include/openssl
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.8") 
-- MaNGOS-Core revision  : b8ce9508483375a36699c309bce36810c4548007
-- Install server to     : /usr/local
-- Use PCH               : No
CMake Warning (dev) at CMakeLists.txt:300 (get_target_property):
  Policy CMP0026 is not set: Disallow use of the LOCATION target property.
  Run "cmake --help-policy CMP0026" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The LOCATION property should not be read from target "genrev".  Use the
  target name directly with add_custom_command, or use the generator
  expression $<TARGET_FILE>, as appropriate.

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
CMake Warning (dev) at src/framework/CMakeLists.txt:86 (add_dependencies):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "TBB_Project" of target "framework" does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /tmp/tmpjgQglj

Running make...
$ make -i -j4
Scanning dependencies of target ACE_Project
Scanning dependencies of target genrev
Scanning dependencies of target detour
Scanning dependencies of target g3dlite
[  1%] [  1%] Creating directories for 'ACE_Project'
Building CXX object CMakeFiles/genrev.dir/src/tools/genrevision/genrevision.cpp.o
[  1%] Linking CXX executable genrev
Building CXX object dep/recastnavigation/Detour/Source/CMakeFiles/detour.dir/DetourAlloc.cpp.o
[  1%] [  1%] Built target genrev
Building CXX object dep/recastnavigation/Detour/Source/CMakeFiles/detour.dir/DetourCommon.cpp.o
Scanning dependencies of target gsoap
[  1%] Building CXX object dep/recastnavigation/Detour/Source/CMakeFiles/detour.dir/DetourNavMeshBuilder.cpp.o
[  1%] [  1%] [  1%] Building CXX object dep/recastnavigation/Detour/Source/CMakeFiles/detour.dir/DetourNavMesh.cpp.o
No download step for 'ACE_Project'
Building CXX object dep/src/gsoap/CMakeFiles/gsoap.dir/stdsoap2.cpp.o
[  1%] Linking CXX static library libgsoap.a
Building CXX object dep/recastnavigation/Detour/Source/CMakeFiles/detour.dir/DetourNavMeshQuery.cpp.o
[  1%] [  1%] No patch step for 'ACE_Project'
/usr/bin/ranlib: 'libgsoap.a': No such file
Building CXX object dep/recastnavigation/Detour/Source/CMakeFiles/detour.dir/DetourNode.cpp.o
[  1%] [  1%] Built target gsoap
[  2%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/AABox.cpp.o
Building CXX object dep/recastnavigation/Detour/Source/CMakeFiles/detour.dir/DetourObstacleAvoidance.cpp.o
[  2%] [  2%] Scanning dependencies of target revision.h
No update step for 'ACE_Project'
make[2]: *** No rule to make target 'genrev', needed by 'CMakeFiles/revision.h'.  Stop.
Linking CXX static library libdetour.a
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Any.cpp.o
[  2%] [  2%] Built target revision.h
[  2%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/BinaryFormat.cpp.o
[  2%] /usr/bin/ranlib: 'libdetour.a': No such file
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/BinaryInput.cpp.o
Performing configure step for 'ACE_Project'
[  3%] [  3%] Built target detour
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/BinaryOutput.cpp.o
[  3%] [  3%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Capsule.cpp.o
[  3%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Box.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/CollisionDetection.cpp.o
[  3%] [  3%] [  3%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Crypto.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/CoordinateFrame.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Cylinder.cpp.o
[  3%] [  4%] [  4%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/FileSystem.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/LineSegment.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Line.cpp.o
[  4%] [  4%] [  4%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Log.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Matrix3.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Matrix4.cpp.o
[  4%] [  4%] [  5%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/MemoryManager.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/PhysicsFrame.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Plane.cpp.o
[  5%] [  5%] [  5%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Random.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Ray.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Quat.cpp.o
checking build system type... [  5%] [  5%] [  5%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/ReferenceCount.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/RegistryUtil.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Sphere.cpp.o
[  6%] [  6%] [  6%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/System.cpp.o
x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/TextOutput.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/TextInput.cpp.o
/usr/bin/install -c
checking whether build environment is sane... [  6%] [  6%] [  6%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Triangle.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/UprightFrame.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Vector2.cpp.o
[  6%] [  7%] [  7%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Vector3.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/Vector4.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/debugAssert.cpp.o
[  7%] [  7%] [  7%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/fileutils.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/format.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/g3dfnmatch.cpp.o
[  7%] [  7%] [  7%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/g3dmath.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/stringutils.cpp.o
Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/prompt.cpp.o
[  8%] Building CXX object dep/src/g3dlite/CMakeFiles/g3dlite.dir/uint128.cpp.o
Linking CXX static library libg3dlite.a
/usr/bin/ranlib: 'libg3dlite.a': No such file
[  8%] Built target g3dlite
yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking whether #! works in shell scripts... yes
checking whether the C++ compiler works... no
configure: error: in `/tmp/tmpjgQglj/dep/ACE_wrappers':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
[  9%] Performing build step for 'ACE_Project'
[100%] Performing build step for 'ACE_Project'
[100%] Performing build step for 'ACE_Project'
[100%] Performing build step for 'ACE_Project'
[100%] Performing build step for 'ACE_Project'
[... endless ...]
^CTraceback (most recent call last):
  File "/home/al/.vim/bundle/YCM-Generator/config_gen.py", line 460, in <module>
    sys.exit(main())
  File "/home/al/.vim/bundle/YCM-Generator/config_gen.py", line 107, in main
    fake_build(project_dir, c_build_log.name, cxx_build_log.name, **args)
  File "/home/al/.vim/bundle/YCM-Generator/config_gen.py", line 224, in fake_build
    run(make_args, env=env, **proc_opts)
  File "/home/al/.vim/bundle/YCM-Generator/config_gen.py", line 198, in run
    subprocess.call(cmd, *args, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 1384, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/usr/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
    return func(*args)
KeyboardInterrupt

No commands were logged to the build log?

So I had the issue and read "if you receive the error message ERROR: No commands were logged to the build logs, try using the --verbose flag to see any error messages"
So I tried :YcmGenerateConfig --verbose and tried running the config_gen.py with ./config_gen.py --verbose so how do I get more info so I can find by problem?

Add Options for OpenFOAM build

Thanks for the nice script.
I made an option for supporting OpenFOAM in fake_build function. Could you reflect this option to the source code?
the code is as follows:

    elif(os.path.exists(os.path.join(project_dir, "Make/options"))):
        # OpenFOAM build
        print("Found OpenFOAM Make/options")
        print("Preparing build directory...")
        build_dir = tempfile.mkdtemp()

        keys = os.environ.keys()
        WM = re.compile('^WM_')
        for key in keys:
            if(WM.match(key)):
                env[key] = os.environ[key]

        make_args = ['wmake']
        print("\nRunning wmake...")
        proc_opts['cwd'] = project_dir
        env['WM_COMPILER']='Gcc'
        env['WM_CC']='gcc'
        # for Debug
        subprocess.call(make_args, env=env, stdin=None, stdout=None, stderr=None, shell=True, cwd=project_dir)
        #subprocess.call(make_args, env=env, **proc_opts)

No errors, but not getting proper completion suggestions

Hello, I'm new to Linux and having an issue getting YCM to work. I can't tell if I'm screwing up something on the YCM end, or the YCM-Generator end. I'm running it all on Ubuntu 14.04.

I followed the instructions on the YCM page for the full install originally, but I was having trouble with clang, so I swapped to using vundle instead of pathogen and followed the shorter vundle instructions on the YCM page.

I'm at a point where nothing is giving me errors, but I'm still not getting the completion suggestions that I would expect. For example, "#include <std " pulls up Intrin.h and altivec.h, but not stdlib.h. It's also saying "User defined completion (U^N^P)" all the time.

I have my base directory 'Code' with 'C' as a subdirectory, and 'HelloWorld.c' as the file I'm trying to work with. Here's my CMake files:

CMakeLists.txt in 'Code'

cmake_minimum_required(VERSION 2.7)
project(CODE)

set((CMAKE_CXX_FLAGS "-g -Wall")
add_subdirectory(C)

CMakeLists.txt in 'C'

include_directories($(CODE_SOURCE_DIR)/C)
link_directories($(CODE_BINARY_DIR)/C)

add_executable(helloworld HelloWorld.c)

The .ycm_extra_conf.py that was generated is long, so here's a link to it with the comments excluded.
Link to .ycm_extra_conf.py

Let me know if there's somewhere better to ask this. Like I said, still new!

Incorrect .ycm_extra_config.py if using add_subdirectory in CMakeLists.txt (GLFW)

I noticed that the .ycm_extra_config.py does not include flags defined in the top level CMakeLists.txt if the the add_subdirectory command is used.

Summary:

going from

set(CMAKE_CXX_FLAGS "-std=c++11")

to

set(CMAKE_CXX_FLAGS "-std=c++11")
add_subdirectory(./glfw)

changes the flags from:

flags = [
    '-x',
    'c++',
    '-std=c++11',
]

to

flags = [
    '-x',
    'c',
    '-D_GLFW_USE_CONFIG_H',
    '-I/home/dmitri/Code/GLEngine/glfw/deps',
    '-I/home/dmitri/Code/GLEngine/glfw/include',
    '-I/home/dmitri/Code/GLEngine/glfw/src',
    '-I/tmp/tmpp_eHQV/glfw/src',
    '-Wall',
]

Which does not keep the '-std=c++11' flag for example.

Detailed explanation:

I have a sample CMakeLists.txt file :

project(GLEngine)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_BINDAY_DIR ${PROJECT_SOURCE_DIR}/build)

set(CMAKE_CXX_FLAGS "-std=c++11")

add_executable(window ./src/glfw_window_test.cpp)

which generates:

# Generated by YCM Generator at 2015-11-28 17:49:34.779058

# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>

import os
import ycm_core

flags = [
    '-x',
    'c++',
    '-std=c++11',
]


# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
#   set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''

if os.path.exists( compilation_database_folder ):
  database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
  database = None

SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]

def DirectoryOfThisScript():
  return os.path.dirname( os.path.abspath( __file__ ) )


def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
  if not working_directory:
    return list( flags )
  new_flags = []
  make_next_absolute = False
  path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
  for flag in flags:
    new_flag = flag

    if make_next_absolute:
      make_next_absolute = False
      if not flag.startswith( '/' ):
        new_flag = os.path.join( working_directory, flag )

    for path_flag in path_flags:
      if flag == path_flag:
        make_next_absolute = True
        break

      if flag.startswith( path_flag ):
        path = flag[ len( path_flag ): ]
        new_flag = path_flag + os.path.join( working_directory, path )
        break

    if new_flag:
      new_flags.append( new_flag )
  return new_flags


def IsHeaderFile( filename ):
  extension = os.path.splitext( filename )[ 1 ]
  return extension in [ '.h', '.hxx', '.hpp', '.hh' ]


def GetCompilationInfoForFile( filename ):
  # The compilation_commands.json file generated by CMake does not have entries
  # for header files. So we do our best by asking the db for flags for a
  # corresponding source file, if any. If one exists, the flags for that file
  # should be good enough.
  if IsHeaderFile( filename ):
    basename = os.path.splitext( filename )[ 0 ]
    for extension in SOURCE_EXTENSIONS:
      replacement_file = basename + extension
      if os.path.exists( replacement_file ):
        compilation_info = database.GetCompilationInfoForFile(
          replacement_file )
        if compilation_info.compiler_flags_:
          return compilation_info
    return None
  return database.GetCompilationInfoForFile( filename )


def FlagsForFile( filename, **kwargs ):
  if database:
    # Bear in mind that compilation_info.compiler_flags_ does NOT return a
    # python list, but a "list-like" StringVec object
    compilation_info = GetCompilationInfoForFile( filename )
    if not compilation_info:
      return None

    final_flags = MakeRelativePathsInFlagsAbsolute(
      compilation_info.compiler_flags_,
      compilation_info.compiler_working_dir_ )

  else:
    relative_to = DirectoryOfThisScript()
    final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )

  return {
    'flags': final_flags,
    'do_cache': True
  }

If I add the GLFW subdirectory:

project(GLEngine)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_BINDAY_DIR ${PROJECT_SOURCE_DIR}/build)

set(CMAKE_CXX_FLAGS "-std=c++11")

add_subdirectory(./glfw)
include_directories(./glfw/include)

add_executable(window ./src/glfw_window_test.cpp)

The generated .ycm_extra_config.py file is:

# Generated by YCM Generator at 2015-11-28 17:50:17.486645

# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>

import os
import ycm_core

flags = [
    '-x',
    'c',
    '-D_GLFW_USE_CONFIG_H',
    '-I/home/dmitri/Code/GLEngine/glfw/deps',
    '-I/home/dmitri/Code/GLEngine/glfw/include',
    '-I/home/dmitri/Code/GLEngine/glfw/src',
    '-I/tmp/tmpp_eHQV/glfw/src',
    '-Wall',
]


# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
#   set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''

if os.path.exists( compilation_database_folder ):
  database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
  database = None

SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]

def DirectoryOfThisScript():
  return os.path.dirname( os.path.abspath( __file__ ) )


def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
  if not working_directory:
    return list( flags )
  new_flags = []
  make_next_absolute = False
  path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
  for flag in flags:
    new_flag = flag

    if make_next_absolute:
      make_next_absolute = False
      if not flag.startswith( '/' ):
        new_flag = os.path.join( working_directory, flag )

    for path_flag in path_flags:
      if flag == path_flag:
        make_next_absolute = True
        break

      if flag.startswith( path_flag ):
        path = flag[ len( path_flag ): ]
        new_flag = path_flag + os.path.join( working_directory, path )
        break

    if new_flag:
      new_flags.append( new_flag )
  return new_flags


def IsHeaderFile( filename ):
  extension = os.path.splitext( filename )[ 1 ]
  return extension in [ '.h', '.hxx', '.hpp', '.hh' ]


def GetCompilationInfoForFile( filename ):
  # The compilation_commands.json file generated by CMake does not have entries
  # for header files. So we do our best by asking the db for flags for a
  # corresponding source file, if any. If one exists, the flags for that file
  # should be good enough.
  if IsHeaderFile( filename ):
    basename = os.path.splitext( filename )[ 0 ]
    for extension in SOURCE_EXTENSIONS:
      replacement_file = basename + extension
      if os.path.exists( replacement_file ):
        compilation_info = database.GetCompilationInfoForFile(
          replacement_file )
        if compilation_info.compiler_flags_:
          return compilation_info
    return None
  return database.GetCompilationInfoForFile( filename )


def FlagsForFile( filename, **kwargs ):
  if database:
    # Bear in mind that compilation_info.compiler_flags_ does NOT return a
    # python list, but a "list-like" StringVec object
    compilation_info = GetCompilationInfoForFile( filename )
    if not compilation_info:
      return None

    final_flags = MakeRelativePathsInFlagsAbsolute(
      compilation_info.compiler_flags_,
      compilation_info.compiler_working_dir_ )

  else:
    relative_to = DirectoryOfThisScript()
    final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )

  return {
    'flags': final_flags,
    'do_cache': True
  }

Special characters in directory name

$ pwd /home/yamakaky/téléchargements/TP2_PARAMETRAGE/TP3 Paramétrage PVM (corrigé)
In vim:
:YcmGenerateConfig zsh:1: number expected
", ', ( are valid characters for a file name.

More Noob Friendly Intro

Could you post an example makefile with the bare minumum of what you'd need to generate a ycm_extra_conf file? I'm not really a noob, but I can't really handle understanding the source of large projects like the ones linked in a reasonable time.

Generate include path with absolute system path

This tool is very convenient to generate the '.ycm_extra_conf.py' file.
In most of the case, this file should be placed in the root path with the project source code.
However, I have a requirement that put this file to the upper-level folder.
So YCM could not get the correct place for the include file specified by "-I" because it's not the absolute path.
Is there any possibility that adds a parameter to define if the path in the flags is relative or absolute?
Thanks.

Add -e to make_args

Hi,

please add the switch -e / --environment-overrides to your make_args.
This allows overriding CC, CXX even if they are unconditionally assigned with '=' inside the Makefile.
It should not have any negative side-effects.

Thanks for your work!
Hagen Graf

--compiler option appends ++ to every 'clang' match in the path.

My clang executable is ~/devtoolset/clang/bin/clang++
executing in build folder (cmake), with clang already in $PATH
~/.vim/bundle/YCM-generator/config_gen.py . --verbose -e --compiler /devtoolset/clang/bin/clang++
which: no clang++++ in (
/devtoolset/clang++/bin)

Or:
~/.vim/bundle/YCM-generator/config_gen.py . --verbose -e --compiler /devtoolset/clang/bin
which: no clang++ in (
/devtoolset/clang++/bin)

It is appending ++ in every match, not only at the final clang.
Not much time to solve it, sorry! Hope it helps

Release, master

You doesn't seem to use master. Maybe you should delete it ?
Do you plan to do a release, like 0.1 or 1.0 ?

Does not work with LLVM tree

Clone llvm.git and run ycm-gen on it -- fails. The verbose output is too large to include here; please run yourself.

Breaks when installed in a directory with spaces

My Vim is installed such that this is the path to YCM-Generator:

/Users/ec/Library/System Repo/Dotfiles/vim/bundle/YCM-Generator

Unfortunately, the space in ‘System Repo’ causes YCM-Generator to spit up:

> vim                           
color_coded unavailable: you need to compile it (see README.md)
Press ENTER or type command to continue
zsh:1: permission denied: /Users/ec/Library/System

shell returned 126

Press ENTER or type command to continue

Needs to clear CMake cache before running

Before clearing CMake cache, I had this problem:

$ cmake /home/linux/Projects/ZeldaOOL
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-3.2/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/cc" is not able to compile a simple test program.

Now it seems to be ok. I think it's because I use GCC with CMake, and the fake build uses Clang?

Maybe add a line in README.md to tell users a clear is needed?

Interaction w/ cmake external_project & build sub dir

Hi,
I'm trying to wrap my head around this nice project of yours.
I'm using the following toy repo for reference: https://github.com/MatthiasKauer/cpp-appveyor

If I create a subdirectory:

mkdir build
cd build
cmake ..

I can subsequently make, but your script reports that nothing was logged. Full output:

matthias@rp3deb:~/dvl/cpp-appveyor/build$ python ~/dvl/YCM-Generator/config_gen.py . --verbose
Preparing build directory...
$ make clean
make -f CMakeFiles/Makefile2 clean
make[1]: Entering directory '/home/matthias/dvl/cpp-appveyor/build'
make -f CMakeFiles/catch.dir/build.make CMakeFiles/catch.dir/clean
make[2]: Entering directory '/home/matthias/dvl/cpp-appveyor/build'
/usr/bin/cmake -P CMakeFiles/catch.dir/cmake_clean.cmake
make[2]: Leaving directory '/home/matthias/dvl/cpp-appveyor/build'
make -f CMakeFiles/test_runner.dir/build.make CMakeFiles/test_runner.dir/clean
make[2]: Entering directory '/home/matthias/dvl/cpp-appveyor/build'
/usr/bin/cmake -P CMakeFiles/test_runner.dir/cmake_clean.cmake
make[2]: Leaving directory '/home/matthias/dvl/cpp-appveyor/build'
make[1]: Leaving directory '/home/matthias/dvl/cpp-appveyor/build'

Running make...
$ make -i -j8
/usr/bin/cmake -H/home/matthias/dvl/cpp-appveyor -B/home/matthias/dvl/cpp-appveyor/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/matthias/dvl/cpp-appveyor/build/CMakeFiles /home/matthias/dvl/cpp-appveyor/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/matthias/dvl/cpp-appveyor/build'
make -f CMakeFiles/catch.dir/build.make CMakeFiles/catch.dir/depend
make[2]: Entering directory '/home/matthias/dvl/cpp-appveyor/build'
cd /home/matthias/dvl/cpp-appveyor/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matthias/dvl/cpp-appveyor /home/matthias/dvl/cpp-appveyor /home/matthias/dvl/cpp-appveyor/build /home/matthias/dvl/cpp-appveyor/build /home/matthias/dvl/cpp-appveyor/build/CMakeFiles/catch.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/matthias/dvl/cpp-appveyor/build'
make -f CMakeFiles/catch.dir/build.make CMakeFiles/catch.dir/build
make[2]: Entering directory '/home/matthias/dvl/cpp-appveyor/build'
[ 10%] Creating directories for 'catch'
/usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/build/catch/src/catch
/usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-build
/usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/build/catch
/usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/build/catch/tmp
/usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp
/usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/build/catch/src
/usr/bin/cmake -E touch /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-mkdir
[ 20%] Performing download step (git clone) for 'catch'
cd /home/matthias/dvl/cpp-appveyor/build/catch/src && /usr/bin/cmake -P /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-download-.cmake
-- catch download command succeeded.  See also /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-download-*.log
cd /home/matthias/dvl/cpp-appveyor/build/catch/src && /usr/bin/cmake -E touch /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-download
[ 30%] Performing update step for 'catch'
cd /home/matthias/dvl/cpp-appveyor/build/catch/src/catch && /usr/bin/cmake -P /home/matthias/dvl/cpp-appveyor/build/catch/tmp/catch-gitupdate.cmake
[ 40%] No patch step for 'catch'
/usr/bin/cmake -E echo_append
/usr/bin/cmake -E touch /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-patch
[ 50%] No configure step for 'catch'
cd /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-build && /usr/bin/cmake -E echo_append
cd /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-build && /usr/bin/cmake -E touch /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-configure
[ 60%] No build step for 'catch'
cd /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-build && /usr/bin/cmake -E echo_append
cd /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-build && /usr/bin/cmake -E touch /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-build
[ 70%] No install step for 'catch'
cd /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-build && /usr/bin/cmake -E echo_append
cd /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-build && /usr/bin/cmake -E touch /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-install
[ 80%] Completed 'catch'
/usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/build/CMakeFiles
/usr/bin/cmake -E touch /home/matthias/dvl/cpp-appveyor/build/CMakeFiles/catch-complete
/usr/bin/cmake -E touch /home/matthias/dvl/cpp-appveyor/build/catch/src/catch-stamp/catch-done
make[2]: Leaving directory '/home/matthias/dvl/cpp-appveyor/build'
[ 80%] Built target catch
make -f CMakeFiles/test_runner.dir/build.make CMakeFiles/test_runner.dir/depend
make[2]: Entering directory '/home/matthias/dvl/cpp-appveyor/build'
cd /home/matthias/dvl/cpp-appveyor/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/matthias/dvl/cpp-appveyor /home/matthias/dvl/cpp-appveyor /home/matthias/dvl/cpp-appveyor/build /home/matthias/dvl/cpp-appveyor/build /home/matthias/dvl/cpp-appveyor/build/CMakeFiles/test_runner.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/matthias/dvl/cpp-appveyor/build'
make -f CMakeFiles/test_runner.dir/build.make CMakeFiles/test_runner.dir/build
make[2]: Entering directory '/home/matthias/dvl/cpp-appveyor/build'
[ 90%] Building CXX object CMakeFiles/test_runner.dir/main_catch.cpp.o
/usr/bin/c++    -std=c++11 -I/home/matthias/dvl/cpp-appveyor/build/catch/src/catch/single_include    -o CMakeFiles/test_runner.dir/main_catch.cpp.o -c /home/matthias/dvl/cpp-appveyor/main_catch.cpp
[100%] Linking CXX executable test_runner
/usr/bin/cmake -E cmake_link_script CMakeFiles/test_runner.dir/link.txt --verbose=1
/usr/bin/c++    -std=c++11   CMakeFiles/test_runner.dir/main_catch.cpp.o  -o test_runner -rdynamic 
c++: error: CMakeFiles/test_runner.dir/main_catch.cpp.o: No such file or directory
c++: fatal error: no input files
compilation terminated.
CMakeFiles/test_runner.dir/build.make:97: recipe for target 'test_runner' failed
make[2]: [test_runner] Error 1 (ignored)
make[2]: Leaving directory '/home/matthias/dvl/cpp-appveyor/build'
[100%] Built target test_runner
make[1]: Leaving directory '/home/matthias/dvl/cpp-appveyor/build'
/usr/bin/cmake -E cmake_progress_start /home/matthias/dvl/cpp-appveyor/build/CMakeFiles 0
Build completed in 6.74 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /tmp/tmpePPfRP, C++: /tmp/tmpSvGy8G).
Your build system may not be compatible.

If I generate make files in the top folder, your tool runs successfully. The include for the external project looks weird, however. See below.

flags = [
    '-x',
    'c++',
    '-I/tmp/tmp4wXunX/catch/src/catch/single_include',
    '-std=c++11',
]

I am now wondering: Is there a general issue with out-of-tree builds? The script's help suggests this somehow. Can I use the generator in-tree and then use the config out-of-tree later? Is it sufficient to adjust the include path to the external project manually? This project is header-only, full libraries are going to create bigger trouble, I suppose.

I hope this is a reasonable description.

Kind regards,
Matthias

ERROR: Unknown build system

I'm trying to use YCM-Generator to generate the .ycm_extra_conf.py in my MacVim.
OSX 10.10.4

I got error

:! /Users/yangyy/.vim/bundle/YCM-Generator/config_gen.py -F cc --verbose /Users/yangyy </dev/null
[No write since last change]
ERROR: Unknown build system

shell returned 2

I've referred this issue but it didn't help.

Run :CCGenerateConfig --verbose showed nothing but the same error message?

Parameters for cmake

I have a project built with cmake. For cross-compiling, I have to add -D to cmake, or it could not find the toolchain and wxWidget correctly.

Is it possible to add a parameter in order to append arguments when calling cmake?

Not all includes detected

Using the code here, and running :YcmGenerateConfig, several includes appear to be missing. Errors such as "implicit declaration of function 'kzalloc' " are reported, but 'kzalloc' is defined in linux/slab.h, as noted by the comment. Adding the flag '-I/usr/scr/linux-headers-4.4.0-21/include' appeared to fix most errors on Xubuntu, including the kzalloc one, but a similar flag on Archlinux, '-I/lib/modules/4.5.4-1-ARCH/build/include/linux' did not.

qmake support

It'd be nice to have support for qmake.

I gave it a quick try, but I got stuck trying to set a custom compiler for qmake... Apparently it'd involve writing a custom mkspec. Bleh.

ERROR: No commands were logged to the build logs (cmake/clang/ubuntu-14.04)

I used cmake & clang to build & compile my project
I ran ./config_gen.py -v $PRJROOT, and I got this:

Preparing build directory...
$ make clean

Running make...
$ make -i -j4
[  1%] [  2%] Running C++ protocol buffer compiler on message.proto
Building CXX object src/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[  3%] [  5%] Building CXX object src/util/CMakeFiles/util.dir/md5_hash.cc.o
Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer.dir/memory_piece.cc.o
Scanning dependencies of target message
[  6%] Building CXX object src/message/CMakeFiles/message.dir/message.pb.cc.o
[  7%] Building CXX object src/util/CMakeFiles/util.dir/simple_hash.cc.o
[  9%] Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer.dir/memory_allocator.cc.o
[ 10%] Building CXX object src/util/CMakeFiles/util.dir/logging.cc.o
[ 11%] Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer.dir/sorted_buffer.cc.o
[ 13%] Building CXX object src/message/CMakeFiles/message.dir/protofile.cc.o
[ 14%] Building CXX object src/util/CMakeFiles/util.dir/strcodec.cc.o
[ 15%] Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer.dir/sorted_buffer_iterator.cc.o
[ 17%] Building CXX object src/message/CMakeFiles/message.dir/asciifile.cc.o
[ 18%] Building CXX object src/util/CMakeFiles/util.dir/split_string.cc.o
[ 19%] Building CXX object src/util/CMakeFiles/util.dir/stringprintf.cc.o
[ 21%] Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer.dir/__/util/stringprintf.cc.o
[ 22%] Building CXX object src/util/CMakeFiles/util.dir/random.cc.o
[ 23%] Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer.dir/__/util/varint32.cc.o
Linking CXX static library libsorted_buffer.a
[ 23%] Built target sorted_buffer
[ 25%] Building CXX object src/message/CMakeFiles/message.dir/reader.cc.o
[ 26%] Building CXX object src/util/CMakeFiles/util.dir/bitmap.cc.o
[ 27%] Building CXX object src/util/CMakeFiles/util.dir/varint32.cc.o
[ 28%] Building CXX object src/user/cxx/CMakeFiles/brook.dir/initial/brook.cc.o
Linking CXX static library libmessage.a
[ 28%] Built target message
Scanning dependencies of target communication
[ 30%] Building CXX object src/communication/CMakeFiles/communication.dir/mpi_sendrecv.cc.o
Linking CXX static library libbrook.a
[ 30%] Built target brook
[ 31%] Building CXX object src/system/CMakeFiles/system.dir/filepattern.cc.o
[ 32%] Building CXX object src/communication/CMakeFiles/communication.dir/signaling_queue.cc.o
[ 34%] Building CXX object src/system/CMakeFiles/system.dir/condition_variable.cc.o
Linking CXX static library libsystem.a
[ 34%] Built target system
[ 35%] Building CXX object src/consistency/CMakeFiles/consistency.dir/fifo.cc.o
Linking CXX static library libutil.a
[ 35%] Built target util
[ 36%] Building CXX object src/consistency/CMakeFiles/consistency.dir/consistency.cc.o
[ 38%] Building CXX object src/communication/CMakeFiles/communication.dir/mpi_communicator.cc.o
Linking CXX static library libconsistency.a
[ 38%] Built target consistency
[ 39%] Building CXX object src/executor/demo/CMakeFiles/client.dir/client.cc.o
Linking CXX static library libgtest.a
[ 39%] Built target gtest
[ 40%] Building CXX object src/gtest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
Linking CXX executable client
[ 40%] Built target client
Linking CXX static library libgtest_main.a
[ 40%] Built target gtest_main
[ 42%] [ 43%] Building CXX object src/util/CMakeFiles/class_register_test.dir/class_register_test.cc.o
Building CXX object src/util/CMakeFiles/bitmap_test.dir/bitmap_test.cc.o
[ 44%] Building CXX object src/util/CMakeFiles/file_util_test.dir/file_util_test.cc.o
Linking CXX executable file_util_test
[ 44%] Built target file_util_test
[ 46%] Building CXX object src/util/CMakeFiles/join_strings_test.dir/join_strings_test.cc.o
Linking CXX executable bitmap_test
[ 46%] Built target bitmap_test
[ 47%] Building CXX object src/util/CMakeFiles/md5_hash_test.dir/md5_hash_test.cc.o
Linking CXX static library libcommunication.a
[ 47%] Built target communication
[ 48%] Building CXX object src/util/CMakeFiles/split_string_test.dir/split_string_test.cc.o
[ 50%] Building CXX object src/util/CMakeFiles/class_register_test.dir/class_register_test_helper.cc.o
Linking CXX executable md5_hash_test
Linking CXX executable join_strings_test
[ 50%] Built target md5_hash_test
[ 51%] Building CXX object src/util/CMakeFiles/stl-util_test.dir/stl-util_test.cc.o
[ 51%] Built target join_strings_test
[ 52%] Building CXX object src/util/CMakeFiles/strcodec_test.dir/strcodec_test.cc.o
Linking CXX executable class_register_test
[ 52%] Built target class_register_test
[ 53%] Building CXX object src/util/CMakeFiles/stringprintf_test.dir/stringprintf_test.cc.o
Linking CXX executable split_string_test
[ 53%] Built target split_string_test
[ 55%] Building CXX object src/util/CMakeFiles/varint32_test.dir/varint32_test.cc.o
Linking CXX executable stl-util_test
Linking CXX executable strcodec_test
[ 55%] Built target stl-util_test
[ 56%] Building CXX object src/parameter/CMakeFiles/carray_vector_tmpl_test.dir/carray_vector_tmpl_test.cc.o
Linking CXX executable stringprintf_test
[ 56%] Built target strcodec_test
[ 57%] Building CXX object src/parameter/CMakeFiles/dense_store_tmpl_test.dir/dense_store_tmpl_test.cc.o
[ 57%] Built target stringprintf_test
[ 59%] Building CXX object src/parameter/CMakeFiles/server_parameter_tmpl_test.dir/server_parameter_tmpl_test.cc.o
Linking CXX executable varint32_test
[ 59%] Built target varint32_test
[ 60%] Building CXX object src/parameter/CMakeFiles/skip_list_tmpl_test.dir/skip_list_tmpl_test.cc.o
Linking CXX executable carray_vector_tmpl_test
[ 60%] Built target carray_vector_tmpl_test
[ 61%] Building CXX object src/parameter/CMakeFiles/sparse_store_tmpl_test.dir/sparse_store_tmpl_test.cc.o
Linking CXX executable skip_list_tmpl_test
Linking CXX executable dense_store_tmpl_test
[ 61%] Built target skip_list_tmpl_test
[ 63%] Building CXX object src/parameter/CMakeFiles/update_tmpl_test.dir/update_tmpl_test.cc.o
[ 63%] Built target dense_store_tmpl_test
[ 64%] Building CXX object src/parameter/CMakeFiles/version_buffer_tmpl_test.dir/version_buffer_tmpl_test.cc.o
Linking CXX executable server_parameter_tmpl_test
[ 64%] Built target server_parameter_tmpl_test
[ 65%] Building CXX object src/message/CMakeFiles/asciifile_test.dir/asciifile_test.cc.o
Linking CXX executable sparse_store_tmpl_test
Linking CXX executable update_tmpl_test
[ 65%] Built target sparse_store_tmpl_test
Scanning dependencies of target message_test
[ 65%] Built target update_tmpl_test
[ 67%] Building CXX object src/message/CMakeFiles/message_test.dir/message_test.cc.o
[ 68%] Building CXX object src/message/CMakeFiles/partition_test.dir/partition_test.cc.o
Linking CXX executable asciifile_test
[ 68%] Built target asciifile_test
Scanning dependencies of target reader_test
[ 69%] Building CXX object src/message/CMakeFiles/reader_test.dir/reader_test.cc.o
Linking CXX executable version_buffer_tmpl_test
[ 69%] Built target version_buffer_tmpl_test
Scanning dependencies of target brook_main
[ 71%] Building CXX object src/executor/CMakeFiles/brook_main.dir/brook_main.cc.o
Linking CXX executable partition_test
[ 71%] Built target partition_test
[ 72%] Building CXX object src/system/CMakeFiles/condition_variable_test.dir/condition_variable_test.cc.o
[ 73%] Building CXX object src/executor/CMakeFiles/brook_main.dir/brook.cc.o
Linking CXX executable message_test
[ 73%] Built target message_test
[ 75%] Building CXX object src/system/CMakeFiles/filepattern_test.dir/filepattern_test.cc.o
Linking CXX executable reader_test
[ 75%] Built target reader_test
Linking CXX executable condition_variable_test
[ 76%] Building CXX object src/system/CMakeFiles/mutex_test.dir/mutex_test.cc.o
[ 76%] Built target condition_variable_test
[ 77%] Building CXX object src/consistency/CMakeFiles/consistency_asp_test.dir/consistency_asp_test.cc.o
Linking CXX executable filepattern_test
[ 77%] Built target filepattern_test
[ 78%] Building CXX object src/consistency/CMakeFiles/consistency_bsp_test.dir/consistency_bsp_test.cc.o
Linking CXX executable mutex_test
[ 78%] Built target mutex_test
[ 80%] Building CXX object src/consistency/CMakeFiles/consistency_ssp_test.dir/consistency_ssp_test.cc.o
Linking CXX executable consistency_asp_test
[ 80%] Built target consistency_asp_test
[ 81%] Building CXX object src/consistency/CMakeFiles/fifo_test.dir/fifo_test.cc.o
Linking CXX executable consistency_bsp_test
[ 81%] Built target consistency_bsp_test
Scanning dependencies of target mpi_communicator_test
[ 82%] Building CXX object src/communication/CMakeFiles/mpi_communicator_test.dir/mpi_communicator_test.cc.o
Linking CXX executable consistency_ssp_test
[ 82%] Built target consistency_ssp_test
[ 84%] Building CXX object src/communication/CMakeFiles/mpi_sendrecv_test.dir/mpi_sendrecv_test.cc.o
[ 85%] Building CXX object src/executor/CMakeFiles/brook_main.dir/agent.cc.o
Linking CXX executable fifo_test
[ 85%] Built target fifo_test
Scanning dependencies of target signaling_queue_test
[ 86%] Building CXX object src/communication/CMakeFiles/signaling_queue_test.dir/signaling_queue_test.cc.o
[ 88%] Building CXX object src/executor/CMakeFiles/brook_main.dir/server.cc.o
[ 89%] Building CXX object src/executor/CMakeFiles/brook_main.dir/flags.cc.o
Linking CXX executable mpi_sendrecv_test
[ 89%] Built target mpi_sendrecv_test
[ 90%] Building CXX object src/sorted_buffer/CMakeFiles/memory_allocator_test.dir/memory_allocator_test.cc.o
[ 92%] Building CXX object src/executor/CMakeFiles/brook_main.dir/master.cc.o
Linking CXX executable memory_allocator_test
[ 92%] Built target memory_allocator_test
[ 93%] Building CXX object src/sorted_buffer/CMakeFiles/memory_piece_io_test.dir/memory_piece_io_test.cc.o
Linking CXX executable brook_main
[ 93%] Built target brook_main
[ 94%] Building CXX object src/sorted_buffer/CMakeFiles/memory_piece_less_than_test.dir/memory_piece_less_than_test.cc.o
Linking CXX executable mpi_communicator_test
[ 94%] Built target mpi_communicator_test
[ 96%] Building CXX object src/sorted_buffer/CMakeFiles/memory_piece_test.dir/memory_piece_test.cc.o
Linking CXX executable memory_piece_io_test
Linking CXX executable signaling_queue_test
[ 96%] Built target memory_piece_io_test
[ 97%] Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer_iterator_test.dir/sorted_buffer_iterator_test.cc.o
Linking CXX executable memory_piece_test
[ 97%] Built target signaling_queue_test
[ 98%] Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer_regression_test.dir/sorted_buffer_regression_test.cc.o
[ 98%] Built target memory_piece_test
[100%] Building CXX object src/sorted_buffer/CMakeFiles/sorted_buffer_test.dir/sorted_buffer_test.cc.o
Linking CXX executable memory_piece_less_than_test
[100%] Built target memory_piece_less_than_test
Linking CXX executable sorted_buffer_test
Linking CXX executable sorted_buffer_iterator_test
[100%] Built target sorted_buffer_test
[100%] Built target sorted_buffer_iterator_test
Linking CXX executable sorted_buffer_regression_test
[100%] Built target sorted_buffer_regression_test
Build completed in 27.67 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /tmp/tmpMjqUff, C++: /tmp/tmp0LKPaA).
Your build system may not be compatible.

Any suggestions?

"YCM-Generator/fake-toolchain/Unix/clang" is not able to compile a simple test program

[nix-shell:~/dev/genesis]$ ~/Downloads/YCM-Generator/config_gen.py . --verbose
Running cmake in '/run/user/1000/tmpVUUWXy'...
$ cmake /home/andy/dev/genesis
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang -- broken
CMake Error at /nix/store/l2w8cfzgh72ggz00afgig2scywz0snk0-cmake-3.2.2/share/cmake-3.2/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler
  "/home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang" is not able
  to compile a simple test program.

  It fails with the following output:

   Change Dir: /run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp



  Run Build
  Command:"/nix/store/hv8pgyn6a0a5h9dyd7s7cwh5105gykj5-gnumake-4.1/bin/make"
  "cmTryCompileExec2779557708/fast"

  /nix/store/hv8pgyn6a0a5h9dyd7s7cwh5105gykj5-gnumake-4.1/bin/make -f
  CMakeFiles/cmTryCompileExec2779557708.dir/build.make
  CMakeFiles/cmTryCompileExec2779557708.dir/build

  make[1]: Entering directory '/run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp'

  /nix/store/l2w8cfzgh72ggz00afgig2scywz0snk0-cmake-3.2.2/bin/cmake -E
  cmake_progress_report
  /run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building C object
  CMakeFiles/cmTryCompileExec2779557708.dir/testCCompiler.c.o

  /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang -o
  CMakeFiles/cmTryCompileExec2779557708.dir/testCCompiler.c.o -c
  /run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp/testCCompiler.c

  make[1]: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang:
  Command not found

  CMakeFiles/cmTryCompileExec2779557708.dir/build.make:57: recipe for target
  'CMakeFiles/cmTryCompileExec2779557708.dir/testCCompiler.c.o' failed

  make[1]: *** [CMakeFiles/cmTryCompileExec2779557708.dir/testCCompiler.c.o]
  Error 127

  make[1]: Leaving directory '/run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp'

  Makefile:117: recipe for target 'cmTryCompileExec2779557708/fast' failed

  make: *** [cmTryCompileExec2779557708/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:11 (project)


-- Configuring incomplete, errors occurred!
See also "/run/user/1000/tmpVUUWXy/CMakeFiles/CMakeOutput.log".
See also "/run/user/1000/tmpVUUWXy/CMakeFiles/CMakeError.log".

Running make...
$ make -i -j8
make: *** No targets specified and no makefile found.  Stop.

Cleaning up...

Build completed in 0.29 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /run/user/1000/tmpv8jjBA, C++: /run/user/1000/tmpbvAir8).
Your build system may not be compatible.

[nix-shell:~/dev/genesis]$ clang --version
clang version 3.6.1 (tags/RELEASE_361/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Error when executing YCM-Generator/fake-toolchain/Unix/clang++ on Ubuntu 14.04

I noticed in the latest version of YCM-Generator, .ycm_extra_conf.py was not being generated correctly. I'm running 64-bit Ubuntu 14.04. The last working commit of YCM-Generator for me is 355155c. The first commit where things no longer work is 6ae9ab0.

Running config_gen.py on a simple hello world cmake C++ project using commit 6ae9ab0 yields,

% ~/.vim/bundle/YCM-Generator/config_gen.py -v .                                                                                    !11310
Running cmake in '/tmp/tmpWiViSs'...
$ cmake /tmp/hello
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working CXX compiler: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++
-- Check for working CXX compiler: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmpWiViSs

Running make...
$ make -i -j4
Scanning dependencies of target hello
[100%] Building CXX object CMakeFiles/hello.dir/hello.cpp.o
/home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++: 3: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++: [[: not found
/home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++: 7: [: -o: unexpected operator
Linking CXX executable hello
/home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++: 3: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++: [[: not found
clang version 3.5.0 (fake toolchain)
[100%] Built target hello

Cleaning up...

Build completed in 0.22 sec

Collected 6 relevant entries for C compilation (0 discarded).
Collected 6 relevant entries for C++ compilation (0 discarded).
Created YCM config file with 0 C++ flags

There appear to be shell script errors. Running config_gen.py on the same project using commit 355155c yields,

  % ~/.vim/bundle/YCM-Generator/config_gen.py -v .                                                                                    !11312
Running cmake in '/tmp/tmpD33Hor'...
$ cmake /tmp/hello
-- The C compiler identification is Clang 3.4.0
-- The CXX compiler identification is Clang 3.4.0
-- Check for working C compiler: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++
-- Check for working CXX compiler: /home/jdaly/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmpD33Hor

Running make...
$ make -i -j4
Scanning dependencies of target hello
[100%] Building CXX object CMakeFiles/hello.dir/hello.cpp.o
Linking CXX executable hello
[100%] Built target hello

Cleaning up...

Build completed in 0.62 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 2 relevant entries for C++ compilation (0 discarded).
Created YCM config file with 0 C++ flags

When I run config_gen.py from commit 6ae9ab0 or later on my actual project, the result is that none of the include paths are set.

Thanks for your work on YCM-Generator! It's a great help. Let me know if I can help sort this issue out.

Linux Kernel Flags

Hi,
I've been trying to use YCM for Yocto Project's linux kernel source code. From what I read, this generator is tested against the kernel source (not quite the same as Yocto's, but should be close...).
I've been trying to use this tool in the top directory of the source code, and the config file does generate. However, it seems there's alot missing... Just opening kernel/exit.c has YCM throwing a bunch of errors about things not being defined/etc.

Here's all the output:

~/Code/linux(hw1 ✔) ~/.vim/plugged/YCM-Generator/config_gen.py ~/Code/linux/ --preserve-environment
'/home/jadin/Code/linux/.ycm_extra_conf.py' already exists. Overwrite? [y/N] y
 Preparing build directory...
$ make clean

Running make...
$ make -i -j4
Build completed in 6.09 sec

WARNING: 232 distinct definitions of macro KBUILD_MODNAME found
WARNING: 232 distinct definitions of macro KBUILD_BASENAME found
Collected 288 relevant entries for C compilation (176 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
Created YCM config file with 54 C flags

Using the newest source from git://git.yoctoproject.org/linux-yocto-3.14, tag v3.14.26.

Is this tool not going to work for me? Or am I missing some necessary option?

Thanks!

Generation for CloudCompare

Hi!

Can you explain me how to get rid of the error when generating the YCM configuration for the CloudCompare project at https://github.com/cloudcompare/trunk ?

Everything seem to work fine except those lines saying "no rules to make *.so".
The whole compilation process works fine without YCM-Generator but I can't get the TCM configuration I'm looking for.

Many thanks in advance!

env entry for HOME

Hi,

First of all thanks for taking the effort to automate config files for YCM. Although i think i have a possible enhancement.

find_package command in cmake searches for the package config file in couple of directories, one of the directories is $HOME/.cmake/packages/<package>/. A file with random name in the aforementioned directories points to the location of config file. This happens when the package we are looking for uses the export(PACKAGE) and doesn't provide install option. Unfortunately i was using such packages.

cmake in all cases was working, but YCM-Generator was failing for packages in User package registry, reason being env passed to run was not containing entry for HOME. I know one can use the preserve_environment for such cases, but having HOME in for the default case could be benficial all around.

ERROR: No commands were logged to the build logs . Your build system may not be compatible.

CppTest  python2 ~/.vim/bundle/YCM-Generator/config_gen.py ~/CppTest --verbose
Running cmake in '/tmp/tmpMaTYE9'...
$ cmake /home/maik/CppTest
-- The C compiler identification is Clang 3.7.0
-- The CXX compiler identification is Clang 3.7.0
-- Check for working C compiler: /home/maik/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/maik/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/maik/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++
-- Check for working CXX compiler: /home/maik/.vim/bundle/YCM-Generator/fake-toolchain/Unix/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmpMaTYE9

Running make...
$ make -i -j4
Scanning dependencies of target CppTest
[ 50%] Building CXX object CMakeFiles/CppTest.dir/main.cpp.o
[100%] Linking CXX executable CppTest
[100%] Built target CppTest

Cleaning up...

Build completed in 6.1 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /tmp/tmphWWHFL, C++: /tmp/tmpdBfH6z).
Your build system may not be compatible.
project(CppTest)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
SET (CMAKE_CXX_COMPILER             "/usr/bin/clang++")
SET (CMAKE_CXX_FLAGS                "-std=c++1z")
INCLUDE_DIRECTORIES(libs)
➜  CppTest  ls
CMakeLists.txt  CMakeLists.txt.user  libs  main.cpp

Some flags arguments are truncated

For example the compilation flag
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

would be parsed and added to the ycm_extra_conf.py just as :
-isysroot
stripping the directory location

My guess is that the generator split the string with spaces and ignore pieces that does not start with the char '-'

I can't config for my own project

while i run ./config_gen.py $PROJECT_DIR in the shell, I got below:

Running cmake in '/tmp/tmpppC4tz'...
$ cmake /home/huangzh/Github/face-alignment-at-3000fps
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /home/huangzh/.vim_runtime/sources_non_forked/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/huangzh/.vim_runtime/sources_non_forked/YCM-Generator/fake-toolchain/Unix/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/huangzh/.vim_runtime/sources_non_forked/YCM-Generator/fake-toolchain/Unix/clang++
-- Check for working CXX compiler: /home/huangzh/.vim_runtime/sources_non_forked/YCM-Generator/fake-toolchain/Unix/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:7 (add_executable):
Cannot find source file:

./../liblinear/blas/blas.h

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx

CMake Error: CMake can not determine linker language for target: application
CMake Error: Cannot determine link language for target "application".

so it can't make successfully. And blas.h mentioned above is some header file for my project in the the $PROJECT_DIR. Hope for advice.

package request.

hello,
I want to pack this git repo and upload to aur(archlinux user repository).may I?
ssfdust

OSX qmake support

Hi,
I've tried to generate a .ycm_extra_conf.py for a qmake project (Qt5) on Mac OSX and realized that config_gen.py creates a Makefile for linux platforms. So I've changed (line 270)

env_config["QMAKESPEC"] = "unsupported/linux-clang" if qt_version == "4" else "linux-clang"

to

env_config["QMAKESPEC"] = "unsupported/macx-clang" if qt_version == "4" else "macx-clang"

to get a OSX specific Makefile. After that YCM-Generator does not find any build flags any more, although the build passes without any problems. Any ideas why the OSX configuration does not work?

How to pass build system options?

I need to pass configure options to an autotools-based project to disable a feature that seems to be hard-enabled - configure fails if a dependency can't be found.
In this case it already would help if the simple "found Makefile" case could be used in the first place (IMHO would make sense in any case) as "autotools" and "cmake" will create a functional Makefile.
Or give a CMDLine option to forcefully select a generator?

Furthermore YCM-Generator seems to be "destructive" - it runs make clean and cleans up a perfectly fine configured build environment.

YCM-Generator returns "ERROR: No commands were logged to the build log"

Hello, I use YCM-Generator as a vim plugin, and run :YcmGenerateConfig in vim. But something was wrong with the following log. I ran echo $CC to make sure I didn't use my own environment variables.

Preparing build directory...
$ make clean

Running make...
$ make -i -j2
Build completed in 2.01 sec
ERROR: No commands were logged to the build log (/tmp/tmp60ki41).
Your build system may not be compatible.

Shell 已返回3

请按 ENTER 或其它命令继续

PS: the project I want to use YCM is the uboot source code, and I can compile it in my environment with arm-gcc. Here is my environment variables to compile it.

  1 #                                                                                                   
  2 # project env-setup                                                                            
  3 #                                                                                                   
  4                                                                                                     
  5 export PRJROOT=$(pwd)                                                                               
  6                                                                                                     
  7 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin                                   
  8 #
  9 #export PATH=$PATH:${TOOLCHAIN}                                                                     
 10 export ARCH=arm                                                                                     
 11 #export CROSS=arm-cortex_a9-linux-gnueabi                                                           
 12 export CROSS=arm-linux-gnueabi                                                                      
 13 export CROSS_COMPILE=${CROSS}-                                                                      
 14 export CC=${CROSS}-gcc                                                                              
 15 export CXX=${CROSS}-g++                                                                             
 16 export LD=${CROSS}-ld                                                                               
 17 export AR=${CROSS}-ar                                                                               
 18 export NM=${CROSS}-nm                                                                               
 19 export RANLIB=${CROSS}-ranlib                                                                       
 20 export STRIP=${CROSS}-strip                                                                         
 21 export BUILD_DIR=/home/sunyongfeng/src/uboot/build

Fails when clang path contains "clang"

My version of clang is installed in path that contains "clang" in its name, i.e. ~/build/share/clang/trunk/bin/clang.
This tools fails because to determine the path of the c++ compiler, it replaces "clang" with "clang++", leading to:
ERROR: Could not find clang++ at '/build/share/clang++/trunk/bin/clang++'. Please make sure it is installed and specified appropriately
I temporarily fixed it locally by using
cxx = os.path.join(os.path.dirname(args["compiler"]), 'clang++') or 'clang++'
but you might prefer an other/better solution.

Do I need to manually add path?

This problem doesn't happen to my mac, but only to the linux server:

Using the extra conf generated, when typing "#include ...", I don't get prompted of the system library, but only those in my project folder.

It still works okay when trying to jump to definition from c lib functions such as "strcmp"...

The server runs on scientific linux the gcc of which is old, and I use devtoolset-2 to update its gcc. so the gcc is located at /opt/rh/devtoolset-2/root/usr/bin/gcc. However, the header files I think are still located in /usr/include. If adding this path with -I flag to extra conf my problem solved!

Am I supposed to do so? Or there is some other problems with my setting?

thanks!

ERROR: No commands were logged to the build log when clang is not installed

It also says:
Your build system may not be compatible.

I'm using cmake to build my project. Cmake configures fine and then using make the build succeeds. However, YCM-Generator can not produce any output. I tried this on two different machines.

Sorry for the lack of info, but I'm not sure how to get any more debug info from the program.

The line parser ignores critical cmake output

This is partially due to intended behaviour.

I am currently working on a rather large cmake project.
When building, CMake builds individual objects and then links them all. The necessary compiler flags are passed only during compilation of the temporary objects. As such, few lines are read, none of which contain any flags that are useful for YCM-Generator.

I fixed this by disabling the temporary output exclusion.

Build Error

I am trying to generate a config file for the code here: https://github.com/EntilZha/GrappaRDD. The makefile there references a Makefile generated from the project here: https://github.com/EntilZha/grappa. This is being executed on a clean Linux Mint 17 VM.

If I run make -i -j2 from the shell I get the following (correct) output and a program:

pedro@terminus /media/sf_Code/GrappaRDD $ make clean
rm -f main.o main
pedro@terminus /media/sf_Code/GrappaRDD $ make
/usr/bin/g++ -DENABLE_RDMA_AGGREGATOR  -std=c++11 -Winline -Wno-inline -mno-red-zone  -O3 -g -DNDEBUG -I/home/pedro/dependencies/grappa/build/Make+Release/install/include -I/home/pedro/dependencies/grappa/build/Make+Release/install/include/Grappa -I/home/pedro/dependencies/grappa/build/Make+Release/install/include/Grappa/tasks -I/usr/local/include   -c -o main.o main.cpp
/usr/bin/g++ -Wl,-rpath  -Wl,/usr/local/lib  -Wl,--enable-new-dtags  -L/home/pedro/dependencies/grappa/build/Make+Release/install/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu  main.o  -Wl,-Bstatic -lGrappa -lglog -lgflags -lgraph500-generator -lboost_system -lboost_filesystem -Wl,-Bdynamic -lmpicxx -lmpi -lpthread -lrt -o main

However, when I run ~/.vim/bundle/YCM-Generator/config_gen.py -v -e . I get

pedro@terminus /media/sf_Code/GrappaRDD $ ~/.vim/bundle/YCM-Generator/config_gen.py -v -e .
Preparing build directory...
$ make clean
rm -f main.o main

Running make...
$ make -i -j2
/usr/bin/g++ -DENABLE_RDMA_AGGREGATOR  -std=c++11 -Winline -Wno-inline -mno-red-zone  -O3 -g -DNDEBUG -I/home/pedro/dependencies/grappa/build/Make+Release/install/include -I/home/pedro/dependencies/grappa/build/Make+Release/install/include/Grappa -I/home/pedro/dependencies/grappa/build/Make+Release/install/include/Grappa/tasks -I/usr/local/include   -c -o main.o main.cpp
/usr/bin/g++ -Wl,-rpath  -Wl,/usr/local/lib  -Wl,--enable-new-dtags  -L/home/pedro/dependencies/grappa/build/Make+Release/install/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu  main.o  -Wl,-Bstatic -lGrappa -lglog -lgflags -lgraph500-generator -lboost_system -lboost_filesystem -Wl,-Bdynamic -lmpicxx -lmpi -lpthread -lrt -o main
g++: error: main.o: No such file or directory
make: [main] Error 1 (ignored)
Build completed in 4.14 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /tmp/tmpGRwJep, C++: /tmp/tmp8JlxNM).
Your build system may not be compatible.

I understand what that error (missing file), but I don't know why it happens only when I run the generate script. Any ideas?

support for meson build system

I'm trying out meson for a few pet projects and I was hoping if YCM-Generator could support it. It generates a compile_command.json, just like CMake does, of such format -

[
  {
    "directory": "/home/agauniyal/projects/rang/build",
    "command": "ccache c++  '-pipe' '-Wall' '-Winvalid-pch' '-Wnon-virtual-dtor' '-std=c++11' '-g' '-Itest/RCBTest@exe' '-I../test' '-Itest' '-Iinclude' '-I../include' '-MMD' '-MQ' 'test/RCBTest@exe/RCBTest.cpp.o' '-MF' 'test/RCBTest@exe/RCBTest.cpp.o.d' -o 'test/RCBTest@exe/RCBTest.cpp.o' -c ../test/RCBTest.cpp",
    "file": "../test/RCBTest.cpp"
  },
  {
    "directory": "/home/agauniyal/projects/rang/build",
    "command": "ccache c++  '-pipe' '-Wall' '-Winvalid-pch' '-Wnon-virtual-dtor' '-std=c++11' '-g' '-Itest/VTest@exe' '-I../test' '-Itest' '-Iinclude' '-I../include' '-MMD' '-MQ' 'test/VTest@exe/visualTest.cpp.o' '-MF' 'test/VTest@exe/visualTest.cpp.o.d' -o 'test/VTest@exe/visualTest.cpp.o' -c ../test/visualTest.cpp",
    "file": "../test/visualTest.cpp"
  }
]

append default flags

Provide an option to append some flags since it works on per project basis. eg. I would like to append these flags in front of my .ycm file

'-Wall',
'-Wextra',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
'-DUNIT_TESTS',
'-std=c++11',
'-x', 'c++',
'-isystem', '/home/sehe/custom/boost',
'-isystem', '/usr/lib/gcc/x86_64-linux-gnu/4.8/include',
'-I', 'src',
'-I', 'include',
'-isystem', '/usr/include',
'-isystem', '/usr/local/include', 

ERROR: Unknown build system

I get the following error:

ERROR: Unknown build system

after running

~/.vim/bundle/YCM-Generator/config_gen.py --verbose --compiler clang-3.6 .

on

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:    14.04
Codename:   trusty

Unable to generate config form CMake

» ~/.vim/bundle/git-YCM-Generator/config_gen.py -v -c clang-3.8 .
Running cmake in '/tmp/user/1000/tmpayXnMA'...
$ cmake /home/foo_daten/dev/00_pool/c++/libobi
-- The C compiler identification is Clang 3.8.1
-- The CXX compiler identification is Clang 3.8.1
-- Check for working C compiler: /home/foo/.vim/bundle-available-github/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/foo/.vim/bundle-available-github/YCM-Generator/fake-toolchain/Unix/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/foo/.vim/bundle-available-github/YCM-Generator/fake-toolchain/Unix/clang++
-- Check for working CXX compiler: /home/foo/.vim/bundle-available-github/YCM-Generator/fake-toolchain/Unix/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:29 (if):
Policy CMP0064 is not set: Support new TEST if() operator. Run "cmake
--help-policy CMP0064" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.

TEST will be interpreted as an operator when the policy is set to NEW.
Since the policy is not set the OLD behavior will be used.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/user/1000/tmpayXnMA

Running make...
$ make -i -j8

Cleaning up...

Build completed in 1.75 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /tmp/user/1000/tmpnwICnA, C++: /tmp/user/1000/tmpDHpXUi).
Your build system may not be compatible.
foo@bar:/home/foo_daten/dev/00_pool/c++/libobi
git: master *%=

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.