| 1 | # This is mainly for Windows declspec, but other platforms know |
|---|
| 2 | # what to do with it. |
|---|
| 3 | ADD_DEFINITIONS(-DOPENTHREADS_EXPORTS) |
|---|
| 4 | |
|---|
| 5 | SET(OPENTHREADS_MAJOR_VERSION 2) |
|---|
| 6 | SET(OPENTHREADS_MINOR_VERSION 5) |
|---|
| 7 | SET(OPENTHREADS_PATCH_VERSION 0) |
|---|
| 8 | SET(OPENTHREADS_SOVERSION 12) |
|---|
| 9 | |
|---|
| 10 | SET(OPENTHREADS_VERSION ${OPENTHREADS_MAJOR_VERSION}.${OPENTHREADS_MINOR_VERSION}.${OPENTHREADS_PATCH_VERSION}) |
|---|
| 11 | |
|---|
| 12 | INCLUDE(CheckAtomicOps) |
|---|
| 13 | |
|---|
| 14 | # User Options |
|---|
| 15 | OPTION(DYNAMIC_OPENTHREADS "Set to ON to build OpenThreads for dynamic linking. Use OFF for static." ON) |
|---|
| 16 | IF(DYNAMIC_OPENTHREADS) |
|---|
| 17 | SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED") |
|---|
| 18 | ELSE() |
|---|
| 19 | SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC") |
|---|
| 20 | SET(OT_LIBRARY_STATIC 1) |
|---|
| 21 | ENDIF() |
|---|
| 22 | |
|---|
| 23 | ################################################################################ |
|---|
| 24 | # Set Config file |
|---|
| 25 | |
|---|
| 26 | SET(OPENTHREADS_CONFIG_HEADER "${PROJECT_BINARY_DIR}/include/OpenThreads/Config") |
|---|
| 27 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/common/Config.in" |
|---|
| 28 | "${OPENTHREADS_CONFIG_HEADER}") |
|---|
| 29 | |
|---|
| 30 | SET(OPENTHREADS_VERSION_HEADER "${PROJECT_SOURCE_DIR}/include/OpenThreads/Version") |
|---|
| 31 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/common/Version.in" |
|---|
| 32 | "${OPENTHREADS_VERSION_HEADER}") |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | ################################################################################ |
|---|
| 36 | # Set Version Info resource file |
|---|
| 37 | |
|---|
| 38 | IF(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}") |
|---|
| 42 | ENDIF() |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | # INSTALL_FILES(/include/OpenThreads/ FILES "${OPENTHREADS_CONFIG_HEADER}") |
|---|
| 46 | |
|---|
| 47 | ################################################################################ |
|---|
| 48 | |
|---|
| 49 | SET(HEADER_PATH ${OpenThreads_SOURCE_DIR}/include/OpenThreads) |
|---|
| 50 | SET(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. |
|---|
| 66 | FIND_PACKAGE(Threads) |
|---|
| 67 | |
|---|
| 68 | # Do we have sproc? |
|---|
| 69 | IF(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() |
|---|
| 78 | ENDIF(CMAKE_SYSTEM MATCHES IRIX) |
|---|
| 79 | |
|---|
| 80 | # Maybe we should be using the FindThreads.cmake module? |
|---|
| 81 | IF(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() |
|---|
| 90 | ELSE() |
|---|
| 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() |
|---|
| 100 | ENDIF() |
|---|
| 101 | |
|---|
| 102 | # Make sure everyone can find Config |
|---|
| 103 | INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/include) |
|---|
| 104 | |
|---|
| 105 | # Generate pkg-config configuration file |
|---|
| 106 | |
|---|
| 107 | CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/openthreads.pc.in |
|---|
| 108 | ${PROJECT_BINARY_DIR}/packaging/pkgconfig/openthreads.pc |
|---|
| 109 | @ONLY |
|---|
| 110 | ) |
|---|
| 111 | |
|---|
| 112 | INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/openthreads.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig COMPONENT libopenthreads-dev) |
|---|