Skip to content

Commit

Permalink
do not use Qt4 macros for Qt5 version of fc_wrap_cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 15, 2016
1 parent 6d1eddc commit 92db556
Showing 1 changed file with 47 additions and 28 deletions.
75 changes: 47 additions & 28 deletions CMakeLists.txt
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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-----------------------

Expand Down

0 comments on commit 92db556

Please sign in to comment.