Explorar o código

[cmake][android] symlink external libs instead of copying them

saves some disk space, Gradle will package actual files anyway
Andrey Filipenkov hai 3 meses
pai
achega
54dab0cca6
Modificáronse 2 ficheiros con 18 adicións e 4 borrados
  1. 1 3
      CMakeLists.txt
  2. 17 1
      cmake_modules/VCMIUtils.cmake

+ 1 - 3
CMakeLists.txt

@@ -736,9 +736,7 @@ if(ANDROID)
 
 	if(ANDROID_STL MATCHES "_shared$")
 		set(stlLibName "${CMAKE_SHARED_LIBRARY_PREFIX}${ANDROID_STL}${CMAKE_SHARED_LIBRARY_SUFFIX}")
-		install(FILES "${CMAKE_SYSROOT}/usr/lib/${ANDROID_SYSROOT_LIB_SUBDIR}/${stlLibName}"
-			DESTINATION ${LIB_DIR}
-		)
+		vcmi_install_libs_symlink("${CMAKE_SYSROOT}/usr/lib/${ANDROID_SYSROOT_LIB_SUBDIR}/${stlLibName}")
 	endif()
 else()
 	install(DIRECTORY config DESTINATION ${DATA_DIR})

+ 17 - 1
cmake_modules/VCMIUtils.cmake

@@ -118,6 +118,18 @@ function(vcmi_print_git_commit_hash)
 
 endfunction()
 
+# install(FILES) of shared libs but using symlink instead of copying
+function(vcmi_install_libs_symlink libs)
+	install(CODE "
+		foreach(lib ${libs})
+			cmake_path(GET lib FILENAME filename)
+			file(CREATE_LINK \${lib} \"\${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/\${filename}\"
+				COPY_ON_ERROR SYMBOLIC
+			)
+		endforeach()
+	")
+endfunction()
+
 # install dependencies from Conan, CONAN_RUNTIME_LIBS_FILE is set in conanfile.py
 function(vcmi_install_conan_deps)
 	if(NOT USING_CONAN)
@@ -125,7 +137,11 @@ function(vcmi_install_conan_deps)
 	endif()
 
 	file(STRINGS "${CONAN_RUNTIME_LIBS_FILE}" runtimeLibs)
-	install(FILES ${runtimeLibs} DESTINATION ${LIB_DIR})
+	if(ANDROID)
+		vcmi_install_libs_symlink("${runtimeLibs}")
+	else()
+		install(FILES ${runtimeLibs} DESTINATION ${LIB_DIR})
+	endif()
 endfunction()
 
 function(vcmi_deploy_qt deployQtToolName deployQtOptions)