make logc an OBJECT library and enable clang-tidy for my code

This commit is contained in:
oxmox 2023-02-18 12:12:43 +01:00
parent 67fba60f47
commit cc4f66f8de
2 changed files with 9 additions and 10 deletions

View file

@ -9,12 +9,4 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON")
add_subdirectory(external) add_subdirectory(external)
# Way too much. Have to exclude the imgui implementation files at least. Also
# not sure if the .clang-tidy file is picked up. Probably best to pass it on the
# command line using "${CMAKE_SOURCE_DIR}/.clang-tidy".
#set(CMAKE_C_CLANG_TIDY clang-tidy -p ${CMAKE_BINARY_DIR})
#set(CMAKE_CXX_CLANG_TIDY clang-tidy -p ${CMAKE_BINARY_DIR})
add_subdirectory(src) add_subdirectory(src)

View file

@ -1,15 +1,22 @@
set(DP_WARN_FLAGS -Wall -Wextra -Wpedantic) set(DP_WARN_FLAGS -Wall -Wextra -Wpedantic)
# Source: log.c by rxi (https://github.com/rxi/log.c) # Source: log.c by rxi (https://github.com/rxi/log.c)
add_library(logc log.c) add_library(logc OBJECT log.c)
target_compile_features(logc PRIVATE c_std_11) target_compile_features(logc PRIVATE c_std_11)
if (NOT WIN32) if (NOT WIN32)
target_compile_definitions(logc PRIVATE -DLOG_USE_COLOR) target_compile_definitions(logc PRIVATE -DLOG_USE_COLOR)
endif() endif()
target_compile_options(logc INTERFACE -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=. PRIVATE ${DP_WARN_FLAGS}) target_compile_options(logc PUBLIC -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=. PRIVATE ${DP_WARN_FLAGS})
find_package(Threads) find_package(Threads)
# Bit of a hack to set the variables here. If set earlier clang-tidy will for
# some reason pickup log.c and warn about some va_list stuff. Might be because
# log.c is in the source directory as the same does not happen with the imgui
# object library. TODO: move logc to externals.
set(CMAKE_C_CLANG_TIDY clang-tidy -p ${CMAKE_BINARY_DIR} --extra-arg=-std=c11)
set(CMAKE_CXX_CLANG_TIDY clang-tidy -p ${CMAKE_BINARY_DIR} --extra-arg=-std=c++17)
add_library(dp_common dp_common.c) add_library(dp_common dp_common.c)
target_compile_features(dp_common PRIVATE c_std_11) target_compile_features(dp_common PRIVATE c_std_11)
target_compile_options(dp_common PUBLIC ${DP_WARN_FLAGS}) # spread warning flags target_compile_options(dp_common PUBLIC ${DP_WARN_FLAGS}) # spread warning flags