From 95fc2e46526e0b83122613f3125dc10f8c254e89 Mon Sep 17 00:00:00 2001 From: Pere Mato Date: Wed, 13 Aug 2014 14:06:38 +0200 Subject: [PATCH] Correct the problem with -pthread flag when building with CMake. Should fix issue ROOT-6390 --- cmake/modules/CheckCompiler.cmake | 8 ++++++++ cmake/modules/RootBuildOptions.cmake | 1 + cmake/modules/RootConfiguration.cmake | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmake/modules/CheckCompiler.cmake b/cmake/modules/CheckCompiler.cmake index e25d601..c0f22bd 100644 --- a/cmake/modules/CheckCompiler.cmake +++ b/cmake/modules/CheckCompiler.cmake @@ -75,6 +75,11 @@ endif() #---Need to locate thead libraries and options to set properly some compilation flags---------------- find_package(Threads) +if(CMAKE_USE_PTHREADS_INIT) + set(CMAKE_THREAD_FLAG -pthread) +else() + set(CMAKE_THREAD_FLAG) +endif() #---Setup details depending opn the major platform type---------------------------------------------- if(CMAKE_SYSTEM_NAME MATCHES Linux) @@ -85,6 +90,9 @@ elseif(WIN32) include(SetupWindows) endif() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_FLAG}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_THREAD_FLAG}") + if(cxx11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if(CMAKE_COMPILER_IS_GNUCXX) diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index e2db2b4..76af457 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -170,6 +170,7 @@ ROOT_BUILD_OPTION(srp ON "SRP support, requires SRP source tree") ROOT_BUILD_OPTION(ssl ON "SSL encryption support, requires openssl") ROOT_BUILD_OPTION(gnuinstall OFF "Perform installation following the GNU guidelines") ROOT_BUILD_OPTION(table ${table_defvalue} "Build libTable contrib library") +ROOT_BUILD_OPTION(thread ON "Using thread library (cannot be disabled)") ROOT_BUILD_OPTION(tmva ON "Build TMVA multi variate analysis library") ROOT_BUILD_OPTION(unuran ${unuran_defvalue} "UNURAN - package for generating non-uniform random numbers") ROOT_BUILD_OPTION(vc ${vc_defvalue} "Vc adds a few new types for portable and intuitive SIMD programming") diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index 955ebde..b63c543 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -72,8 +72,8 @@ set(xpmlibdir -L${X11_LIBRARY_DIR}) set(xpmlib ${X11_Xpm_LIB}) set(enable_xft ${value${xft}}) -set(enable_thread yes) -set(threadflag) +set(enable_thread ${value${thread}}) +set(threadflag ${CMAKE_THREAD_FLAG}) set(threadlibdir) set(threadlib ${CMAKE_THREAD_LIBS_INIT}) -- 1.8.2