chiark / gitweb /
Fix THREADLOCAL definition
authorJulien Schueller <schueller@phimeca.com>
Thu, 20 Sep 2018 12:00:59 +0000 (14:00 +0200)
committerJulien Schueller <schueller@phimeca.com>
Thu, 20 Sep 2018 14:43:49 +0000 (16:43 +0200)
Fixes #216

CMakeLists.txt

index f34bd5d353208b9aea822959dc5172e5a04b001d..542d1a2930a124a3a10b86b849c0713cee23c187 100644 (file)
@@ -138,7 +138,7 @@ if (NOT DEFINED HAVE_FPCLASSIFY)
 endif ()
 
 option (WITH_THREADLOCAL "check thread local keyword" ON)
-if (WITH_THREADLOCAL AND NOT DEFINED HAVE_THREAD_LOCAL_STORAGE)
+if (WITH_THREADLOCAL AND NOT DEFINED THREADLOCAL)
   foreach (_THREADLOCAL_KEY "__thread" "__declspec(thread)")
     unset (HAVE_THREAD_LOCAL_STORAGE CACHE)
     check_c_source_compiles("
@@ -147,12 +147,13 @@ if (WITH_THREADLOCAL AND NOT DEFINED HAVE_THREAD_LOCAL_STORAGE)
     int main(void) {
         return 0;
     }" HAVE_THREAD_LOCAL_STORAGE)
-    if (${HAVE_THREAD_LOCAL_STORAGE})
-      set (THREADLOCAL ${_THREADLOCAL_KEY})
+    if (HAVE_THREAD_LOCAL_STORAGE)
+      set (THREADLOCAL ${_THREADLOCAL_KEY} CACHE STRING "Thread local keyword")
     endif ()
   endforeach()
 endif ()
 
+
 if (NLOPT_CXX OR NLOPT_PYTHON OR NLOPT_GUILE OR NLOPT_OCTAVE)
   check_cxx_symbol_exists (__cplusplus ciso646 SYSTEM_HAS_CXX)
   if (SYSTEM_HAS_CXX)