Pārlūkot izejas kodu

Merge branch 'master' of git://github.com/pieper/CTK

Luis Ibanez 15 gadi atpakaļ
vecāks
revīzija
2739e83283

+ 1 - 1
CMake/ctkMacroGenerateDGraphInput.cmake

@@ -15,7 +15,7 @@ MACRO(ctkMacroGenerateDGraphInput dir name target_directories)
   FOREACH(target_info ${target_directories})
 
     # extract target_dir and option_name
-    STRING(REPLACE ":" "\\;" target_info ${target_info})
+    STRING(REPLACE "^^" "\\;" target_info ${target_info})
     SET(target_info_list ${target_info})
     LIST(GET target_info_list 0 target_dir)
     LIST(GET target_info_list 1 option_name)

+ 1 - 1
CMake/ctkMacroGenerateProjectXml.cmake

@@ -17,7 +17,7 @@ MACRO(ctkMacroGenerateProjectXml dir name target_directories is_superbuild)
   FOREACH(target_info ${target_directories})
 
     # extract target_dir and option_name
-    STRING(REPLACE ":" "\\;" target_info ${target_info})
+    STRING(REPLACE "^^" "\\;" target_info ${target_info})
     SET(target_info_list ${target_info})
     LIST(GET target_info_list 0 target_dir)
     LIST(GET target_info_list 1 option_name)

+ 16 - 5
CMakeLists.txt

@@ -12,6 +12,13 @@ PROJECT(CTK)
 SET(CTK_LIBRARY_MODE "SHARED")
 SET(CTK_BUILD_SHARED_LIBS TRUE)
 
+IF(CMAKE_CXX_COMPILER_ID)
+  # Set the default symbol visibility to hidden for gcc
+  IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+    SET(CTK_CXX_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
+  ENDIF()
+ENDIF()
+
 #-----------------------------------------------------------------------------
 # Output directories.
 #
@@ -200,21 +207,21 @@ SET(target_directories)
 FOREACH(lib ${CTK_LIBS})
   SET(option_name CTK_LIB_${lib})
   IF(${${option_name}})
-    LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}:${option_name}")
+    LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}^^${option_name}")
   ENDIF()
 ENDFOREACH()
 
 FOREACH(plugin ${CTK_PLUGINS})
   SET(option_name CTK_PLUGIN_${plugin})
   IF(${${option_name}})
-    LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}:${option_name}")
+    LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}^^${option_name}")
   ENDIF()
 ENDFOREACH()
 
 FOREACH(app ${CTK_APPLICATIONS})
   SET(option_name CTK_APP_${app})
   IF(${${option_name}})
-    LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}:${option_name}")
+    LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}^^${option_name}")
   ENDIF()
 ENDFOREACH()
 
