copy missing cmake modules from vtr project
This commit is contained in:
parent
b728773159
commit
68bf7a9462
|
@ -0,0 +1,46 @@
|
|||
include(ProcessorCount)
|
||||
ProcessorCount(CPU_COUNT)
|
||||
if(CPU_COUNT EQUAL 0)
|
||||
message(FATAL_ERROR "Unknown number of CPUs!?")
|
||||
endif()
|
||||
|
||||
#
|
||||
# ----------------------- Code format --------------------------
|
||||
#
|
||||
|
||||
set(FIND_TO_FORMAT_CPP
|
||||
-name '*.cpp' -print -o -name '*.h' -print
|
||||
-o -name '*.tpp' -print -o -name '*.hpp' -print)
|
||||
|
||||
list(APPEND DIRS_TO_FORMAT_CPP "")
|
||||
|
||||
#
|
||||
# List the files which will be auto-formatted.
|
||||
#
|
||||
add_custom_target(format-cpp-files
|
||||
COMMAND find ${DIRS_TO_FORMAT_CPP} ${FIND_TO_FORMAT_CPP})
|
||||
|
||||
#
|
||||
# Use clang-format-7 for code format
|
||||
#
|
||||
add_custom_target(format-cpp
|
||||
COMMAND find ${DIRS_TO_FORMAT_CPP} ${FIND_TO_FORMAT_CPP} |
|
||||
xargs -P ${CPU_COUNT} clang-format-7 -style=file -i)
|
||||
|
||||
#
|
||||
# Use simple python script for fixing C like boxed comments
|
||||
#
|
||||
add_custom_target(format-cpp-fix-comments DEPENDS format-cpp
|
||||
COMMAND find ${DIRS_TO_FORMAT_CPP} ${FIND_TO_FORMAT_CPP} |
|
||||
xargs -L 1 -P ${CPU_COUNT}
|
||||
python3 ${PROJECT_SOURCE_DIR}/dev/code_format_fixup.py --inplace --fix-comments --input)
|
||||
|
||||
#
|
||||
# Use simple python script for fixing template brackets e.g. <<>
|
||||
#
|
||||
add_custom_target(format-cpp-fix-template-operators DEPENDS format-cpp
|
||||
COMMAND find ${DIRS_TO_FORMAT_CPP} ${FIND_TO_FORMAT_CPP} |
|
||||
xargs -L 1 -P ${CPU_COUNT}
|
||||
python3 ${PROJECT_SOURCE_DIR}/dev/code_format_fixup.py --inplace --fix-template-operators --input)
|
||||
|
||||
add_custom_target(format DEPENDS format-cpp-fix-comments format-cpp-fix-template-operators)
|
|
@ -0,0 +1,27 @@
|
|||
# Support ccache for faster builds.
|
||||
#
|
||||
# By default ccache will be used if it is found in your path.
|
||||
#
|
||||
# You can use `BUILD_USING_CCACHE=off` to disable it's usage.
|
||||
# You can use `BUILD_USING_CCACHE=off` to make sure ccache is used.
|
||||
#
|
||||
set(BUILD_USING_CCACHE "auto")
|
||||
if(NOT "$ENV{BUILD_USING_CCACHE}" STREQUAL "")
|
||||
set(BUILD_USING_CCACHE $ENV{BUILD_USING_CCACHE})
|
||||
endif()
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if (BUILD_USING_CCACHE STREQUAL "on")
|
||||
if(NOT CCACHE_PROGRAM)
|
||||
message(FATAL_ERROR "BUILD_USING_CCACHE set to on but ccache binary not found!")
|
||||
endif()
|
||||
endif()
|
||||
if (NOT BUILD_USING_CCACHE STREQUAL "off")
|
||||
if(CCACHE_PROGRAM)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
||||
message(STATUS "Using ccache binary found @ ${CCACHE_PROGRAM}")
|
||||
endif()
|
||||
else()
|
||||
if(CCACHE_PROGRAM)
|
||||
message(STATUS "**Not** using ccache binary found @ ${CCACHE_PROGRAM} (as BUILD_USING_CCACHE is off)")
|
||||
endif()
|
||||
endif()
|
Loading…
Reference in New Issue