CMakeLists.txt
184 lines
| 5.5 KiB
| text/plain
|
TextLexer
florianlink
|
r166 | project(PythonQt) | ||
Orochimarufan
|
r205 | cmake_minimum_required(VERSION 2.8.10) | ||
florianlink
|
r166 | |||
Orochimarufan
|
r213 | IF(POLICY CMP0020) | ||
cmake_policy(SET CMP0020 NEW) | ||||
ENDIF() | ||||
florianlink
|
r202 | include(CTestUseLaunchers OPTIONAL) | ||
Orochimarufan
|
r205 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | ||
florianlink
|
r166 | |||
Orochimarufan
|
r212 | #----------------------------------------------------------------------------- | ||
Orochimarufan
|
r214 | # Version | ||
Orochimarufan
|
r212 | SET(PythonQt_VERSION 2.2.0) | ||
florianlink
|
r166 | #----------------------------------------------------------------------------- | ||
Orochimarufan
|
r205 | # Debug | ||
florianlink
|
r166 | option(PythonQt_DEBUG "Enable/Disable PythonQt debug output" OFF) | ||
if(PythonQt_DEBUG) | ||||
Orochimarufan
|
r205 | add_definitions(-DPYTHONQT_DEBUG) | ||
florianlink
|
r166 | else() | ||
Orochimarufan
|
r205 | remove_definitions(-DPYTHONQT_DEBUG) | ||
florianlink
|
r166 | endif() | ||
Orochimarufan
|
r211 | if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Release) | ||||
endif() | ||||
florianlink
|
r166 | #----------------------------------------------------------------------------- | ||
Orochimarufan
|
r205 | # Qt | ||
Orochimarufan
|
r212 | option(PythonQt_Qt5 "Use Qt 5.x" OFF) | ||
Orochimarufan
|
r205 | if(PythonQt_Qt5) | ||
include(PythonQt_Qt_5x) | ||||
else(PythonQt_Qt5) | ||||
include(PythonQt_Qt_4x) | ||||
endif(PythonQt_Qt5) | ||||
florianlink
|
r166 | |||
florianlink
|
r202 | #----------------------------------------------------------------------------- | ||
Orochimarufan
|
r205 | # The variable "generated_cpp_suffix" allows to conditionnally compile the generated wrappers | ||
florianlink
|
r202 | # associated with the Qt version being used. | ||
Orochimarufan
|
r208 | set(generated_cpp_suffix "_${QT_VERSION_MAJOR}${QT_VERSION_MINOR}") | ||
Orochimarufan
|
r205 | |||
florianlink
|
r202 | if("${generated_cpp_suffix}" STREQUAL "_48") | ||
Orochimarufan
|
r205 | set(generated_cpp_suffix "") | ||
florianlink
|
r202 | endif() | ||
if("${generated_cpp_suffix}" STREQUAL "_46") | ||||
Orochimarufan
|
r205 | 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") | ||||
florianlink
|
r202 | endif() | ||
florianlink
|
r166 | #----------------------------------------------------------------------------- | ||
Orochimarufan
|
r205 | # Generator | ||
Orochimarufan
|
r206 | if(PythonQt_Qt5) | ||
add_subdirectory(generator_50 EXCLUDE_FROM_ALL) | ||||
add_custom_target(generator) | ||||
add_dependencies(generator pythonqt_generator) | ||||
endif() | ||||
florianlink
|
r166 | |||
Orochimarufan
|
r205 | # TODO | ||
florianlink
|
r166 | |||
#----------------------------------------------------------------------------- | ||||
Orochimarufan
|
r205 | # Build options | ||
florianlink
|
r166 | |||
Orochimarufan
|
r205 | #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() | ||||
florianlink
|
r166 | |||
Orochimarufan
|
r205 | # 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() | ||||
florianlink
|
r166 | |||
#----------------------------------------------------------------------------- | ||||
# Add extra sources | ||||
Orochimarufan
|
r205 | #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() | ||||
florianlink
|
r166 | |||
#----------------------------------------------------------------------------- | ||||
Orochimarufan
|
r205 | # Find Python | ||
option(PythonQt_Python3 "Use Python 3.x (3.3+)" OFF) | ||||
Orochimarufan
|
r207 | 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) | ||||
Orochimarufan
|
r205 | endif() | ||
florianlink
|
r166 | |||
Orochimarufan
|
r211 | if(NOT ${PYTHON_VERSION} VERSION_LESS 3) | ||
set(PythonQt_Python3 ON) | ||||
else() | ||||
set(PythonQt_Python3 OFF) | ||||
endif() | ||||
Orochimarufan
|
r205 | include_directories(${PYTHON_INCLUDE_DIRS}) | ||
add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK) | ||||
florianlink
|
r166 | |||
Orochimarufan
|
r208 | #----------------------------------------------------------------------------- | ||
# Library Name | ||||
Orochimarufan
|
r212 | # The variable PythonQt contains the PythonQt core library name | ||
Orochimarufan
|
r208 | # It incorporates library mayor versions | ||
Orochimarufan
|
r212 | set(PythonQt PythonQt) | ||
Orochimarufan
|
r208 | |||
if(PythonQt_Qt5) | ||||
Orochimarufan
|
r212 | set(PythonQt ${PythonQt}5) | ||
Orochimarufan
|
r208 | endif() | ||
Orochimarufan
|
r211 | if(PythonQt_Python3) | ||
Orochimarufan
|
r212 | set(PythonQt ${PythonQt}_3) | ||
Orochimarufan
|
r208 | endif() | ||
Orochimarufan
|
r212 | set(CMAKE_DEBUG_POSTFIX "_d") | ||
Orochimarufan
|
r208 | |||
Orochimarufan
|
r212 | message(STATUS "Building ${PythonQt} (Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} + Python ${PYTHON_VERSION} | ${CMAKE_BUILD_TYPE})") | ||
Orochimarufan
|
r208 | |||
Orochimarufan
|
r207 | #----------------------------------------------------------------------------- | ||
# Core | ||||
Orochimarufan
|
r205 | add_subdirectory(src) | ||
florianlink
|
r166 | |||
#----------------------------------------------------------------------------- | ||||
Orochimarufan
|
r205 | # 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) | ||||
florianlink
|
r166 | |||
#----------------------------------------------------------------------------- | ||||
Orochimarufan
|
r205 | # Extenseions (QtAll) | ||
Orochimarufan
|
r211 | add_subdirectory(extensions) | ||
Orochimarufan
|
r205 | # QtAll alias | ||
add_custom_target(QtAll) | ||||
Orochimarufan
|
r211 | add_dependencies(QtAll ${PythonQt_QtAll}) | ||
florianlink
|
r166 | |||
Orochimarufan
|
r205 | #----------------------------------------------------------------------------- | ||
# Examples | ||||
include_directories(src) | ||||
include_directories(extensions/PythonQt_QtAll) | ||||
add_subdirectory(examples EXCLUDE_FROM_ALL) | ||||
Orochimarufan
|
r211 | |||
#----------------------------------------------------------------------------- | ||||
# uninstall target | ||||
configure_file( | ||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" | ||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | ||||
IMMEDIATE @ONLY) | ||||
add_custom_target(uninstall | ||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) | ||||