Browse Source

* Moved modules to cmake subdirectory.

* Added readme.
master
bergmann 4 years ago
parent
commit
fb5498f0ce
7 changed files with 156 additions and 1 deletions
  1. +155
    -0
      README.md
  2. +0
    -0
      cmake/cmake_tests.cmake
  3. +0
    -0
      cmake/cotire.cmake
  4. +0
    -0
      cmake/find_local_module.cmake
  5. +0
    -0
      cmake/git_helper.cmake
  6. +1
    -1
      cmake/pedantic.cmake
  7. +0
    -0
      cmake/strip_symbols.cmake

+ 155
- 0
README.md View File

@@ -0,0 +1,155 @@
# CMake Modules

Collection of usefull CMake modules.

# Collection

## cmake_tests

Add a `tests` target to automatically build and run all tests.

**Usage:**

Add a new test with name `fuu` that depends on target `bar`.

```cmake
Add_CMake_Test ( NAME fuu
TARGET bar
[ GROUP baz ]
[ COMMAND /bin/sh do_something ] )

```

**Parameters**

| Parameter | Description |
| --- | --- |
| `NAME <name>` | Name of the test. |
| `TARGET <target>` | Taget the test depends on. |
| `GROUP <group>` | Add the test to the passed group. |
| `COMMAND <args..>` | Command to execute for testing. If no command is passed the passed target is executed. |

## find_local_modules

Helper function to include a local module into the cmake environment.

**Usage:**

```cmake
FindLocalModule ( <module-name> <local-path> )
```

**Parameters**

| Parameter | Description |
| --- | --- |
| `<module-name>` | Name of the module to add to cmake environment. |
| `<local-path>` | Path to the local module. |

## pedantic

Helper functions to add pedantic flags to the compiler.

**Pedantic_Apply_Flags:**

Add pedantic flags to `CMAKE_C_FLAGS` and `CMAKE_CXX_FLAGS`.

```cmake
Pedantic_Apply_Flags ( [ C ]
[ CXX ]
[ ALL ]
[ IGNORE <flags..> ]
[ IGNORE_C <flags..> ]
[ IGNORE_CXX <flags..> ]
[ ADDITIONAL <flags..> ]
[ ADDITIONAL_C <flags..> ]
[ ADDITIONAL_CXX <flags..> ] )
```

**Parameters:**

| Parameter | Description |
| --- | --- |
| `C <flags..>` | Only add flags to the C compiler. |
| `CXX <flags..>` | Only add flags to the C++ compiler. |
| `ALL <flags..>` | Add flags to all compilers. |
| `IGNORE <flags..>` | List of compiler flags to ignore. |
| `IGNORE_C <flags..>` | List of C compiler flags to ignore. |
| `IGNORE_CXX <flags..>` | List of C++ compiler flags to ignore. |
| `ADDITIONAL <flags..>` | List of additional compiler flags to ignore. |
| `ADDITIONAL_C <flags..>` | List of additional C compiler flags to ignore. |
| `ADDITIONAL_CXX <flags..>` | List of additional C++ compiler flags to ignore. |

**Pedantic_Apply_Flags_Target:**

Add pedantic flags for compilers to the given target.

```cmake
Pedantic_Apply_Flags_Target ( <target>
[ C ]
[ CXX ]
[ ALL ]
[ IGNORE <flags..> ]
[ IGNORE_C <flags..> ]
[ IGNORE_CXX <flags..> ]
[ ADDITIONAL <flags..> ]
[ ADDITIONAL_C <flags..> ]
[ ADDITIONAL_CXX <flags..> ]
[ VISIBILITY <PRIVATE|PUBLIC> ] )
```

**Parameters:**

| Parameter | Description |
| --- | --- |
| `<target>` | Target to add flags to. |
| `C <flags..>` | Only add flags to the C compiler. |
| `CXX <flags..>` | Only add flags to the C++ compiler. |
| `ALL <flags..>` | Add flags to all compilers. |
| `IGNORE <flags..>` | List of compiler flags to ignore. |
| `IGNORE_C <flags..>` | List of C compiler flags to ignore. |
| `IGNORE_CXX <flags..>` | List of C++ compiler flags to ignore. |
| `ADDITIONAL <flags..>` | List of additional compiler flags to ignore. |
| `ADDITIONAL_C <flags..>` | List of additional C compiler flags to ignore. |
| `ADDITIONAL_CXX <flags..>` | List of additional C++ compiler flags to ignore. |
| `VISIBILITY <PRIVATE|PUBLIC>` | Visibility to use to add flags to the target. |

**Pedantic_Test_Flags:**

Check if the passed flags are supported by the compiler.

```cmake
Pedantic_Test_Flags ( <C|CXX> <out-var> <flags..> )
```

**Parameters:**

+ `<C|CXX>` Compiler to use for checking the flags
+ `<out-var>` Name of the variable to store valid flags into.
+ `<flags..>` Flags to check.

## strip_symbols

Strip thedebug symbols from the passed target.

**Usage:**

```cmake
Strip_Symbols ( <target> <output> )
```

**Parameters**

| Parameter | Description |
| --- | --- |
| `<target>` | Target to strip symbols from. |
| `<output>` | Variable to store the path of the striped symbols to. |

# Third Party

+ [sanitizers-cmake](https://github.com/arsenm/sanitizers-cmake)
+ Collection to add sanitizer support to cmake.
+ Is merged into this project.
+ [cotire](https://github.com/sakra/cotire)
+ Collection to speed up the build process.
+ Is merged into this project.

cmake_tests.cmake → cmake/cmake_tests.cmake View File


cotire.cmake → cmake/cotire.cmake View File


find_local_module.cmake → cmake/find_local_module.cmake View File


git_helper.cmake → cmake/git_helper.cmake View File


pedantic.cmake → cmake/pedantic.cmake View File

@@ -123,7 +123,7 @@ Function ( Pedantic_Apply_Flags )
__PEDANTIC_GET_FLAGS ( CXX TMP
IGNORE ${ARG_IGNORE};${ARG_IGNORE_CXX}
ADDITIONAL ${ARG_ADDITIONAL};${ARG_ADDITIONAL_CXX} )
Set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TMP}" PARENT_SCOPE )
Set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TMP}" PARENT_SCOPE )
EndIf ( )
EndFunction ( )


strip_symbols.cmake → cmake/strip_symbols.cmake View File


Loading…
Cancel
Save