Commit 74bbcae6 authored by Jan Möbius's avatar Jan Möbius

Enable Automoc in OpenFlipper

parent a5966892
......@@ -80,14 +80,8 @@ acg_append_files (ui "*.ui" ${directories})
# remove template cc files from source file list
acg_drop_templates (sources)
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers})
else ()
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
endif()
# genereate uic targets
acg_qt5_autouic (uic_targets ${ui})
set(RC_SRC "")
......@@ -120,14 +114,14 @@ RECURSE_GROUPS( ${CMAKE_CURRENT_SOURCE_DIR}/../../ )
if (WIN32)
# add app icon rc file to windows build
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${uic_targets} ${sources} ${headers} ${RC_SRC})
# link to qtmain library to get WinMain function for a non terminal app
target_link_libraries (${OPENFLIPPER_PRODUCT_STRING} ${QT_QTMAIN_LIBRARY})
elseif (APPLE)
# generate bundle on mac
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} MACOSX_BUNDLE ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} MACOSX_BUNDLE ${uic_targets} ${sources} ${headers} ${RC_SRC})
else ()
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} ${uic_targets} ${sources} ${headers} ${RC_SRC})
endif ()
# Mark this build part as building OpenFlippers Core
......
......@@ -4,6 +4,7 @@
- <b>OpenFlipper 4.0 ( ?/?/? )</b>
- <b>Breaking changes</b>
- Picking functions use size_t instead of unsigned int now (Required to get rid of a lot of warnings during compilation)
- Enabled AUTOMOC in cmake for QT ( If you get redefinition errors, guard the corresponding headers with a #pragma once )
- <b>Core</b>
- Use QOpenGLDebuglogger
- Queued cross plugin interconnection feature
......
......@@ -149,7 +149,6 @@ acg_drop_templates (sources)
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers})
endif ()
#=======================================================
......@@ -158,7 +157,7 @@ endif ()
RECURSE_GROUPS( ${CMAKE_CURRENT_SOURCE_DIR}/../../ )
if (QT5_FOUND)
acg_add_library (OpenFlipperPluginLib SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})
acg_add_library (OpenFlipperPluginLib SHARED ${uic_targets} ${sources} ${headers} )
endif ()
......
......@@ -153,51 +153,6 @@ macro (acg_qt5)
endif ()
endmacro ()
# generate moc targets for sources in list
macro (acg_qt5_automoc moc_SRCS)
qt5_get_moc_flags (_moc_INCS)
list(REMOVE_DUPLICATES _moc_INCS)
set (_matching_FILES )
foreach (_current_FILE ${ARGN})
get_filename_component (_abs_FILE ${_current_FILE} ABSOLUTE)
# if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
# here. this is required to make bouic work correctly:
# we need to add generated .cpp files to the sources (to compile them),
# but we cannot let automoc handle them, as the .cpp files don't exist yet when
# cmake is run for the very first time on them -> however the .cpp files might
# exist at a later run. at that time we need to skip them, so that we don't add two
# different rules for the same moc file
get_source_file_property (_skip ${_abs_FILE} SKIP_AUTOMOC)
if ( NOT _skip AND EXISTS ${_abs_FILE} )
file (READ ${_abs_FILE} _contents)
get_filename_component (_abs_PATH ${_abs_FILE} PATH)
string (REGEX MATCHALL "Q_OBJECT" _match "${_contents}")
if (_match)
get_filename_component (_basename ${_current_FILE} NAME_WE)
set (_header ${_abs_FILE})
set (_moc ${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp)
add_custom_command (OUTPUT ${_moc}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${_moc_INCS} ${_header} -o ${_moc}
DEPENDS ${_header}
)
add_file_dependencies (${_abs_FILE} ${_moc})
set (${moc_SRCS} ${${moc_SRCS}} ${_moc})
endif ()
endif ()
endforeach ()
endmacro ()
# generate uic targets for sources in list
macro (acg_qt5_autouic uic_SRCS)
......
......@@ -58,6 +58,11 @@ endif()
# add our macro directory to cmake search path
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/OpenFlipper/cmake)
# Enable automoc
set(CMAKE_AUTOMOC ON)
# Include some of our OpenFlipper cmake macros
include(OpenFlipper_common)
......
......@@ -373,16 +373,10 @@ macro (_plugin_licensemanagement)
acg_append_files (keygen_src "*.cc" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen")
acg_append_files (keygen_ui "*.ui" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen")
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (keygen_uic ${keygen_ui})
acg_qt5_automoc (keygen_moc ${keygen_hdr})
else ()
acg_qt4_autouic (keygen_uic ${keygen_ui})
acg_qt4_automoc (keygen_moc ${keygen_hdr})
endif()
# genereate uic targets
acg_qt5_autouic (keygen_uic ${keygen_ui})
add_executable (Plugin-${plugin}-keygen ${keygen_uic} ${keygen_moc} ${keygen_hdr} ${keygen_src})
add_executable (Plugin-${plugin}-keygen ${keygen_uic} ${keygen_hdr} ${keygen_src})
target_link_libraries (
Plugin-${plugin}-keygen
......@@ -647,19 +641,12 @@ function (_build_openflipper_plugin plugin)
add_definitions(${${_PLUGIN}_TYPE_DEFINITIONS})
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers})
acg_qt5_autoqrc (qrc_targets ${qrc})
else ()
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
acg_qt4_autoqrc (qrc_targets ${qrc})
endif ()
# genereate uic targets
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_autoqrc (qrc_targets ${qrc})
add_library (Plugin-${plugin} MODULE ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets} ${${_PLUGIN}_ADDSRC})
add_library (Plugin-${plugin} MODULE ${uic_targets} ${sources} ${headers} ${qrc_targets} ${${_PLUGIN}_ADDSRC})
#group projects by parent folder name on MSVC (used for e.g. plugincollection)
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
get_filename_component(PARENT_DIR_NAME "${PARENT_DIR}" NAME)
......@@ -669,7 +656,7 @@ function (_build_openflipper_plugin plugin)
acg_set (OPENFLIPPER_${_PLUGIN}_BUILD "1")
if (STATIC_PLUGIN_${_PLUGIN})
add_library (Plugin-Static-${plugin} STATIC ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets} ${${_PLUGIN}_ADDSRC})
add_library (Plugin-Static-${plugin} STATIC ${uic_targets} ${sources} ${headers} ${qrc_targets} ${${_PLUGIN}_ADDSRC})
set_target_properties(Plugin-Static-${plugin} PROPERTIES COMPILE_DEFINITIONS "QT_STATICPLUGIN")
get_target_property(PLUGIN_OUTPUT_FILENAME Plugin-${plugin} LOCATION)
get_filename_component(PLUGIN_OUTPUT_FILENAME "${PLUGIN_OUTPUT_FILENAME}" NAME)
......
......@@ -41,7 +41,6 @@ endif ()
acg_append_files_recursive (headers "*.hh" . )
acg_append_files_recursive (sources "*.cc" . )
acg_append_files_recursive (ui "*.ui" . )
acg_qt5_automoc (moc_targets ${headers})
acg_qt5_autouic (uic_targets ${ui})
......@@ -63,7 +62,7 @@ include_directories (
# remove template cc files from source file list
acg_drop_templates (sources)
acg_add_library ( ${TYPENAME} SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})
acg_add_library ( ${TYPENAME} SHARED ${uic_targets} ${sources} ${headers})
set_target_properties ( ${TYPENAME} PROPERTIES MACOSX_RPATH 0 )
add_dependencies( ${TYPENAME} OpenMeshCore OpenMeshTools ACG OpenFlipperPluginLib)
......
......@@ -116,13 +116,12 @@ acg_drop_templates (sources)
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers})
acg_qt5_autoqrc (qrc_targets ${qrc})
endif()
if (QT5_FOUND)
acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets})
acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${qrc_targets})
endif()
if ( NOT WIN32 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment