mine-chad / server

MIT License
1 stars 1 forks source link

Manage CMake project #7

Closed TheRealOne78 closed 1 week ago

TheRealOne78 commented 6 months ago

From now on, header files have to be put in the include directory, sepparated from the src directory. CMake includes this directory at compile-time. You should configure your editor to use CMake as LSP or something. If you use clangd, you can configure it to work along with CMake by initiating the build directory with the CMAKE_EXPORT_COMPILE_COMMANDS set to 1 (see example below) to generate compile_commands.json. Note that clangd will search for this json file at either the source directory or the build directory. Otherwise, there's always CMake-Language-Server or CMakeLS.

# example build directory

mkdir build
CMAKE_EXPORT_COMPILE_COMMANDS=1 cmake . -B build

Header files from the include directory must use relative paths instead of absolute paths (with the include directory being the include). This is due to CMake not being configured to treat include as a source directory. This should make sense.

Header files with CPP features must have the .HPP|.HXX file extension, and C-only ones should have the .H extension. This is because it brings consistency and some editors default the C language before writing any CPP code. So until you refresh the editor, your LSP might complain that certain CPP features don't exist because the LSP is in C mode.

This CMake is obviously not complete, but that's because we need some actual code before we can generate the documentation with Doxygen, test with CMake's CTest (I think we might use CppUTest for the framework), install to the system, have different release types, and package it.

Please write docstrings for Doxygen. If you don't feel like it, please add at least a TODO: comment. Thanks :)

Tests should be put in the tests directory.