title: Finding Boost compiled with CLang with CMake
body: <p>I have compiled Boost 1.51.0 on Windows using the <a href="http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.1-release/" rel="noreferrer">rubenvb</a>'s CLang build. I actually compiled b2 using MinGW:</p>
  
  <pre><code>bootstrap mingw
  ... compiling b2 using mingw...
  </code></pre>
  
  <p>and then I compiled the libraries with CLang:</p>
  
  <pre><code>b2 toolset=clang stage --stagedir=. --build-type=complete --with-regex ...
  </code></pre>
  
  <p>By the way, even if I specified <code>--build-type=complete</code> there are no DLLs in lib directory, but I read somewhere that CLang has still problem with linking on Windows so that might be the reason. Anyway static libraries are fine for me. I got these files in <code>%BOOST_ROOT%\lib</code>:</p>
  
  <pre><code>libboost_regex-clang31-1_51.lib
  libboost_regex-clang31-d-1_51.lib
  libboost_regex-clang31-mt-1_51.lib
  libboost_regex-clang31-mt-d-1_51.lib
  libboost_regex-clang31-mt-s-1_51.lib
  libboost_regex-clang31-mt-sd-1_51.lib
  libboost_regex-clang31-s-1_51.lib
  libboost_regex-clang31-sd-1_51.lib
  </code></pre>
  
  <p>Now, if I compile something with CLang from command line everything works. The problem shows when I try to make CMake find Boost libraries: it simply could not find them. I tried with this CMakeFiles.txt:</p>
  
  <pre><code>cmake_minimum_required (VERSION 2.8)
  project(ccc)
  
  # Setting/unsetting this does not change anything.
  set(Boost_USE_STATIC_LIBS ON)
  
  find_package(Boost COMPONENTS regex REQUIRED)
  
  include_directories(${Boost_INCLUDE_DIR})
  link_directories(${Boost_LIBRARY_DIRS})
  
  add_executable(ccc main.cpp)
  
  target_link_libraries(ccc
      ${Boost_REGEX_LIBRARY}
      )
  </code></pre>
  
  <p>Building it using MinGW (and a MinGW compiled version of Boost) it works. If I try with CLang (after having setted <code>CC=clang</code>, <code>CXX=clang++</code> and <code>BOOST_ROOT=C:/misc/boost/clang-1_51_0</code>) it does not:</p>
  
  <pre><code>D:\Desktop\ppp&gt;cmake -G "MinGW Makefiles" ..\ccc
  -- The C compiler identification is Clang 3.1.0
  -- The CXX compiler identification is Clang 3.1.0
  -- Check for working C compiler: C:/misc/clang/bin/clang.exe
  -- Check for working C compiler: C:/misc/clang/bin/clang.exe -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working CXX compiler: C:/misc/clang/bin/clang++.exe
  -- Check for working CXX compiler: C:/misc/clang/bin/clang++.exe -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  CMake Error at C:/misc/cmake/share/cmake-2.8/Modules/FindBoost.cmake:1191 (message):
    Unable to find the requested Boost libraries.
  
    Boost version: 1.51.0
  
    Boost include path: C:/misc/boost/clang-1_51_0
  
    The following Boost libraries could not be found:
  
            boost_regex
  
    No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
    directory containing Boost libraries or BOOST_ROOT to the location of
    Boost.
  Call Stack (most recent call first):
    CMakeLists.txt:5 (find_package)
  
  
  CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
  Please set them or make sure they are set and tested correctly in the CMake files:
  Boost_REGEX_LIBRARY (ADVANCED)
      linked by target "ccc" in directory D:/Desktop/ccc
  
  -- Configuring incomplete, errors occurred!
  </code></pre>
  
  <p>However, if I compile manually it works again:</p>
  
  <pre><code>clang++ main.cpp -I%BOOST_ROOT% -L%BOOST_ROOT%\lib -llibboost_regex-clang31-1_51
  ...Ok, and the executable works
  </code></pre>
  
  <p>Manually setting <code>BOOST_LIBRARYDIR</code> does not work either. Neither does using backslashes <code>\</code>.</p>