-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
133 lines (117 loc) · 4.48 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
cmake_minimum_required(VERSION 3.22)
project(pixelify LANGUAGES CXX CUDA)
include(CTest)
include(GoogleTest REQUIRED)
find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)
find_package(GLEW REQUIRED)
find_package(exiv2 REQUIRED)
enable_testing()
# set architecture flags
# this depends on your GPU
# see link below
# https://developer.nvidia.com/cuda-gpus
set(CMAKE_CUDA_ARCHITECTURES 61)
set(SOURCES
src/main.cu
src/gui.cu
src/render.cu
src/kernel.cu
src/filters.cpp
src/filter_impl.cpp
src/kernel_formulas.cpp
)
set(IMGUI_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/imgui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/imgui_demo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/imgui_draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/imgui_widgets.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/imgui_tables.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/misc/cpp/imgui_stdlib.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends/imgui_impl_opengl3.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/ImGuiFileDialog/ImGuiFileDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui_tex_inspect/imgui_tex_inspect.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui_tex_inspect/backends/tex_inspect_opengl.cpp
)
add_library(imgui_lib ${IMGUI_SOURCES})
target_include_directories(imgui_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends
${CMAKE_CURRENT_SOURCE_DIR}/external/ImGuiFileDialog
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui_tex_inspect
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui_tex_inspect/backends
${CMAKE_CURRENT_SOURCE_DIR}/external/imgInspect
)
target_compile_options(imgui_lib PRIVATE -DIMGUI_IMPL_OPENGL_LOADER_GLEW)
add_library(pixelify_lib STATIC ${SOURCES})
target_include_directories(pixelify_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/external
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends
${CMAKE_CURRENT_SOURCE_DIR}/external/ImGuiFileDialog
${CMAKE_CURRENT_SOURCE_DIR}/external/imgInspect
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui_tex_inspect
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui_tex_inspect/backends
${CMAKE_CURRENT_SOURCE_DIR}/external/stb
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
${OPENGL_INCLUDE_DIR} ${GLFW_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS}
)
add_executable(pixelify src/main.cu)
target_include_directories(pixelify PRIVATE ${INCLUDE_DIRS})
target_link_libraries(pixelify PUBLIC
${OPENGL_LIBRARIES}
pixelify_lib
glfw
imgui_lib
OpenGL::GL
exiv2
GLEW
${CMAKE_DL_LIBS}
)
# ------ TESTS ------
set(SOURCES_TEST
src/kernel.cu
src/filters.cpp
src/filter_impl.cpp
src/kernel_formulas.cpp
)
set(HEADERS_TEST
${CMAKE_CURRENT_SOURCE_DIR}/include/kernel.cuh
${CMAKE_CURRENT_SOURCE_DIR}/include/filters.h
${CMAKE_CURRENT_SOURCE_DIR}/include/filter_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/include/kernel_formulas.h
${CMAKE_CURRENT_SOURCE_DIR}/include/pixel.h
)
add_library(pixelify_tests STATIC ${SOURCES_TEST})
target_include_directories(pixelify_tests PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/external
${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/include
${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googlemock/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui
${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends
)
add_executable(tests tests/tests.cu)
target_link_libraries(tests
pixelify_tests
imgui_lib
gtest_main
gtest
)
# both Debug and Release builds
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -ggdb3 -fno-omit-frame-pointer -fstack-protector-all -Wformat -Wformat-security")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -D_DEBUG -O0 -G -diag-suppress=326")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -mtune=native -fomit-frame-pointer -fno-stack-protector -flto")
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -O3 -Xptxas -use_fast_math")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(SUFFIX "_debug")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
set(SUFFIX "_release")
else()
message(FATAL_ERROR "Unsupported build type: ${CMAKE_BUILD_TYPE}")
endif()