diff options
-rw-r--r-- | modules/FindPyKDE4.cmake | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/modules/FindPyKDE4.cmake b/modules/FindPyKDE4.cmake index 1db7bf08..98f7c374 100644 --- a/modules/FindPyKDE4.cmake +++ b/modules/FindPyKDE4.cmake @@ -159,6 +159,27 @@ MACRO(PYKDE4_ADD_EXECUTABLE _pyname _exename) if(NOT PROJECT_NAME) MESSAGE(STATUS "Project name is necessary to create symlink against python program!!! It will fail.") endif(NOT PROJECT_NAME) - INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -DTARGET=${DATA_INSTALL_DIR}/${PROJECT_NAME}/${_pyname} -DLINK_NAME=${BIN_INSTALL_DIR}/${_exename} -P ${current_module_dir}/create_exe_symlink.cmake)" ) + if(WIN32) + # we generate a batch file instead of a symlink. A windows link would only + # work if the file extension .py is associated with python - but that is + # not guaranteed. + # What if python.exe is not in PATH or points to a wrong python version? + # The python app should check for compatible versions at startup. + # TODO: we cannot attach an icon to a bat file. So we might have to write a + # C program which then calls python + FILE(TO_CMAKE_PATH "${BIN_INSTALL_DIR}/${_exename}.bat" LINK_NAME) + FILE(TO_CMAKE_PATH "${DATA_INSTALL_DIR}/${PROJECT_NAME}/${_pyname}" TARGET) + GET_FILENAME_COMPONENT(abs_link_name $ENV{DESTDIR}/${LINK_NAME} ABSOLUTE) + GET_FILENAME_COMPONENT(link_path $ENV{DESTDIR}/${LINK_NAME} PATH) + GET_FILENAME_COMPONENT(abs_link_path ${link_path} ABSOLUTE) + FILE(MAKE_DIRECTORY ${abs_link_path}) + + FILE(TO_NATIVE_PATH "../${TARGET}" rel_target) + FILE(WRITE ${abs_link_name} "rem this file has been generated by PYKDE4_ADD_EXECUTABLE\n") + FILE(APPEND ${abs_link_name} "python ${rel_target}\n") + INSTALL(PROGRAMS ${LINK_NAME} DESTINATION $ENV{DESTDIR}/${BIN_INSTALL_DIR}) + else(WIN32) + INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -DTARGET=${DATA_INSTALL_DIR}/${PROJECT_NAME}/${_pyname} -DLINK_NAME=${BIN_INSTALL_DIR}/${_exename} -P ${current_module_dir}/create_exe_symlink.cmake)" ) + endif(WIN32) ENDMACRO(PYKDE4_ADD_EXECUTABLE) |