mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-02-05 20:09:05 +00:00
Set warnings as errors
This commit is contained in:
parent
409537d600
commit
41c6647fd9
@ -23,4 +23,5 @@ enable_driver_support()
|
||||
|
||||
##########################################
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory_and_get_targets("src" SRC_TARGETS)
|
||||
targets_set_warnings_as_errors(${SRC_TARGETS})
|
||||
|
@ -1,3 +1,5 @@
|
||||
include_guard()
|
||||
|
||||
##########################################
|
||||
|
||||
macro(set_artifact_directory directory)
|
||||
@ -31,4 +33,75 @@ endmacro()
|
||||
macro(enable_driver_support)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/external/FindWDK/cmake")
|
||||
find_package(WDK REQUIRED)
|
||||
endmacro()
|
||||
endmacro()
|
||||
|
||||
##########################################
|
||||
|
||||
function(target_set_warnings_as_errors target)
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
if(("${target_type}" STREQUAL "INTERFACE_LIBRARY") OR ("${target_type}" STREQUAL "UTILITY"))
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(compile_options)
|
||||
|
||||
if(MSVC)
|
||||
set(compile_options /W4 /WX)
|
||||
if (CLANG)
|
||||
set(compile_options ${compile_options} -Xclang -Wconversion)
|
||||
endif()
|
||||
else()
|
||||
# lots of warnings and all warnings as errors
|
||||
set(compile_options -Wall -Wextra -Wconversion -pedantic -Werror)
|
||||
endif()
|
||||
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:C>:$<$<CONFIG:RELEASE>:${compile_options}>>
|
||||
$<$<COMPILE_LANGUAGE:CXX>:$<$<CONFIG:RELEASE>:${compile_options}>>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
##########################################
|
||||
|
||||
function(targets_set_warnings_as_errors)
|
||||
foreach(target ${ARGV})
|
||||
target_set_warnings_as_errors(${target})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
##########################################
|
||||
|
||||
function(get_all_targets var)
|
||||
set(targets)
|
||||
get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(${var} ${targets} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
##########################################
|
||||
|
||||
macro(get_all_targets_recursive targets dir)
|
||||
get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
|
||||
foreach(subdir ${subdirectories})
|
||||
get_all_targets_recursive(${targets} ${subdir})
|
||||
endforeach()
|
||||
|
||||
get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
|
||||
list(APPEND ${targets} ${current_targets})
|
||||
endmacro()
|
||||
|
||||
##########################################
|
||||
|
||||
macro(list_difference list_a list_to_remove result)
|
||||
set(${result} ${list_a})
|
||||
list(REMOVE_ITEM ${result} ${list_to_remove})
|
||||
endmacro()
|
||||
|
||||
##########################################
|
||||
|
||||
macro(add_subdirectory_and_get_targets directory targets)
|
||||
get_all_targets(EXISTING_TARGETS)
|
||||
add_subdirectory(${directory})
|
||||
get_all_targets(ALL_TARGETS)
|
||||
|
||||
list_difference("${ALL_TARGETS}" "${EXISTING_TARGETS}" ${targets})
|
||||
endmacro()
|
||||
|
@ -18,7 +18,7 @@ std::filesystem::path get_current_path()
|
||||
return selfdir;
|
||||
}
|
||||
|
||||
int main(const int argc, char* argv[])
|
||||
int main(const int /*argc*/, char* /*argv*/[])
|
||||
{
|
||||
const auto manager = OpenSCManagerA(nullptr, nullptr, SC_MANAGER_ALL_ACCESS);
|
||||
if (manager == nullptr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user