From 92db556a3ecd619804f18afe8e51e5cd9eb437f2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 15 Dec 2016 13:33:33 +0100 Subject: [PATCH] do not use Qt4 macros for Qt5 version of fc_wrap_cpp --- CMakeLists.txt | 75 +++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f37551af..90c2f634d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,9 +70,6 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION) OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION) ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION) -# Switch to build FreeCAD with Qt5 -OPTION(BUILD_QT5 "Build with Qt5." OFF) - # Enabled C++11 for Freecad 0.17 and later IF(FREECAD_VERSION VERSION_GREATER 0.16) OPTION(BUILD_ENABLE_CXX11 "Enable C++11 support." ON) @@ -154,6 +151,8 @@ endif(MSVC) # ============================================================================== # == All the options for the build process ============ +# Switch to build FreeCAD with Qt5 +OPTION(BUILD_QT5 "Build with Qt5." OFF) OPTION(BUILD_GUI "Build FreeCAD Gui. Otherwise you have only the command line and the Python import module." ON) OPTION(FREECAD_MAINTAINERS_BUILD "Build FreeCAD for Maintainers, with Docu and 3rd party libs. On Windows the Installer is build." OFF) OPTION(FREECAD_USE_EXTERNAL_ZIPIOS "Use system installed zipios++ instead of the bundled." OFF) @@ -711,6 +710,31 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") "========================================================\n") ENDIF(NOT QT_QTWEBKIT_FOUND) + # This is a special version of the built in macro qt4_wrap_cpp + # It is required since moc'ed files are now included instead of being added to projects directly + # It adds a reverse dependency to solve this + # This has the unfortunate side effect that some files are always rebuilt + # There is probably a cleaner solution than this + macro(fc_wrap_cpp outfiles) + # get include dirs + QT4_GET_MOC_FLAGS(moc_flags) + QT4_EXTRACT_OPTIONS(moc_files moc_options moc_target ${ARGN}) + # fixes bug 0000585: bug with boost 1.48 + SET(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) + + foreach(it ${moc_files}) + get_filename_component(it ${it} ABSOLUTE) + QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${moc_options} ${it} -o ${outfile} + MAIN_DEPENDENCY ${it} + ) + set(${outfiles} ${${outfiles}} ${outfile}) + add_file_dependencies(${it} ${outfile}) + endforeach(it) + endmacro(fc_wrap_cpp) + elseif (BUILD_QT5) find_package(Qt5Network) find_package(Qt5Xml) @@ -734,33 +758,28 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") "========================\n") ENDIF(NOT Qt5Core_FOUND) - include(Qt4Macros) + # This is a special version of the built in macro qt5_wrap_cpp + # It is required since moc'ed files are now included instead of being added to projects directly + # It adds a reverse dependency to solve this + # This has the unfortunate side effect that some files are always rebuilt + # There is probably a cleaner solution than this + macro(fc_wrap_cpp outfiles ) + # get include dirs + qt5_get_moc_flags(moc_flags) + set(moc_files ${ARGN}) + # fixes bug 0000585: bug with boost 1.48 + set(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) + + foreach(it ${moc_files}) + get_filename_component(it ${it} ABSOLUTE) + qt5_make_output_file(${it} moc_ cpp outfile) + qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}") + set(${outfiles} ${${outfiles}} ${outfile}) + add_file_dependencies(${it} ${outfile}) + endforeach(it) + endmacro(fc_wrap_cpp) endif (NOT BUILD_QT5) - # This is a special version of the built in macro qt4_wrap_cpp - # It is required since moc'ed files are now included instead of being added to projects directly - # It adds a reverse dependency to solve this - # This has the unfortunate side effect that some files are always rebuilt - # There is probably a cleaner solution than this - macro(fc_wrap_cpp outfiles) - # get include dirs - QT4_GET_MOC_FLAGS(moc_flags) - QT4_EXTRACT_OPTIONS(moc_files moc_options moc_target ${ARGN}) - # fixes bug 0000585: bug with boost 1.48 - SET(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) - - foreach(it ${moc_files}) - get_filename_component(it ${it} ABSOLUTE) - QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${moc_options} ${it} -o ${outfile} - MAIN_DEPENDENCY ${it} - ) - set(${outfiles} ${${outfiles}} ${outfile}) - add_file_dependencies(${it} ${outfile}) - endforeach(it) - endmacro(fc_wrap_cpp) #--------------------FreeType-----------------------