Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
CMakeModules/ | 23-Nov-2023 | - | 140 | 120 | ||
contrib/ | 23-Nov-2023 | - | 78 | 61 | ||
lib/ | 23-Nov-2023 | - | 226 | 194 | ||
programs/ | 23-Nov-2023 | - | 142 | 117 | ||
tests/ | 23-Nov-2023 | - | 117 | 103 | ||
.gitignore | D | 23-Nov-2023 | 137 | 11 | 9 | |
CMakeLists.txt | D | 23-Nov-2023 | 7.6 KiB | 204 | 174 | |
README.md | D | 23-Nov-2023 | 2.2 KiB | 105 | 79 | |
zstdConfig.cmake | D | 23-Nov-2023 | 55 | 2 | 1 |
README.md
1# Cmake contributions 2 3Contributions to the cmake build configurations are welcome. Please 4use case sensitivity that matches modern (ie. cmake version 2.6 and above) 5conventions of using lower-case for commands, and upper-case for 6variables. 7 8## How to build 9 10As cmake doesn't support command like `cmake clean`, it's recommended to perform a "out of source build". 11To do this, you can create a new directory and build in it: 12```sh 13cd build/cmake 14mkdir builddir 15cd builddir 16cmake .. 17make 18``` 19Then you can clean all cmake caches by simply delete the new directory: 20```sh 21rm -rf build/cmake/builddir 22``` 23 24And of course, you can directly build in build/cmake: 25```sh 26cd build/cmake 27cmake 28make 29``` 30 31To show cmake build options, you can: 32```sh 33cd build/cmake/builddir 34cmake -LH .. 35``` 36 37Bool options can be set to `ON/OFF` with `-D[option]=[ON/OFF]`. You can configure cmake options like this: 38```sh 39cd build/cmake/builddir 40cmake -DZSTD_BUILD_TESTS=ON -DZSTD_LEGACY_SUPPORT=ON .. 41make 42``` 43 44### referring 45[Looking for a 'cmake clean' command to clear up CMake output](https://stackoverflow.com/questions/9680420/looking-for-a-cmake-clean-command-to-clear-up-cmake-output) 46 47## CMake Style Recommendations 48 49### Indent all code correctly, i.e. the body of 50 51 * if/else/endif 52 * foreach/endforeach 53 * while/endwhile 54 * macro/endmacro 55 * function/endfunction 56 57Use spaces for indenting, 2, 3 or 4 spaces preferably. Use the same amount of 58spaces for indenting as is used in the rest of the file. Do not use tabs. 59 60### Upper/lower casing 61 62Most important: use consistent upper- or lowercasing within one file ! 63 64In general, the all-lowercase style is preferred. 65 66So, this is recommended: 67 68``` 69add_executable(foo foo.c) 70``` 71 72These forms are discouraged 73 74``` 75ADD_EXECUTABLE(bar bar.c) 76Add_Executable(hello hello.c) 77aDd_ExEcUtAbLe(blub blub.c) 78``` 79 80### End commands 81To make the code easier to read, use empty commands for endforeach(), endif(), 82endfunction(), endmacro() and endwhile(). Also, use empty else() commands. 83 84For example, do this: 85 86``` 87if(FOOVAR) 88 some_command(...) 89else() 90 another_command(...) 91endif() 92``` 93 94and not this: 95 96``` 97if(BARVAR) 98 some_other_command(...) 99endif(BARVAR) 100``` 101 102### Other resources for best practices 103 104https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#modules 105