diff --git a/CMakeLists.txt b/CMakeLists.txt index ab3acf4b..148b1209 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,16 +33,27 @@ macro(register_lego1_target __target) list(APPEND lego1_targets ${__target}) endmacro() -function(check_cxx_has_option VAR OPTION) +function(add_cxx_warning WARNING) + if(ISLE_WERROR) + set(compiler_option "-Werror=${WARNING}") + else() + set(compiler_option "-W${WARNING}") + endif() + string(MAKE_C_IDENTIFIER "COMPILER_SUPPORTS${compiler_option}" varname) + cmake_push_check_state(RESET) - set(CMAKE_REQUIRED_FLAGS "${OPTION} ") + set(CMAKE_REQUIRED_FLAGS "${compiler_option} ") if(MSVC) string(APPEND CMAKE_REQUIRED_FLAGS "/WX") else() string(APPEND CMAKE_REQUIRED_FLAGS "-Werror") endif() - check_cxx_source_compiles("int main() { return 0; }" ${VAR}) + check_cxx_source_compiles("int main() { return 0; }" ${varname}) cmake_pop_check_state() + + if(${varname}) + add_compile_options(${compiler_option}) + endif() endfunction() message(STATUS "MSVC for decompilation: ${MSVC_FOR_DECOMP}") @@ -61,10 +72,7 @@ if(ISLE_WERROR) endif() endif() -check_cxx_has_option(COMPILER_SUPPORTS_Wparentheses -Wparentheses) -if(COMPILER_SUPPORTS_Wparentheses) - add_compile_options(-Wparentheses) -endif() +add_cxx_warning(parentheses) add_library(DirectX5::DirectX5 INTERFACE IMPORTED) target_include_directories(DirectX5::DirectX5 INTERFACE "${CMAKE_SOURCE_DIR}/3rdparty/dx5/inc")