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
f1e7b37c
Commit
f1e7b37c
authored
Mar 17, 2014
by
Andreas Schuh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CheckCXXLibraryExists.cmake module and use it in FindTreadsCXX.cmake.
parent
1b1b61d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
6 deletions
+86
-6
CMakeLists.txt
CMakeLists.txt
+1
-1
CheckCXXLibraryExists.cmake
cmake/CheckCXXLibraryExists.cmake
+80
-0
FindThreadsCxx.cmake
cmake/FindThreadsCxx.cmake
+5
-5
No files found.
CMakeLists.txt
View file @
f1e7b37c
...
...
@@ -103,7 +103,7 @@ foreach (fname IN ITEMS strtoll strtoq)
endforeach
()
set
(
CMAKE_THREAD_PREFER_PTHREAD TRUE
)
find_package
(
ThreadsC
xx
)
find_package
(
ThreadsC
XX
)
if
(
Threads_FOUND AND CMAKE_USE_PTHREADS_INIT
)
set
(
GFLAGS_HAVE_PTHREAD TRUE
)
check_type_size
(
pthread_rwlock_t GFLAGS_HAVE_RWLOCK LANGUAGE CXX
)
...
...
cmake/CheckCXXLibraryExists.cmake
0 → 100644
View file @
f1e7b37c
#.rst:
# CheckLibraryExists
# ------------------
#
# Check if the function exists.
#
# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE)
#
# ::
#
# LIBRARY - the name of the library you are looking for
# FUNCTION - the name of the function
# LOCATION - location where the library should be found
# VARIABLE - variable to store the result
#
#
#
# The following variables may be set before calling this macro to modify
# the way the check is run:
#
# ::
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
macro
(
CHECK_CXX_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE
)
if
(
"
${
VARIABLE
}
"
MATCHES
"^
${
VARIABLE
}
$"
)
set
(
MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
"-DCHECK_FUNCTION_EXISTS=
${
FUNCTION
}
${
CMAKE_REQUIRED_FLAGS
}
"
)
message
(
STATUS
"Looking for
${
FUNCTION
}
in
${
LIBRARY
}
"
)
set
(
CHECK_LIBRARY_EXISTS_LIBRARIES
${
LIBRARY
}
)
if
(
CMAKE_REQUIRED_LIBRARIES
)
set
(
CHECK_LIBRARY_EXISTS_LIBRARIES
${
CHECK_LIBRARY_EXISTS_LIBRARIES
}
${
CMAKE_REQUIRED_LIBRARIES
}
)
endif
()
configure_file
(
${
CMAKE_ROOT
}
/Modules/CheckFunctionExists.c
${
CMAKE_BINARY_DIR
}
/CheckFunctionExists.cxx COPYONLY
)
try_compile
(
${
VARIABLE
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
/CheckFunctionExists.cxx
COMPILE_DEFINITIONS
${
CMAKE_REQUIRED_DEFINITIONS
}
LINK_LIBRARIES
${
CHECK_LIBRARY_EXISTS_LIBRARIES
}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=
${
MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
}
-DLINK_DIRECTORIES:STRING=
${
LOCATION
}
OUTPUT_VARIABLE OUTPUT
)
if
(
${
VARIABLE
}
)
message
(
STATUS
"Looking for
${
FUNCTION
}
in
${
LIBRARY
}
- found"
)
set
(
${
VARIABLE
}
1 CACHE INTERNAL
"Have library
${
LIBRARY
}
"
)
file
(
APPEND
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CMakeOutput.log
"Determining if the function
${
FUNCTION
}
exists in the
${
LIBRARY
}
"
"passed with the following output:
\n
"
"
${
OUTPUT
}
\n\n
"
)
else
()
message
(
STATUS
"Looking for
${
FUNCTION
}
in
${
LIBRARY
}
- not found"
)
set
(
${
VARIABLE
}
""
CACHE INTERNAL
"Have library
${
LIBRARY
}
"
)
file
(
APPEND
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CMakeError.log
"Determining if the function
${
FUNCTION
}
exists in the
${
LIBRARY
}
"
"failed with the following output:
\n
"
"
${
OUTPUT
}
\n\n
"
)
endif
()
endif
()
endmacro
()
cmake/FindThreadsCxx.cmake
View file @
f1e7b37c
...
...
@@ -34,7 +34,7 @@
# License text for the above reference.)
include
(
CheckIncludeFileCXX
)
include
(
CheckLibraryExists
)
include
(
Check
CXX
LibraryExists
)
include
(
CheckCXXSymbolExists
)
set
(
Threads_FOUND FALSE
)
...
...
@@ -67,7 +67,7 @@ else()
if
(
NOT CMAKE_HAVE_THREADS_LIBRARY
)
# Do we have -lpthreads
CHECK_LIBRARY_EXISTS
(
pthreads pthread_create
""
CMAKE_HAVE_PTHREADS_CREATE
)
CHECK_
CXX_
LIBRARY_EXISTS
(
pthreads pthread_create
""
CMAKE_HAVE_PTHREADS_CREATE
)
if
(
CMAKE_HAVE_PTHREADS_CREATE
)
set
(
CMAKE_THREAD_LIBS_INIT
"-lpthreads"
)
set
(
CMAKE_HAVE_THREADS_LIBRARY 1
)
...
...
@@ -75,7 +75,7 @@ else()
endif
()
# Ok, how about -lpthread
CHECK_LIBRARY_EXISTS
(
pthread pthread_create
""
CMAKE_HAVE_PTHREAD_CREATE
)
CHECK_
CXX_
LIBRARY_EXISTS
(
pthread pthread_create
""
CMAKE_HAVE_PTHREAD_CREATE
)
if
(
CMAKE_HAVE_PTHREAD_CREATE
)
set
(
CMAKE_THREAD_LIBS_INIT
"-lpthread"
)
set
(
CMAKE_HAVE_THREADS_LIBRARY 1
)
...
...
@@ -84,7 +84,7 @@ else()
if
(
CMAKE_SYSTEM MATCHES
"SunOS.*"
)
# On sun also check for -lthread
CHECK_LIBRARY_EXISTS
(
thread thr_create
""
CMAKE_HAVE_THR_CREATE
)
CHECK_
CXX_
LIBRARY_EXISTS
(
thread thr_create
""
CMAKE_HAVE_THR_CREATE
)
if
(
CMAKE_HAVE_THR_CREATE
)
set
(
CMAKE_THREAD_LIBS_INIT
"-lthread"
)
set
(
CMAKE_HAVE_THREADS_LIBRARY 1
)
...
...
@@ -153,7 +153,7 @@ if(CMAKE_USE_PTHREADS_INIT)
# but we need to maintain compatibility here.
# The CMAKE_HP_PTHREADS setting actually indicates whether CMA threads
# are available.
CHECK_LIBRARY_EXISTS
(
cma pthread_attr_create
""
CMAKE_HAVE_HP_CMA
)
CHECK_
CXX_
LIBRARY_EXISTS
(
cma pthread_attr_create
""
CMAKE_HAVE_HP_CMA
)
if
(
CMAKE_HAVE_HP_CMA
)
set
(
CMAKE_THREAD_LIBS_INIT
"-lcma"
)
set
(
CMAKE_HP_PTHREADS_INIT 1
)
...
...
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