Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake compilation database support #40

Open
MagBad opened this issue Sep 4, 2018 · 5 comments · May be fixed by #99
Open

CMake compilation database support #40

MagBad opened this issue Sep 4, 2018 · 5 comments · May be fixed by #99

Comments

@MagBad
Copy link

MagBad commented Sep 4, 2018

Currently the language server supports 'only' a manually generated configuration file
for communicating the file hierarchy. With CMake it's possible to generate a compilation database with contains all flags, directories, etc. for
a given file. It would be nice for CMake user to add the reading of this database.

@hansec
Copy link
Owner

hansec commented Sep 4, 2018

Thanks for the suggestion. I will look into this. I think that the manual config file is probably fine for 99% of projects, since you only need to specify directories/files if you want to exclude subdirectories of the project root. However, there may be some projects with complicated structures (likely using CMake) that would benefit from this more automated approach.

@MagBad
Copy link
Author

MagBad commented Sep 4, 2018

Yes you are probably right about that percentage number. Another advantage of the compilation database are that all compiler arguments
are listed as well. My guess is that you're using gfortran for the diagnostics? Nevertheless other compiler may complain about other stuff. Say one is using PGI or IBM XL compilers, which may provide different errors etc. An issue with that approach may be that in a mixed language project ( which may be a case of use for CMake ) one would have to filter out the relevant Fortran files.

@hansec
Copy link
Owner

hansec commented Sep 10, 2018

Actually, the only diagnostics currently implemented are simple ones that can be derived from the language server's internal representation of the code. At some point it would be nice to add a more complete set of diagnostics using compilers if a user provided the necessary build information as you described.

@MaskRay
Copy link

MaskRay commented Oct 11, 2018

compile_commands.json parsing is not too difficult and there are mature generators.

You may check out https://github.com/nickdiego/compiledb and Buiding EAR.

@wgurecky wgurecky linked a pull request Mar 21, 2019 that will close this issue
@letmaik
Copy link

letmaik commented Aug 6, 2019

One practical use case for this could be to extract the preprocessor definitions from the compiler command line per file and use them instead of the static ones from .fortls.

My only concern in general is that CMake doesn't produce this compilation db file by default which would limit the out-of-the-box experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants