Skip to content
Snippets Groups Projects
Commit f9ceb5d5 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #8574: added optional EXECUTABLE to python_install macro, which makes the...

Task #8574: added optional EXECUTABLE to python_install macro, which makes the installed python files executable
parent a425673c
No related branches found
No related tags found
No related merge requests found
...@@ -67,9 +67,24 @@ macro(python_install) ...@@ -67,9 +67,24 @@ macro(python_install)
endif(NOT PYTHON_EXECUTABLE) endif(NOT PYTHON_EXECUTABLE)
# Parse arguments. # Parse arguments.
# apart from the python files list, there are two additional arguments
# DESTINATION (required), where to put the py files (relative to python lib dir)
# EXECUTABLE (optional), makes the py files executable
string(REGEX REPLACE ";?DESTINATION.*" "" _py_files "${ARGN}") string(REGEX REPLACE ";?DESTINATION.*" "" _py_files "${ARGN}")
string(REGEX REPLACE ";?EXECUTABLE.*" "" _py_files "${_py_files}")
string(REGEX MATCH "DESTINATION;.*" _dest_dir "${ARGN}") string(REGEX MATCH "DESTINATION;.*" _dest_dir "${ARGN}")
string(REGEX REPLACE "^DESTINATION;" "" _dest_dir "${_dest_dir}") string(REGEX REPLACE "^DESTINATION;" "" _dest_dir "${_dest_dir}")
string(REGEX REPLACE ";?EXECUTABLE.*" "" _dest_dir "${_dest_dir}")
string(REGEX MATCH "EXECUTABLE;" _executable "${ARGN}")
#check if optional argument EXECUTABLE is set
#if so, then install the _py_files as EXECUTABLE type (executable)
#else as normal files (not executable)
if("${_executable}" STRGREATER "")
set(INSTALL_TYPE PROGRAMS)
else()
set(INSTALL_TYPE FILES)
endif("${_executable}" STRGREATER "")
if(_py_files MATCHES "^$") if(_py_files MATCHES "^$")
message(FATAL_ERROR "python_install: no sources files specified") message(FATAL_ERROR "python_install: no sources files specified")
...@@ -98,7 +113,7 @@ macro(python_install) ...@@ -98,7 +113,7 @@ macro(python_install)
file(MAKE_DIRECTORY ${_build_dir}/${_py_path}) file(MAKE_DIRECTORY ${_build_dir}/${_py_path})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${_py_abs} ${_build_dir}/${_py}) ${_py_abs} ${_build_dir}/${_py})
install(FILES ${_py_abs} DESTINATION ${_inst_dir}/${_py_path}) install(${INSTALL_TYPE} ${_py_abs} DESTINATION ${_inst_dir}/${_py_path})
if(USE_PYTHON_COMPILATION) if(USE_PYTHON_COMPILATION)
set(_py_code set(_py_code
"import py_compile, os" "import py_compile, os"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment