diff --git a/CMakeLists.txt b/CMakeLists.txt
index e5a557c3842546a799031d7d80bf9cdc9dbf0e82..3bd30ed36b542905b1a064d881bfea6256c4eb2a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -260,21 +260,22 @@ endif(NOT DEFINED COMPILE_PACKAGING)
 # clients builds here.
 
 add_subdirectory (castor)
+add_subdirectory (client/src/stager)
 add_subdirectory (common)
+add_subdirectory (config)
 add_subdirectory (dlf)
+add_subdirectory (h)
+add_subdirectory (hsmtools)
 add_subdirectory (ns)
 add_subdirectory (rfio)
 add_subdirectory (rmc)
 add_subdirectory (security)
+add_subdirectory (shlib)
 add_subdirectory (tapebridge)
 add_subdirectory (upv)
 add_subdirectory (vdqm)
 add_subdirectory (vmgr)
-add_subdirectory (h)
-add_subdirectory (config)
-add_subdirectory (shlib)
-add_subdirectory (hsmtools)
-add_subdirectory (client/src/stager)
+add_subdirectory (xrootd)
 if(${COMPILE_SERVER} STREQUAL "1")
   add_subdirectory (tape)
 endif(${COMPILE_SERVER} STREQUAL "1")
diff --git a/cmake/Findxrootd.cmake b/cmake/Findxrootd.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..945a1b98e8c4bfc4a613adc47625cc04fea38f56
--- /dev/null
+++ b/cmake/Findxrootd.cmake
@@ -0,0 +1,63 @@
+#                      cmake/Findxrootd.cmake
+#
+# This file is part of the Castor project.
+# See http://castor.web.cern.ch/castor
+#
+# Copyright (C) 2003  CERN
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#
+# Steven.Murray@cern.ch
+#
+
+# - Find xroot
+# Finds the header files of xrootd-devel by searching for XrdVersion.hh
+# Finds the header files of xrootd-private-devel by searching for XrdOssApi.hh
+#
+# XROOTD_FOUND               - true if xrootd has been found
+# XROOTD_INCLUDE_DIR         - location of the xrootd-devel header files
+# XROOTD_PRIVATE_INCLUDE_DIR - location of the private xrootd files, in other
+#                              words the header files that do not contribute to
+#                              the xrootd ABI.
+# XROOTD_XRDCL_LIB           - location of the XrdCl library
+# XROOTD_XRDCLIENT_LIB       - location of the XrdClient library
+# XROOTD_XRDOFS_LIB          - location of the XrdOfs library
+# XROOTD_XRDUTILS_LIB        - location of the XrdUtils library
+
+# Be silent if XROOTD_INCLUDE_DIR is already cached
+if (XROOTD_INCLUDE_DIR)
+  set(XROOTD_FIND_QUIETLY TRUE)
+endif (XROOTD_INCLUDE_DIR)
+
+find_path (XROOTD_INCLUDE_DIR XrdVersion.hh
+  PATH_SUFFIXES include/xrootd
+)
+
+find_path (XROOTD_PRIVATE_INCLUDE_DIR XrdOss/XrdOssApi.hh
+  PATH_SUFFIXES include/xrootd/private
+)
+
+find_library (XROOTD_XRDCL_LIB XrdCl)
+find_library (XROOTD_XRDCLIENT_LIB XrdClient)
+find_library (XROOTD_XRDOFS_LIB XrdOfs)
+find_library (XROOTD_XRDUTILS_LIB XrdUtils)
+
+include (FindPackageHandleStandardArgs)
+find_package_handle_standard_args( xrootd DEFAULT_MSG 
+  XROOTD_INCLUDE_DIR
+  XROOTD_LIB_DIR
+  XROOTD_PRIVATE_INCLUDE_DIR
+  XROOTD_XRDCL_LIB
+  XROOTD_XRDCLIENT_LIB
+  XROOTD_XRDOFS_LIB
+  XROOTD_XRDUTILS_LIB)
diff --git a/xrootd/CMakeLists.txt b/xrootd/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..da47de30d18dbe8e0f3c312c812ba684febe0723
--- /dev/null
+++ b/xrootd/CMakeLists.txt
@@ -0,0 +1,66 @@
+#
+#                      xrootd/CMakeLists.txt
+#
+# This file is part of the Castor project.
+# See http://castor.web.cern.ch/castor
+#
+# Copyright (C) 2003  CERN
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#
+# Steven.Murray@cern.ch
+#
+cmake_minimum_required (VERSION 2.6)
+
+find_package (xrootd)
+
+message (STATUS "XROOTD_FOUND               = ${XROOTD_FOUND}")
+message (STATUS "XROOTD_INCLUDE_DIR         = ${XROOTD_INCLUDE_DIR}")
+message (STATUS "XROOTD_PRIVATE_INCLUDE_DIR = ${XROOTD_PRIVATE_INCLUDE_DIR}")
+message (STATUS "XROOTD_XRDCL_LIB           = ${XROOTD_XRDCL_LIB}")
+message (STATUS "XROOTD_XRDCLIENT_LIB       = ${XROOTD_XRDCLIENT_LIB}")
+message (STATUS "XROOTD_XRDOFS_LIB          = ${XROOTD_XRDOFS_LIB}")
+message (STATUS "XROOTD_XRDUTILS_LIB        = ${XROOTD_XRDUTILS_LIB}")
+
+include_directories (${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR})
+
+################################################################################
+# Rules to build and install libXrdxCastor2Fs.so
+################################################################################
+set (XRDXCASTOR2FS_LIB_SRC_FILES
+  XrdxCastor2Fs.cpp
+  XrdxCastor2FsConfig.cpp
+  XrdxCastor2FsStats.cpp
+  XrdxCastor2ServerAcc.cpp
+  XrdxCastor2Stager.cpp
+  XrdxCastor2Proc.cpp
+  XrdxCastorLogging.cpp
+  XrdxCastorTiming.cpp
+  XrdxCastorClient.cpp)
+add_library (XrdxCastor2Fs SHARED ${XRDXCASTOR2FS_LIB_SRC_FILES})
+set_target_properties (XrdxCastor2Fs PROPERTIES
+  SOVERSION ${MAJOR_CASTOR_VERSION}
+  COMPILE_DEFINITIONS _FILE_OFFSET_BITS=64)
+target_link_libraries (XrdxCastor2Fs castorclient castorcommon castorns crypto
+  ${XROOTD_XRDOFS_LIB} ${XROOTD_XRDUTILS_LIB})
+install (TARGETS XrdxCastor2Fs DESTINATION ${CASTOR_DEST_LIB_DIR})
+
+################################################################################
+# Rules to build and install libXrdxCastor2ServerAcc.so
+################################################################################
+set (XRDXCASTOR2SERVERACC_LIB_SRC_FILES
+  XrdxCastor2ServerAcc.cpp
+  XrdxCastorTiming.cpp)
+add_library (XrdxCastor2ServerAcc SHARED ${XRDXCASTOR2SERVERACC_LIB_SRC_FILES})
+target_link_libraries (XrdxCastor2ServerAcc crypto ${XROOTD_XRDUTILS_LIB})
+install (TARGETS XrdxCastor2ServerAcc DESTINATION ${CASTOR_DEST_LIB_DIR})