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

[NUP-2399] Added style guides to new guide #3528

Merged
merged 2 commits into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ Provide technical details about how code changes are vetted, tested, approved, a

#### [Release Process](RELEASE.md)

Learn more about how NuPIC is released through the wiki linked above.
Learn more about how NuPIC is released through the page linked above.

### Developer Resources
- [Development Tips](https://discourse.numenta.org/t/development-tips/2140)
- [C++ Development Workflow](https://github.com/numenta/nupic.core/wiki/Development-Workflow)
- [Developer Workflow](https://discourse.numenta.org/t/developer-workflow/2132)
- [Documenting Code](docs/README.md)
- [External Libraries](https://discourse.numenta.org/t/external-libraries/2141)
- [Profiling and Optimization for Speed](https://github.com/numenta/nupic/wiki/Optimization-&-Profiling,-Speed)
- [Profiling and Optimization for Speed](https://discourse.numenta.org/t/optimization-profiling-speed/2142)

#### Coding Standards and Guides

- [C/C++ Coding Guide](https://github.com/numenta/nupic/wiki/C-Coding-Guide)
- [C/C++ Coding Guide](https://numenta.github.io/nupic/guides/contributing/cpp-style-guide.html)
- [CMake Style Guide](https://discourse.numenta.org/t/cmake-style-guide/2137/1)
- [Python Style Guide](https://discourse.numenta.org/t/python-style-guide/2128/1)
- [Contribution Standards](https://discourse.numenta.org/t/contribution-standards/2130/1)
Expand Down
47 changes: 47 additions & 0 deletions docs/source/contributing/cmake-style-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# CMake Style Guide

## Naming

**Functions**: _lower_case_ name. Ex:
`do_something(...)`

**Local variables**: _lower_case_ name. Local variables are used exclusively inside the file that contained them, and their values were simply passed as parameters to CMake functions. Ex:
`set(some_variable "...")`

**Global variables**: _UPPER_CASE_ name. Global variables(can also be called "export variables") are intended for exporting up/down-stream via the environment variable mechanism. Ex:
`set(SOME_VARIABLE "...")`

**Control statements**: _lower_case_ name without repeat the condition in the closing brackets. Ex:

```
if(condition)
...
else() # not repeat condition
...
endif() # not repeat condition
```

**Operators**: _UPPER_CASE_ name. Ex:
`if(condition STREQUAL "")`

**Directives and/or extra options**: _UPPER_CASE_ name. Ex:
`do_something(... USE_THIS)`

## Examples

An real-world example:

```
function(set_platform system_name)
if(${system_name} MATCHES "Darwin")
set(PLATFORM "darwin")
elseif(${system_name} MATCHES "Linux")
set(PLATFORM "linux")
else()
set(PLATFORM "")
endif()
endfunction()

cmake_minimum_required(VERSION 3.0)
set_platform(${CMAKE_SYSTEM_NAME})
```
Loading