1 # dethread cmake file 2 3 if (NOT DE_DEFS) 4 message(FATAL_ERROR "Include Defs.cmake") 5 endif () 6 7 set(DETHREAD_SRCS 8 deAtomic.c 9 deAtomic.h 10 deMutex.h 11 deSemaphore.h 12 deSingleton.c 13 deSingleton.h 14 deThread.h 15 deThreadLocal.h 16 deThreadTest.c 17 deThreadTest.h 18 ) 19 20 set(DETHREAD_LIBS 21 debase 22 depool 23 ) 24 25 include_directories( 26 ../debase 27 ../depool 28 ${CMAKE_CURRENT_SOURCE_DIR} 29 ) 30 31 if (DE_OS_IS_WIN32 OR DE_OS_IS_WINCE) 32 set(DETHREAD_SRCS 33 ${DETHREAD_SRCS} 34 win32/deMutexWin32.c 35 win32/deSemaphoreWin32.c 36 win32/deThreadWin32.c 37 win32/deThreadLocalWin32.c 38 ) 39 40 elseif (DE_OS_IS_UNIX OR DE_OS_IS_ANDROID) 41 if (DE_OS_IS_UNIX) 42 add_definitions(-D_GNU_SOURCE) 43 set(DETHREAD_LIBS ${DETHREAD_LIBS} pthread) 44 else () 45 add_definitions(-D_XOPEN_SOURCE=600) 46 endif () 47 48 set(DETHREAD_SRCS 49 ${DETHREAD_SRCS} 50 unix/deMutexUnix.c 51 unix/deSemaphoreUnix.c 52 unix/deThreadUnix.c 53 unix/deThreadLocalUnix.c 54 ) 55 56 elseif (DE_OS_IS_OSX OR DE_OS_IS_IOS) 57 add_definitions(-D_XOPEN_SOURCE=600) 58 # \note OS X doesn't support unnamed semaphores. 59 set(DETHREAD_SRCS 60 ${DETHREAD_SRCS} 61 unix/deMutexUnix.c 62 unix/deNamedSemaphoreUnix.c 63 unix/deThreadUnix.c 64 unix/deThreadLocalUnix.c 65 ) 66 67 else () 68 message(FATAL_ERROR "Unsupported os for dethread") 69 endif () 70 71 add_library(dethread STATIC ${DETHREAD_SRCS}) 72 target_link_libraries(dethread ${DETHREAD_LIBS}) 73 74 set(DETHREAD_STANDALONE_TEST ON CACHE STRING "Build standalone binary for testing dethread.") 75 76 if (DETHREAD_STANDALONE_TEST AND (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX)) 77 add_executable(dethread_test standalone_test.c) 78 target_link_libraries(dethread_test dethread debase) 79 endif () 80