From fb5498f0ce7b89d27925702e7ee1c9417aed9587 Mon Sep 17 00:00:00 2001 From: bergmann Date: Tue, 5 Nov 2019 21:58:48 +0100 Subject: [PATCH] * Moved modules to cmake subdirectory. * Added readme. --- README.md | 155 ++++++++++++++++++ cmake_tests.cmake => cmake/cmake_tests.cmake | 0 cotire.cmake => cmake/cotire.cmake | 0 .../find_local_module.cmake | 0 git_helper.cmake => cmake/git_helper.cmake | 0 pedantic.cmake => cmake/pedantic.cmake | 2 +- .../strip_symbols.cmake | 0 7 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 README.md rename cmake_tests.cmake => cmake/cmake_tests.cmake (100%) rename cotire.cmake => cmake/cotire.cmake (100%) rename find_local_module.cmake => cmake/find_local_module.cmake (100%) rename git_helper.cmake => cmake/git_helper.cmake (100%) rename pedantic.cmake => cmake/pedantic.cmake (99%) rename strip_symbols.cmake => cmake/strip_symbols.cmake (100%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..8032bcf --- /dev/null +++ b/README.md @@ -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 of the test. | +| `TARGET ` | Taget the test depends on. | +| `GROUP ` | Add the test to the passed group. | +| `COMMAND ` | 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 ( ) +``` + +**Parameters** + +| Parameter | Description | +| --- | --- | +| `` | Name of the module to add to cmake environment. | +| `` | 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 ] + [ IGNORE_C ] + [ IGNORE_CXX ] + [ ADDITIONAL ] + [ ADDITIONAL_C ] + [ ADDITIONAL_CXX ] ) +``` + +**Parameters:** + +| Parameter | Description | +| --- | --- | +| `C ` | Only add flags to the C compiler. | +| `CXX ` | Only add flags to the C++ compiler. | +| `ALL ` | Add flags to all compilers. | +| `IGNORE ` | List of compiler flags to ignore. | +| `IGNORE_C ` | List of C compiler flags to ignore. | +| `IGNORE_CXX ` | List of C++ compiler flags to ignore. | +| `ADDITIONAL ` | List of additional compiler flags to ignore. | +| `ADDITIONAL_C ` | List of additional C compiler flags to ignore. | +| `ADDITIONAL_CXX ` | 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 ( + [ C ] + [ CXX ] + [ ALL ] + [ IGNORE ] + [ IGNORE_C ] + [ IGNORE_CXX ] + [ ADDITIONAL ] + [ ADDITIONAL_C ] + [ ADDITIONAL_CXX ] + [ VISIBILITY ] ) +``` + +**Parameters:** + +| Parameter | Description | +| --- | --- | +| `` | Target to add flags to. | +| `C ` | Only add flags to the C compiler. | +| `CXX ` | Only add flags to the C++ compiler. | +| `ALL ` | Add flags to all compilers. | +| `IGNORE ` | List of compiler flags to ignore. | +| `IGNORE_C ` | List of C compiler flags to ignore. | +| `IGNORE_CXX ` | List of C++ compiler flags to ignore. | +| `ADDITIONAL ` | List of additional compiler flags to ignore. | +| `ADDITIONAL_C ` | List of additional C compiler flags to ignore. | +| `ADDITIONAL_CXX ` | List of additional C++ compiler flags to ignore. | +| `VISIBILITY ` | 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 ( ) +``` + +**Parameters:** + ++ `` Compiler to use for checking the flags ++ `` Name of the variable to store valid flags into. ++ `` Flags to check. + +## strip_symbols + +Strip thedebug symbols from the passed target. + +**Usage:** + +```cmake +Strip_Symbols ( ) +``` + +**Parameters** + +| Parameter | Description | +| --- | --- | +| `` | Target to strip symbols from. | +| `` | 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. diff --git a/cmake_tests.cmake b/cmake/cmake_tests.cmake similarity index 100% rename from cmake_tests.cmake rename to cmake/cmake_tests.cmake diff --git a/cotire.cmake b/cmake/cotire.cmake similarity index 100% rename from cotire.cmake rename to cmake/cotire.cmake diff --git a/find_local_module.cmake b/cmake/find_local_module.cmake similarity index 100% rename from find_local_module.cmake rename to cmake/find_local_module.cmake diff --git a/git_helper.cmake b/cmake/git_helper.cmake similarity index 100% rename from git_helper.cmake rename to cmake/git_helper.cmake diff --git a/pedantic.cmake b/cmake/pedantic.cmake similarity index 99% rename from pedantic.cmake rename to cmake/pedantic.cmake index b2f32d5..cc2ed06 100644 --- a/pedantic.cmake +++ b/cmake/pedantic.cmake @@ -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 ( ) diff --git a/strip_symbols.cmake b/cmake/strip_symbols.cmake similarity index 100% rename from strip_symbols.cmake rename to cmake/strip_symbols.cmake