Skip to main content
added 6 characters in body
Source Link

    % tree . 
    └── src
        ├── bar
        │   ├── bar.c
        │   └── bar.h
        └── foo
            ├── foo.c
            └── foo.h


In this case, perhaps the following cmake file will work for you.  Call it CMakeLists.txt and put it in the top directory.

    cmake_minimum_required(VERSION 3.5)
    project(myProjectName)
    file(GLOB_RECURSE SRC_FILES src/*.c)
    add_executable(myProjectName ${SRC_FILES})

BuildPut build commands for the project in the directory ./build by calling 

    cmake -H. -Bbuild

Then export the compile command to a file that rtags will use

    cmake build -DCMAKE_EXPORT_COMPILE_COMMANDS=1

And build the project

    cmake --build build

Now, to make sure things are working cleanly, clear projects and quit the rdm daemon if it was running with 

    rc -C
    rc -q

and restart the daemon

    rdm &

and read that .json file you exported from cmake

    rc -J build

You should see output like this:

    % rc -J build                                                                                                                                                         Cprogrammingglanguage/wtf (hcn ⚡) alejandro
    [Server] Compilation database loading...
     % [  3%] 1/35 23:40:23 ~/Google Drive/Work Cloud/... in 211ms. (549 syms, 780 symNames, 28 includes, 17 of 22 files, symbols: 792 of 1445, 1840 cursors, 21 queried 86ms) (37/111/49ms). (priority 0)
    [  6%] 2/35 23:40:24 ~/Google Drive/Work Cloud/.../code/main/src/inrflow/reporting.c in 226ms. (1354 syms, 521 symNames, 15 includes, 6 of 87 files, symbols: 1714 of 4676, 7220 cursors, 5 queried 2ms) (119/61/25ms). (priority 0)

Note the following pitfall: can't have spaces in the path to the project.  I worked around this by symlinking to the project folder from a space-less path.

*Now* you are finally able to start following the rest of the instructions in [1] about configuring `rtags`, `company-rtags`, rtags + helm, `irony-mode`, `company-irony`, `company-irony-c-headers`, and `flycheck-rtags`, and `cmake-ide`, which mostly follows the documentation for each package.

I tend to fumble through these things and would like to help other users, so constructive comments are welcome.

  [1]: http://syamajala.github.io/c-ide.html
  [2]: https://github.com/Andersbakken/rtags



    % tree . └── src
        ├── bar
        │   ├── bar.c
        │   └── bar.h
        └── foo
            ├── foo.c
            └── foo.h


In this case, perhaps the following cmake file will work for you.  Call it CMakeLists.txt and put it in the top directory.

    cmake_minimum_required(VERSION 3.5)
    project(myProjectName)
    file(GLOB_RECURSE SRC_FILES src/*.c)
    add_executable(myProjectName ${SRC_FILES})

Build the project in the directory ./build by calling 

    cmake -H. -Bbuild

Then export the compile command to a file that rtags will use

    cmake build -DCMAKE_EXPORT_COMPILE_COMMANDS=1

And build the project

    cmake --build build

Now, to make sure things are working cleanly, clear projects and quit the rdm daemon if it was running with 

    rc -C
    rc -q

and restart the daemon

    rdm &

and read that .json file you exported from cmake

    rc -J build

You should see output like this:

    % rc -J build                                                                                                                                                         Cprogrammingglanguage/wtf (hcn ⚡) alejandro
    [Server] Compilation database loading...
     % [  3%] 1/35 23:40:23 ~/Google Drive/Work Cloud/... in 211ms. (549 syms, 780 symNames, 28 includes, 17 of 22 files, symbols: 792 of 1445, 1840 cursors, 21 queried 86ms) (37/111/49ms). (priority 0)
    [  6%] 2/35 23:40:24 ~/Google Drive/Work Cloud/.../code/main/src/inrflow/reporting.c in 226ms. (1354 syms, 521 symNames, 15 includes, 6 of 87 files, symbols: 1714 of 4676, 7220 cursors, 5 queried 2ms) (119/61/25ms). (priority 0)

Note the following pitfall: can't have spaces in the path to the project.  I worked around this by symlinking to the project folder from a space-less path.

*Now* you are finally able to start following the rest of the instructions in [1] about configuring `rtags`, `company-rtags`, rtags + helm, `irony-mode`, `company-irony`, `company-irony-c-headers`, and `flycheck-rtags`, and `cmake-ide`, which mostly follows the documentation for each package.

I tend to fumble through these things and would like to help other users, so constructive comments are welcome.

  [1]: http://syamajala.github.io/c-ide.html
  [2]: https://github.com/Andersbakken/rtags



    % tree . 
    └── src
        ├── bar
        │   ├── bar.c
        │   └── bar.h
        └── foo
            ├── foo.c
            └── foo.h


In this case, perhaps the following cmake file will work for you.  Call it CMakeLists.txt and put it in the top directory.

    cmake_minimum_required(VERSION 3.5)
    project(myProjectName)
    file(GLOB_RECURSE SRC_FILES src/*.c)
    add_executable(myProjectName ${SRC_FILES})

Put build commands for the project in the directory ./build by calling 

    cmake -H. -Bbuild

Then export the compile command to a file that rtags will use

    cmake build -DCMAKE_EXPORT_COMPILE_COMMANDS=1

And build the project

    cmake --build build

Now, to make sure things are working cleanly, clear projects and quit the rdm daemon if it was running with 

    rc -C
    rc -q

and restart the daemon

    rdm &

and read that .json file you exported from cmake

    rc -J build

You should see output like this:

    % rc -J build                                                                                                                                                         Cprogrammingglanguage/wtf (hcn ⚡) alejandro
    [Server] Compilation database loading...
     % [  3%] 1/35 23:40:23 ~/Google Drive/Work Cloud/... in 211ms. (549 syms, 780 symNames, 28 includes, 17 of 22 files, symbols: 792 of 1445, 1840 cursors, 21 queried 86ms) (37/111/49ms). (priority 0)
    [  6%] 2/35 23:40:24 ~/Google Drive/Work Cloud/.../code/main/src/inrflow/reporting.c in 226ms. (1354 syms, 521 symNames, 15 includes, 6 of 87 files, symbols: 1714 of 4676, 7220 cursors, 5 queried 2ms) (119/61/25ms). (priority 0)

Note the following pitfall: can't have spaces in the path to the project.  I worked around this by symlinking to the project folder from a space-less path.

*Now* you are finally able to start following the rest of the instructions in [1] about configuring `rtags`, `company-rtags`, rtags + helm, `irony-mode`, `company-irony`, `company-irony-c-headers`, and `flycheck-rtags`, and `cmake-ide`, which mostly follows the documentation for each package.

I tend to fumble through these things and would like to help other users, so constructive comments are welcome.

  [1]: http://syamajala.github.io/c-ide.html
  [2]: https://github.com/Andersbakken/rtags


added 1250 characters in body
Source Link

    % tree . └── src
        ├── bar
        │   ├── bar.c
        │   └── bar.h
        └── foo
            ├── foo.c
            └── foo.h


In this case, perhaps the following cmake file will work for you.  Call it CMakeLists.txt and put it in the top directory.

    cmake_minimum_required(VERSION 3.5)
    project(myProjectName)
    file(GLOB_RECURSE SRC_FILES src/*.c)
    add_executable(myProjectName ${SRC_FILES})

NowBuild the commandsproject in the directory ./build by calling 

    cmake -H. -Bbuild

Then export the compile command to a file that rtags will use

    cmake build with-DCMAKE_EXPORT_COMPILE_COMMANDS=1

And build the project

    cmake and--build clangbuild

Now, to make sure things are working cleanly, clear projects and thenquit buildthe rdm daemon if it was running with 

    rc -C
    rc -q

and restart the rtagsdaemon

 database   rdm &

and read that .json file you exported from cmake

    rc -J build

You should worksee output like this:

    % rc -J build                                                                                                                                                         Cprogrammingglanguage/wtf (hcn ⚡) alejandro
    [Server] Compilation database loading...
     % [  3%] 1/35 23:40:23 ~/Google Drive/Work Cloud/... in 211ms. (549 syms, but780 notesymNames, 28 includes, 17 of 22 files, symbols: 792 of 1445, 1840 cursors, 21 queried 86ms) (37/111/49ms). (priority 0)
    [  6%] 2/35 23:40:24 ~/Google Drive/Work Cloud/.../code/main/src/inrflow/reporting.c in 226ms. (1354 syms, 521 symNames, 15 includes, 6 of 87 files, symbols: 1714 of 4676, 7220 cursors, 5 queried 2ms) (119/61/25ms). (priority 0)

Note the following pitfall: can't have spaces in the path to the project.  I worked around this by symlinking to the project folder from a space-less path.

*Now* you are finally able to start following the rest of the instructions in [1] about configuring `rtags`, `company-rtags`, rtags + helm, `irony-mode`, `company-irony`, `company-irony-c-headers`, and `flycheck-rtags`, and `cmake-ide`, which mostly follows the documentation for each package.

 

I tend to fumble through these things and would like to help other users, so constructive comments are welcome.

  [1]: http://syamajala.github.io/c-ide.html
  [2]: https://github.com/Andersbakken/rtags 



    % tree . └── src
        ├── bar
        │   ├── bar.c
        │   └── bar.h
        └── foo
            ├── foo.c
            └── foo.h


In this case, perhaps the following cmake file will work for you.  Call it CMakeLists.txt and put it in the top directory.

    cmake_minimum_required(VERSION 3.5)
    project(myProjectName)
    file(GLOB_RECURSE SRC_FILES src/*.c)
    add_executable(myProjectName ${SRC_FILES})

Now the commands to build with cmake and clang, and then build the rtags database should work, but note the following pitfall: can't have spaces in the path to the project.  I worked around this by symlinking to the project folder from a space-less path.

*Now* you are finally able to start following the rest of the instructions in [1] about configuring `rtags`, `company-rtags`, rtags + helm, `irony-mode`, `company-irony`, `company-irony-c-headers`, and `flycheck-rtags`, and `cmake-ide`, which mostly follows the documentation for each package.

 



  [1]: http://syamajala.github.io/c-ide.html
  [2]: https://github.com/Andersbakken/rtags

    % tree . └── src
        ├── bar
        │   ├── bar.c
        │   └── bar.h
        └── foo
            ├── foo.c
            └── foo.h


In this case, perhaps the following cmake file will work for you.  Call it CMakeLists.txt and put it in the top directory.

    cmake_minimum_required(VERSION 3.5)
    project(myProjectName)
    file(GLOB_RECURSE SRC_FILES src/*.c)
    add_executable(myProjectName ${SRC_FILES})

Build the project in the directory ./build by calling 

    cmake -H. -Bbuild

Then export the compile command to a file that rtags will use

    cmake build -DCMAKE_EXPORT_COMPILE_COMMANDS=1

And build the project

    cmake --build build

Now, to make sure things are working cleanly, clear projects and quit the rdm daemon if it was running with 

    rc -C
    rc -q

and restart the daemon

    rdm &

and read that .json file you exported from cmake

    rc -J build

You should see output like this:

    % rc -J build                                                                                                                                                         Cprogrammingglanguage/wtf (hcn ⚡) alejandro
    [Server] Compilation database loading...
     % [  3%] 1/35 23:40:23 ~/Google Drive/Work Cloud/... in 211ms. (549 syms, 780 symNames, 28 includes, 17 of 22 files, symbols: 792 of 1445, 1840 cursors, 21 queried 86ms) (37/111/49ms). (priority 0)
    [  6%] 2/35 23:40:24 ~/Google Drive/Work Cloud/.../code/main/src/inrflow/reporting.c in 226ms. (1354 syms, 521 symNames, 15 includes, 6 of 87 files, symbols: 1714 of 4676, 7220 cursors, 5 queried 2ms) (119/61/25ms). (priority 0)

Note the following pitfall: can't have spaces in the path to the project.  I worked around this by symlinking to the project folder from a space-less path.

*Now* you are finally able to start following the rest of the instructions in [1] about configuring `rtags`, `company-rtags`, rtags + helm, `irony-mode`, `company-irony`, `company-irony-c-headers`, and `flycheck-rtags`, and `cmake-ide`, which mostly follows the documentation for each package.

I tend to fumble through these things and would like to help other users, so constructive comments are welcome.

  [1]: http://syamajala.github.io/c-ide.html
  [2]: https://github.com/Andersbakken/rtags 


Source Link

I have followed the directions at [this blog which supplements the C ide stuff by Tudho][1] to install rtags and irony (as suggested by Dmitry) and it provides the features I asked for.

I'll expand with a summary of steps I had to take to get it all working on a Mac:

  • Install a recent version of the clang compiler with macports (likely optional)
  • Set environment variable CC=clang so that the most basic cmake files will call clang
  • make and install rtags v2.3 from [rtags the repository][2]. Detailed instructions and quick start guide worked but not with Apple XCode's clang (which lacked a link to libclang). follow instructions at the repository to check it works. Not clear to me whether you need to install rtags package in emacs from melpa, but I did that too.
  • write a very basic cmake file. If you are a cmake newbie like me you might have a simple C project with no libraries, with a root directory structured like this:

    % tree . └── src
        ├── bar
        │   ├── bar.c
        │   └── bar.h
        └── foo
            ├── foo.c
            └── foo.h


In this case, perhaps the following cmake file will work for you.  Call it CMakeLists.txt and put it in the top directory.

    cmake_minimum_required(VERSION 3.5)
    project(myProjectName)
    file(GLOB_RECURSE SRC_FILES src/*.c)
    add_executable(myProjectName ${SRC_FILES})

Now the commands to build with cmake and clang, and then build the rtags database should work, but note the following pitfall: can't have spaces in the path to the project.  I worked around this by symlinking to the project folder from a space-less path.

*Now* you are finally able to start following the rest of the instructions in [1] about configuring `rtags`, `company-rtags`, rtags + helm, `irony-mode`, `company-irony`, `company-irony-c-headers`, and `flycheck-rtags`, and `cmake-ide`, which mostly follows the documentation for each package.





  [1]: http://syamajala.github.io/c-ide.html
  [2]: https://github.com/Andersbakken/rtags