Commit 1fea1fd1 authored by Jan Möbius's avatar Jan Möbius
Browse files

Added the qt5 stuff to Comiso ACGCommon

git-svn-id: http://www.openflipper.org/svnrepo/CoMISo/trunk@253 1355f012-dd97-4b2f-ae87-10fa9f823a57
parent b43f521c
......@@ -184,6 +184,11 @@ macro (acg_qt4)
set (QT_MIN_VERSION ${ARGN})
if(POLICY CMP0020)
# Automatically link Qt executables to qtmain target on Windows
cmake_policy(SET CMP0020 NEW)
endif(POLICY CMP0020)
find_package (Qt4 COMPONENTS QtCore QtGui )
set (QT_USE_QTOPENGL 1)
......@@ -204,6 +209,146 @@ macro (acg_qt4)
endif ()
endmacro ()
macro (acg_qt5)
if(POLICY CMP0020)
# Automatically link Qt executables to qtmain target on Windows
cmake_policy(SET CMP0020 NEW)
endif(POLICY CMP0020)
#if (NOT QT5_FOUND)
#set (QT_MIN_VERSION ${ARGN})
#for custom installation of qt5, dont use any of these variables
set (QT5_INSTALL_PATH "" CACHE PATH "Path to Qt5 directory which contains lib and include folder")
if (EXISTS ${QT5_INSTALL_PATH})
if (NOT EXISTS "${QT5_INSTALL_PATH}/include")
message( FATAL_ERROR "Could not find Qt5 include directory. Please set QT5_INSTALL_PATH to the directory which contains Qt5 lib and include folder.")
endif()
if (NOT EXISTS "${QT5_INSTALL_PATH}/lib")
message( FATAL_ERROR "Could not find Qt5 lib directory. Please set QT5_INSTALL_PATH to the directory which contains Qt5 lib and include folder.")
endif()
else()
message( FATAL_ERROR "The Given QT5_INSTALL_PATH does not exists")
endif()
set (CMAKE_PREFIX_PATH ${QT5_INSTALL_PATH})
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set (QT_PLUGINS_DIR "${QT5_INSTALL_PATH}/plugins" CACHE PATH "")
set (QT_BINARY_DIR "${QT5_INSTALL_PATH}/bin" CACHE PATH "Qt5 binary Directory")
set (QT_RCC_EXECUTABLE "${QT5_INSTALL_PATH}/bin/rcc" CACHE PATH "Path to the rcc executable")
#glu32.lib is needed by qt5 opengl version. it cannot find it by itself so we help qt
if ( WIN32 )
set(WINDOWS_SDK_LIBS "COULD_NOT_FOUND" CACHE PATH "Path to the latest windows sdk libs which includes glu32.lib")
if (EXISTS "${WINDOWS_SDK_LIBS}\\glu32.lib")
set (WINDOWS_SDK_LIBS ${WINDOWS_SDK_LIBS})
set (CMAKE_PREFIX_PATH "${QT5_INSTALL_PATH};${WINDOWS_SDK_LIBS}")
else()
message( FATAL_ERROR "Could not find glu32.lib in your Windows sdk libs.")
endif()
endif()#WIN32
find_package (Qt5Core REQUIRED)
find_package (Qt5Declarative REQUIRED)
find_package (Qt5Widgets REQUIRED)
find_package (Qt5Gui REQUIRED)
find_package (Qt5OpenGL REQUIRED)
find_package (Qt5Network REQUIRED)
find_package (Qt5Script REQUIRED)
find_package (Qt5ScriptTools REQUIRED)
find_package (Qt5Sql REQUIRED)
find_package (Qt5Xml REQUIRED)
find_package (Qt5XmlPatterns REQUIRED)
find_package (Qt5Help REQUIRED)
find_package (Qt5WebKit REQUIRED)
find_package (Qt5UiTools REQUIRED)
find_package (Qt5Concurrent REQUIRED)
find_package (Qt5PrintSupport REQUIRED)
set (QT5_FOUND ${Qt5Core_FOUND} AND ${Qt5Declarative} AND ${Qt5Widgets_FOUND}
AND ${Qt5Gui_FOUND} AND ${Qt5OpenGL_FOUND} AND ${Qt5Network_FOUND}
AND ${Qt5Script_FOUND} AND ${Qt5ScriptTools_FOUND} AND ${Qt5Sql_FOUND}
AND ${Qt5Xml_FOUND} AND ${Qt5XmlPatterns_FOUND} AND ${Qt5Help_FOUND}
AND ${Qt5WebKit_FOUND} AND ${Qt5UiTools_FOUND} AND ${Qt5Concurrent_FOUND}
AND ${Qt5PrintSupport_FOUND})
if (QT5_FOUND)
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Declarative_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
include_directories(${Qt5OpenGL_INCLUDE_DIRS})
include_directories(${Qt5Network_INCLUDE_DIRS})
include_directories(${Qt5Script_INCLUDE_DIRS})
include_directories(${Qt5ScriptTools_INCLUDE_DIRS})
include_directories(${Qt5Sql_INCLUDE_DIRS})
include_directories(${Qt5Xml_INCLUDE_DIRS})
include_directories(${Qt5XmlPatterns_INCLUDE_DIRS})
include_directories(${Qt5Help_INCLUDE_DIRS})
include_directories(${Qt5WebKit_INCLUDE_DIRS})
include_directories(${Qt5UiTools_INCLUDE_DIRS})
include_directories(${Qt5Concurrent_INCLUDE_DIRS})
include_directories(${Qt5PrintSupport_INCLUDE_DIRS})
add_definitions(${Qt5Core_DEFINITIONS})
add_definitions(${Qt5Widgets_DEFINITIONS})
add_definitions(${Qt5Gui_DEFINITIONS})
add_definitions(${Qt5OpenGL_DEFINITIONS})
add_definitions(${Qt5Network_DEFINITIONS})
add_definitions(${Qt5Script_DEFINITIONS})
add_definitions(${Qt5ScriptTools_DEFINITIONS})
add_definitions(${Qt5Sql_DEFINITIONS})
add_definitions(${Qt5Xml_DEFINITIONS})
add_definitions(${Qt5XmlPatterns_DEFINITIONS})
add_definitions(${Qt5Help_DEFINITIONS})
add_definitions(${Qt5WebKit_DEFINITIONS})
add_definitions(${Qt5UiTools_DEFINITIONS})
add_definitions(${Qt5Concurrent_DEFINITIONS})
add_definitions(${Qt5PrintSupport_DEFINITIONS})
if ( NOT MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
set (QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Declarative_LIBRARIES} ${Qt5Widgets_LIBRARIES}
${Qt5Gui_LIBRARIES} ${Qt5OpenGL_LIBRARIES} ${Qt5Network_LIBRARIES}
${Qt5Script_LIBRARIES} ${Qt5ScriptTools_LIBRARIES} ${Qt5Sql_LIBRARIES}
${Qt5Xml_LIBRARIES} ${Qt5XmlPatterns_LIBRARIES} ${Qt5Help_LIBRARIES}
${Qt5WebKit_LIBRARIES} ${Qt5UiTools_LIBRARIES} ${Qt5Concurrent_LIBARIES} ${Qt5PrintSupport_LIBRARIES})
if (MSVC)
set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5Core_QTMAIN_LIBRARIES})
endif()
add_definitions(-DQT_NO_OPENGL)
#adding QT_NO_DEBUG to all release modes.
# Note: for multi generators like msvc you cannot set this definition depending of
# the current build type, because it may change in the future inside the ide and not via cmake
if (MSVC_IDE)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /DQT_NO_DEBUG")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE} /DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_MINSITEREL "${CMAKE_C_FLAGS_RELEASE} /DQT_NO_DEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /DQT_NO_DEBUG")
else(MSVC_IDE)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DQT_NO_DEBUG)
endif()
endif(MSVC_IDE)
endif ()
endmacro ()
# unsets the given variable
macro (acg_unset var)
set (${var} "" CACHE INTERNAL "")
......@@ -290,6 +435,8 @@ endmacro ()
# generate moc targets for sources in list
macro (acg_qt4_automoc moc_SRCS)
qt4_get_moc_flags (_moc_INCS)
list(REMOVE_DUPLICATES _moc_INCS)
set (_matching_FILES )
foreach (_current_FILE ${ARGN})
......@@ -330,6 +477,51 @@ macro (acg_qt4_automoc moc_SRCS)
endforeach ()
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_qt4_autouic uic_SRCS)
......@@ -362,6 +554,37 @@ macro (acg_qt4_autouic uic_SRCS)
endforeach ()
endmacro ()
# generate uic targets for sources in list
macro (acg_qt5_autouic uic_SRCS)
set (_matching_FILES )
foreach (_current_FILE ${ARGN})
get_filename_component (_abs_FILE ${_current_FILE} ABSOLUTE)
if ( EXISTS ${_abs_FILE} )
file (READ ${_abs_FILE} _contents)
get_filename_component (_abs_PATH ${_abs_FILE} PATH)
get_filename_component (_basename ${_current_FILE} NAME_WE)
string (REGEX REPLACE "Ui$" "" _cbasename ${_basename})
set (_outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${_basename}.hh)
set (_header ${_basename}.hh)
set (_source ${_abs_PATH}/${_cbasename}.cc)
add_custom_command (OUTPUT ${_outfile}
COMMAND ${Qt5Widgets_UIC_EXECUTABLE}
ARGS -o ${_outfile} ${_abs_FILE}
DEPENDS ${_abs_FILE})
add_file_dependencies (${_source} ${_outfile})
set (${uic_SRCS} ${${uic_SRCS}} ${_outfile})
endif ()
endforeach ()
endmacro ()
# generate qrc targets for sources in list
macro (acg_qt4_autoqrc qrc_SRCS)
......@@ -392,6 +615,35 @@ macro (acg_qt4_autoqrc qrc_SRCS)
endforeach ()
endmacro ()
# generate qrc targets for sources in list
macro (acg_qt5_autoqrc qrc_SRCS)
set (_matching_FILES )
foreach (_current_FILE ${ARGN})
get_filename_component (_abs_FILE ${_current_FILE} ABSOLUTE)
if ( EXISTS ${_abs_FILE} )
file (READ ${_abs_FILE} _contents)
get_filename_component (_abs_PATH ${_abs_FILE} PATH)
get_filename_component (_basename ${_current_FILE} NAME_WE)
set (_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${_basename}.cpp)
add_custom_command (OUTPUT ${_outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS -o ${_outfile} ${_abs_FILE}
DEPENDS ${_abs_FILE})
add_file_dependencies (${_source} ${_outfile})
set (${qrc_SRCS} ${${qrc_SRCS}} ${_outfile})
endif ()
endforeach ()
endmacro ()
# get all files in directory, but ignore svn
macro (acg_get_files_in_dir ret dir)
file (GLOB_RECURSE __files RELATIVE "${dir}" "${dir}/*")
......@@ -509,7 +761,7 @@ function (acg_add_library _target _libtype)
if (NOT EXISTS ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_PLUGINDIR})
file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_PLUGINDIR})
endif ()
add_custom_command (TARGET ${_target} POST_BUILD
add_custom_command (TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${fullname}.dll
......@@ -544,26 +796,26 @@ function (acg_add_library _target _libtype)
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${fullname}.so
${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_PLUGINDIR}/lib${fullname}.so)
elseif (${_type} STREQUAL STATIC)
add_custom_command (TARGET ${_target} POST_BUILD
add_custom_command (TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${fullname}.a
${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_LIBDIR}/lib${fullname}.a)
endif ()
endif()
if (_and_static)
add_custom_command (TARGET ${_target}Static POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy_if_different
copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${_target}Static${postfix}.a
${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_LIBDIR}/lib${fullname}.a)
endif ()
elseif (NOT APPLE AND _and_static)
add_custom_command (TARGET ${_target}Static POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy_if_different
add_custom_command (TARGET ${_target}Static POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${_target}Static${postfix}.a
${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_LIBDIR}/lib${fullname}.a)
${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_LIBDIR}/lib${fullname}.a)
endif ()
......@@ -612,11 +864,19 @@ function (acg_add_translations _target _languages _sources)
set (_qm_files)
if ( _new_ts_files )
if (QT5_FOUND)
#qt5_create_translation(_qm_files ${_sources} ${_new_ts_files})
elseif (QT4_FOUND)
qt4_create_translation(_qm_files ${_sources} ${_new_ts_files})
endif ()
endif ()
if ( _ts_files )
if (QT5_FOUND)
#qt5_add_translation(_qm_files2 ${_ts_files})
elseif (QT4_FOUND)
qt4_add_translation(_qm_files2 ${_ts_files})
endif()
list (APPEND _qm_files ${_qm_files2})
endif ()
......
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