From 8bda7ff0c8d31a868e126aca17a41bceb5e0dd35 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Wed, 13 Feb 2013 16:00:08 +0100 Subject: [PATCH] MinGW LLVM compiler flag fixes. Our CMake code should be rewritten to not expect things as strings that really aren't, but this would entail a whole lot of cross- platform testing, so I'm postponing it for now. --- cmake/Modules/FindLLVM.cmake | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/FindLLVM.cmake b/cmake/Modules/FindLLVM.cmake index 47fea36f..d984fb97 100644 --- a/cmake/Modules/FindLLVM.cmake +++ b/cmake/Modules/FindLLVM.cmake @@ -42,10 +42,25 @@ if (NOT LLVM_CONFIG) list(REMOVE_ITEM LLVM_FIND_COMPONENTS "all-targets" index) list(APPEND LLVM_FIND_COMPONENTS ${LLVM_TARGETS_TO_BUILD}) list(REMOVE_ITEM LLVM_FIND_COMPONENTS "backend" index) + llvm_map_components_to_libraries(tmplibs ${LLVM_FIND_COMPONENTS}) - foreach(lib ${tmplibs}) - list(APPEND LLVM_LIBRARIES "${LLVM_LIBRARY_DIRS}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}") - endforeach() + if(MSVC) + foreach(lib ${tmplibs}) + list(APPEND LLVM_LIBRARIES "${LLVM_LIBRARY_DIRS}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}") + endforeach() + else() + # Rely on the library search path being set correctly via -L on + # MinGW and others, as the library list returned by + # llvm_map_components_to_libraries also includes imagehlp and psapi. + set(LLVM_LDFLAGS "-L${LLVM_LIBRARY_DIRS}") + set(LLVM_LIBRARIES ${tmplibs}) + + # When using the CMake LLVM module, LLVM_DEFINITIONS is a list + # instead of a string. Later, the list seperators would entirely + # disappear, replace them by spaces instead. A better fix would be + # to switch to add_definitions() instead of throwing strings around. + string(REPLACE ";" " " LLVM_CXXFLAGS "${LLVM_CXXFLAGS}") + endif() else() if (NOT FIND_LLVM_QUIETLY) message(WARNING "Could not find llvm-config. Try manually setting LLVM_CONFIG to the llvm-config executable of the installation to use.")