root/OpenSceneGraph/trunk/src/OpenThreads/CMakeLists.txt @ 11179

Revision 11179, 3.6 kB (checked in by robert, 5 years ago)

Added automatic updating of the OpenThreads? version number from the CMake version numbers

Line 
1# This is mainly for Windows declspec, but other platforms know
2# what to do with it.
3ADD_DEFINITIONS(-DOPENTHREADS_EXPORTS)
4
5SET(OPENTHREADS_MAJOR_VERSION 2)
6SET(OPENTHREADS_MINOR_VERSION 5)
7SET(OPENTHREADS_PATCH_VERSION 0)
8SET(OPENTHREADS_SOVERSION 12)
9
10SET(OPENTHREADS_VERSION ${OPENTHREADS_MAJOR_VERSION}.${OPENTHREADS_MINOR_VERSION}.${OPENTHREADS_PATCH_VERSION})
11
12INCLUDE(CheckAtomicOps)
13
14# User Options
15OPTION(DYNAMIC_OPENTHREADS "Set to ON to build OpenThreads for dynamic linking.  Use OFF for static." ON)
16IF(DYNAMIC_OPENTHREADS)
17    SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
18ELSE()
19    SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
20    SET(OT_LIBRARY_STATIC 1)
21ENDIF()
22
23################################################################################
24# Set Config file
25
26SET(OPENTHREADS_CONFIG_HEADER "${PROJECT_BINARY_DIR}/include/OpenThreads/Config")
27CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/common/Config.in"
28               "${OPENTHREADS_CONFIG_HEADER}")
29
30SET(OPENTHREADS_VERSION_HEADER "${PROJECT_SOURCE_DIR}/include/OpenThreads/Version")
31CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/common/Version.in"
32               "${OPENTHREADS_VERSION_HEADER}")
33
34
35################################################################################
36# Set Version Info resource file
37
38IF(MSVC)
39    SET(OPENTHREADS_VERSIONINFO_RC "${PROJECT_BINARY_DIR}/PlatformSpecifics/Windows/OpenThreadsVersionInfo.rc")
40    CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/OpenThreadsVersionInfo.rc.in"
41                   "${OPENTHREADS_VERSIONINFO_RC}")
42ENDIF()
43
44
45# INSTALL_FILES(/include/OpenThreads/ FILES "${OPENTHREADS_CONFIG_HEADER}")
46
47################################################################################
48
49SET(HEADER_PATH ${OpenThreads_SOURCE_DIR}/include/OpenThreads)
50SET(OpenThreads_PUBLIC_HEADERS
51    ${HEADER_PATH}/Atomic
52    ${HEADER_PATH}/Barrier
53    ${HEADER_PATH}/Block
54    ${HEADER_PATH}/Condition
55    ${HEADER_PATH}/Exports
56    ${HEADER_PATH}/Mutex 
57    ${HEADER_PATH}/ReadWriteMutex 
58    ${HEADER_PATH}/ReentrantMutex 
59    ${HEADER_PATH}/ScopedLock 
60    ${HEADER_PATH}/Thread
61    ${HEADER_PATH}/Version
62    ${OPENTHREADS_CONFIG_HEADER}
63)
64
65# Use our modified version of FindThreads.cmake which has Sproc hacks.
66FIND_PACKAGE(Threads)
67
68# Do we have sproc?
69IF(CMAKE_SYSTEM MATCHES IRIX)
70    IF(CMAKE_USE_SPROC_INIT)
71        # In this case, only Sproc exists, so no option.
72        SET(OPENTHREADS_USE_SPROC_INSTEAD_OF_PTHREADS 1)
73    ELSE()
74        IF(CMAKE_HAVE_SPROC_H)
75            OPTION(OPENTHREADS_USE_SPROC_INSTEAD_OF_PTHREADS "Set to ON to build OpenThreads against sproc instead of pthreads" OFF)
76        ENDIF()
77    ENDIF()
78ENDIF(CMAKE_SYSTEM MATCHES IRIX)
79
80# Maybe we should be using the FindThreads.cmake module?
81IF(WIN32)
82    # So I think Cygwin wants to use pthreads
83    IF(CYGWIN)
84        SUBDIRS(pthreads)
85    ELSE()
86        # Everybody else including Msys should probably go here
87        SUBDIRS(win32)
88        # examples)
89    ENDIF()
90ELSE()
91    IF(UNIX)
92        IF(OPENTHREADS_USE_SPROC_INSTEAD_OF_PTHREADS)
93            SUBDIRS(sproc)
94        ELSE()
95            SUBDIRS(pthreads)
96        ENDIF()
97    ELSE()
98        MESSAGE("Sorry, OpenThreads may not support your platform")
99    ENDIF()
100ENDIF()
101
102# Make sure everyone can find Config
103INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/include)
104
105# Generate pkg-config configuration file
106
107CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/openthreads.pc.in
108        ${PROJECT_BINARY_DIR}/packaging/pkgconfig/openthreads.pc
109    @ONLY
110    )
111
112INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/openthreads.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig  COMPONENT libopenthreads-dev)
Note: See TracBrowser for help on using the browser.