]> Creatis software - crea.git/commitdiff
CMake 2.6 compatibility :
authorguigues <guigues>
Fri, 21 Nov 2008 12:31:21 +0000 (12:31 +0000)
committerguigues <guigues>
Fri, 21 Nov 2008 12:31:21 +0000 (12:31 +0000)
* new find GTK2
* Patched creaNewProject root CMakeLists.txt to add cmake_minimum_required and cmake policies

appli/creaNewProject/NewProject/CMakeLists.txt.in
cmake/CREAMacro_FindAndUseLibraries.cmake
cmake/CREAMacro_wxWidgets.cmake
cmake/FindGTK2.cmake
samples/CMakeLists.txt

index f4a0f5ea60b78068a0ccd923ce4d3a70c5da3464..f86e7b5cece82ccbb57f5f022ddd659e2f85e526 100644 (file)
@@ -1,3 +1,15 @@
+#
+# Test CMake version
+#
+CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
+#MARK_AS_ADVANCED( FORCE CMAKE_BACKWARDS_COMPATIBILITY )
+
+# for CMake 2.6 corrected behaviour (see "cmake --help-policy CMP0003")
+IF(COMMAND cmake_policy AND ${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
+  CMAKE_POLICY(SET CMP0003 NEW)
+  CMAKE_POLICY(SET CMP0005 NEW)
+ENDIF(COMMAND cmake_policy AND ${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
+
 PROJECT(PROJECT_NAME)
 
 SET(PROJECT_MAJOR_VERSION 1)
index 0d2a29a8cedc1abd0c2e0f991af2484f149fb8f4..dda7ff9b7f76cca9ec1e40396c807f7f9d4757b5 100644 (file)
@@ -150,6 +150,55 @@ ENDIF(USE_GDCM)
 
 #-----------------------------------------------------------------------------
 
+#-----------------------------------------------------------------------------
+IF(USE_GDCM2)
+  # Search GDCM2
+  FIND_PACKAGE(GDCM)
+  # If gdcm found
+  IF(GDCM_FOUND)
+    INCLUDE(${GDCM_USE_FILE})
+    
+    IF(NOT ${GDCM_MAJOR_VERSION} EQUAL 2)
+      MESSAGE(FATAL_ERROR "gdcm version 2 needed. found ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}. Set GDCM_DIR to the gdcm version 2 directory")
+    ENDIF(NOT ${GDCM_MAJOR_VERSION} EQUAL 2)
+
+    CREA_DEFINE( USE_GDCM2 )
+    CREA_DEFINE_WITH_VAL( GDCM_NAME_SPACE gdcm )
+
+    MESSAGE ( STATUS "Looking for GDCM2... found")
+    MESSAGE ( STATUS "* Dir       = ${GDCM_DIR}")
+    MESSAGE ( STATUS "* Version   = ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")
+    MESSAGE ( STATUS "* Namespace = ${GDCM_NAME_SPACE}")
+
+    # Test that GDCM_NAME_SPACE is **NOT** "gdcm" or will conflict with 
+    # embedded gdcm in ITK and will result in hard seg faults !
+    IF(USE_ITK)
+      IF (GDCM_NAME_SPACE STREQUAL "gdcm")
+       MESSAGE(FATAL_ERROR "GDCM_NAME_SPACE value is 'gdcm' which conflicts with ITK embededd gdcm namespace : rebuild gdcm with another GDCM_NAME_SPACE value")
+      ENDIF (GDCM_NAME_SPACE STREQUAL "gdcm")
+    ENDIF(USE_ITK)
+    
+    MARK_AS_ADVANCED(GDCM_DIR)
+    
+    SET(GDCM_LIBRARIES
+        ${GDCM_LIBRARIES} 
+      )
+
+# TODO : Test that GDCM was built with option "vtkgdcm"
+    IF(USE_GDCM_VTK)
+     IF(USE_VTK)
+       SET(GDCM_LIBRARIES
+        ${GDCM_LIBRARIES}
+         vtkgdcm  
+         )
+     ENDIF(USE_VTK)
+    ENDIF(USE_GDCM_VTK)
+
+  ENDIF(GDCM_FOUND)
+ENDIF(USE_GDCM2)
+
+#-----------------------------------------------------------------------------
+
 #-----------------------------------------------------------------------------
 IF(USE_WXWIDGETS)
   INCLUDE(${CREA_CMAKE_DIR}/CREAMacro_wxWidgets.cmake)
index 6e5dd19d3a70cc2959750fab2735b6ccabd05ead..765ddf8614eee206bd9323c89336ae9a67d93b79 100644 (file)
@@ -27,12 +27,22 @@ MACRO(CREA_FIND_WXWIDGETS)
     #
   
   ELSE(WIN32)
+    # CMake 2.6:
+    # technically those packages are not required 
+    # since one can still use the Motif/X11 version and not the gtk one:
+    FIND_PACKAGE(PkgConfig)
+    pkg_check_modules (GTK2 gtk+-2.0)
+    #MESSAGE("${GTK2_INCLUDE_DIRS}")
+    # Can I require all my user to have the gl lib on linux, even if they do not really need it...
+    SET(WXGLCANVASLIBS "gl")
     # GTK2
   INCLUDE(${CREA_CMAKE_DIR}/FindGTK2.cmake)
#   INCLUDE(${CREA_CMAKE_DIR}/FindGTK2_new.cmake)
     # WX
     # LG : Do not force but use what is installed !
     # SET(wxWidgets_USE_LIBS base core gl)
-    FIND_PACKAGE( wxWidgets REQUIRED) 
+    #FIND_PACKAGE( GTK REQUIRED) 
+#    FIND_PACKAGE( wxWidgets REQUIRED) 
+    FIND_PACKAGE(wxWidgets COMPONENTS base core adv ${WXGLCANVASLIBS})
     #
     IF(wxWidgets_FOUND)
       MESSAGE(STATUS "Looking for wxWidgets... found ${wxWidgets_CONFIG_EXECUTABLE}")
@@ -72,10 +82,14 @@ MACRO(CREA_USE_WXWIDGETS)
     LINK_DIRECTORIES(${GTK2_LIBRARY_DIRS})
     LINK_LIBRARIES(${GTK2_LIBRARIES})
     # WX
+
+
+#    INCLUDE( ${GTK_USE_FILE} )
     INCLUDE( ${wxWidgets_USE_FILE} )
     MARK_AS_ADVANCED(wxWidgets_CONFIG_EXECUTABLE)
     SET(WXWIDGETS_LIBRARIES
       ${GTK2_LIBRARIES}
+      #${GTK_LIBRARIES}
       ${wxWidgets_LIBRARIES}
       )
   ENDIF(WIN32)
index dcd23fe2b920358c32181a08f01a9961eb372db9..c8764808cedc44536b239bcc6e3c7a3d4cdced21 100644 (file)
@@ -8,7 +8,11 @@ ELSE (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
     # in the FIND_PATH() and FIND_LIBRARY() calls
     INCLUDE(UsePkgConfig)
 
-    PKGCONFIG(gtk-2.0 _GTK22IncDir _GTK22LinkDir _GTK22LinkFlags _GTK22Cflags)
+#    PKGCONFIG
+FindPkgConfig(gtk-2.0 _GTK22IncDir _GTK22LinkDir _GTK22LinkFlags _GTK22Cflags)
+
+#   pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
+#     checks for given modules and uses the first working one
 
     FIND_PATH(GTK2_GTK_INCLUDE_PATH gtk/gtk.h
       $ENV{GTK2_HOME}
index 7d503d322933e287f8e9441203b9c0becfb565d1..6e85974cd1b2ca3dbcd25be8f27260a7606ceeba 100644 (file)
@@ -1,2 +1,3 @@
 SUBDIRS(creaSample_MessageManager)
 SUBDIRS(creaSample_preprocessor)
+SUBDIRS(creaSample_VtkBasicSlicer)