Fix C++11 library check's thread dependency
authorRoland Schulz <roland.schulz@intel.com>
Tue, 5 Dec 2017 20:41:18 +0000 (12:41 -0800)
committerErik Lindahl <erik.lindahl@gmail.com>
Thu, 7 Dec 2017 13:37:29 +0000 (14:37 +0100)
Test was depending on thread library without explicit linking it,
which some compiler require.

Fixes #2051

Change-Id: I9929d9373a4e8caa393f548d25a78bc03c016bf9

cmake/gmxTestCXX11.cmake

index a9d58547a76cb38c75d62e8871526969154d2c03..9b559c6e20da23a322158ed19e287eedd8fa9c41 100644 (file)
@@ -33,6 +33,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 include(CheckCXXSourceCompiles)
+include(FindThreads)
 
 # Check whether both a suitable C++11-compatible compiler and standard
 # library is available, and give a fatal error if not.
@@ -155,7 +156,7 @@ int main() {
     # Now check the standard library is OK
 
     set(CMAKE_REQUIRED_FLAGS "${CXX11_CXX_FLAG} ${${STDLIB_CXX_FLAG_NAME}}")
-    set(CMAKE_REQUIRED_LIBRARIES "${${STDLIB_LIBRARIES_NAME}}")
+    set(CMAKE_REQUIRED_LIBRARIES "${${STDLIB_LIBRARIES_NAME}} ${CMAKE_THREAD_LIBS_INIT}")
     check_cxx_source_compiles(
 "#include <algorithm>
 #include <array>