Home | History | Annotate | Download | only in dethread
      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 OR DE_OS_IS_SYMBIAN)
     41 	add_definitions(-D_XOPEN_SOURCE=600)
     42 	set(DETHREAD_SRCS
     43 		${DETHREAD_SRCS}
     44 		unix/deMutexUnix.c
     45 		unix/deSemaphoreUnix.c
     46 		unix/deThreadUnix.c
     47 		unix/deThreadLocalUnix.c
     48 		)
     49 
     50 	if (DE_OS_IS_UNIX)
     51 		set(DETHREAD_LIBS ${DETHREAD_LIBS} pthread)
     52 	elseif (DE_OS_IS_SYMBIAN)
     53 		find_file(PTHREAD_LIB libpthread.dso PATHS ${SYMBIAN_LIB_DIR} NO_CMAKE_FIND_ROOT_PATH)
     54 		set(DETHREAD_LIBS ${DETHREAD_LIBS} ${PTHREAD_LIB})
     55     endif ()
     56 
     57 elseif (DE_OS_IS_OSX OR DE_OS_IS_IOS)
     58 	add_definitions(-D_XOPEN_SOURCE=600)
     59 	# \note OS X doesn't support unnamed semaphores.
     60 	set(DETHREAD_SRCS
     61 		${DETHREAD_SRCS}
     62 		unix/deMutexUnix.c
     63 		unix/deNamedSemaphoreUnix.c
     64 		unix/deThreadUnix.c
     65 		unix/deThreadLocalUnix.c
     66 		)
     67 
     68 else ()
     69 	message(FATAL_ERROR "Unsupported os for dethread")
     70 endif ()
     71 
     72 add_library(dethread STATIC ${DETHREAD_SRCS})
     73 target_link_libraries(dethread ${DETHREAD_LIBS})
     74 
     75 set(DETHREAD_STANDALONE_TEST ON CACHE STRING "Build standalone binary for testing dethread.")
     76 
     77 if (DETHREAD_STANDALONE_TEST AND (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX))
     78 	add_executable(dethread_test standalone_test.c)
     79 	target_link_libraries(dethread_test dethread debase)
     80 endif ()
     81