Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
gflags
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
gflags
Commits
b18fe77e
Commit
b18fe77e
authored
Mar 18, 2014
by
Andreas Schuh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix check for pthreads library on Ubuntu.
parent
b8f57174
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
5 deletions
+55
-5
CMakeLists.txt
CMakeLists.txt
+11
-1
CheckForPthreads.cxx
cmake/CheckForPthreads.cxx
+38
-0
FindThreadsCXX.cmake
cmake/FindThreadsCXX.cmake
+6
-4
No files found.
CMakeLists.txt
View file @
b18fe77e
...
@@ -145,15 +145,25 @@ set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
...
@@ -145,15 +145,25 @@ set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package
(
ThreadsCXX
)
find_package
(
ThreadsCXX
)
if
(
Threads_FOUND AND CMAKE_USE_PTHREADS_INIT
)
if
(
Threads_FOUND AND CMAKE_USE_PTHREADS_INIT
)
set
(
GFLAGS_HAVE_PTHREAD TRUE
)
set
(
GFLAGS_HAVE_PTHREAD TRUE
)
check_type_size
(
pthread_rwlock_t GFLAGS_HAVE_RWLOCK LANGUAGE CXX
)
check_type_size
(
pthread_rwlock_t RWLOCK LANGUAGE CXX
)
if
(
HAVE_RWLOCK
)
set
(
GFLAGS_HAVE_RWLOCK TRUE
)
else
()
set
(
GFLAGS_HAVE_RWLOCK FALSE
)
endif
()
else
()
else
()
set
(
GFLAGS_HAVE_PTHREAD FALSE
)
set
(
GFLAGS_HAVE_PTHREAD FALSE
)
endif
()
endif
()
if
(
UNIX AND NOT GFLAGS_HAVE_PTHREAD AND BUILD_gflags_LIB
)
if
(
UNIX AND NOT GFLAGS_HAVE_PTHREAD AND BUILD_gflags_LIB
)
set_property
(
CACHE BUILD_gflags_LIB PROPERTY VALUE OFF
)
set_property
(
CACHE BUILD_gflags_LIB PROPERTY VALUE OFF
)
if
(
CMAKE_HAVE_PTHREAD_H
)
message
(
WARNING
"Could not find the pthread(s) library."
" Disabling the build of the multi-threaded gflags library."
)
else
()
message
(
WARNING
"Could not find the <pthread.h> header file."
message
(
WARNING
"Could not find the <pthread.h> header file."
" Disabling the build of the multi-threaded gflags library."
)
" Disabling the build of the multi-threaded gflags library."
)
endif
()
endif
()
endif
()
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
...
...
cmake/CheckForPthreads.cxx
0 → 100644
View file @
b18fe77e
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
void
*
runner
(
void
*
);
int
res
=
0
;
#ifdef __CLASSIC_C__
int
main
(){
int
ac
;
char
*
av
[];
#else
int
main
(
int
ac
,
char
*
av
[]){
#endif
pthread_t
tid
[
2
];
pthread_create
(
&
tid
[
0
],
0
,
runner
,
(
void
*
)
1
);
pthread_create
(
&
tid
[
1
],
0
,
runner
,
(
void
*
)
2
);
#if defined(__BEOS__) && !defined(__ZETA__) // (no usleep on BeOS 5.)
usleep
(
1
);
// for strange behavior on single-processor sun
#endif
pthread_join
(
tid
[
0
],
0
);
pthread_join
(
tid
[
1
],
0
);
if
(
ac
>
1000
){
return
*
av
[
0
];}
return
res
;
}
void
*
runner
(
void
*
args
)
{
int
cc
;
for
(
cc
=
0
;
cc
<
10
;
cc
++
)
{
printf
(
"%p CC: %d
\n
"
,
args
,
cc
);
}
res
++
;
return
0
;
}
cmake/FindThreadsCXX.cmake
View file @
b18fe77e
...
@@ -38,6 +38,7 @@ include (CheckCXXLibraryExists)
...
@@ -38,6 +38,7 @@ include (CheckCXXLibraryExists)
include
(
CheckCXXSymbolExists
)
include
(
CheckCXXSymbolExists
)
set
(
Threads_FOUND FALSE
)
set
(
Threads_FOUND FALSE
)
# Do we have sproc?
# Do we have sproc?
if
(
CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD
)
if
(
CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD
)
CHECK_INCLUDE_FILES_CXX
(
"sys/types.h;sys/prctl.h"
CMAKE_HAVE_SPROC_H
)
CHECK_INCLUDE_FILES_CXX
(
"sys/types.h;sys/prctl.h"
CMAKE_HAVE_SPROC_H
)
...
@@ -95,14 +96,15 @@ else()
...
@@ -95,14 +96,15 @@ else()
endif
()
endif
()
if
(
NOT CMAKE_HAVE_THREADS_LIBRARY
)
if
(
NOT CMAKE_HAVE_THREADS_LIBRARY
)
# If we did not found -lpthread, -lpthread
, or -lthread, look for -pthread
# If we did not found -lpthread, -lpthread
s, or -lthread, look for -pthread
if
(
"THREADS_HAVE_PTHREAD_ARG"
MATCHES
"^THREADS_HAVE_PTHREAD_ARG"
)
if
(
"THREADS_HAVE_PTHREAD_ARG"
MATCHES
"^THREADS_HAVE_PTHREAD_ARG"
)
message
(
STATUS
"Check if compiler accepts -pthread"
)
message
(
STATUS
"Check if compiler accepts -pthread"
)
configure_file
(
"
${
CMAKE_ROOT
}
/Modules/CheckForPthreads.c"
"
${
CMAKE_BINARY_DIR
}
/CheckForPthreads.cxx"
COPYONLY
)
configure_file
(
"
${
CMAKE_CURRENT_LIST_DIR
}
/CheckForPthreads.cxx"
"
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CheckForPthreads.cxx"
COPYONLY
)
try_run
(
THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
try_run
(
THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
/CheckForPthreads.cxx
${
CMAKE_BINARY_DIR
}
${
CMAKE_FILES_DIRECTORY
}
/CheckForPthreads.cxx
CMAKE_FLAGS
-DLINK_LIBRARIES:STRING=-pthread
CMAKE_FLAGS
"-DLINK_LIBRARIES:STRING=-pthread;-DCMAKE_CXX_FLAGS:STRING=-fpermissive"
COMPILE_OUTPUT_VARIABLE OUTPUT
)
COMPILE_OUTPUT_VARIABLE OUTPUT
)
if
(
THREADS_HAVE_PTHREAD_ARG
)
if
(
THREADS_HAVE_PTHREAD_ARG
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment