-
Notifications
You must be signed in to change notification settings - Fork 370
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
55 lines (41 loc) · 2.22 KB
/
CMakeLists.txt
File metadata and controls
55 lines (41 loc) · 2.22 KB
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
set(TAICHI_PROJECT_NAME "differentiable_mpm")
file(GLOB_RECURSE PROJECT_SOURCES "src/*.cpp" "src/*.h" "src/*/*.h" "src/*/*.cpp" "src/*.cuh")
file(GLOB_RECURSE PROJECT_OP_SOURCES "src/*.cc")
file(GLOB_RECURSE PROJECT_SOURCES_CUDA "src/*.cu")
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(TAICHI_PROJECT_LIBRARIES ${TAICHI_PROJECT_LIBRARIES} ${TAICHI_PROJECT_NAME} PARENT_SCOPE)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"import tensorflow as tf; import sys;\
sys.stdout.write(tf.sysconfig.get_include())"
OUTPUT_VARIABLE TF_INCLUDE_DIRS)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"import tensorflow as tf; import sys;\
sys.stdout.write(tf.sysconfig.get_lib())"
OUTPUT_VARIABLE TF_LIBRARY_DIR)
message("Including tensorflow include dir: ${TF_INCLUDE_DIRS}")
message(" tensorflow library dir: ${TF_LIBRARY_DIR}")
include_directories(${TF_INCLUDE_DIRS})
include_directories(external/partio/include)
if (NOT $ENV{CUDA_ARCH})
set(${CUDA_ARCH} 61)
else()
set(${CUDA_ARCH} $ENV{CUDA_ARCH})
endif()
message("CUDA Arch: ${CUDA_ARCH}")
find_package(CUDA 8.0 REQUIRED)
set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
#set(CUDA_NVCC_FLAGS ${CMAKE_CXX_FLAGS} ${CUDA_NVCC_FLAGS} -arch=compute_$ENV{CUDA_ARCH} -code=sm_$ENV{CUDA_ARCH} -Xcompiler "-fPIC" --maxrregcount 64 --use_fast_math --ptxas-options=-allow-expensive-optimizations=true,-O3)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler "-fPIC" --use_fast_math --ptxas-options=-allow-expensive-optimizations=true,-O3)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -D__CUDA_ARCH___=${CUDA_ARCH}0 -std=c++14)
message("NVCC Flags: ${CUDA_NVCC_FLAGS}")
set(CUDA_PROPAGATE_HOST_FLAGS ON)
cuda_add_library(cudmpm SHARED ${PROJECT_SOURCES_CUDA})
add_subdirectory(external/partio)
add_library(taichi_tf_${TAICHI_PROJECT_NAME} SHARED ${PROJECT_OP_SOURCES})
add_library(taichi_${TAICHI_PROJECT_NAME} SHARED ${PROJECT_SOURCES})
target_link_libraries(taichi_${TAICHI_PROJECT_NAME} ${CORE_LIBRARY_NAME} ${SHARED_LIBS} partio cudmpm)
target_link_libraries(taichi_tf_${TAICHI_PROJECT_NAME} cudmpm ${TF_LIBRARY_DIR}/libtensorflow_framework.so)
find_package(ZLIB)
if (ZLIB_FOUND)
target_link_libraries(taichi_${TAICHI_PROJECT_NAME} z)
endif(ZLIB_FOUND)