Index: llvm/cmake/modules/FindZ3.cmake =================================================================== --- llvm/cmake/modules/FindZ3.cmake +++ llvm/cmake/modules/FindZ3.cmake @@ -3,7 +3,7 @@ # Function to check Z3's version function(check_z3_version z3_include z3_lib) # The program that will be executed to print Z3's version. - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.c + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.cpp "#include #include int main() { @@ -16,13 +16,19 @@ # Get lib path get_filename_component(z3_lib_path ${z3_lib} PATH) + # Try to find a threading module in case Z3 was built with threading support. + # Threads are required elsewhere in LLVM, but not marked as required here because + # Z3 could have been compiled without threading support. + find_package(Threads) + set(z3_link_libs "-lz3" "${CMAKE_THREAD_LIBS_INIT}") + try_run( Z3_RETURNCODE Z3_COMPILED ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.c + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.cpp COMPILE_DEFINITIONS -I"${z3_include}" - LINK_LIBRARIES -L${z3_lib_path} -lz3 + LINK_LIBRARIES -L${z3_lib_path} ${z3_link_libs} RUN_OUTPUT_VARIABLE SRC_OUTPUT )