title: CMAKE and cross compiling
body: <p>I have to change sysroot for my cmake. There is rootfs located on my disk in /u02/rootfs.</p>
  
  <p>I created toolchain_rootfs file and added this config into it:</p>
  
  <pre><code>SET(CMAKE_INSTALL_PREFIX "/u02/rootfs")
  
  set(CMAKE_SYSTEM_NAME Linux)
  set(CMAKE_SYSROOT ${CMAKE_INSTALL_PREFIX})
  #set(CMAKE_STAGING_PREFIX /home/devel/stage)
  set(CMAKE_FIND_ROOT_PATH ${CMAKE_INSTALL_PREFIX})
  
  
  set(CMAKE_C_COMPILER "${CMAKE_INSTALL_PREFIX}/usr/bin/gcc")
  set(CMAKE_CXX_COMPILER "${CMAKE_INSTALL_PREFIX}/usr/bin/c++")
  
  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
  
  
  ###
  SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
  SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
  SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib")
  SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib")
  </code></pre>
  
  <p>After that I run cmake with option:</p>
  
  <pre><code>cmake ../myproject/ -DCMAKE_TOOLCHAIN_FILE=/u02/myproject/toolchain_rootfs
  </code></pre>
  
  <p>And got error like this:</p>
  
  <pre><code>------------  /u02/rootfs/usr/lib
  ------------  /u02/rootfs/usr/lib
  -- The C compiler identification is unknown
  -- The CXX compiler identification is GNU 5.4.0
  -- Check for working C compiler: /u02/rootfs/usr/bin/gcc
  ------------  /u02/rootfs/usr/lib
  -- Check for working C compiler: /u02/rootfs/usr/bin/gcc -- broken
  CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
    The C compiler "/u02/rootfs/usr/bin/gcc" is not able to
    compile a simple test program.
  
    It fails with the following output:
  
     Change Dir: /u02/myproject/CMakeFiles/CMakeTmp
  
  
  
    Run Build Command:"/usr/bin/make" "cmTC_0e039/fast"
  
    /usr/bin/make -f CMakeFiles/cmTC_0e039.dir/build.make
    CMakeFiles/cmTC_0e039.dir/build
  
    make[1]: Entering directory '/u02/myproject_build/CMakeFiles/CMakeTmp'
  
    Building C object CMakeFiles/cmTC_0e039.dir/testCCompiler.c.o
  
    /u02/rootfs/usr/bin/gcc -o
    CMakeFiles/cmTC_0e039.dir/testCCompiler.c.o -c
    /u02/myproject_build/CMakeFiles/CMakeTmp/testCCompiler.c
  
    /u02/rootfs/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/cc1:
    error while loading shared libraries: libisl.so.10: cannot open shared
    object file: No such file or directory
  </code></pre>
  
  <p>Could you help me please solve this error.  I went through cmake manual, set RPATH, but it doesn't work to me.  What is wrong?</p>
  
  <p>UDP1:</p>
  
  <p>I've tried to use sysroot, without toolchain like:</p>
  
  <pre><code>SET(CMAKE_INSTALL_PREFIX "/u02/rootfs")
  set(CMAKE_SYSROOT ${CMAKE_INSTALL_PREFIX})
  set(CMAKE_FIND_ROOT_PATH ${CMAKE_INSTALL_PREFIX})
  SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib/x86_64-linux-gnu")
  </code></pre>
  
  <p>CMAKE was passed, but MAKE was failed. I got error:</p>
  
  <pre><code>/u02/rootfs/usr/bin/ar: error while loading shared libraries: libbfd-2.25-system.so: cannot open shared object file: No such file or directory
  </code></pre>
  
  <p>rootfs has this library.</p>
  
  <p>How to specify PATH to LIBs in rootfs(sysroot)?</p>