title: 'cannot find -lgcc_s' error when giving toolchain file for Power-PC to CMAKE setup
body: <p>I am facing some strange issue in cmake while trying to do the cross compilation build. For native build it is working as per expectation:</p>
  
  <p><strong>Case 1:</strong>  toolchain file is given in include() of CMakelists.txt file.</p>
  
  <p>For Power-PC build, when I give the toolchain file in following way in the CMakelists.txt file : </p>
  
  <pre><code>if(ARM)
  include(config/toolchain_la9.cmake)
  elseif(POWER-PC)
  include(config/toolchain_lppc.cmake)
  endif()
  </code></pre>
  
  <p>everything is working fine and I am able to get all generated executable and binaries with these following compiler and linker flags </p>
  
  <p><strong>/opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc   -mdouble-float
   -msoft-float   -static-libgcc -lpthread -lm -lrt</strong></p>
  
  <p><strong>Case 2:</strong> toolchain file is given with cmake -D command.</p>
  
  <p>Again when I commented the case 1 code snippet and try to give the same file as </p>
  
  <p><strong>cmake PATH_TO_CMAKE_DIRECTORY -DCMAKE_TOOLCHAIN_FILE=/home/one/toolchain_files/toolchain_lppc.cmake</strong></p>
  
  <p>This time I am not able to cross compile the source code.</p>
  
  <p>with the following error: </p>
  
  <blockquote>
    <p>/opt/freescale-2010.09/bin/../lib/gcc/powerpc-linux-gnu/4.5.1/../../../../powerpc-linux-gnu/bin/ld:
    cannot find -lgcc_</p>
  </blockquote>
  
  <p>s</p>
  
  <p><strong>Case 3:</strong>   With Cmake-gui using 'specify toolchain file for cross-compiling' option </p>
  
  <p><a href="https://i.stack.imgur.com/QRabr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QRabr.png" alt="enter image description here"></a></p>
  
  <p>When I give the same file as input to this option. Again I am getting the same issue:</p>
  
  <blockquote>
    <p>/opt/freescale-2010.09/bin/../lib/gcc/powerpc-linux-gnu/4.5.1/../../../../powerpc-linux-gnu/bin/ld:
    cannot find -lgcc_s</p>
  </blockquote>
  
  <ol>
  <li>The error clearly indicates that the libgcc_s is not present under specified toolchain path. But if it is not present how it is working in case 1.</li>
  <li>How I am getting -static-libgcc flag in case 1, do I need to give it explicitly in toolchain file in 2nd and 3rd case. </li>
  <li>Even in toolchain file if I am using CMAKE_EXE_LINKER_FLAGS for adding -static-libgcc in 2nd and 3rd case, it is still showing same errors. </li>
  </ol>
  
  <p>I am new in cmake. though it seems very useful to me but here I am stuck.  </p>
  
  <p>The toolchain file content is as follows:</p>
  
  <pre><code>set(CMAKE_SYSTEM_NAME Linux)
  set(CMAKE_C_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc )
  set(CMAKE_CXX_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++)
  set(CMAKE_STRIP /opt/freescale-2010.09/bin/powerpc-linux-gnu-strip)
  
  set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/opt/freescale-2010.09/lib/gcc/powerpc-linux-gnu/4.5.1/")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mdouble-float -msoft-float")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mdouble-float -msoft-float")
  
  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)
  </code></pre>