Commit b1505255 authored by saubatn's avatar saubatn
Browse files

UPDATED Improved CMake configuration for including Qt in CamiTK libraries....

UPDATED Improved CMake configuration for including Qt in CamiTK libraries. Work done for library-qtpropertybrowser.
parent 256116e7
......@@ -22,7 +22,7 @@
#! [NEEDS_LIBXML2]
#! [NEEDS_XERCESC]
#! [NEEDS_XSD]
#! [NEEDS_QT_MODULES]
#! [NEEDS_QT]
#! [DEFINES flag1 flag2 ...]
#! [EXTERNAL_LIBRARIES lib1 lib2... ]
#! [INCLUDE_DIRECTORIES dir1 dir2...]
......@@ -45,7 +45,7 @@
#! \param NEEDS_LIBXML2 add this if the CEP library needs libxml2
#! \param NEEDS_XERCESC add this if your action / component needs XercesC library
#! \param NEEDS_XSD add this if your action needs Codesynthesis xsd cxx (xml schema compiler)
#! \param NEEDS_QT_MODULES add this if your library depends on Qt modules, such as QtCore, QtGui, QtMultimedia, QtNetwork, QtOpenGL, QtScript, QtScriptTools, QtSql, QtSvg, QtWebkit, QtXml, QtXmlPatterns, QtDeclarative
#! \param NEEDS_QT add this if your library depends on Qt 5.x
#! \param LIBNAME force the CEP library name to be different from the directory it is in
#! \param LINK_DIRECTORIES additional directories to use in link_directories(...)
#! \param DEFINES list of define flags to add at compilation time
......@@ -76,7 +76,7 @@ macro(camitk_library)
parse_arguments(${DEFAULT_LIBRARY_NAME_CMAKE}
"SOURCES;NEEDS_CEP_LIBRARIES;EXTERNAL_LIBRARIES;INCLUDE_DIRECTORIES;LIBNAME;DEFINES;LINK_DIRECTORIES;HEADERS_TO_INSTALL;CEP_NAME;DESCRIPTION;EXTRA_TRANSLATE_LANGUAGE;CXX_FLAGS" # possible lists
"SHARED;STATIC;NEEDS_ITK;NEEDS_LIBXML2;NEEDS_XERCESC;NEEDS_XSD;NEEDS_QT_MODULES;PUBLIC" # possible options
"SHARED;STATIC;NEEDS_ITK;NEEDS_LIBXML2;NEEDS_XERCESC;NEEDS_XSD;NEEDS_QT;PUBLIC" # possible options
${ARGN}
)
......@@ -160,6 +160,35 @@ macro(camitk_library)
#########################################################################
# #
# TARGET COMPILATION DEFINITION #
# #
# * Additional sources files to consider at compilation (.cpp) #
# * CMake project target definition depending on library type #
# public / private #
# #
#########################################################################
# CMAKE TARGET DEFINITION DEPENDENDING ON THE LIBRARY TYPE (SHARED or STATIC)
if (${DEFAULT_LIBRARY_NAME_CMAKE}_SHARED) # shared library
message(STATUS "Adding shared library: ${LIBRARY_TARGET_NAME}")
add_library(${LIBRARY_TARGET_NAME} SHARED ${${DEFAULT_LIBRARY_NAME_CMAKE}_SOURCES})
# prepare the library specific info (SONAME...)
set(${LIBRARY_TARGET_NAME}_LIBRARY_PROPERTIES ${${LIBRARY_TARGET_NAME}_LIBRARY_PROPERTIES}
VERSION "${CAMITK_VERSION_MAJOR}.${CAMITK_VERSION_MINOR}.${CAMITK_VERSION_PATCH}"
SOVERSION "${CAMITK_VERSION_MAJOR}"
)
#
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES ${${LIBRARY_TARGET_NAME}_LIBRARY_PROPERTIES} LINK_INTERFACE_LIBRARIES "")
elseif (${DEFAULT_LIBRARY_NAME_CMAKE}_STATIC) # static library
message(STATUS "Adding static library: ${LIBRARY_TARGET_NAME}")
add_library(${LIBRARY_TARGET_NAME} STATIC ${${DEFAULT_LIBRARY_NAME_CMAKE}_SOURCES})
else()
message(FATAL_ERROR "In adding static library ${LIBRARY_TARGET_NAME}.\n Please specify the library type: SHARED or STATIC")
endif()
#########################################################################
# #
# ADDITIONAL KNOWN LIBRARY DEPENDENCIES #
......@@ -661,21 +690,19 @@ macro(camitk_library)
endif()
endif()
# Nico : Vérifier si on peut le supprimer
# ADDITIONAL QT MODULES
# set(QT_MODULES_LIBRARIES)
# if(${DEFAULT_LIBRARY_NAME_CMAKE}_NEEDS_QT_MODULES)
# find_package(Qt4 "4.7" COMPONENTS QtCore QtGui QtXml QtXmlPatterns QtWebkit QtOpenGL QtScript QtSQL QtNetwork QtTest REQUIRED)
# if(NOT QT4_FOUND)
# message(SEND_ERROR "${DEFAULT_LIBRARY_NAME} : Failed to find Qt 4.7 or greater. This is needed by CamiTK.")
# endif()
# # CMake will add the Qt modules specific include directories
# include(${QT_USE_FILE})
# # Qt additional modules are required for linking
# set(QT_MODULES_LIBRARIES ${QT_LIBRARIES})
# endif()
# QT
if(${DEFAULT_LIBRARY_NAME_CMAKE}_NEEDS_QT)
set(QT_COMPONENTS Core Gui Xml XmlPatterns Widgets Help UiTools OpenGL OpenGLExtensions)
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED)
if (Qt5_FOUND)
message(STATUS "${LIBRARY_TARGET_NAME}: found Qt ${Qt5_VERSION}.")
set(QT_INCLUDE_DIRS ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5XmlPatterns_INCLUDE_DIRS} ${Qt5Declarative_INCLUDE_DIRS} ${Qt5Help_INCLUDE_DIRS} ${Qt5UiTools_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS} ${Qt5OpenGLExtensions_INCLUDE_DIRS})
include_directories(${QT_INCLUDE_DIRS})
qt5_use_modules(${LIBRARY_TARGET_NAME} ${QT_COMPONENTS})
else()
message(SEND_ERROR "${LIBRARY_TARGET_NAME}: Failed to find Qt 5.x. This is needed by ${LIBRARY_TARGET_NAME}.")
endif()
endif()
# EXTERNAL DEPENDENCIES
set(LINKER_EXTERNAL_LIBRARIES)
......@@ -714,35 +741,6 @@ macro(camitk_library)
#########################################################################
# #
# TARGET COMPILATION DEFINITION #
# #
# * Additional sources files to consider at compilation (.cpp) #
# * CMake project target definition depending on library type #
# public / private #
# #
#########################################################################
# CMAKE TARGET DEFINITION DEPENDENDING ON THE LIBRARY TYPE (SHARED or STATIC)
if (${DEFAULT_LIBRARY_NAME_CMAKE}_SHARED) # shared library
message(STATUS "Adding shared library: ${LIBRARY_TARGET_NAME}")
add_library(${LIBRARY_TARGET_NAME} SHARED ${${DEFAULT_LIBRARY_NAME_CMAKE}_SOURCES})
# prepare the library specific info (SONAME...)
set(${LIBRARY_TARGET_NAME}_LIBRARY_PROPERTIES ${${LIBRARY_TARGET_NAME}_LIBRARY_PROPERTIES}
VERSION "${CAMITK_VERSION_MAJOR}.${CAMITK_VERSION_MINOR}.${CAMITK_VERSION_PATCH}"
SOVERSION "${CAMITK_VERSION_MAJOR}"
)
#
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES ${${LIBRARY_TARGET_NAME}_LIBRARY_PROPERTIES} LINK_INTERFACE_LIBRARIES "")
elseif (${DEFAULT_LIBRARY_NAME_CMAKE}_STATIC) # static library
message(STATUS "Adding static library: ${LIBRARY_TARGET_NAME}")
add_library(${LIBRARY_TARGET_NAME} STATIC ${${DEFAULT_LIBRARY_NAME_CMAKE}_SOURCES})
else()
message(FATAL_ERROR "In adding static library ${LIBRARY_TARGET_NAME}.\n Please specify the library type: SHARED or STATIC")
endif()
#########################################################################
# #
# CAMITK LIBRARIES DEPENDENCIES #
......
......@@ -13,20 +13,7 @@ if (NOT CEP_NAME STREQUAL "SDK")
endif()
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC OFF)
find_package(Qt5 COMPONENTS Core Gui Xml XmlPatterns Widgets Help UiTools OpenGL OpenGLExtensions REQUIRED)
if (Qt5_FOUND)
message(STATUS "QtPropertyBrowser : found Qt ${Qt5_VERSION}.")
set(QT_INCLUDE_DIRS ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5XmlPatterns_INCLUDE_DIRS} ${Qt5Declarative_INCLUDE_DIRS} ${Qt5Help_INCLUDE_DIRS} ${Qt5UiTools_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS} ${Qt5OpenGLExtensions_INCLUDE_DIRS})
include_directories(${QT_INCLUDE_DIRS})
set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5XmlPatterns_LIBRARIES} ${Qt5Declarative_LIBRARIES} ${Qt5Help_LIBRARIES} ${Qt5UiTools_LIBRARIES} ${Qt5OpenGL_LIBRARIES} ${Qt5OpenGLExtensions_LIBRARIES} ${Qt5Widgets_LIBRARIES})
message(WARNING "QT_LIBRARIES = ${QT_LIBRARIES}")
else()
message(SEND_ERROR "Failed to find Qt 5.x. This is needed by QtPropertyBrowser.")
endif()
# include(${QT_USE_FILE})
set(CMAKE_AUTOMOC ON)
set(qtpropertyeditor_SRCS
src/qtpropertybrowser.cpp
......@@ -45,83 +32,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
${QT_INCLUDE_DIR}
)
qt5_generate_moc(
src/qtpropertybrowser.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertybrowser.cpp
)
qt5_generate_moc(
src/qtpropertymanager.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertymanager.cpp
)
qt5_generate_moc(
src/qteditorfactory.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qteditorfactory.cpp
)
qt5_generate_moc(
src/qtvariantproperty.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtvariantproperty.cpp
)
qt5_generate_moc(
src/qttreepropertybrowser.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qttreepropertybrowser.cpp
)
qt5_generate_moc(
src/qtbuttonpropertybrowser.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtbuttonpropertybrowser.cpp
)
qt5_generate_moc(
src/qtgroupboxpropertybrowser.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtgroupboxpropertybrowser.cpp
)
qt5_generate_moc(
src/qtpropertymanager.cpp
${CMAKE_CURRENT_BINARY_DIR}/qtpropertymanager.moc
)
qt5_generate_moc(
src/qteditorfactory.cpp
${CMAKE_CURRENT_BINARY_DIR}/qteditorfactory.moc
)
qt5_generate_moc(
src/qttreepropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/qttreepropertybrowser.moc
)
set(
qtpropertyeditor_HEADERS_ONLY_MOC
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertymanager.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qteditorfactory.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qtvariantproperty.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qttreepropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qtbuttonpropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qtgroupboxpropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/qtpropertymanager.moc
${CMAKE_CURRENT_BINARY_DIR}/qteditorfactory.moc
${CMAKE_CURRENT_BINARY_DIR}/qttreepropertybrowser.moc
)
set_source_files_properties(
${qtpropertyeditor_HEADERS_ONLY_MOC}
PROPERTIES
HEADER_FILE_ONLY true
)
qt5_generate_moc(
src/qtpropertybrowserutils_p.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertybrowserutils_p.cpp
)
set(
qtpropertyeditor_HEADERS_MOC
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertybrowserutils_p.cpp
)
set(
qtpropertyeditor_MOC
${qtpropertyeditor_HEADERS_MOC}
${qtpropertyeditor_HEADERS_ONLY_MOC}
)
qt5_add_resources(
qtpropertyeditor_RESOURCES
src/qtpropertybrowser.qrc
......@@ -129,7 +39,7 @@ qt5_add_resources(
qt5_add_resources(RESOURCE_SRCS src/qtpropertybrowser.qrc)
set(SRCS ${extension_MOC}
set(SRCS ${extension_MOC}
${qtpropertyeditor_MOC}
${qtpropertyeditor_SRCS}
${qtpropertyeditor_RESOURCES}
......@@ -143,18 +53,13 @@ file(GLOB HEADERS_UPPERCASE "src/Qt*")
camitk_library(SHARED
SOURCES ${SRCS}
NEEDS_QT_MODULES
NEEDS_QT
PUBLIC #install directly in lib (or bin for Windows).
HEADERS_TO_INSTALL ${HEADERS_H} ${HEADERS_UPPERCASE}
CEP_NAME SDK
DESCRIPTION "Allows displaying and editing Qt Meta Object properties. Used to display component properties. This library is required."
)
qt5_use_modules(${LIBRARY_TARGET_NAME} Core Gui Xml XmlPatterns Widgets Help UiTools OpenGL OpenGLExtensions)
# Add Qt5 link libraries at link stage
#target_link_libraries(${LIB_NAME} ${QT_LIBRARIES})
# Recursively update the shiboken path variable containing the CamiTK SDK tree structure
set(SHIBOKEN_CAMITK_SDK_PATH ${SHIBOKEN_CAMITK_SDK_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
set(SHIBOKEN_CAMITK_SDK_PATH ${SHIBOKEN_CAMITK_SDK_PATH}:${CMAKE_CURRENT_SOURCE_DIR}/src CACHE INTERNAL "")
\ No newline at end of file
Supports Markdown
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