cmake: add option to disable install

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2023-01-14 12:23:04 +08:00
parent eb6fc55006
commit d1f17eb239
2 changed files with 61 additions and 52 deletions

View File

@ -41,6 +41,7 @@ option(FRAMELESSHELPER_NO_BUNDLE_RESOURCE "Do not bundle any resources within Fr
option(FRAMELESSHELPER_NO_PRIVATE "Do not use any private functionalities from Qt." OFF)
option(FRAMELESSHELPER_ENABLE_VCLTL "MSVC only: link to the system MSVCRT/UCRT and get rid of API sets." OFF)
option(FRAMELESSHELPER_NO_PERMISSIVE_CHECKS "MSVC only: disable the additional permissive checks." OFF)
option(FRAMELESSHELPER_NO_INSTALL "Don't install any files." OFF)
if(FRAMELESSHELPER_NO_BUNDLE_RESOURCE)
message(WARNING "Nothing will be embeded into FramelessHelper, the chrome buttons will have no icon.")
@ -156,11 +157,13 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
if(NOT FRAMELESSHELPER_NO_INSTALL)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
endif()
if(TARGET Qt${QT_VERSION_MAJOR}::Core AND TARGET Qt${QT_VERSION_MAJOR}::Gui)
add_subdirectory(src)

View File

@ -187,30 +187,32 @@ function(setup_gui_app arg_target)
endfunction()
function(setup_package_export arg_target arg_path arg_public arg_alias arg_private)
include(GNUInstallDirs)
set(__targets ${arg_target})
if(TARGET ${arg_target}_resources_1)
list(APPEND __targets ${arg_target}_resources_1) # Ugly hack to workaround a CMake configure error.
endif()
install(TARGETS ${__targets}
EXPORT ${arg_target}Targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${arg_path}"
)
export(EXPORT ${arg_target}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${arg_target}Targets.cmake"
NAMESPACE ${PROJECT_NAME}::
)
install(FILES ${arg_public} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${arg_path}")
install(FILES ${arg_alias} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${arg_path}")
install(FILES ${arg_private} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${arg_path}/private")
install(EXPORT ${arg_target}Targets
FILE ${arg_target}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
if(NOT FRAMELESSHELPER_NO_INSTALL)
include(GNUInstallDirs)
set(__targets ${arg_target})
if(TARGET ${arg_target}_resources_1)
list(APPEND __targets ${arg_target}_resources_1) # Ugly hack to workaround a CMake configure error.
endif()
install(TARGETS ${__targets}
EXPORT ${arg_target}Targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${arg_path}"
)
install(FILES ${arg_public} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${arg_path}")
install(FILES ${arg_alias} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${arg_path}")
install(FILES ${arg_private} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${arg_path}/private")
install(EXPORT ${arg_target}Targets
FILE ${arg_target}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
endif()
endfunction()
function(deploy_qt_runtime arg_target)
@ -299,29 +301,31 @@ function(deploy_qt_runtime arg_target)
elseif(UNIX)
# TODO
endif()
include(GNUInstallDirs)
install(TARGETS ${arg_target}
BUNDLE DESTINATION .
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
set(__deploy_script)
if(${__is_quick_app})
qt_generate_deploy_qml_app_script(
TARGET ${arg_target}
FILENAME_VARIABLE __deploy_script
#MACOS_BUNDLE_POST_BUILD
NO_UNSUPPORTED_PLATFORM_ERROR
DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
else()
qt_generate_deploy_app_script(
TARGET ${arg_target}
FILENAME_VARIABLE __deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
if(NOT FRAMELESSHELPER_NO_INSTALL)
include(GNUInstallDirs)
install(TARGETS ${arg_target}
BUNDLE DESTINATION .
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
set(__deploy_script)
if(${__is_quick_app})
qt_generate_deploy_qml_app_script(
TARGET ${arg_target}
FILENAME_VARIABLE __deploy_script
#MACOS_BUNDLE_POST_BUILD
NO_UNSUPPORTED_PLATFORM_ERROR
DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
else()
qt_generate_deploy_app_script(
TARGET ${arg_target}
FILENAME_VARIABLE __deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
endif()
install(SCRIPT "${__deploy_script}")
endif()
install(SCRIPT "${__deploy_script}")
endif()
endfunction()
@ -352,10 +356,6 @@ function(setup_translations arg_target)
if(DEFINED TRANSLATION_ARGS_QM_DIR)
set(__qm_dir "${TRANSLATION_ARGS_QM_DIR}")
endif()
set(__inst_dir translations)
if(DEFINED TRANSLATION_ARGS_INSTALL_DIR)
set(__inst_dir "${TRANSLATION_ARGS_INSTALL_DIR}")
endif()
set(__ts_files)
foreach(__locale ${TRANSLATION_ARGS_LOCALES})
list(APPEND __ts_files "${__ts_dir}/${arg_target}_${__locale}.ts")
@ -374,5 +374,11 @@ function(setup_translations arg_target)
-nounfinished # Don't include unfinished translations (to save file size).
-removeidentical # Don't include translations that are the same with their original texts (to save file size).
)
install(FILES ${__qm_files} DESTINATION "${__inst_dir}")
if(NOT FRAMELESSHELPER_NO_INSTALL)
set(__inst_dir translations)
if(DEFINED TRANSLATION_ARGS_INSTALL_DIR)
set(__inst_dir "${TRANSLATION_ARGS_INSTALL_DIR}")
endif()
install(FILES ${__qm_files} DESTINATION "${__inst_dir}")
endif()
endfunction()