2012-10-03 41 views
6

He compilado Boost 1.51.0 en Windows usando la compilación CLang de rubenvb. En realidad compilado b2 utilizando MinGW:Encontrar Boost compilado con CLang con CMake

bootstrap mingw 
... compiling b2 using mingw... 

y luego compilé las bibliotecas con CLANG:

b2 toolset=clang stage --stagedir=. --build-type=complete --with-regex ... 

Por cierto, incluso si he especificado --build-type=complete no hay archivos DLL en el directorio lib, pero leo en algún lugar, CLang todavía tiene problemas para vincular Windows, por lo que esa podría ser la razón. De todos modos, las bibliotecas estáticas están bien para mí. Tengo estos archivos en %BOOST_ROOT%\lib:

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 

Ahora, si puedo compilar algo con sonido metálico de la línea de comandos todo funciona. El problema aparece cuando trato de hacer que CMake encuentre las bibliotecas de Boost: simplemente no las pudo encontrar. Probé con este CMakeFiles.txt:

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} 
    ) 

La construcción utilizando MinGW (MinGW y una versión compilada de Boost) funciona. Si trato con sonido metálico (después de haber enchufar CC=clang, CXX=clang++ y BOOST_ROOT=C:/misc/boost/clang-1_51_0) no lo hace:

D:\Desktop\ppp>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! 

Sin embargo, si puedo compilar manualmente funciona otra vez:

clang++ main.cpp -I%BOOST_ROOT% -L%BOOST_ROOT%\lib -llibboost_regex-clang31-1_51 
...Ok, and the executable works 

La configuración manual de BOOST_LIBRARYDIR tampoco funciona . Tampoco lo hace el uso de barras diagonales inversas \.

Respuesta

5

Mirando dentro del archivo "C: /misc/cmake/share/cmake-2.8/Modules/FindBoost.cmake" puede encontrar una lista de todas las variables relacionadas con Boost que puede usar. El único que se necesita es Boost_COMPILER (Boost_DETAILED_FAILURE_MSG también puede ser útil para el diagnóstico de problemas):

# Boost_COMPILER    Set this to the compiler suffix used by Boost 
#        (e.g. "-gcc43") if FindBoost has problems finding 
#        the proper Boost installation 
+1

Configuración '' Boost_COMPILER' a -clang31' * y * '' Boost_USE_STATIC_RUNTIME' a TRUE resolvió el problema. Gracias. – Claudio