forked from torch/threads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
63 lines (54 loc) · 1.49 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
cmake_minimum_required (VERSION 2.8)
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_MODULE_PATH}")
find_package(Torch REQUIRED)
set(src
lib/init.c
lib/THThread.c
)
set(luasrc
init.lua
threads.lua
serialize.lua
sharedserialize.lua
queue.lua
)
ADD_LIBRARY(threadsmain MODULE lib/thread-main.c)
IF(APPLE)
SET_TARGET_PROPERTIES(threadsmain PROPERTIES
LINK_FLAGS "-undefined dynamic_lookup")
ENDIF()
INSTALL(TARGETS threadsmain LIBRARY DESTINATION "${Torch_INSTALL_LIB_SUBDIR}")
if(WIN32)
link_directories(${LINK_DIRECTORIES} ${WIN_DLFCN_LIBDIR})
include_directories(${INCLUDE_DIRECTORIES} ${WIN_DLFCN_INCDIR})
endif()
add_torch_package(threads "${src}" "${luasrc}" "Threads")
target_link_libraries(threads luaT TH)
if(WIN32)
target_link_libraries(threads dl)
endif()
if(WIN32 AND (NOT DEFINED USE_PTHREAD_THREADS))
add_definitions(-DUSE_WIN32_THREADS=1)
else()
if(WIN32)
add_definitions(-D_TIMESPEC_DEFINED=1)
endif()
set(CMAKE_THREAD_PREFER_PTHREAD)
find_package(Threads REQUIRED)
if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
add_definitions(-DUSE_PTHREAD_THREADS=1)
if(PTHREAD_LIB_NAME)
target_link_libraries(threads ${PTHREAD_LIB_NAME})
else()
target_link_libraries(threads ${CMAKE_THREAD_LIBS_INIT})
endif()
else()
message(FATAL_ERROR "no threading system (pthread or Win32) available")
endif()
endif()
IF(LUALIB)
TARGET_LINK_LIBRARIES(threads ${LUALIB})
TARGET_LINK_LIBRARIES(threadsmain ${LUALIB})
ENDIF()