| 1 |
include(icecc.cmake) # this must be the first line! |
| 2 |
|
| 3 |
project(pysidemobility) |
| 4 |
|
| 5 |
cmake_minimum_required(VERSION 2.6) |
| 6 |
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/ |
| 7 |
${CMAKE_MODULE_PATH}) |
| 8 |
find_package(PythonLibs REQUIRED) |
| 9 |
find_package(PythonInterpWithDebug REQUIRED) |
| 10 |
find_package(Shiboken 1.1.0 REQUIRED) |
| 11 |
find_package(PySide 1.1.0 REQUIRED) |
| 12 |
find_package(Qt4 4.6.2 REQUIRED) |
| 13 |
SET(SUPPORTED_QT_VERSION "4.6.0") |
| 14 |
find_package(QtMobility 1.0.0 REQUIRED ) |
| 15 |
|
| 16 |
|
| 17 |
if(CMAKE_HOST_UNIX) |
| 18 |
option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) |
| 19 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing") |
| 20 |
set(CMAKE_CXX_FLAGS_DEBUG "-g") |
| 21 |
if(ENABLE_GCC_OPTIMIZATION) |
| 22 |
set(CMAKE_BUILD_TYPE Release) |
| 23 |
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Os -Wl,-O1") |
| 24 |
if(NOT CMAKE_HOST_APPLE) |
| 25 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--hash-style=gnu") |
| 26 |
endif() |
| 27 |
endif() |
| 28 |
|
| 29 |
if(CMAKE_HOST_APPLE) |
| 30 |
if (NOT QT_INCLUDE_DIR) |
| 31 |
set(QT_INCLUDE_DIR "/Library/Frameworks") |
| 32 |
endif() |
| 33 |
endif() |
| 34 |
endif() |
| 35 |
|
| 36 |
if(NOT CMAKE_BUILD_TYPE) |
| 37 |
set(CMAKE_BUILD_TYPE Release) |
| 38 |
endif() |
| 39 |
|
| 40 |
set(BINDING_NAME QtMobility) |
| 41 |
set(BINDING_API_MAJOR_VERSION "0") |
| 42 |
set(BINDING_API_MINOR_VERSION "2") |
| 43 |
set(BINDING_API_MICRO_VERSION "3") |
| 44 |
set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}") |
| 45 |
|
| 46 |
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) |
| 47 |
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) |
| 48 |
|
| 49 |
include(${QT_USE_FILE}) |
| 50 |
|
| 51 |
set(BINDING_VERSION ${BINDING_API_VERSION}) |
| 52 |
find_program(GENERATOR generatorrunner REQUIRED) |
| 53 |
|
| 54 |
if (NOT GENERATOR) |
| 55 |
message(FATAL_ERROR "You need to specify GENERATOR variable (-DGENERATOR=value)") |
| 56 |
endif() |
| 57 |
|
| 58 |
# uninstall target |
| 59 |
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake" |
| 60 |
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
| 61 |
IMMEDIATE @ONLY) |
| 62 |
add_custom_target(uninstall "${CMAKE_COMMAND}" |
| 63 |
-P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
| 64 |
|
| 65 |
|
| 66 |
set(ARCHIVE_NAME pyside-mobility-${BINDING_API_VERSION}) |
| 67 |
add_custom_target(dist |
| 68 |
COMMAND mkdir -p "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}" && |
| 69 |
git log > "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}/ChangeLog" && |
| 70 |
git archive --prefix=${ARCHIVE_NAME}/ HEAD --format=tar --output="${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && |
| 71 |
tar -C "${CMAKE_BINARY_DIR}" --owner=root --group=root -r "${ARCHIVE_NAME}/ChangeLog" -f "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && |
| 72 |
bzip2 -f9 "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && |
| 73 |
echo "Source package created at ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2.\n" |
| 74 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) |
| 75 |
|
| 76 |
execute_process( |
| 77 |
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; \\ |
| 78 |
print sysconfig.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}')" |
| 79 |
OUTPUT_VARIABLE SITE_PACKAGE |
| 80 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 81 |
if (NOT SITE_PACKAGE) |
| 82 |
message(FATAL_ERROR "Could not detect Python module installation directory.") |
| 83 |
endif() |
| 84 |
|
| 85 |
# Detect if the python libs were compiled in debug mode |
| 86 |
execute_process( |
| 87 |
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; \\ |
| 88 |
print sysconfig.get_config_var('Py_DEBUG')" |
| 89 |
OUTPUT_VARIABLE PY_DEBUG |
| 90 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 91 |
|
| 92 |
if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 93 |
if(NOT PYTHON_DEBUG_LIBRARIES) |
| 94 |
message(FATAL_ERROR "Python debug library not found. Try compile PySide with -DCMAKE_BUILD_TYPE=Release") |
| 95 |
endif() |
| 96 |
if(NOT PY_DEBUG) |
| 97 |
message(WARNING "Compiling PySide with debug enabled, but the python executable was not compiled with debug support.") |
| 98 |
else() |
| 99 |
add_definitions("-DPy_DEBUG") |
| 100 |
endif() |
| 101 |
set(PYSIDE_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES}) |
| 102 |
else() |
| 103 |
set(PYSIDE_PYTHON_LIBRARIES ${PYTHON_LIBRARIES}) |
| 104 |
endif() |
| 105 |
|
| 106 |
set(GENERATOR_EXTRA_FLAGS --generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic) |
| 107 |
if(WIN32 OR DEFINED AVOID_PROTECTED_HACK) |
| 108 |
message(STATUS "PySide-Mobility will be generated avoiding the protected hack!") |
| 109 |
set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack) |
| 110 |
add_definitions(-DAVOID_PROTECTED_HACK) |
| 111 |
else() |
| 112 |
message(STATUS "PySide-Mobility will be generated using the protected hack!") |
| 113 |
endif() |
| 114 |
|
| 115 |
enable_testing() |
| 116 |
|
| 117 |
add_subdirectory(${BINDING_NAME}) |
| 118 |
add_subdirectory(doc) |
| 119 |
add_subdirectory(tests) |