mirror of
https://github.com/ModOrganizer2/cmake_common.git
synced 2026-07-27 14:06:46 -07:00
python plugin now handles .ui, .qrc and installing subdirectories
set_project_to_run_from_install() was called too early, couldn't use OUTPUT_NAME added libbsarch to requires_library()
This commit is contained in:
+84
-1
@@ -11,6 +11,89 @@ macro(do_project)
|
||||
endmacro()
|
||||
|
||||
|
||||
# sets `var` to TRUE if the given directory should be installed
|
||||
#
|
||||
function(is_interesting_python_dir var dir)
|
||||
file(GLOB_RECURSE dir_content "${dir}/*.py")
|
||||
|
||||
if("X${dir_content}" STREQUAL "X")
|
||||
set(${var} FALSE PARENT_SCOPE)
|
||||
else()
|
||||
set(${var} TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(do_src)
|
||||
install(FILES ${source_files} DESTINATION ${install_dir})
|
||||
# this copies all the .py files that are directly in src/ into
|
||||
# ${install_dir}/
|
||||
#
|
||||
# any folder that contains at least one .py file (recursive) is copied in
|
||||
# bin/plugins/data
|
||||
|
||||
|
||||
# everything in the src directory
|
||||
file(GLOB everything ${CMAKE_SOURCE_DIR}/src/*)
|
||||
|
||||
foreach(object ${everything})
|
||||
if(IS_DIRECTORY "${object}")
|
||||
# only copy interesting directories
|
||||
is_interesting_python_dir(is_interesting "${object}")
|
||||
if (${is_interesting})
|
||||
list(APPEND data_dirs "${object}")
|
||||
endif()
|
||||
else()
|
||||
get_filename_component(ext "${object}" LAST_EXT)
|
||||
|
||||
if("${ext}" STREQUAL ".py")
|
||||
# copy .py files directly
|
||||
list(APPEND src_files "${object}")
|
||||
elseif("${ext}" STREQUAL ".ui")
|
||||
# process .ui files and copy the resulting .py in data
|
||||
get_filename_component(name "${object}" NAME_WLE)
|
||||
set(output "${CMAKE_CURRENT_BINARY_DIR}/${name}.py")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_ROOT}/PCbuild/amd64/python.exe
|
||||
-m PyQt5.uic.pyuic
|
||||
-o "${output}"
|
||||
"${object}"
|
||||
WORKING_DIRECTORY ${PYTHON_ROOT})
|
||||
|
||||
list(APPEND data_files "${output}")
|
||||
elseif("${ext}" STREQUAL ".qrc")
|
||||
# process .qrc files and copy the resulting .py in data
|
||||
get_filename_component(name "${object}" NAME_WLE)
|
||||
set(output "${CMAKE_CURRENT_BINARY_DIR}/${name}_rc.py")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_ROOT}/PCbuild/amd64/python.exe
|
||||
-m PyQt5.pyrcc_main
|
||||
-o "${output}"
|
||||
"${object}"
|
||||
WORKING_DIRECTORY ${PYTHON_ROOT})
|
||||
|
||||
list(APPEND data_files "${output}")
|
||||
elseif("${ext}" STREQUAL ".json")
|
||||
# copy .json files in data
|
||||
list(APPEND data_files "${object}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# files that go directly in bin/plugins
|
||||
install(
|
||||
FILES ${src_files}
|
||||
DESTINATION ${install_dir})
|
||||
|
||||
# files that go in bin/plugins/data
|
||||
install(
|
||||
FILES ${data_files}
|
||||
DESTINATION ${install_dir}/data)
|
||||
|
||||
# directories that go in bin/plugins/data
|
||||
install(
|
||||
DIRECTORY ${data_dirs}
|
||||
DESTINATION ${install_dir}/data
|
||||
FILES_MATCHING PATTERN ".py")
|
||||
endmacro()
|
||||
|
||||
Reference in New Issue
Block a user