diff options
author | Philipp Kerling <yol@casix.org> | 2024-03-25 20:56:23 +0100 |
---|---|---|
committer | Philipp Kerling <yol@casix.org> | 2024-06-13 20:28:07 +0200 |
commit | ddcdcc156b00294e54397ff37d50a4771f0d09a3 (patch) | |
tree | 1283c78b479758207d09435dd09fc2afd3797ddb /cmake | |
parent | 6094e540f79b533506195ea5affb4f2f587408f3 (diff) |
[windows] c++20: Do not compile C files as C++
C and C++ aren't actually compatible and this breaks the build starting with C++20 (due to cc_overlay.c using u8 literals).
When these files are now compiled as C files, they cannot use the C++ precompiled headers, so just disable PCH for those few files.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/scripts/common/Macros.cmake | 14 | ||||
-rw-r--r-- | cmake/scripts/windows/Macros.cmake | 3 | ||||
-rw-r--r-- | cmake/scripts/windowsstore/Macros.cmake | 67 |
3 files changed, 4 insertions, 80 deletions
diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index 08455f6d80..65d6406ec7 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake @@ -88,7 +88,6 @@ function(core_add_library name) # 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) - set_language_cxx(${name}) endif() else() foreach(src IN LISTS SOURCES HEADERS OTHERS) @@ -183,19 +182,6 @@ function(core_add_shared_library name) endif() endfunction() -# Sets the compile language for all C source files in a target to CXX. -# Needs to be called from the CMakeLists.txt that defines the target. -# Arguments: -# target target -function(set_language_cxx target) - get_property(sources TARGET ${target} PROPERTY SOURCES) - foreach(file IN LISTS sources) - if(file MATCHES "\.c$") - set_source_files_properties(${file} PROPERTIES LANGUAGE CXX) - endif() - endforeach() -endfunction() - # Add a data file to installation list with a mirror in build tree # Mirroring files in the buildtree allows to execute the app from there. # Arguments: diff --git a/cmake/scripts/windows/Macros.cmake b/cmake/scripts/windows/Macros.cmake index 2d3500d8f3..db608856d0 100644 --- a/cmake/scripts/windows/Macros.cmake +++ b/cmake/scripts/windows/Macros.cmake @@ -35,6 +35,9 @@ function(add_precompiled_header target pch_header pch_source) foreach(exclude_source IN LISTS PCH_EXCLUDE_SOURCES) list(REMOVE_ITEM sources ${exclude_source}) endforeach() + # A PCH compiled in C++ mode cannot be used for C code + list(FILTER sources EXCLUDE REGEX "\\.c$") + set_source_files_properties(${sources} PROPERTIES COMPILE_FLAGS "/Yu\"${pch_header}\" /Fp\"${pch_binary}\" /FI\"${pch_header}\"" OBJECT_DEPENDS "${pch_binary}") diff --git a/cmake/scripts/windowsstore/Macros.cmake b/cmake/scripts/windowsstore/Macros.cmake index 6c28e38033..b86bf627ff 100644 --- a/cmake/scripts/windowsstore/Macros.cmake +++ b/cmake/scripts/windowsstore/Macros.cmake @@ -1,69 +1,4 @@ -function(core_link_library lib wraplib) - message(AUTHOR_WARNING "core_link_library is not compatible with windows.") -endfunction() - -function(find_soname lib) - # Windows uses hardcoded dlls in xbmc/DllPaths_win32.h. - # Therefore the output of this function is unused. -endfunction() - -# Add precompiled header to target -# Arguments: -# target existing target that will be set up to compile with a precompiled header -# pch_header the precompiled header file -# pch_source the precompiled header source file -# Optional Arguments: -# PCH_TARGET build precompiled header as separate target with the given name -# so that the same precompiled header can be used for multiple libraries -# EXCLUDE_SOURCES if not all target sources shall use the precompiled header, -# the relevant files can be listed here -# On return: -# Compiles the pch_source into a precompiled header and adds the header to -# the given target -function(add_precompiled_header target pch_header pch_source) - cmake_parse_arguments(PCH "" "PCH_TARGET" "EXCLUDE_SOURCES" ${ARGN}) - - if(PCH_PCH_TARGET) - set(pch_binary ${PRECOMPILEDHEADER_DIR}/${PCH_PCH_TARGET}.pch) - else() - set(pch_binary ${PRECOMPILEDHEADER_DIR}/${target}.pch) - endif() - - # Set compile options and dependency for sources - get_target_property(sources ${target} SOURCES) - list(REMOVE_ITEM sources ${pch_source}) - foreach(exclude_source IN LISTS PCH_EXCLUDE_SOURCES) - list(REMOVE_ITEM sources ${exclude_source}) - endforeach() - set_source_files_properties(${sources} - PROPERTIES COMPILE_FLAGS "/Yu\"${pch_header}\" /Fp\"${pch_binary}\" /FI\"${pch_header}\"" - OBJECT_DEPENDS "${pch_binary}") - - # Set compile options for precompiled header - if(NOT PCH_PCH_TARGET OR NOT TARGET ${PCH_PCH_TARGET}_pch) - set_source_files_properties(${pch_source} - PROPERTIES COMPILE_FLAGS "/Yc\"${pch_header}\" /Fp\"${pch_binary}\"" - OBJECT_OUTPUTS "${pch_binary}") - endif() - - # Compile precompiled header - if(PCH_PCH_TARGET) - # As own target for usage in multiple libraries - if(NOT TARGET ${PCH_PCH_TARGET}_pch) - add_library(${PCH_PCH_TARGET}_pch STATIC ${pch_source}) - set_target_properties(${PCH_PCH_TARGET}_pch PROPERTIES COMPILE_PDB_NAME vc140 - COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR} - FOLDER "Build Utilities") - endif() - # From VS2012 onwards, precompiled headers have to be linked against (LNK2011). - target_link_libraries(${target} PUBLIC ${PCH_PCH_TARGET}_pch) - set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME vc140 - COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR}) - else() - # As part of the target - target_sources(${target} PRIVATE ${pch_source}) - endif() -endfunction() +include(${CMAKE_CURRENT_LIST_DIR}/../windows/Macros.cmake) macro(winstore_set_assets target) file(GLOB ASSET_FILES "${CMAKE_SOURCE_DIR}/tools/windows/packaging/uwp/media/*.png") |