-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
105 lines (81 loc) · 2.9 KB
/
Copy pathCMakeLists.txt
File metadata and controls
105 lines (81 loc) · 2.9 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
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
###############################################################################
## Prelude
###############################################################################
cmake_minimum_required(VERSION 3.20)
message(STATUS "CMake version: ${CMAKE_VERSION}")
enable_testing()
set(languages CXX)
set(CMAKE_CXX_STANDARD 26)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CLANG TRUE)
endif()
if(CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
###############################################################################
## Global Options
###############################################################################
option(USE_CUDA "Use CUDA" OFF)
option(USE_HALIDE "Use Halide" OFF)
if(USE_CUDA)
list(APPEND languages CUDA)
endif()
if(USE_HALIDE)
list(APPEND languages C)
endif()
project(cg_cpp LANGUAGES ${languages} VERSION 0.1.0)
if(USE_CUDA)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 75)
endif()
endif()
###############################################################################
## Dependencies
###############################################################################
if (USE_HALIDE)
if (APPLE)
#set(CMAKE_PREFIX_PATH "/usr/local/opt" ${CMAKE_PREFIX_PATH})
set(homebrew_modules_path "/opt/homebrew/lib/share/cmake/Modules")
#currently only supporting homebrew on macos
#set(Halide_DIR "/opt/homebrew/Cellar/halide/12.0.1/lib/cmake/Halide")
set(LLVM_DIR "/opt/homebrew/Cellar/llvm@15/15.0.7/lib/cmake/llvm")
endif()
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${homebrew_modules_path}
${LLVM_DIR}
)
find_package(Halide REQUIRED)
endif()
set(STB_DIR ${CMAKE_SOURCE_DIR}/cpp/deps/stb)
set(HAPPLY_DIR ${CMAKE_SOURCE_DIR}/cpp/deps/happly)
###############################################################################
## Targets
###############################################################################
add_subdirectory(cpp/src)
add_subdirectory(cpp/tests)
if(MSVC)
# make these files visible in visual studio solution explorer
set(config_files
#conanfile.txt
cpp/_clang-format
.gitignore
.editorconfig
readme.md
)
set(cmake_config_files
#make/conan.cmake
#cmake/generic.vcxproj.user.in
)
set(script_files
cpp/scripts/build_vs2019.ps1
cpp/scripts/build_vs2022.ps1
cpp/scripts/generate_vs_solution.ps1
)
add_custom_target(config_files SOURCES ${config_files} ${cmake_config_files} ${script_files})
set_target_properties(config_files PROPERTIES LANGUAGE NONE)
source_group("config" FILES ${config_files})
source_group("cmake" FILES ${cmake_config_files})
source_group("scripts" FILES ${script_files})
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()