-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
71 lines (51 loc) · 2.08 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
64
65
66
67
68
69
70
71
CMAKE_MINIMUM_REQUIRED(VERSION 3.17)
PROJECT(CUJ CXX)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
################ global options ################
OPTION(CUJ_BUILD_TEST "build cuj tests" ON)
OPTION(CUJ_ENABLE_CUDA "enable CUDA in tests" ON)
OPTION(CUJ_BUILD_EXAMPLE "build cuj examples" ON)
IF(CUJ_ENABLE_CUDA)
FIND_PACKAGE(CUDAToolkit REQUIRED)
ENDIF()
FIND_PACKAGE(LLVM REQUIRED)
SET_TARGET_PROPERTIES(
acc_gen intrinsics_gen omp_gen PROPERTIES FOLDER "ThirdParty")
################ cuj ################
FILE(GLOB_RECURSE CUJ_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/cuj/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/cuj/*.inl"
"${CMAKE_CURRENT_SOURCE_DIR}/cuj/*.cpp")
ADD_LIBRARY(cuj STATIC ${CUJ_SRC})
FOREACH(_SRC IN ITEMS ${CUJ_SRC})
GET_FILENAME_COMPONENT(CUJ_SRC "${_SRC}" PATH)
STRING(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/cuj/inc/cuj" "inc" _GRP_PATH "${CUJ_SRC}")
STRING(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/cuj/inc" "inc" _GRP_PATH "${_GRP_PATH}")
STRING(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/cuj/src" "src" _GRP_PATH "${_GRP_PATH}")
STRING(REPLACE "/" "\\" _GRP_PATH "${_GRP_PATH}")
SOURCE_GROUP("${_GRP_PATH}" FILES "${_SRC}")
ENDFOREACH()
SET_PROPERTY(TARGET cuj PROPERTY CXX_STANDARD 20)
SET_PROPERTY(TARGET cuj PROPERTY CXX_STANDARD_REQUIRED ON)
TARGET_INCLUDE_DIRECTORIES(cuj PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/cuj/inc")
TARGET_INCLUDE_DIRECTORIES(cuj PUBLIC ${LLVM_INCLUDE_DIRS})
IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
TARGET_COMPILE_OPTIONS(cuj PUBLIC $<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>)
ENDIF()
llvm_map_components_to_libnames(
LLVM_LIBS
Core ExecutionEngine Interpreter Support objcarcopts
mcjit nativecodegen nvptxcodegen)
TARGET_LINK_LIBRARIES(cuj PUBLIC ${LLVM_LIBS})
IF(CUJ_ENABLE_CUDA)
TARGET_COMPILE_DEFINITIONS(cuj PUBLIC CUJ_ENABLE_CUDA)
TARGET_LINK_LIBRARIES(cuj PUBLIC CUDA::nvrtc)
ENDIF()
################ tests ################
IF(CUJ_BUILD_TEST)
ADD_SUBDIRECTORY(./test)
ENDIF()
################ examples ################
IF(CUJ_BUILD_EXAMPLE)
ADD_SUBDIRECTORY(./example)
ENDIF()