@@ -241,7 +248,11 @@ TRY_COMPILE(RESULT_VAR ${CTK_BINARY_DIR}/Utilities/DGraph ${CTK_SOURCE_DIR}/Util
 IF(NOT RESULT_VAR)
   MESSAGE(FATAL_ERROR "Failed to compile DGraph application.\n${output}")
 ENDIF()
-SET(DGraph_EXECUTABLE ${CTK_BINARY_DIR}/Utilities/DGraph/DGraph)
+FIND_PROGRAM(DGraph_EXECUTABLE DGraph
+  "${CTK_BINARY_DIR}/Utilities/DGraph/"
+  "${CTK_BINARY_DIR}/Utilities/DGraph/bin/"
+  "${CTK_BINARY_DIR}/Utilities/DGraph/Debug/"
+  "${CTK_BINARY_DIR}/Utilities/DGraph/Release/")
 
 # Obtain list of target ordered topologically
 EXECUTE_PROCESS(
@@ -253,7 +264,7 @@ EXECUTE_PROCESS(
   OUTPUT_STRIP_TRAILING_WHITESPACE
   )
 IF(RESULT_VAR)
-  MESSAGE(FATAL_ERROR "Failed to obtain list of target ordered topologically.\n${error}")
+  MESSAGE(FATAL_ERROR "Failed to obtain list of target ordered topologically.\n${RESULT_VAR}\n${CTK_BINARY_DIR}\n${error}")
 ENDIF()         
 
 # Configure CTestConfigSubProject.cmake used that could be used by CTest scripts

+ 6 - 7
Libs/CTKExport.h.in

@@ -8,14 +8,13 @@
 #ifndef __@MY_EXPORT_HEADER_PREFIX@Export_h
 #define __@MY_EXPORT_HEADER_PREFIX@Export_h
 
-#if defined(WIN32) && !defined(@MY_LIBNAME@_STATIC)
- #if defined(@MY_LIBNAME@_EXPORTS)
-  #define @MY_LIBRARY_EXPORT_DIRECTIVE@ __declspec( dllexport ) 
- #else
-  #define @MY_LIBRARY_EXPORT_DIRECTIVE@ __declspec( dllimport ) 
- #endif
+#include <QtCore/qglobal.h>
+
+#if defined(@MY_LIBNAME@_EXPORTS)
+ #define @MY_LIBRARY_EXPORT_DIRECTIVE@ Q_DECL_EXPORT
 #else
- #define @MY_LIBRARY_EXPORT_DIRECTIVE@
+ #define @MY_LIBRARY_EXPORT_DIRECTIVE@ Q_DECL_IMPORT
 #endif
 
 #endif
+

+ 2 - 0
Libs/Core/Testing/Cxx/CMakeLists.txt

@@ -1,6 +1,7 @@
 SET(KIT ${PROJECT_NAME})
 
 CREATE_TEST_SOURCELIST(Tests ${KIT}CxxTests.cxx
+  ctkModelTesterTest1.cxx
   ctkUtilsTest1.cxx
   #EXTRA_INCLUDE TestingMacros.h
   )
@@ -27,4 +28,5 @@ ENDMACRO( SIMPLE_TEST  )
 # Add Tests
 #
 
+SIMPLE_TEST( ctkModelTesterTest1 )
 SIMPLE_TEST( ctkUtilsTest1 )

+ 84 - 0
Libs/Core/Testing/Cxx/ctkModelTesterTest1.cxx

@@ -0,0 +1,84 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc. 
+  All rights reserved.
+  Distributed under a BSD License. See LICENSE.txt file.
+
+  This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the above copyright notice for more information.
+
+=========================================================================*/
+
+// Qt includes
+#include <QAbstractItemModel>
+#include <QApplication>
+#include <QList>
+#include <QModelIndex>
+#include <QTreeWidget>
+
+// CTK includes
+#include "ctkModelTester.h"
+
+// STL includes
+#include <stdlib.h>
+#include <iostream>
+
+class QAbstractItemModelHelper : public QAbstractItemModel
+{
+public:
+  virtual QModelIndex index(int, int, const QModelIndex&) const { return QModelIndex(); }
+  virtual QModelIndex parent(const QModelIndex&) const { return QModelIndex(); }
+  virtual int rowCount(const QModelIndex&) const { return 0; }
+  virtual int columnCount(const QModelIndex&) const { return 0; }
+  virtual QVariant data(const QModelIndex&, int) const { return QVariant(); }
+};
+
+int ctkModelTesterTest1(int argc, char * argv [] )
+{
+  QApplication app(argc, argv);
+
+  QAbstractItemModelHelper * item = new QAbstractItemModelHelper;
+  QObject * object = new QObject; 
+
+  ctkModelTester ctkTester( item, object );
+
+  delete item;
+
+  try
+    {
+    // as we can infer that QTreeWidget is correct, ctkModelTester shall not fail
+    // for any of the actions on QTreeWidget.
+    QTreeWidget treeWidget(0);
+    ctkModelTester treeModelTester(treeWidget.model());
+    treeWidget.setColumnCount(1);
+    QList<QTreeWidgetItem *> items;
+    for (int i = 0; i < 10; ++i)
+      {
+      items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
+      }
+    treeWidget.addTopLevelItems(items);
+    treeWidget.takeTopLevelItem(0);
+    treeWidget.takeTopLevelItem(treeWidget.topLevelItemCount() / 2 );
+    treeWidget.takeTopLevelItem(treeWidget.topLevelItemCount() - 1);
+    treeWidget.insertTopLevelItem(0, new QTreeWidgetItem(&treeWidget, QStringList("new item 0")));
+    treeWidget.insertTopLevelItem(treeWidget.topLevelItemCount() / 2, 
+                                  new QTreeWidgetItem((QTreeWidget*)0, QStringList("new item 1")));
+    treeWidget.insertTopLevelItem(treeWidget.topLevelItemCount(), 
+                                  new QTreeWidgetItem((QTreeWidget*)0, QStringList("new item 2")));
+    new QTreeWidgetItem(treeWidget.topLevelItem(0), QStringList("new item 3"));
+    QAbstractItemModel* model = treeWidget.model();
+    model->setData(model->index(0,0),QString("foo"));
+    treeWidget.sortItems(0, Qt::DescendingOrder);
+    }
+  catch (const char* error)
+    {
+    std::cerr << error << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  return EXIT_SUCCESS;
+}
+

+ 24 - 6
SuperBuild.cmake

@@ -40,6 +40,14 @@ ENDIF()
 # Use this value where semi-colons are needed in ep_add args:
 set(sep "^^")
 
+# Find the git executable, used for custom git commands for external projects
+# (e.g. for QtMobility)
+find_program(Git_EXECUTABLE git DOC "git command line client")
+mark_as_advanced(Git_EXECUTABLE)
+if(NOT Git_EXECUTABLE)
+  message(SEND_ERROR "Set Git_EXECUTABLE to the path of your git executable")
+endif()
+
 #-----------------------------------------------------------------------------
 # Update CMake module path
 #
@@ -163,9 +171,9 @@ IF(${add_project})
   SET(qtmobility_patch_dir ${CTK_SOURCE_DIR}/Utilities/QtMobility/)
   SET(qtmobility_configured_patch_dir ${CTK_BINARY_DIR}/Utilities/QtMobility/)
   SET(qtmobility_patchscript
-    ${CTK_BINARY_DIR}/Utilities/QtMobility/QtMobilityBeta1-patch.cmake)
+    ${CTK_BINARY_DIR}/Utilities/QtMobility/QtMobilityGitBranch1.0-patch.cmake)
   CONFIGURE_FILE(
-    ${CTK_SOURCE_DIR}/Utilities/QtMobility/QtMobilityBeta1-patch.cmake.in
+    ${CTK_SOURCE_DIR}/Utilities/QtMobility/QtMobilityGitBranch1.0-patch.cmake.in
     ${qtmobility_patchscript} @ONLY)
 
   # Define configure options
@@ -178,12 +186,22 @@ IF(${add_project})
   ELSEIF(NOT ${CMAKE_CFG_INTDIR} STREQUAL "Release")
   SET(qtmobility_build_type "debug")
   ENDIf()
+  
+  SET(qtmobility_make_cmd)
+  IF(UNIX OR MINGW)
+    SET(qtmobility_make_cmd make)
+  ELSEIF(WIN32)
+    SET(qtmobility_make_cmd nmake)
+  ENDIF()
 
   ExternalProject_Add(${proj}
-    URL "http://get.qt.nokia.com/qt/solutions/qt-mobility-src-1.0.0-beta1.tar.gz"
-    CONFIGURE_COMMAND <SOURCE_DIR>/configure -${qtmobility_build_type} -libdir ${CMAKE_BINARY_DIR}/CTK-build/bin -no-docs -modules ${qtmobility_modules}
+    GIT_REPOSITORY git://gitorious.org/qt-mobility/qt-mobility.git
+    # the patch command is also used to checkout the 1.0 branch    
     PATCH_COMMAND ${CMAKE_COMMAND} -P ${qtmobility_patchscript}
-    BUILD_IN_SOURCE 1
+    CONFIGURE_COMMAND <SOURCE_DIR>/configure -${qtmobility_build_type} -libdir ${CMAKE_BINARY_DIR}/CTK-build/bin -no-docs -modules ${qtmobility_modules}
+    BUILD_COMMAND ${qtmobility_make_cmd}
+	INSTALL_COMMAND ${qtmobility_make_cmd} install
+	BUILD_IN_SOURCE 1
     )
 ENDIF()
 
@@ -308,6 +326,7 @@ ExternalProject_Add(${proj}
     -DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS}
     -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
     -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+    -DCMAKE_CXX_FLAGS:STRING=${CTK_CXX_FLAGS}
     -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
     -DCTK_KWSTYLE_EXECUTABLE:FILEPATH=${CTK_KWSTYLE_EXECUTABLE}
     -DDCMTK_DIR=${DCMTK_DIR} # FindDCMTK expects DCMTK_DIR
@@ -344,4 +363,3 @@ ADD_CUSTOM_TARGET(CTK
   COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/CTK-build
   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CTK-build
   )
- 

+ 1 - 1
Utilities/QtMobility/QtMobilityBeta1-patch.cmake.in

@@ -28,4 +28,4 @@ IF(UNIX)
 ENDIF()
 
 # Apply patches
-ctkMacroApplyPatches(@CTK_PATCH_EXECUTABLE@ @qtmobility_src_dir@ "${patch_files}")
+ctkMacroApplyPatches("@CTK_PATCH_EXECUTABLE@" "@qtmobility_src_dir@" "${patch_files}")

+ 44 - 0
Utilities/QtMobility/QtMobilityGitBranch1.0-apple.patch

@@ -0,0 +1,44 @@
+*** ../qt-mobility-src-1.0.0-beta1/configure	2010-02-12 03:54:12.000000000 -0500
+--- configure	2010-03-24 18:51:06.000000000 -0400
+***************
+*** 413,423 ****
+  }
+  
+  #compile tests
+! compileTest QMF qmf
+! compileTest NetworkManager networkmanager
+! compileTest "CoreWLAN (MacOS 10.6)" corewlan
+! compileTest "Maemo ICD" maemo-icd
+! compileTest "Maemo ICD WLAN" maemo-icd-network-wlan
+  
+  # Now module selection
+  # using 'expr match ....' should help a bit
+--- 413,423 ----
+  }
+  
+  #compile tests
+! #compileTest QMF qmf
+! #compileTest NetworkManager networkmanager
+! #compileTest "CoreWLAN (MacOS 10.6)" corewlan
+! #compileTest "Maemo ICD" maemo-icd
+! #compileTest "Maemo ICD WLAN" maemo-icd-network-wlan
+  
+  # Now module selection
+  # using 'expr match ....' should help a bit
+***************
+*** 493,499 ****
+  fi
+  
+  echo "Running qmake..."
+! if qmake -recursive "$relpath/qtmobility.pro"; then
+      echo ""
+      echo "configure has finished. You may run make or gmake to build the project now."
+  else
+--- 493,499 ----
+  fi
+  
+  echo "Running qmake..."
+! if qmake -spec macx-g++ -recursive "$relpath/qtmobility.pro"; then
+      echo ""
+      echo "configure has finished. You may run make or gmake to build the project now."
+  else

