-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
96 lines (72 loc) · 2.57 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
cmake_minimum_required (VERSION 3.1)
include(cmake/safeguards.cmake)
project(glcuda
VERSION 0.1.0
LANGUAGES C CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "gcc5.0 or newer required.")
endif()
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
# --- Common ---
add_library(Common INTERFACE)
add_library(glcuda::common ALIAS Common)
target_include_directories(Common INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/inc>
)
# --- CUDA ---
find_package(CUDA REQUIRED)
list(APPEND CUDA_NVCC_FLAGS "-arch=sm_30")
list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
list(APPEND CUDA_NVCC_FLAGS "-lineinfo")
add_library(Cuda INTERFACE)
add_library(glcuda::cuda ALIAS Cuda)
# workaround for FindCUDA that uses plain link_libraries
set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
# --- GLFW ---
# re-used cmake settings from nanogui cmake files
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw/src")
message(FATAL_ERROR "The dependency repositories (GLFW, etc.) are missing! "
"You probably did not clone the project with --recursive. It is possible to recover "
"by calling \"git submodule update --init --recursive\"")
endif()
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
set(GLFW_BUILD_INSTALL OFF CACHE BOOL " " FORCE)
set(GLFW_INSTALL OFF CACHE BOOL " " FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
# Compile GLAD and GLFW
if (MSVC)
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/ext/glad.c"
PROPERTIES COMPILE_FLAGS "/wd4055 ")
endif()
#...(dir binary-dir)
add_subdirectory(ext/glfw ext_build/glfw)
target_include_directories(Common INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/ext/glfw/include>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/ext/glfw/deps>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/ext/glfw/deps/glad>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/ext/glfw/deps/KHR>
)
# --- glm (header only library for OpenGL math) ---
set(GLM_TEST_ENABLE_FAST_MATH OFF CACHE BOOL " " FORCE)
target_include_directories(Common INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/ext/glm>
)
# ---
add_library(glcuda_glad STATIC
"${CMAKE_SOURCE_DIR}/ext/glfw/deps/glad.c")
target_link_libraries(glcuda_glad PRIVATE Common)
target_link_libraries(Common INTERFACE
glcuda_glad
glfw
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
)
add_subdirectory(src)