aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Fetzer <fetzer.ch@gmail.com>2016-07-26 22:26:50 +0200
committerChristian Fetzer <fetzer.ch@gmail.com>2016-07-27 23:17:35 +0200
commitabe3fb9144dfbf02d3f11a90a78bba8e66555b68 (patch)
tree122731472829a2a589873415b320b6b7eebf81d1
parentc4dd3d7a488e984199c21d4229f3f9d5203b2cb8 (diff)
[cmake] Add a 'destination directory' parameter to copy_file_to_buildtree
The function copy_file_to_buildtree is used to mirror files to the build directory, so that Kodi can be launched from there. The previous implementation of that function only allowed to mirror files to the same tree structure. With this change files can be mirrored also into different directories as this is needed for some use cases (DLLs on Windows, certificates on IOS/OSX). This changes the following parts: - Patterns specified in installdata now support an optional second parameter that specifies where the files should be mirrored to. This parameter is optional. If specified it points to the destination directory (relative to CMAKE_BINARY_DIR) otherwise the files are mirrored in the same tree structure under CMAKE_BINARY_DIR. - Mirror files for in-source-builds where necessary. - Remove the relative parameter from copy_file_to_buildtree. Its API was confusing and it's not necessary because the files are always relative to CORE_SOURCE_DIR. - Remove Windows specific hook to mirror additional files and use the newly introduced mechanism instead.
-rw-r--r--project/cmake/CMakeLists.txt1
-rw-r--r--project/cmake/installdata/windows/dlls.txt8
-rw-r--r--project/cmake/modules/FindCpluff.cmake2
-rw-r--r--project/cmake/modules/FindD3DX11Effects.cmake1
-rw-r--r--project/cmake/scripts/common/Macros.cmake62
-rw-r--r--project/cmake/scripts/common/ProjectMacros.cmake7
-rw-r--r--project/cmake/scripts/windows/Macros.cmake18
7 files changed, 44 insertions, 55 deletions
diff --git a/project/cmake/CMakeLists.txt b/project/cmake/CMakeLists.txt
index a5b896c238..1f5a1fc8db 100644
--- a/project/cmake/CMakeLists.txt
+++ b/project/cmake/CMakeLists.txt
@@ -343,7 +343,6 @@ unset(_MAIN_LIBRARIES)
if(WIN32)
set_target_properties(${APP_NAME_LC} PROPERTIES WIN32_EXECUTABLE ON)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${APP_NAME_LC})
- copy_main_dlls_to_buildtree()
elseif(CORE_SYSTEM_NAME STREQUAL android)
# Nothing
else()
diff --git a/project/cmake/installdata/windows/dlls.txt b/project/cmake/installdata/windows/dlls.txt
index 72cca7df4d..64d9756a59 100644
--- a/project/cmake/installdata/windows/dlls.txt
+++ b/project/cmake/installdata/windows/dlls.txt
@@ -1,6 +1,2 @@
-system/*.dll
-system/airplay/*.dll
-system/cdrip/*.dll
-system/players/dvdplayer/*.dll
-system/players/paplayer/*.dll
-system/players/VideoPlayer/*.dll
+system/*.dll .
+project/Win32BuildSetup/dependencies/python27.dll . \ No newline at end of file
diff --git a/project/cmake/modules/FindCpluff.cmake b/project/cmake/modules/FindCpluff.cmake
index ca7decba97..b4f3428e3f 100644
--- a/project/cmake/modules/FindCpluff.cmake
+++ b/project/cmake/modules/FindCpluff.cmake
@@ -41,7 +41,7 @@ else()
BUILD_COMMAND msbuild ${CORE_SOURCE_DIR}/project/VS2010Express/XBMC\ for\ Windows.sln
/t:cpluff /p:Configuration=${CORE_BUILD_CONFIG}
INSTALL_COMMAND "")
- copy_file_to_buildtree(${CORE_SOURCE_DIR}/system/cpluff.dll ${CORE_SOURCE_DIR})
+ copy_file_to_buildtree(${CORE_SOURCE_DIR}/cpluff.dll)
add_dependencies(export-files libcpluff)
endif()
set_target_properties(libcpluff PROPERTIES FOLDER "External Projects")
diff --git a/project/cmake/modules/FindD3DX11Effects.cmake b/project/cmake/modules/FindD3DX11Effects.cmake
index 8837ac6265..8a36f9c040 100644
--- a/project/cmake/modules/FindD3DX11Effects.cmake
+++ b/project/cmake/modules/FindD3DX11Effects.cmake
@@ -38,6 +38,7 @@ if(NOT D3DCOMPILER_DLL)
message(WARNING "Could NOT find Direct3D Compiler")
endif()
mark_as_advanced(D3DCOMPILER_DLL)
+copy_file_to_buildtree(${D3DCOMPILER_DLL} DIRECTORY .)
find_program(FXC fxc
PATHS
diff --git a/project/cmake/scripts/common/Macros.cmake b/project/cmake/scripts/common/Macros.cmake
index 1527732594..d8ca611664 100644
--- a/project/cmake/scripts/common/Macros.cmake
+++ b/project/cmake/scripts/common/Macros.cmake
@@ -179,39 +179,43 @@ function(set_language_cxx target)
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:
-# file full path to file to mirror
-# relative the relative base of file path in the build/install tree
+# file full path to file to mirror
# Optional Arguments:
-# NO_INSTALL: exclude file from installation target
-# Implicit arguments:
-# CORE_SOURCE_DIR - root of source tree
+# NO_INSTALL: exclude file from installation target (only mirror)
+# DIRECTORY: directory where the file should be mirrored to
+# (default: preserve tree structure relative to CORE_SOURCE_DIR)
# On return:
# Files is mirrored to the build tree and added to ${install_data}
# (if NO_INSTALL is not given).
-function(copy_file_to_buildtree file relative)
- cmake_parse_arguments(arg "NO_INSTALL" "" "" ${ARGN})
- string(REPLACE "${relative}/" "" outfile ${file})
- get_filename_component(outdir ${outfile} DIRECTORY)
-
- if(NOT CMAKE_BINARY_DIR STREQUAL CORE_SOURCE_DIR)
- if(NOT TARGET export-files)
- 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)
- set_target_properties(export-files PROPERTIES FOLDER "Build Utilities")
- endif()
+function(copy_file_to_buildtree file)
+ cmake_parse_arguments(arg "NO_INSTALL" "DIRECTORY" "" ${ARGN})
+ if(arg_DIRECTORY)
+ set(outdir ${arg_DIRECTORY})
+ get_filename_component(outfile ${file} NAME)
+ set(outfile ${outdir}/${outfile})
+ else()
+ string(REPLACE "${CORE_SOURCE_DIR}/" "" outfile ${file})
+ get_filename_component(outdir ${outfile} DIRECTORY)
+ endif()
+
+ if(NOT TARGET export-files)
+ 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)
+ 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(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(NOT TARGET export-files)
- add_custom_target(export-files ALL)
- set_target_properties(export-files PROPERTIES FOLDER "Build Utilities")
- endif()
endif()
+
if(NOT arg_NO_INSTALL)
list(APPEND install_data ${outfile})
set(install_data ${install_data} PARENT_SCOPE)
@@ -244,12 +248,20 @@ function(copy_files_from_filelist_to_buildtree pattern)
string(STRIP ${filename} filename)
core_file_read_filtered(fstrings ${filename})
foreach(dir ${fstrings})
- file(GLOB_RECURSE files RELATIVE ${CORE_SOURCE_DIR} ${CORE_SOURCE_DIR}/${dir})
+ string(REPLACE " " ";" dir ${dir})
+ list(GET dir 0 src)
+ list(LENGTH dir len)
+ if(len EQUAL 1)
+ set(dest)
+ else()
+ list(GET dir -1 dest)
+ endif()
+ file(GLOB_RECURSE files RELATIVE ${CORE_SOURCE_DIR} ${CORE_SOURCE_DIR}/${src})
foreach(file ${files})
if(arg_NO_INSTALL)
- copy_file_to_buildtree(${CORE_SOURCE_DIR}/${file} ${CORE_SOURCE_DIR} NO_INSTALL)
+ copy_file_to_buildtree(${CORE_SOURCE_DIR}/${file} DIRECTORY ${dest} NO_INSTALL)
else()
- copy_file_to_buildtree(${CORE_SOURCE_DIR}/${file} ${CORE_SOURCE_DIR})
+ copy_file_to_buildtree(${CORE_SOURCE_DIR}/${file} DIRECTORY ${dest})
endif()
endforeach()
endforeach()
diff --git a/project/cmake/scripts/common/ProjectMacros.cmake b/project/cmake/scripts/common/ProjectMacros.cmake
index f6a3c7d397..653382c039 100644
--- a/project/cmake/scripts/common/ProjectMacros.cmake
+++ b/project/cmake/scripts/common/ProjectMacros.cmake
@@ -23,18 +23,17 @@ endfunction()
# Add a skin to installation list, mirroring it in build tree, packing textures
# Arguments:
# skin skin directory
-# relative relative base path in build tree
# On return:
# xbt is added to ${XBT_FILES}, data added to ${install_data}, mirror in build tree
-function(copy_skin_to_buildtree skin relative)
+function(copy_skin_to_buildtree skin)
file(GLOB_RECURSE FILES ${skin}/*)
file(GLOB_RECURSE MEDIA_FILES ${skin}/media/*)
list(REMOVE_ITEM FILES ${MEDIA_FILES})
foreach(file ${FILES})
- copy_file_to_buildtree(${file} ${relative})
+ copy_file_to_buildtree(${file})
endforeach()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${dest}/media)
- string(REPLACE "${relative}/" "" dest ${skin})
+ string(REPLACE "${CORE_SOURCE_DIR}/" "" dest ${skin})
pack_xbt(${skin}/media ${CMAKE_BINARY_DIR}/${dest}/media/Textures.xbt)
file(GLOB THEMES RELATIVE ${skin}/themes ${skin}/themes/*)
diff --git a/project/cmake/scripts/windows/Macros.cmake b/project/cmake/scripts/windows/Macros.cmake
index a908ba7f29..2d3500d8f3 100644
--- a/project/cmake/scripts/windows/Macros.cmake
+++ b/project/cmake/scripts/windows/Macros.cmake
@@ -64,21 +64,3 @@ function(add_precompiled_header target pch_header pch_source)
target_sources(${target} PRIVATE ${pch_source})
endif()
endfunction()
-
-# Copies the main dlls to the root of the buildtree
-# On return:
-# files added to ${install_data}, mirror in build tree
-function(copy_main_dlls_to_buildtree)
- set(dir ${PROJECT_SOURCE_DIR}/../Win32BuildSetup/dependencies)
- file(GLOB_RECURSE files ${dir}/*)
- foreach(file ${files})
- copy_file_to_buildtree(${file} ${dir})
- endforeach()
-
- if(D3DCOMPILER_DLL)
- get_filename_component(d3dcompiler_dir ${D3DCOMPILER_DLL} DIRECTORY)
- copy_file_to_buildtree(${D3DCOMPILER_DLL} ${d3dcompiler_dir})
- endif()
-
- set(install_data ${install_data} PARENT_SCOPE)
-endfunction()