From e5b1170a6aeae87adbfb66a6318b094ab32bf11c Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 22 May 2020 19:22:13 +0200 Subject: [PATCH] - added processorcount.cmake to get the available threads for the system via NPROC and NPROC_HALF - added iwyu.cmake and add an "run-iwyu" if the "iwyu_tool" executable is available - adjusted some includes based on include-what-you-use --- CHANGELOG | 3 +++ CMakeLists.txt | 4 +++- common.h | 2 +- iwyu.cmake | 5 +++++ mame_regtest.c | 3 +-- processorcount.cmake | 9 +++++++++ 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 iwyu.cmake create mode 100644 processorcount.cmake diff --git a/CHANGELOG b/CHANGELOG index d022537..a253394 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -723,6 +723,9 @@ - implemented ATTR_NORETURN for Visual Studio - added CMake option USE_VS_ANALYZE to enable Visual Studio Code Analysis - added CMake option USE_GCC_ANALYZER to enable GCC Static Analysis + - added processorcount.cmake to get the available threads for the system via NPROC and NPROC_HALF + - added iwyu.cmake and add an "run-iwyu" if the "iwyu_tool" executable is available + - adjusted some includes based on include-what-you-use create_report - fixed some clang-tidy warnings diff --git a/CMakeLists.txt b/CMakeLists.txt index d00bf0b..db1787d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,4 +123,6 @@ if (WIN32) target_link_libraries(create_image_xml PRIVATE ws2_32) endif() -include(clang_tidy.cmake) \ No newline at end of file +include(processorcount.cmake) +include(clang_tidy.cmake) +include(iwyu.cmake) \ No newline at end of file diff --git a/common.h b/common.h index f8ff8f5..6b58da6 100644 --- a/common.h +++ b/common.h @@ -2,8 +2,8 @@ #define COMMON_H_ #include - #include +#include #include diff --git a/iwyu.cmake b/iwyu.cmake new file mode 100644 index 0000000..d85f821 --- /dev/null +++ b/iwyu.cmake @@ -0,0 +1,5 @@ +find_program(IWYU_TOOL NAMES iwyu_tool) +message(STATUS "IWYU_TOOL=${IWYU_TOOL}") +if (IWYU_TOOL) + add_custom_target(run-iwyu ${IWYU_TOOL} -p ${CMAKE_BINARY_DIR} -j ${NPROC_HALF}) +endif() \ No newline at end of file diff --git a/mame_regtest.c b/mame_regtest.c index 8bcf3f5..6e76b2b 100644 --- a/mame_regtest.c +++ b/mame_regtest.c @@ -37,8 +37,7 @@ #endif #ifndef WIN32 -#include -#include +#include #define USE_VALGRIND 1 #else #define USE_VALGRIND 0 diff --git a/processorcount.cmake b/processorcount.cmake new file mode 100644 index 0000000..67ca69c --- /dev/null +++ b/processorcount.cmake @@ -0,0 +1,9 @@ +include(ProcessorCount) +ProcessorCount(NPROC) +if(NPROC EQUAL 0) + message(FATAL_ERROR "could not get processor count") +endif() +math(EXPR NPROC_HALF "${NPROC} / 2") + +message(STATUS "NPROC=${NPROC}") +message(STATUS "NPROC_HALF=${NPROC_HALF}") \ No newline at end of file