Browse Source

* initial commit

master
bergmann 6 years ago
commit
b125a1a176
4 changed files with 4198 additions and 0 deletions
  1. +55
    -0
      cmake_tests.cmake
  2. +4054
    -0
      cotire.cmake
  3. +67
    -0
      pedantic.cmake
  4. +22
    -0
      strip_symbols.cmake

+ 55
- 0
cmake_tests.cmake View File

@@ -0,0 +1,55 @@
If ( __CMAKE_TESTS_INCLUDED )
Return ( )
EndIf ( )
Set ( __CMAKE_TESTS_INCLUDED TRUE )

CMake_Minimum_Required ( VERSION 3.0 )
Include ( CMakeParseArguments )
Include ( CTest )

Function ( ADD_CMAKE_TEST )

Set ( OPTIONS COMMAND )
Set ( ONE_VALUE_ARGS NAME TARGET )
Set ( MULTI_VALUE_ARGS )
CMake_Parse_Arguments ( ADD_CMAKE_TEST "${OPTIONS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN} )

If ( NOT ADD_CMAKE_TEST_NAME )
Message ( FATAL_ERROR "ADD_CMAKE_TEST expects the NAME parameter!" )
EndIf ( )

If ( NOT ADD_CMAKE_TEST_TARGET )
Message ( FATAL_ERROR "ADD_CMAKE_TEST expects the TARGET parameter!" )
EndIf ( )

If ( NOT ADD_CMAKE_TEST_COMMAND )
Set ( ADD_CMAKE_TEST_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${ADD_CMAKE_TEST_TARGET} )
Else ( )
Set ( ADD_CMAKE_TEST_COMMAND ${ADD_CMAKE_TEST_UNPARSED_ARGUMENTS} )
EndIf ( )

# Build Tests #################################################################################

If ( NOT TARGET build_tests)
Add_Custom_Target ( build_tests )
Add_Test ( NAME "build"
COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target build_tests )
EndIf ( )
Add_Dependencies ( build_tests ${ADD_CMAKE_TEST_TARGET} )

# Run Tests ###################################################################################

If ( NOT TARGET tests)
Add_Custom_Target ( tests )
EndIf ( )
Add_Custom_Target ( run_${ADD_CMAKE_TEST_TARGET}
DEPENDS ${ADD_CMAKE_TEST_TARGET}
COMMAND ${ADD_CMAKE_TEST_COMMAND} )
Add_Dependencies ( tests run_${ADD_CMAKE_TEST_TARGET} )

# CTest #######################################################################################

Add_Test ( NAME ${ADD_CMAKE_TEST_NAME}
COMMAND ${ADD_CMAKE_TEST_COMMAND} )

EndFunction ( )

+ 4054
- 0
cotire.cmake
File diff suppressed because it is too large
View File


+ 67
- 0
pedantic.cmake View File

@@ -0,0 +1,67 @@
If ( __PEDANTIC_INCLUDED )
Return ( )
EndIf ( )
set ( __PEDANTIC_INCLUDED TRUE )

Include (CheckCCompilerFlag)
Include (CheckCXXCompilerFlag)

Macro (__PEDANTIC_CHECK_AND_ADD_C_FLAG FLAG)
CHECK_C_COMPILER_FLAG(${FLAG} TMP)
If (TMP)
Set (PEDANTIC_C_FLAGS "${PEDANTIC_C_FLAGS} ${FLAG}")
EndIf ( )
EndMacro()

Macro (__PEDANTIC_CHECK_AND_ADD_CXX_FLAG FLAG)
CHECK_CXX_COMPILER_FLAG(${FLAG} TMP)
If (TMP)
Set (PEDANTIC_CXX_FLAGS "${PEDANTIC_CXX_FLAGS} ${FLAG}")
EndIf ( )
EndMacro()

Set (PEDANTIC_C_FLAGS "")
Set (PEDANTIC_CXX_FLAGS "")

__PEDANTIC_CHECK_AND_ADD_C_FLAG(-g)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wall)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wextra)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wconversion)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Werror)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wno-unused-parameter)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wbad-function-cast)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wcast-align)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wcast-qual)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wconversion)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wdouble-promotion)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wfloat-equal)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wnested-externs)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wno-attributes)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wno-builtin-macro-redefined)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wno-vla)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wno-pragmas)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wold-style-definition)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Woverlength-strings)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wshadow)
__PEDANTIC_CHECK_AND_ADD_C_FLAG(-Wwrite-strings)

__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-ftemplate-depth=2000)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-g)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wall)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wextra)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wconversion)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Werror)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wno-reorder)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wno-unused-parameter)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wcast-align)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wcast-qual)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wconversion)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wdouble-promotion)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wfloat-equal)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wno-attributes)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wno-builtin-macro-redefined)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wno-vla)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wno-pragmas)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Woverlength-strings)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wshadow)
__PEDANTIC_CHECK_AND_ADD_CXX_FLAG(-Wwrite-strings)

+ 22
- 0
strip_symbols.cmake View File

@@ -0,0 +1,22 @@
If ( __STRIP_SYMBOLS_INCLUDED )
Return ( )
EndIf ( )
Set ( __STRIP_SYMBOLS_INCLUDED TRUE )

CMake_Minimum_Required ( VERSION 3.0 )

Find_Program ( OBJCOPY objcopy )
If ( OBJCOPY STREQUAL "OBJCOPY-NOTFOUND" )
Message ( FATAL_ERROR "objcopy not found" )
EndIf ( )

Function ( Strip_Symbols TARGET_NAME OUTPUT_FILENAME )
Set ( STRIP_SRC_FILE $<TARGET_FILE:${TARGET_NAME}>)
Set ( STRIP_DST_FILE ${STRIP_SRC_FILE}.dbg )
Add_Custom_Command ( TARGET ${TARGET_NAME}
POST_BUILD
VERBATIM
COMMAND ${OBJCOPY} --only-keep-debug ${STRIP_SRC_FILE} ${STRIP_DST_FILE}
COMMAND ${OBJCOPY} --strip-unneeded ${STRIP_SRC_FILE}
COMMAND ${OBJCOPY} --add-gnu-debuglink=${STRIP_DST_FILE} ${STRIP_SRC_FILE} )
EndFunction ( )

Loading…
Cancel
Save