+ 64 - 0
Utilities/QtMobility/QtMobilityGitBranch1.0-patch.cmake.in

@@ -0,0 +1,64 @@
+# the patch step is run before the update step
+# so we need to checkout the 1.0 branch here
+
+set(work_dir @ep_source_dir@)
+set(proj_dir ${work_dir}/@proj@)
+
+execute_process(
+  COMMAND @Git_EXECUTABLE@ checkout origin/1.0 -t
+  WORKING_DIRECTORY ${proj_dir}
+  ERROR_VARIABLE error_output
+  RESULT_VARIABLE error_code
+  )
+if(error_code)
+  if(NOT ${error_output} MATCHES "branch 1.0 already exists")
+    message(FATAL_ERROR "${error_output}")
+  endif()
+endif()
+
+
+INCLUDE(@CTK_SOURCE_DIR@/CMake/ctkMacroApplyPatches.cmake)
+
+SET(patch_dir @qtmobility_patch_dir@)
+SET(configured_patch_dir @qtmobility_configured_patch_dir@)
+
+# Variable required to properly configured the patch files
+SET(QT_BINARY_DIR @QT_BINARY_DIR@)
+
+SET(patch_files
+)
+
+IF(WIN32)
+  CONFIGURE_FILE(${patch_dir}/QtMobilityGitBranch1.0-win32.patch.in
+    ${configured_patch_dir}/QtMobilityGitBranch1.0-win32.patch @ONLY)
+  LIST(APPEND patch_files
+    ${configured_patch_dir}/QtMobilityGitBranch1.0-win32.patch
+    )
+ENDIF()
+
+IF(UNIX)
+  IF(APPLE)
+    LIST(APPEND patch_files ${patch_dir}/QtMobilityGitBranch1.0-apple.patch)
+  ENDIF()
+ENDIF()
+
+# Apply patches
+ctkMacroApplyPatches("@CTK_PATCH_EXECUTABLE@" "@qtmobility_src_dir@" "${patch_files}")
+
+IF(UNIX)
+
+  # replace all occurences of 'qmake' with the aboslute path to the
+  # qmake executable found by CMake.
+  # This is neccessary for custom Qt builds and for Unix/Linux systems
+  # which use another name for the Qt4 qmake program (e.g. qmake-qt4)
+
+  EXECUTE_PROCESS(
+    COMMAND sed -i "s+qmake +@QT_QMAKE_EXECUTABLE@ +g" configure
+    WORKING_DIRECTORY ${proj_dir}
+    RESULT_VARIABLE error_code
+  )
+
+  IF(error_code)
+    MESSAGE(FATAL_ERROR "Patching ${proj_dir}/configure file failed.")
+  ENDIF()
+ENDIF()

