aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--cmake/scripts/common/ArchSetup.cmake10
-rw-r--r--cmake/scripts/common/Macros.cmake13
3 files changed, 27 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e4dff92e6..8770460fc9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -251,6 +251,10 @@ set_target_properties(compileinfo PROPERTIES FOLDER "Build Utilities")
target_compile_options(compileinfo PRIVATE "${SYSTEM_DEFINES} ${ARCH_DEFINES}")
add_dependencies(compileinfo fmt)
+if(NOT MSVC)
+ target_compile_options(compileinfo PUBLIC ${CORE_COMPILE_OPTIONS})
+endif()
+
# RC File
if(WIN32)
configure_file(${CMAKE_SOURCE_DIR}/xbmc/platform/win32/XBMC_PC.rc.in
diff --git a/cmake/scripts/common/ArchSetup.cmake b/cmake/scripts/common/ArchSetup.cmake
index bf488bc637..7523696ce0 100644
--- a/cmake/scripts/common/ArchSetup.cmake
+++ b/cmake/scripts/common/ArchSetup.cmake
@@ -148,8 +148,18 @@ if(NOT DEFINED NEON OR NEON)
endif()
if(NOT MSVC)
+ # these options affect all code built by cmake including external projects.
add_options(ALL_LANGUAGES ALL_BUILDS "-Wall" "-Wdouble-promotion" "-Wmissing-field-initializers")
add_options(ALL_LANGUAGES DEBUG "-g" "-D_DEBUG")
+
+ # these options affect only core code
+ if(NOT CORE_COMPILE_OPTIONS)
+ set(CORE_COMPILE_OPTIONS
+ -Werror=double-promotion
+ -Werror=missing-field-initializers
+ -Werror=sign-compare
+ )
+ endif()
endif()
# set for compile info to help detect binary addons
diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake
index 9b7fc161e9..27d7d40de7 100644
--- a/cmake/scripts/common/Macros.cmake
+++ b/cmake/scripts/common/Macros.cmake
@@ -75,6 +75,10 @@ function(core_add_library name)
add_dependencies(${name} ${GLOBAL_TARGET_DEPS})
set(CORE_LIBRARY ${name} PARENT_SCOPE)
+ if(NOT MSVC)
+ target_compile_options(${name} PUBLIC ${CORE_COMPILE_OPTIONS})
+ endif()
+
# Add precompiled headers to Kodi main libraries
if(CORE_SYSTEM_NAME MATCHES windows)
add_precompiled_header(${name} pch.h ${CMAKE_SOURCE_DIR}/xbmc/platform/win32/pch.cpp PCH_TARGET kodi)
@@ -104,6 +108,11 @@ function(core_add_test_library name)
FOLDER "Build Utilities/tests")
add_dependencies(${name} ${GLOBAL_TARGET_DEPS})
set(test_archives ${test_archives} ${name} CACHE STRING "" FORCE)
+
+ if(NOT MSVC)
+ target_compile_options(${name} PUBLIC ${CORE_COMPILE_OPTIONS})
+ endif()
+
endif()
foreach(src IN LISTS SOURCES SUPPORTED_SOURCES HEADERS OTHERS)
get_filename_component(src_path "${src}" ABSOLUTE)
@@ -166,6 +175,10 @@ function(core_add_shared_library name)
add_library(${name} STATIC ${SOURCES} ${HEADERS} ${OTHERS})
set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE 1)
core_link_library(${name} ${OUTPUT_DIRECTORY}/lib${name})
+
+ if(NOT MSVC)
+ target_compile_options(${name} PUBLIC ${CORE_COMPILE_OPTIONS})
+ endif()
endif()
endfunction()