mirror of
https://github.com/ModOrganizer2/cmake_common.git
synced 2026-07-27 14:06:46 -07:00
Add deploy_qt function and some fixes.
This commit is contained in:
+6
-4
@@ -92,7 +92,7 @@ function(mo2_configure_target MO2_TARGET)
|
||||
qt5_create_translation(
|
||||
qm_files
|
||||
${source_files} ${header_files} ${ui_files} ${MO2_EXTRA_TRANSLATIONS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}_en.ts
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${MO2_TARGET}_en.ts
|
||||
OPTIONS -silent
|
||||
)
|
||||
endif()
|
||||
@@ -213,7 +213,8 @@ function(mo2_configure_library MO2_TARGET)
|
||||
|
||||
get_target_property(TARGET_TYPE ${MO2_TARGET} TYPE)
|
||||
|
||||
target_include_directories(${MO2_TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(${MO2_TARGET}
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if (${TARGET_TYPE} STREQUAL "STATIC_LIBRARY")
|
||||
set_target_properties(${MO2_TARGET} PROPERTIES MO2_TARGET_TYPE "library-static")
|
||||
@@ -250,7 +251,6 @@ endfunction()
|
||||
function(mo2_install_target MO2_TARGET)
|
||||
cmake_parse_arguments(MO2 "" "INSTALLDIR" "" ${ARGN})
|
||||
|
||||
mo2_set_if_not_defined(MO2_INSTALLDIR "bin")
|
||||
|
||||
get_target_property(MO2_TARGET_TYPE ${MO2_TARGET} MO2_TARGET_TYPE)
|
||||
|
||||
@@ -264,9 +264,11 @@ function(mo2_install_target MO2_TARGET)
|
||||
elseif (${MO2_TARGET_TYPE} STREQUAL "library-static")
|
||||
install(TARGETS ${MO2_TARGET} ARCHIVE DESTINATION libs)
|
||||
elseif (${MO2_TARGET_TYPE} STREQUAL "library-shared")
|
||||
install(TARGETS ${MO2_TARGET} ARCHIVE DESTINATION bin/dlls)
|
||||
mo2_set_if_not_defined(MO2_INSTALLDIR "bin/dlls")
|
||||
install(TARGETS ${MO2_TARGET} RUNTIME DESTINATION ${MO2_INSTALLDIR})
|
||||
install(TARGETS ${MO2_TARGET} ARCHIVE DESTINATION libs)
|
||||
elseif (${MO2_TARGET_TYPE} STREQUAL "executable")
|
||||
mo2_set_if_not_defined(MO2_INSTALLDIR "bin")
|
||||
install(TARGETS ${MO2_TARGET} RUNTIME DESTINATION ${MO2_INSTALLDIR})
|
||||
else()
|
||||
message(ERROR "unknown MO2 target type for target '${MO2_TARGET}', did you forget using mo2_configure_XXX?")
|
||||
|
||||
@@ -108,4 +108,59 @@ function(mo2_find_qt_version VAR)
|
||||
set(${VAR} ${${VAR}} CACHE STRING "Qt Version}")
|
||||
endfunction()
|
||||
|
||||
#! mo2_deploy_qt : add commands to deploy Qt from the given binaries
|
||||
#
|
||||
# this function attach install() entries that deploy Qt for the given binaries
|
||||
#
|
||||
# \param:NOPLUGINS do not deploy Qt plugins
|
||||
# \param:BINARIES names of the binaries (in the install path) to deploy from
|
||||
#
|
||||
function(mo2_deploy_qt)
|
||||
cmake_parse_arguments(DEPLOY "NOPLUGINS" "" "BINARIES" ${ARGN})
|
||||
|
||||
set(qtbin ${QT_ROOT}/bin)
|
||||
find_program(WINDEPLOYQT_COMMAND windeployqt PATHS ${qt5bin} NO_DEFAULT_PATH)
|
||||
|
||||
set(args
|
||||
"--no-translations \
|
||||
--verbose 0 \
|
||||
--webenginewidgets \
|
||||
--websockets \
|
||||
--libdir dlls \
|
||||
--no-compiler-runtime")
|
||||
|
||||
if(${DEPLOY_NOPLUGINS})
|
||||
set(args "${args} --no-plugins")
|
||||
else()
|
||||
set(args "${args} --plugindir qtplugins")
|
||||
endif()
|
||||
|
||||
set(bin "${CMAKE_INSTALL_PREFIX}/bin")
|
||||
|
||||
set(deploys "")
|
||||
foreach(binary ${DEPLOY_BINARIES})
|
||||
set(deploys "${deploys}
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${WINDEPLOYQT_COMMAND} ${args} ${binary}
|
||||
WORKING_DIRECTORY \"${bin}\")")
|
||||
endforeach()
|
||||
|
||||
install(CODE "
|
||||
${deploys}
|
||||
|
||||
file(REMOVE_RECURSE \"${bin}/platforms\")
|
||||
file(REMOVE_RECURSE \"${bin}/styles\")
|
||||
file(REMOVE_RECURSE \"${bin}/dlls/imageformats\")
|
||||
")
|
||||
|
||||
if(NOT ${DEPLOY_NOPLUGINS})
|
||||
install(CODE "
|
||||
file(RENAME \"${bin}/qtplugins/platforms\" \"${bin}/platforms\")
|
||||
file(RENAME \"${bin}/qtplugins/styles\" \"${bin}/styles\")
|
||||
file(RENAME \"${bin}/qtplugins/imageformats\" \"${bin}/dlls/imageformats\")
|
||||
file(REMOVE_RECURSE \"${bin}/qtplugins\")
|
||||
")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set(MO2_UTILS_DEFINED TRUE)
|
||||
|
||||
Reference in New Issue
Block a user