+ 31 - 0
Utilities/QtMobility/QtMobilityGitBranch1.0-win32.patch.in

@@ -0,0 +1,31 @@
+--- C:/development/CTK-master-vc9/CMakeExternals/Source/QtMobility/configure_orig.bat	Sun Apr 11 18:17:43 2010
++++ C:/development/CTK-master-vc9/CMakeExternals/Source/QtMobility/configure.bat	Sun Apr 11 21:19:33 2010
+@@ -60,7 +60,7 @@
+ set MOBILITY_MODULES=bearer location contacts multimedia publishsubscribe versit messaging systeminfo serviceframework sensors
+ set MOBILITY_MODULES_UNPARSED=
+ set VC_TEMPLATE_OPTION=
+-set QT_PATH=
++set QT_PATH=@QT_BINARY_DIR@\
+ set QMAKE_CACHE=%BUILD_PATH%\.qmake.cache
+ 
+ if exist "%QMAKE_CACHE%" del %QMAKE_CACHE%
+@@ -457,10 +457,15 @@
+ echo.
+ echo Start of compile tests
+ REM compile tests go here.
+-call :compileTest LBT lbt
+-call :compileTest SNAP snap
+-call :compileTest OCC occ
+-call :compileTest SymbianContactSIM symbiancntsim
++REM for CTK the compile tests generate errors in Visual Studio -> just disabling them
++REM call :compileTest LBT lbt
++echo lbt_enabled = no >> %PROJECT_CONFIG%
++REM call :compileTest SNAP snap
++echo snap_enabled = no >> %PROJECT_CONFIG%
++REM call :compileTest OCC occ
++echo occ_enabled = no >> %PROJECT_CONFIG%
++REM call :compileTest SymbianContactSIM symbiancntsim
++echo symbiancntsim_enabled = no >> %PROJECT_CONFIG%
+ echo End of compile tests
+ echo.
+ echo.