CMake/Modules/FindOpenThreads.cmake
Brad King 86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00

125 lines
3.7 KiB
CMake

# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindOpenThreads
# ---------------
#
#
#
# OpenThreads is a C++ based threading library. Its largest userbase
# seems to OpenSceneGraph so you might notice I accept OSGDIR as an
# environment path. I consider this part of the Findosg* suite used to
# find OpenSceneGraph components. Each component is separate and you
# must opt in to each module.
#
# Locate OpenThreads This module defines OPENTHREADS_LIBRARY
# OPENTHREADS_FOUND, if false, do not try to link to OpenThreads
# OPENTHREADS_INCLUDE_DIR, where to find the headers
#
# $OPENTHREADS_DIR is an environment variable that would correspond to
# the ./configure --prefix=$OPENTHREADS_DIR used in building osg.
#
# [CMake 2.8.10]: The CMake variables OPENTHREADS_DIR or OSG_DIR can now
# be used as well to influence detection, instead of needing to specify
# an environment variable.
#
# Created by Eric Wing.
# Header files are presumed to be included like
# #include <OpenThreads/Thread>
# To make it easier for one-step automated configuration/builds,
# we leverage environmental paths. This is preferable
# to the -DVAR=value switches because it insulates the
# users from changes we may make in this script.
# It also offers a little more flexibility than setting
# the CMAKE_*_PATH since we can target specific components.
# However, the default CMake behavior will search system paths
# before anything else. This is problematic in the cases
# where you have an older (stable) version installed, but
# are trying to build a newer version.
# CMake doesn't offer a nice way to globally control this behavior
# so we have to do a nasty "double FIND_" in this module.
# The first FIND disables the CMAKE_ search paths and only checks
# the environmental paths.
# If nothing is found, then the second find will search the
# standard install paths.
# Explicit -DVAR=value arguments should still be able to override everything.
find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
HINTS
ENV OPENTHREADS_INCLUDE_DIR
ENV OPENTHREADS_DIR
ENV OSG_INCLUDE_DIR
ENV OSG_DIR
ENV OSGDIR
ENV OpenThreads_ROOT
ENV OSG_ROOT
${OPENTHREADS_DIR}
${OSG_DIR}
PATHS
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
/usr/freeware
PATH_SUFFIXES include
)
find_library(OPENTHREADS_LIBRARY
NAMES OpenThreads OpenThreadsWin32
HINTS
ENV OPENTHREADS_LIBRARY_DIR
ENV OPENTHREADS_DIR
ENV OSG_LIBRARY_DIR
ENV OSG_DIR
ENV OSGDIR
ENV OpenThreads_ROOT
ENV OSG_ROOT
${OPENTHREADS_DIR}
${OSG_DIR}
PATHS
/sw
/opt/local
/opt/csw
/opt
/usr/freeware
PATH_SUFFIXES lib
)
find_library(OPENTHREADS_LIBRARY_DEBUG
NAMES OpenThreadsd OpenThreadsWin32d
HINTS
ENV OPENTHREADS_DEBUG_LIBRARY_DIR
ENV OPENTHREADS_LIBRARY_DIR
ENV OPENTHREADS_DIR
ENV OSG_LIBRARY_DIR
ENV OSG_DIR
ENV OSGDIR
ENV OpenThreads_ROOT
ENV OSG_ROOT
${OPENTHREADS_DIR}
${OSG_DIR}
PATHS
/sw
/opt/local
/opt/csw
/opt
/usr/freeware
PATH_SUFFIXES lib
)
if(OPENTHREADS_LIBRARY_DEBUG)
set(OPENTHREADS_LIBRARIES
optimized ${OPENTHREADS_LIBRARY}
debug ${OPENTHREADS_LIBRARY_DEBUG})
else()
set(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY})
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG
OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)