aboutsummaryrefslogtreecommitdiff
path: root/cmake/scripts
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2022-11-09 13:36:51 +1000
committerfuzzard <fuzzard@kodi.tv>2023-08-27 14:08:44 +1000
commit6508c4cb7292cdeb5d04251a9a5c9c6a82035e63 (patch)
tree6048b6d6c321ebe9211ee1ef1e6eb20a4fb6e4f6 /cmake/scripts
parent6302fa683e39c835f8adf1e1522579b68c5310c9 (diff)
[cmake] Enable Windows Multiconfig Gen to bundle a complete working executable folder
This allows VS (a Multiconfig Generator) to build and create a full file structure required to execute the main app target immediately from the build location that is created in a folder path that is not known at cmake generation. An example, is if you build Kodi as Debug, the executable will be placed in {CMAKE_BINARY_DIR}/Debug/kodi.exe but if you change the Build Type to Release, it will go in ${CMAKE_BINARY_DIR}/Release/kodi.exe. As you can change to any build type you wish after cmake generation, we can not know the location at cmake generation time, so currently all the required dlls/files/folders for a complete bundle are just placed in ${CMAKE_BINARY_DIR}/ and therefore you need to copy the kodi.exe from the folder it was built into the parent folder to be able to execute it.
Diffstat (limited to 'cmake/scripts')
-rw-r--r--cmake/scripts/common/GenerateCompileInfo.cmake14
-rw-r--r--cmake/scripts/common/GenerateSystemAddons.cmake (renamed from cmake/scripts/common/GenerateVersionedFiles.cmake)17
-rw-r--r--cmake/scripts/common/Macros.cmake46
-rw-r--r--cmake/scripts/common/ProjectMacros.cmake23
-rw-r--r--cmake/scripts/windowsstore/Install.cmake30
-rw-r--r--cmake/scripts/windowsstore/Macros.cmake8
6 files changed, 84 insertions, 54 deletions
diff --git a/cmake/scripts/common/GenerateCompileInfo.cmake b/cmake/scripts/common/GenerateCompileInfo.cmake
new file mode 100644
index 0000000000..0fe61d5e19
--- /dev/null
+++ b/cmake/scripts/common/GenerateCompileInfo.cmake
@@ -0,0 +1,14 @@
+include(${CORE_SOURCE_DIR}/cmake/scripts/common/Macros.cmake)
+
+core_find_versions()
+
+# configure_file without dependency tracking
+# configure_file would register additional file dependencies that interfere
+# with the ones from add_custom_command (and the generation would happen twice)
+function(generate_versioned_file _SRC _DEST)
+ file(READ ${CORE_SOURCE_DIR}/${_SRC} file_content)
+ string(CONFIGURE "${file_content}" file_content @ONLY)
+ file(WRITE ${CMAKE_BINARY_DIR}/${_DEST} "${file_content}")
+endfunction()
+
+generate_versioned_file(xbmc/CompileInfo.cpp.in ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp)
diff --git a/cmake/scripts/common/GenerateVersionedFiles.cmake b/cmake/scripts/common/GenerateSystemAddons.cmake
index d54b524219..55472f0af6 100644
--- a/cmake/scripts/common/GenerateVersionedFiles.cmake
+++ b/cmake/scripts/common/GenerateSystemAddons.cmake
@@ -2,15 +2,6 @@ include(${CORE_SOURCE_DIR}/cmake/scripts/common/Macros.cmake)
core_find_versions()
-# configure_file without dependency tracking
-# configure_file would register additional file dependencies that interfere
-# with the ones from add_custom_command (and the generation would happen twice)
-function(generate_versioned_file _SRC _DEST)
- file(READ ${CORE_SOURCE_DIR}/${_SRC} file_content)
- string(CONFIGURE "${file_content}" file_content @ONLY)
- file(WRITE ${CMAKE_BINARY_DIR}/${_DEST} "${file_content}")
-endfunction()
-
# add-on xml's
file(GLOB ADDON_XML_IN_FILE ${CORE_SOURCE_DIR}/addons/*/addon.xml.in)
@@ -21,15 +12,13 @@ foreach(loop_var ${ADDON_XML_IN_FILE})
list(GET loop_var 0 xml_name)
string(REPLACE "/addon.xml.in" "" source_dir ${xml_name})
- string(REPLACE ${CORE_SOURCE_DIR} ${CMAKE_BINARY_DIR} dest_dir ${source_dir})
- file(MAKE_DIRECTORY ${dest_dir})
+ string(REPLACE ${CORE_SOURCE_DIR} ${BUNDLEDIR} dest_dir ${source_dir})
+
+ file(MAKE_DIRECTORY ${dest_dir})
configure_file(${source_dir}/addon.xml.in ${dest_dir}/addon.xml @ONLY)
unset(source_dir)
unset(dest_dir)
unset(xml_name)
endforeach()
-
-
-generate_versioned_file(xbmc/CompileInfo.cpp.in ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp)
diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake
index f0e356ef90..f30a961efc 100644
--- a/cmake/scripts/common/Macros.cmake
+++ b/cmake/scripts/common/Macros.cmake
@@ -231,32 +231,42 @@ function(copy_file_to_buildtree file)
endif()
if(NOT TARGET export-files)
+ if(${CORE_SYSTEM_NAME} MATCHES "windows")
+ set(_bundle_dir $<TARGET_FILE_DIR:${APP_NAME_LC}>)
+ else()
+ set(_bundle_dir ${CMAKE_BINARY_DIR})
+ endif()
file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake)
add_custom_target(export-files ALL COMMENT "Copying files into build tree"
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake)
+ COMMAND ${CMAKE_COMMAND} -DBUNDLEDIR=${_bundle_dir}
+ -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake)
set_target_properties(export-files PROPERTIES FOLDER "Build Utilities")
- file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake "# Export files to build tree\n")
endif()
- if(NOT file STREQUAL ${CMAKE_BINARY_DIR}/${outfile})
- if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows" OR NOT IS_SYMLINK "${file}")
- if(VERBOSE)
- message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}")
- endif()
- file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake
- "file(COPY \"${file}\" DESTINATION \"${CMAKE_BINARY_DIR}/${outdir}\")\n" )
- else()
- if(VERBOSE)
- message(STATUS "copy_file_to_buildtree - copying symlinked file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}")
+ if(${CORE_SYSTEM_NAME} MATCHES "windows")
+ file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake
+ "file(COPY \"${file}\" DESTINATION \"\$\{BUNDLEDIR\}/${outdir}\")\n" )
+ else()
+ if(NOT file STREQUAL ${CMAKE_BINARY_DIR}/${outfile})
+ if(NOT IS_SYMLINK "${file}")
+ if(VERBOSE)
+ message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake
+ "file(COPY \"${file}\" DESTINATION \"${CMAKE_BINARY_DIR}/${outdir}\")\n" )
+ else()
+ if(VERBOSE)
+ message(STATUS "copy_file_to_buildtree - copying symlinked file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake
+ "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy_if_different \"${file}\" \"${CMAKE_BINARY_DIR}/${outfile}\")\n")
endif()
- file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake
- "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy_if_different \"${file}\" \"${CMAKE_BINARY_DIR}/${outfile}\")\n")
endif()
- endif()
- if(NOT arg_NO_INSTALL)
- list(APPEND install_data ${outfile})
- set(install_data ${install_data} PARENT_SCOPE)
+ if(NOT arg_NO_INSTALL)
+ list(APPEND install_data ${outfile})
+ set(install_data ${install_data} PARENT_SCOPE)
+ endif()
endif()
endfunction()
diff --git a/cmake/scripts/common/ProjectMacros.cmake b/cmake/scripts/common/ProjectMacros.cmake
index 3a1910caa6..015cc3db94 100644
--- a/cmake/scripts/common/ProjectMacros.cmake
+++ b/cmake/scripts/common/ProjectMacros.cmake
@@ -8,16 +8,19 @@
# xbt is added to ${XBT_FILES}
function(pack_xbt input output)
file(GLOB_RECURSE MEDIA_FILES ${input}/*)
+
get_filename_component(dir ${output} DIRECTORY)
- add_custom_command(OUTPUT ${output}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${dir}
- COMMAND TexturePacker::TexturePacker::Executable
- ARGS -input ${input}
- -output ${output}
- -dupecheck
- DEPENDS ${MEDIA_FILES})
- list(APPEND XBT_FILES ${output})
- set(XBT_FILES ${XBT_FILES} PARENT_SCOPE)
+ if(${CORE_SYSTEM_NAME} MATCHES "windows")
+ string(REPLACE "${CMAKE_BINARY_DIR}" "\$\{BUNDLEDIR\}" dir ${dir})
+ string(REPLACE "${CMAKE_BINARY_DIR}" "\$\{BUNDLEDIR\}" output ${output})
+ endif()
+
+ file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/GeneratedPackSkins.cmake
+"execute_process(COMMAND \"${CMAKE_COMMAND}\" -E make_directory ${dir})
+execute_process(COMMAND \$\{TEXTUREPACKER_EXECUTABLE\} -input ${input} -output ${output} -dupecheck)\n")
+
+ list(APPEND XBT_FILES ${output})
+ set(XBT_FILES ${XBT_FILES} PARENT_SCOPE)
endfunction()
# Add a skin to installation list, mirroring it in build tree, packing textures
@@ -32,7 +35,7 @@ function(copy_skin_to_buildtree skin)
foreach(file ${FILES})
copy_file_to_buildtree(${file})
endforeach()
- file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${dest}/media)
+
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" dest ${skin})
pack_xbt(${skin}/media ${CMAKE_BINARY_DIR}/${dest}/media/Textures.xbt)
diff --git a/cmake/scripts/windowsstore/Install.cmake b/cmake/scripts/windowsstore/Install.cmake
index a0522d3a48..73b3905225 100644
--- a/cmake/scripts/windowsstore/Install.cmake
+++ b/cmake/scripts/windowsstore/Install.cmake
@@ -1,10 +1,24 @@
# Fix UWP addons security issue caused by empty __init__.py Python Lib files packaged with Kodi
-set(uwp_pythonlibinit_filepattern "${DEPENDS_PATH}/bin/Python/Lib/__init__.py")
-file(GLOB_RECURSE uwp_pythonlibinit_foundfiles "${uwp_pythonlibinit_filepattern}")
-foreach(uwp_pythonlibinit_file ${uwp_pythonlibinit_foundfiles})
- file(SIZE "${uwp_pythonlibinit_file}" uwp_pythonlibinit_filesize)
- if(${uwp_pythonlibinit_filesize} EQUAL 0)
- message("Adding hash comment character in the following empty file: ${uwp_pythonlibinit_file}")
- file(APPEND ${uwp_pythonlibinit_file} "#")
+# Encapsulate fix script to allow post generation execution in the event the python lib is
+# built after project generation.
+
+file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/GeneratedUWPPythonInitFix.cmake)
+file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/GeneratedUWPPythonInitFix.cmake
+"set(uwp_pythonlibinit_filepattern \"\$\{DEPENDS_PATH\}/bin/Python/Lib/__init__.py\")
+file(GLOB_RECURSE uwp_pythonlibinit_foundfiles \"\$\{uwp_pythonlibinit_filepattern\}\")
+foreach(uwp_pythonlibinit_file \$\{uwp_pythonlibinit_foundfiles\})
+ file(SIZE \"\$\{uwp_pythonlibinit_file\}\" uwp_pythonlibinit_filesize)
+ if(\$\{uwp_pythonlibinit_filesize\} EQUAL 0)
+ message(\"Adding hash comment character in the following empty file: \$\{uwp_pythonlibinit_file\}\")
+ file(APPEND ${uwp_pythonlibinit_file} \"#\")
endif()
-endforeach()
+endforeach()\n")
+
+# Change to Python3::Python target when built internal
+add_custom_target(generate-UWP-pythonfix
+ COMMAND ${CMAKE_COMMAND} -DDEPENDS_PATH=${DEPENDS_PATH}
+ -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/GeneratedUWPPythonInitFix.cmake
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+# Make sure we apply fix to dependspath before we export-files copy to buildtree
+add_dependencies(export-files generate-UWP-pythonfix)
diff --git a/cmake/scripts/windowsstore/Macros.cmake b/cmake/scripts/windowsstore/Macros.cmake
index 713e8788b0..6c28e38033 100644
--- a/cmake/scripts/windowsstore/Macros.cmake
+++ b/cmake/scripts/windowsstore/Macros.cmake
@@ -115,9 +115,9 @@ macro(winstore_append_props target)
set(DEBUG_DLLS zlibd.dll)
foreach(_dll ${DEBUG_DLLS})
if (DEBUG_DLLS_EXCLUDE)
- list(APPEND DEBUG_DLLS_EXCLUDE "\;$(BuildRootPath)/dlls/${_dll}")
+ list(APPEND DEBUG_DLLS_EXCLUDE "\;$(BuildRootPath)/${_dll}")
else()
- list(APPEND DEBUG_DLLS_EXCLUDE "$(BuildRootPath)/dlls/${_dll}")
+ list(APPEND DEBUG_DLLS_EXCLUDE "$(BuildRootPath)/${_dll}")
endif()
string(CONCAT DEBUG_DLLS_LINKAGE_PROPS "${DEBUG_DLLS_LINKAGE_PROPS}"
" <ItemGroup Label=\"Binaries\">\n"
@@ -127,7 +127,7 @@ macro(winstore_append_props target)
" </ItemGroup>\n")
endforeach(_dll DEBUG_DLLS)
- add_deployment_content_group($(BuildRootPath)/dlls "" *.dll "${DEBUG_DLLS_EXCLUDE}")
+ add_deployment_content_group($(BuildRootPath) "" *.dll "${DEBUG_DLLS_EXCLUDE}")
add_deployment_content_group($(BuildRootPath)/system system **/* "$(BuildRootPath)/**/shaders/**")
add_deployment_content_group($(BuildRootPath)/system/shaders system/shaders **/*.fx "")
add_deployment_content_group($(BuildRootPath)/media media **/* "")
@@ -158,7 +158,7 @@ macro(winstore_append_props target)
" <ImportGroup Label=\"PropertySheets\" />\n"
" <PropertyGroup Label=\"APP_DLLS\">\n"
" <BinPath>${DEPENDENCIES_DIR_NATIVE}\\bin</BinPath>\n"
- " <BuildRootPath>${CMAKE_CURRENT_BINARY_DIR_NATIVE}</BuildRootPath>\n"
+ " <BuildRootPath>${CMAKE_CURRENT_BINARY_DIR_NATIVE}\\$(Configuration)</BuildRootPath>\n"
" <BinaryAddonsPath>${BINARY_ADDONS_DIR_NATIVE}</BinaryAddonsPath>\n"
" </PropertyGroup>\n"
"${DEBUG_DLLS_LINKAGE_PROPS}"