From e82bd4614c0cd7ee5407efb32718d66af5a6a266 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Wed, 18 Dec 2013 21:36:00 +0100 Subject: [PATCH] Check for pthreads library. This fixes a link error on my ARM devices. --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9b3ae1a..1b76808f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,6 +350,11 @@ else() add_definitions(-D__LITTLE_ENDIAN__) endif() +# +# Check if libpthread is available +# +find_package(Threads) + # # Set up the main ldc/ldc2 target. # @@ -374,7 +379,7 @@ set_target_properties( ) # LDFLAGS should actually be in target property LINK_FLAGS, but this works, and gets around linking problems -target_link_libraries(${LDC_LIB} ${LLVM_LIBRARIES} "${LLVM_LDFLAGS}") +target_link_libraries(${LDC_LIB} ${LLVM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} "${LLVM_LDFLAGS}") if(WIN32) target_link_libraries(${LDC_LIB} imagehlp psapi) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") @@ -394,7 +399,7 @@ set_target_properties( COMPILE_FLAGS "${LLVM_CXXFLAGS} ${EXTRA_CXXFLAGS}" LINK_FLAGS "${SANITIZE_LDFLAGS}" ) -target_link_libraries(${LDC_EXE} ${LDC_LIB} ${LIBCONFIG++_LIBRARY}) +target_link_libraries(${LDC_EXE} ${LDC_LIB} ${LIBCONFIG++_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) if(MSVC) # Add a post build event in Visual Studio to copy the config file into Debug/Release folder add_custom_command(TARGET ${LDC_EXE} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}.conf $ COMMENT "Copy config file ${LDC_EXE}.conf") @@ -432,7 +437,7 @@ set_target_properties( COMPILE_FLAGS "${TABLEGEN_CXXFLAGS} ${LDC_CXXFLAGS}" LINK_FLAGS "${SANITIZE_LDFLAGS}" ) -target_link_libraries(gen_gccbuiltins ${LLVM_LIBRARIES} "${LLVM_LDFLAGS}") +target_link_libraries(gen_gccbuiltins ${LLVM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} "${LLVM_LDFLAGS}") if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") target_link_libraries(gen_gccbuiltins dl) endif()