OUTPUT_VARIABLE LIBT2N_DATADIR
                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
 set(LIBT2N_CLIENT_PCTEMPLATE ${LIBT2N_DATADIR}/clientlib.pc.in)
-set(LIBT2N_GCCXML /usr/bin/libt2n-gccxml.sh)
+set(LIBT2N_CASTXML /usr/bin/castxml)
 
 # Basic pkgconfig settings needed for client.pc generation
 set(prefix      ${CMAKE_INSTALL_PREFIX})
         DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
         PROPERTY INCLUDE_DIRECTORIES
     )
-    set(gccxml_include_dirs "")
-    foreach(gcc_include_dir ${gcc_include_dirs})
-        set(gccxml_include_dirs "${gccxml_include_dirs} -I${gcc_include_dir}")
-    endforeach(gcc_include_dir ${gcc_include_dirs})
+    list(TRANSFORM gcc_include_dirs PREPEND "-I")
+
+    if(NOT DEFINED CASTXML_CXXFLAGS)
+        set(CASTXML_CXXFLAGS --castxml-gccxml -m32 -std=gnu++98 --gcc-install-dir=/usr/lib/gcc/i686-redhat-linux/4.4.4)
+    endif(NOT DEFINED CASTXML_CXXFLAGS)
 
     foreach(CMDGROUP ${ARGV})
         message(STATUS "Processing libt2n command group ${CMDGROUP}")
 
-        # We are going to run each .cpp file through gccxml for the current CMDGROUP
-        set(T2N_GCCXML_FILES "")
-        set(T2N_GCCXML_COMMANDS "")
+        # We are going to run each .cpp file through castxml for the current CMDGROUP
+        set(T2N_CASTXML_FILES "")
+        set(T2N_CASTXML_COMMANDS "")
         foreach(T2NFILE ${${CMDGROUP}_GROUP})
             get_filename_component(FILE_NAME ${T2NFILE} NAME)
             # get_filename_component(FILE_EXT ${T2NFILE} EXT)   <-- Doesn't work for filenames with multiple dots
             endif()
             message(STATUS "   Processing file ${FILE_NAME}")
 
-            # We build the commands in advance which execute gccxml on each file in the CMDGROUP
-            set(T2N_GCCXML_COMMANDS ${T2N_GCCXML_COMMANDS}
-                COMMAND ${LIBT2N_GCCXML} ${gccxml_include_dirs} ${T2NFILE} -fxml=${T2NFILE}.xml
+            # We build the commands in advance which execute castxml on each file in the CMDGROUP
+            set(T2N_CASTXML_COMMANDS ${T2N_CASTXML_COMMANDS}
+                COMMAND ${LIBT2N_CASTXML} ${gcc_include_dirs} ${T2NFILE}  -o ${T2NFILE}.xml ${CASTXML_CXXFLAGS}
                 )
-            # The filenames of the created intermediate gccxml files for the current CMDGROUP
-            set(T2N_GCCXML_FILES ${T2N_GCCXML_FILES} ${T2NFILE}.xml)
+            # The filenames of the created intermediate castxml files for the current CMDGROUP
+            set(T2N_CASTXML_FILES ${T2N_CASTXML_FILES} ${T2NFILE}.xml)
         endforeach(T2NFILE ${${CMDGROUP}_GROUP})
 
         add_custom_command(
             COMMAND echo "\\#include \\\"codegen-stubhead.hxx\\\"" >${CMDGROUP}_common.hxx
             COMMAND echo "\\#include \\\"${CMDGROUP}.hxx\\\"" >>${CMDGROUP}_common.hxx
 
-            # Invoke gccxml on each source file in the current CMDGROUP and delete the dummy file
-            ${T2N_GCCXML_COMMANDS}
+            # Invoke castxml on each source file in the current CMDGROUP and delete the dummy file
+            ${T2N_CASTXML_COMMANDS}
             COMMAND rm -f ${CMDGROUP}_common.hxx
 
-            # Run the code generator on all the generated gccxml files and remove those intermediate gccxml files
-            COMMAND ${LIBT2N_CODEGEN} ${CMDGROUP} ${T2N_GCCXML_FILES}
-            COMMAND rm -f ${T2N_GCCXML_FILES}
+            # Run the code generator on all the generated castxml files and remove those intermediate castxml files
+            COMMAND ${LIBT2N_CODEGEN} ${CMDGROUP} ${T2N_CASTXML_FILES}
+            COMMAND rm -f ${T2N_CASTXML_FILES}
 
             DEPENDS ${${CMDGROUP}_GROUP}
             )