##// END OF EJS Templates
Modify typesystems to #ifdef PyString
Modify typesystems to #ifdef PyString

File last commit:

r208:1476f2d2cf46
r210:d5ac67324004
Show More
CMakeLists.txt
159 lines | 5.1 KiB | text/plain | TextLexer
project(PythonQt)
cmake_minimum_required(VERSION 2.8.10)
include(CTestUseLaunchers OPTIONAL)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
#-----------------------------------------------------------------------------
# Debug
option(PythonQt_DEBUG "Enable/Disable PythonQt debug output" OFF)
if(PythonQt_DEBUG)
add_definitions(-DPYTHONQT_DEBUG)
else()
remove_definitions(-DPYTHONQT_DEBUG)
endif()
#-----------------------------------------------------------------------------
# Qt
option(PythonQt_Qt5 "Use Qt 5.x (5.1+)" OFF)
if(PythonQt_Qt5)
include(PythonQt_Qt_5x)
else(PythonQt_Qt5)
include(PythonQt_Qt_4x)
endif(PythonQt_Qt5)
#-----------------------------------------------------------------------------
# The variable "generated_cpp_suffix" allows to conditionnally compile the generated wrappers
# associated with the Qt version being used.
set(generated_cpp_suffix "_${QT_VERSION_MAJOR}${QT_VERSION_MINOR}")
if("${generated_cpp_suffix}" STREQUAL "_48")
set(generated_cpp_suffix "")
endif()
if("${generated_cpp_suffix}" STREQUAL "_46")
set(generated_cpp_suffix "_47") # Also use 4.7 wrappers for 4.6.x version
endif()
if("${generated_cpp_suffix}" STREQUAL "_51")
set(generated_cpp_suffix "_50")
endif()
#-----------------------------------------------------------------------------
# Generator
if(PythonQt_Qt5)
add_subdirectory(generator_50 EXCLUDE_FROM_ALL)
add_custom_target(generator)
add_dependencies(generator pythonqt_generator)
endif()
# TODO
#-----------------------------------------------------------------------------
# Build options
#option(PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF)
#
#set(qtlibs core gui network opengl sql svg uitools webkit xml xmlpatterns)
#foreach(qtlib ${qtlibs})
# OPTION(PythonQt_Wrap_Qt${qtlib} "Make all of Qt${qtlib} available in python" OFF)
#endforeach()
# Force option if it applies
#if(PythonQt_Wrap_QtAll)
# list(REMOVE_ITEM qtlibs xmlpatterns) # xmlpatterns wrapper does *NOT* build at all :(
# foreach(qtlib ${qtlibs})
# if(NOT ${PythonQt_Wrap_Qt${qtlib}})
# set(PythonQt_Wrap_Qt${qtlib} ON CACHE BOOL "Make all of Qt${qtlib} available in python" FORCE)
# message(STATUS "Enabling [PythonQt_Wrap_Qt${qtlib}] because of [PythonQt_Wrap_QtAll] evaluates to True")
# endif()
# endforeach()
#endif()
#-----------------------------------------------------------------------------
# Add extra sources
#foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
#
# if (${PythonQt_Wrap_Qt${qtlib}})
#
# ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib})
#
# set(file_prefix generated_cpp${generated_cpp_suffix}/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib})
#
# foreach(index RANGE 0 11)
#
# # Source files
# if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.cpp)
# list(APPEND sources ${file_prefix}${index}.cpp)
# endif()
#
# # Headers that should run through moc
# if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.h)
# list(APPEND moc_sources ${file_prefix}${index}.h)
# endif()
#
# endforeach()
#
# list(APPEND sources ${file_prefix}_init.cpp)
#
# endif()
#endforeach()
#-----------------------------------------------------------------------------
# Find Python
option(PythonQt_Python3 "Use Python 3.x (3.3+)" OFF)
option(PythonQt_Python "Use specific Python Version" OFF)
if(PythonQt_Python)
find_package(Python ${PythonQt_Python} REQUIRED EXACT)
elseif(PythonQt_Python3)
find_package(Python 3.3 REQUIRED)
else()
find_package(Python 2.6 REQUIRED)
endif()
include_directories(${PYTHON_INCLUDE_DIRS})
add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
#-----------------------------------------------------------------------------
# Library Name
# The variable PythonQt_LibraryName contains the PythonQt core library name
# It incorporates library mayor versions
# The variable PythonQt_LibrarySuffix is "" or "_d", if it is a debug build
set(PythonQt_LibraryName PythonQt)
if(PythonQt_Qt5)
set(PythonQt_LibraryName ${PythonQt_LibraryName}5)
endif()
if(NOT ${PYTHON_VERSION} VERSION_LESS 3)
set(PythonQt_LibraryName ${PythonQt_LibraryName}_3)
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(PythonQt_LibrarySuffix _d)
endif()
message(STATUS "Building ${PythonQt_LibraryName}${PythonQt_LibrarySuffix} (Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} + Python ${PYTHON_VERSION} | ${CMAKE_BUILD_TYPE})")
#-----------------------------------------------------------------------------
# Core
add_subdirectory(src)
#-----------------------------------------------------------------------------
# Tests
add_subdirectory(tests EXCLUDE_FROM_ALL)
# test alias
add_custom_target(test COMMAND tests/PythonQtTest WORKING_DIRECTORY ${CURRENT_BINARY_DIR})
add_dependencies(test PythonQtTest)
#-----------------------------------------------------------------------------
# Extenseions (QtAll)
add_subdirectory(extensions EXCLUDE_FROM_ALL)
# QtAll alias
add_custom_target(QtAll)
add_dependencies(QtAll PythonQt_QtAll)
#-----------------------------------------------------------------------------
# Examples
include_directories(src)
include_directories(extensions/PythonQt_QtAll)
add_subdirectory(examples EXCLUDE_FROM_ALL)