FreeCAD/cMake/FindPySideTools.cmake
Ian Rees ccfaa56b31 Improves build on MacOS with Homebrew or MacPorts
Squashed commit of the following:

commit e158a2049b922cead90cee4a9d3814093db8d00d
Merge: e7c5c06 d545f5b
Author: Ian Rees <ian.rees@gmail.com>
Date:   Wed Mar 25 17:08:56 2015 +1300

    Merge branch 'mac-app-bundle' into macports-build-1

commit d545f5b0de0efa6a0fd020ac98bb6809d9254019
Author: Ian Rees <ian.rees@gmail.com>
Date:   Thu Mar 19 22:30:20 2015 +1300

    Minor fixes to Mac application bundle creation

commit e7c5c0630b47e89fc719259f3d81be724627f915
Author: Ian Rees <ian.rees@gmail.com>
Date:   Thu Mar 19 16:35:34 2015 +1300

    Report error if no OpenCasCADe found

commit 976b51c13a1619acf66b9d4fad5594fee292aa76
Author: Ian Rees <ian.rees@gmail.com>
Date:   Thu Mar 19 16:30:47 2015 +1300

    Detects OCE automatically on Homebrew and MacPorts

commit 1cc477f77f388f2ccb26f3884320819f8cb33249
Author: Ian Rees <ian.rees@gmail.com>
Date:   Tue Mar 17 15:00:34 2015 +1300

    Find PySide and Shiboken automagically on MacPorts

commit 8bf2ebf7397a1c8c4b1b6f1d97e303f335ab47d7
Author: Ian Rees <ian.rees@gmail.com>
Date:   Mon Mar 16 23:05:35 2015 +1300

    Finds the Python include dir and library on OSX

commit 8bba9b2c78cfe65d7c295c4c99f0a176e1281539
Author: Ian Rees <ian.rees@gmail.com>
Date:   Mon Mar 16 17:31:43 2015 +1300

    Detects Python executable in MacPorts or Homebrew

commit 349a2e0e5c4d370c331bdb54d80d8f4323db8a6b
Author: Ian Rees <ian.rees@gmail.com>
Date:   Mon Mar 16 08:25:16 2015 +1300

    Missing correct Python lib is error on cmake-ing

commit 1625fe7c1c7fb2d944b04d93be8cf90d5c829be9
Author: Ian Rees <ian.rees@gmail.com>
Date:   Sun Mar 15 21:06:08 2015 +1300

    Find PySide's UIC and RCC tools properly on MacPorts
2015-04-01 14:40:34 +02:00

75 lines
3.0 KiB
CMake

# Try to find PySide utilities, PYSIDEUIC4 and PYSIDERCC4:
# PYSIDEUIC4BINARY - Location of PYSIDEUIC4 executable
# PYSIDERCC4BINARY - Location of PYSIDERCC4 executable
# PYSIDE_TOOLS_FOUND - PySide utilities found.
# Also provides macro similar to FindQt4.cmake's WRAP_UI and WRAP_RC,
# for the automatic generation of Python code from Qt4's user interface
# ('.ui') and resource ('.qrc') files. These macros are called:
# - PYSIDE_WRAP_UI
# - PYSIDE_WRAP_RC
IF(PYSIDEUIC4BINARY AND PYSIDERCC4BINARY)
# Already in cache, be silent
set(PYSIDE_TOOLS_FOUND_QUIETLY TRUE)
ENDIF(PYSIDEUIC4BINARY AND PYSIDERCC4BINARY)
if(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#pyside tools are often in same location as python interpreter
get_filename_component(PYTHON_BIN_DIR ${PYTHON_EXECUTABLE} PATH)
set(PYSIDE_BIN_DIR ${PYTHON_BIN_DIR})
endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
FIND_PROGRAM(PYSIDEUIC4BINARY NAMES pyside-uic pyside-uic-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR})
FIND_PROGRAM(PYSIDERCC4BINARY NAMES pyside-rcc pyside-rcc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR})
MACRO(PYSIDE_WRAP_UI outfiles)
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.py)
#ADD_CUSTOM_TARGET(${it} ALL
# DEPENDS ${outfile}
#)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${PYSIDEUIC4BINARY} ${infile} -o ${outfile}
MAIN_DEPENDENCY ${infile}
)
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH(it)
ENDMACRO (PYSIDE_WRAP_UI)
MACRO(PYSIDE_WRAP_RC outfiles)
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}_rc.py)
#ADD_CUSTOM_TARGET(${it} ALL
# DEPENDS ${outfile}
#)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${PYSIDERCC4BINARY} ${infile} -o ${outfile}
MAIN_DEPENDENCY ${infile}
)
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH(it)
ENDMACRO (PYSIDE_WRAP_RC)
IF(EXISTS ${PYSIDEUIC4BINARY} AND EXISTS ${PYSIDERCC4BINARY})
set(PYSIDE_TOOLS_FOUND TRUE)
ENDIF(EXISTS ${PYSIDEUIC4BINARY} AND EXISTS ${PYSIDERCC4BINARY})
if(PYSIDERCC4BINARY AND PYSIDEUIC4BINARY)
if (NOT PySideTools_FIND_QUIETLY)
message(STATUS "Found PySide Tools: ${PYSIDEUIC4BINARY}, ${PYSIDERCC4BINARY}")
endif (NOT PySideTools_FIND_QUIETLY)
else(PYSIDERCC4BINARY AND PYSIDEUIC4BINARY)
if(PySideTools_FIND_REQUIRED)
message(FATAL_ERROR "PySideTools could not be not found, but are required.")
else(PySideTools_FIND_REQUIRED)
if (NOT PySideTools_FIND_QUIETLY)
message(STATUS "PySideTools: not found.")
endif (NOT PySideTools_FIND_QUIETLY)
endif(PySideTools_FIND_REQUIRED)
endif(PYSIDERCC4BINARY AND PYSIDEUIC4BINARY)