From ca58bd51b222d3c3e9dea8657f6c969580602720 2013-01-29 14:20:21 From: florianlink Date: 2013-01-29 14:20:21 Subject: [PATCH] integrated changes from https://github.com/commontk/PythonQt#patched-2 updated main CMakeLists.txt added generator/CMakeLists.txt git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@243 ea8d5007-eb21-0410-b261-ccb3ea6e24a9 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 83f4eee..4976d40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,35 +1,11 @@ cmake_minimum_required(VERSION 2.8) #----------------------------------------------------------------------------- -# See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details -# - -SET(project_policies - CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used. - CMP0002 # NEW: Logical target names must be globally unique. - CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths. - CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace. - CMP0005 # NEW: Preprocessor definition values are now escaped automatically. - CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION. - CMP0007 # NEW: List command no longer ignores empty elements. - CMP0008 # NEW: Libraries linked by full-path must have a valid library file name. - CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default. - CMP0010 # NEW: Bad variable reference syntax is an error. - CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP. - CMP0012 # NEW: if() recognizes numbers and boolean constants. - CMP0013 # NEW: Duplicate binary directories are not allowed. - CMP0014 # NEW: Input directories must have CMakeLists.txt - ) -FOREACH(policy ${project_policies}) - IF(POLICY ${policy}) - CMAKE_POLICY(SET ${policy} NEW) - ENDIF() -ENDFOREACH() - -#----------------------------------------------------------------------------- project(PythonQt) #----------------------------------------------------------------------------- +include(CTestUseLaunchers OPTIONAL) + #----------------------------------------------------------------------------- # Python libraries @@ -40,10 +16,24 @@ add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK) #----------------------------------------------------------------------------- # Build options -foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns) +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() + option(PythonQt_DEBUG "Enable/Disable PythonQt debug output" OFF) if(PythonQt_DEBUG) add_definitions(-DPYTHONQT_DEBUG) @@ -81,6 +71,17 @@ else() endif() #----------------------------------------------------------------------------- +# 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() + +#----------------------------------------------------------------------------- # Sources set(sources @@ -102,12 +103,12 @@ set(sources src/PythonQtStdOut.cpp src/gui/PythonQtScriptingConsole.cpp - generated_cpp/PythonQt_QtBindings.cpp + generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.cpp - generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp - generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin_init.cpp - generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp - generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin_init.cpp + generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp + generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin_init.cpp + generated_cpp${generated_cpp_suffix}/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp + generated_cpp${generated_cpp_suffix}/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin_init.cpp ) #----------------------------------------------------------------------------- @@ -136,7 +137,7 @@ set(headers src/PythonQtSystem.h src/PythonQtVariants.h src/PythonQtPythonInclude.h - generated_cpp/PythonQt_QtBindings.h + generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.h ) #----------------------------------------------------------------------------- @@ -148,8 +149,8 @@ set(moc_sources src/PythonQtStdDecorators.h src/gui/PythonQtScriptingConsole.h - generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h - generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.h + generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h + generated_cpp${generated_cpp_suffix}/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.h ) #----------------------------------------------------------------------------- @@ -160,9 +161,9 @@ foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns) ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib}) - set(file_prefix generated_cpp/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib}) + set(file_prefix generated_cpp${generated_cpp_suffix}/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib}) - foreach(index RANGE 0 10) + foreach(index RANGE 0 11) # Source files if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.cpp) diff --git a/generator/CMakeLists.txt b/generator/CMakeLists.txt new file mode 100644 index 0000000..1d659dd --- /dev/null +++ b/generator/CMakeLists.txt @@ -0,0 +1,162 @@ +cmake_minimum_required(VERSION 2.8) + +#----------------------------------------------------------------------------- +project(PythonQtGenerator) +#----------------------------------------------------------------------------- + +include(CTestUseLaunchers OPTIONAL) + +#----------------------------------------------------------------------------- +# Setup Qt + +set(minimum_required_qt_version "4.6.2") + +find_package(Qt4) + +if(QT4_FOUND) + + set(found_qt_version ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}) + + if(${found_qt_version} VERSION_LESS ${minimum_required_qt_version}) + message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version}.") + endif() + + set(QT_USE_QTXML ON) + + include(${QT_USE_FILE}) +else() + message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable") +endif() + +#----------------------------------------------------------------------------- +# Sources + +set(sources + parser/ast.cpp + parser/binder.cpp + parser/class_compiler.cpp + parser/codemodel.cpp + parser/codemodel_finder.cpp + parser/compiler_utils.cpp + parser/control.cpp + parser/declarator_compiler.cpp + parser/default_visitor.cpp + parser/dumptree.cpp + parser/lexer.cpp + parser/list.cpp + parser/name_compiler.cpp + parser/parser.cpp + parser/smallobject.cpp + parser/tokens.cpp + parser/type_compiler.cpp + parser/visitor.cpp + + abstractmetabuilder.cpp + abstractmetalang.cpp + asttoxml.cpp + customtypes.cpp + fileout.cpp + generator.cpp + generatorset.cpp + generatorsetqtscript.cpp + main.cpp + metajava.cpp + metaqtscriptbuilder.cpp + metaqtscript.cpp + prigenerator.cpp + reporthandler.cpp + setupgenerator.cpp + shellgenerator.cpp + shellheadergenerator.cpp + shellimplgenerator.cpp + typeparser.cpp + typesystem.cpp + ) + +#----------------------------------------------------------------------------- +# List headers. This list is used for the install command. + +set(headers + ) + +#----------------------------------------------------------------------------- +# Headers that should run through moc + +set(moc_sources + fileout.h + generator.h + generatorset.h + generatorsetqtscript.h + prigenerator.h + setupgenerator.h + shellgenerator.h + shellheadergenerator.h + shellimplgenerator.h + ) + +#----------------------------------------------------------------------------- +# UI files + +set(ui_sources ) + +#----------------------------------------------------------------------------- +# Resources + +set(qrc_sources + generator.qrc + ) + +#----------------------------------------------------------------------------- +# Do wrapping +qt4_wrap_cpp(gen_moc_sources ${moc_sources}) +qt4_wrap_ui(gen_ui_sources ${ui_sources}) +qt4_add_resources(gen_qrc_sources ${qrc_sources}) + +#----------------------------------------------------------------------------- +# Copy file expected by the generator and specify install rules + +file(GLOB files_to_copy RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "build_*.txt" "typesystem_*.xml") +list(APPEND files_to_copy qtscript_masterinclude.h parser/rpp/pp-qt-configuration) +foreach(file ${files_to_copy}) + configure_file( + ${file} + ${CMAKE_CURRENT_BINARY_DIR}/${file} + COPYONLY + ) + get_filename_component(destination_dir ${file} PATH) + install(FILES ${file} DESTINATION bin/${destination_dir}) +endforeach() + +#----------------------------------------------------------------------------- +# Build the library + +SOURCE_GROUP("Resources" FILES + ${qrc_sources} + ${ui_sources} + ${files_to_copy} + ) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/parser + ${CMAKE_CURRENT_SOURCE_DIR}/parser/rpp + ) + +add_definitions(-DRXX_ALLOCATOR_INIT_0) + +add_executable(${PROJECT_NAME} + ${sources} + ${gen_moc_sources} + ${gen_ui_sources} + ${gen_qrc_sources} +) + +target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES}) + +#----------------------------------------------------------------------------- +# Install library (on windows, put the dll in 'bin' and the archive in 'lib') + +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib)