root/OpenSceneGraph/trunk/src/OpenThreads/pthreads/CMakeLists.txt @ 9359

Revision 9359, 3.8 kB (checked in by robert, 6 years ago)

From Mattias Helsing,"Added doc/Doxyfiles/openthreads.doxyfile.cmake
Updated all doxyfiles under doc/Doxyfiles. They are now all processed
by cmake but make targets are only generated for
OpenSceneGraphReferenceDocs? and OpenThreadsReferenceDocs?. The others
can be run with doxygen directly in <builddir>/doc.
Fixed a copy-paste in openthreads sproc and pthreads CMakeLists
Added the osg logo to the html footers
Added possibility to get generation of chm files.

CMakeLists (toplevel):
Added install of osg and ot reference docs. This also generates
packaging targets of openscenegraph-doc and openthreads-doc if you
have packaging enabled
Removed the unused USING_OP_OT_TRIPLE_SET since there was no way of
enabling it anyway
Removed BUILD_REF_DOCS. IMO it was redundant - BUILD_DOCUMENTATION
does the same thing and we get that anyway from including
Documentation.cmake.
OsgCPack.cmake:
Removed generation of PACKAGE_SRC for msvc
Added special handling for -doc packaging targets - they don't require
system, architecture or compiler"

Line 
1# This file should only be included when using Pthreads
2
3INCLUDE (CheckFunctionExists)
4INCLUDE (CheckLibraryExists)
5INCLUDE (CheckSymbolExists)
6INCLUDE (CheckCXXSourceCompiles)
7
8SET(LIB_NAME OpenThreads)
9SET(LIB_PUBLIC_HEADERS ${OpenThreads_PUBLIC_HEADERS})
10
11ADD_LIBRARY(${LIB_NAME}
12    ${OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC}
13    ${LIB_PUBLIC_HEADERS}
14    PThread.c++
15    PThreadBarrier.c++
16    PThreadBarrierPrivateData.h
17    PThreadCondition.c++
18    PThreadConditionPrivateData.h
19    PThreadMutex.c++
20    PThreadMutexPrivateData.h
21    PThreadPrivateData.h
22    ../common/Version.cpp
23    ../common/Atomic.cpp
24)
25
26IF(OPENTHREADS_SONAMES)
27  SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${OPENTHREADS_VERSION} SOVERSION ${OPENTHREADS_SOVERSION})
28ENDIF(OPENTHREADS_SONAMES)
29
30SET(CMAKE_REQUIRED_LIBRARIES_SAFE "${CMAKE_REQUIRED_LIBRARIES}")
31SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
32
33CHECK_FUNCTION_EXISTS(pthread_yield HAVE_PTHREAD_YIELD)
34IF(HAVE_PTHREAD_YIELD)
35  ADD_DEFINITIONS(-DHAVE_PTHREAD_YIELD)
36ELSE(HAVE_PTHREAD_YIELD)
37  # sched_yield appears not in libc, pthreads or whatever on some systems
38  CHECK_FUNCTION_EXISTS(sched_yield HAVE_SCHED_YIELD)
39  IF(NOT HAVE_SCHED_YIELD)
40    CHECK_LIBRARY_EXISTS(rt sched_yield "" HAVE_SCHED_YIELD)
41    IF(HAVE_SCHED_YIELD)
42      SET(CMAKE_THREAD_LIBS_INIT "${CMAKE_THREAD_LIBS_INIT} -lrt")
43    ENDIF(HAVE_SCHED_YIELD)
44  ENDIF(NOT HAVE_SCHED_YIELD)
45  IF(HAVE_SCHED_YIELD)
46    ADD_DEFINITIONS(-DHAVE_SCHED_YIELD)
47  ENDIF(HAVE_SCHED_YIELD)
48ENDIF(HAVE_PTHREAD_YIELD)
49
50IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
51  # need to have that for pthread_setaffinity_np on linux
52  ADD_DEFINITIONS(-D_GNU_SOURCE)
53  SET(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE")
54ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
55
56CHECK_FUNCTION_EXISTS(pthread_setconcurrency HAVE_PTHREAD_SETCONCURRENCY)
57IF(HAVE_PTHREAD_SETCONCURRENCY)
58  ADD_DEFINITIONS(-DHAVE_PTHREAD_SETCONCURRENCY)
59ENDIF(HAVE_PTHREAD_SETCONCURRENCY)
60
61CHECK_FUNCTION_EXISTS(pthread_getconcurrency HAVE_PTHREAD_GETCONCURRENCY)
62IF(HAVE_PTHREAD_GETCONCURRENCY)
63  ADD_DEFINITIONS(-DHAVE_PTHREAD_GETCONCURRENCY)
64ENDIF(HAVE_PTHREAD_GETCONCURRENCY)
65
66CHECK_FUNCTION_EXISTS(pthread_setaffinity_np HAVE_PTHREAD_SETAFFINITY_NP)
67IF(HAVE_PTHREAD_SETAFFINITY_NP)
68  ADD_DEFINITIONS(-DHAVE_PTHREAD_SETAFFINITY_NP)
69ELSE(HAVE_PTHREAD_SETAFFINITY_NP)
70  CHECK_CXX_SOURCE_COMPILES("
71#include <sched.h>
72int main() {
73  cpu_set_t cpumask;
74  sched_setaffinity( 0, sizeof(cpumask), &cpumask );
75  return 0;
76}" HAVE_THREE_PARAM_SCHED_SETAFFINITY)
77  IF(HAVE_THREE_PARAM_SCHED_SETAFFINITY)
78    ADD_DEFINITIONS(-DHAVE_THREE_PARAM_SCHED_SETAFFINITY)
79  ELSE(HAVE_THREE_PARAM_SCHED_SETAFFINITY)
80    CHECK_CXX_SOURCE_COMPILES("
81#include <sched.h>
82int main() {
83  cpu_set_t cpumask;
84  sched_setaffinity( 0, &cpumask );
85  return 0;
86}" HAVE_TWO_PARAM_SCHED_SETAFFINITY)
87    IF(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
88      ADD_DEFINITIONS(-DHAVE_TWO_PARAM_SCHED_SETAFFINITY)
89    ENDIF(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
90  ENDIF(HAVE_THREE_PARAM_SCHED_SETAFFINITY)
91ENDIF(HAVE_PTHREAD_SETAFFINITY_NP)
92
93SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_SAFE}")
94
95TARGET_LINK_LIBRARIES(${LIB_NAME}
96    ${CMAKE_THREAD_LIBS_INIT}
97)
98
99# Since we're building different platforms binaries in
100# their respective directories, we need to set the
101# link directory so it can find this location.
102LINK_DIRECTORIES(
103    ${CMAKE_CURRENT_BINARY_DIR}
104)
105
106INSTALL(
107    TARGETS OpenThreads
108    ARCHIVE DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads-dev
109    LIBRARY DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads
110    RUNTIME DESTINATION bin COMPONENT libopenthreads
111)
112INSTALL(
113    FILES ${OpenThreads_PUBLIC_HEADERS}
114    DESTINATION include/OpenThreads
115    COMPONENT libopenthreads-dev
116)
117
118#commented out# INCLUDE(ModuleInstall OPTIONAL)
Note: See TracBrowser for help on using the browser.