-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
129 lines (97 loc) · 4.01 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
PROJECT(Btrc)
OPTION(BTRC_BUILD_GUI "build graphics user interface" OFF)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Options: Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF()
FUNCTION(BTRC_SET_CXX_LANG_VERSION)
SET(TARGET_NAME ${ARGV0})
IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
TARGET_COMPILE_DEFINITIONS(${TARGET_NAME} PUBLIC _CRT_SECURE_NO_WARNINGS)
SET_PROPERTY(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 23)
ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
TARGET_COMPILE_OPTIONS(${TARGET_NAME} PRIVATE "-Wno-microsoft-cast" "-Wno-unused-private-field")
TARGET_COMPILE_DEFINITIONS(${TARGET_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
SET_PROPERTY(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 23)
ELSE()
SET_PROPERTY(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 20)
ENDIF()
SET_PROPERTY(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
ENDFUNCTION()
############## cuda
FIND_PACKAGE(CUDAToolkit REQUIRED)
#ADD_EXECUTABLE(embed "${PROJECT_SOURCE_DIR}/lib/embed/embed_file.c")
#SET_TARGET_PROPERTIES(embed PROPERTIES FOLDER "EmbedPTX")
#SET(BTRC_EMBED_PTX_DIR "${CMAKE_BINARY_DIR}/embed_ptx")
#FUNCTION(BTRC_EMBED_PTX)
# SET(TARGET_NAME ${ARGV0})
# SET(PTX_TARGET ${ARGV1})
# SET(CU_FILENAME ${ARGV2})
# ADD_LIBRARY(${PTX_TARGET} OBJECT ${CU_FILENAME})
# SET_PROPERTY(TARGET ${PTX_TARGET} PROPERTY CUDA_STANDARD 17)
# SET_PROPERTY(TARGET ${PTX_TARGET} PROPERTY CUDA_STANDARD_REQUIRED ON)
# SET(VAR_NAME embed_var_${PTX_TARGET})
# SET(PTX_FILENAME $<TARGET_OBJECTS:${PTX_TARGET}>)
# SET(INL_FILENAME "${CMAKE_BINARY_DIR}/embed_ptx/embed_ptx/${PTX_TARGET}.inl")
# SET_PROPERTY(TARGET ${PTX_TARGET} PROPERTY CUDA_PTX_COMPILATION ON)
# SET_PROPERTY(TARGET ${PTX_TARGET} PROPERTY CUDA_ARCHITECTURES OFF)
# ADD_CUSTOM_COMMAND(
# OUTPUT ${INL_FILENAME}
# COMMAND embed ARGS
# ${INL_FILENAME}
# ${VAR_NAME} ${PTX_FILENAME}
# DEPENDS $<TARGET_OBJECTS:${PTX_TARGET}> ${PTX_TARGET} embed)
# ADD_CUSTOM_TARGET(
# EmbedPTX_${PTX_TARGET} ALL
# DEPENDS ${INL_FILENAME})
# SET_TARGET_PROPERTIES(${PTX_TARGET} PROPERTIES FOLDER "EmbedPTX")
# SET_TARGET_PROPERTIES(EmbedPTX_${PTX_TARGET} PROPERTIES FOLDER "EmbedPTX")
# TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PRIVATE ${BTRC_EMBED_PTX_DIR})
# ADD_DEPENDENCIES(${TARGET_NAME} EmbedPTX_${PTX_TARGET})
#ENDFUNCTION()
############## fmt
ADD_SUBDIRECTORY(lib/fmt)
SET_TARGET_PROPERTIES(fmt PROPERTIES FOLDER "ThirdParty")
############## bvh
ADD_SUBDIRECTORY(lib/bvh)
############## opengl
IF(BTRC_BUILD_GUI)
FIND_PACKAGE(OpenGL REQUIRED)
ADD_SUBDIRECTORY(lib/glfw)
ADD_SUBDIRECTORY(lib/glew/build/cmake)
ADD_SUBDIRECTORY(lib/imgui)
SET_TARGET_PROPERTIES(glfw glew_s imgui PROPERTIES FOLDER "ThirdParty")
ENDIF()
############## cuj
SET(CUJ_BUILD_TEST OFF)
SET(CUJ_BUILD_EXAMPLE OFF)
ADD_SUBDIRECTORY(lib/cuj)
SET_TARGET_PROPERTIES(cuj PROPERTIES FOLDER "ThirdParty")
############## tiny obj loader
ADD_SUBDIRECTORY(lib/tinyobjloader)
SET_TARGET_PROPERTIES(tinyobjloader PROPERTIES FOLDER "ThirdParty")
############## stb & exr
ADD_SUBDIRECTORY(lib/stb)
ADD_SUBDIRECTORY(lib/tinyexr)
SET_TARGET_PROPERTIES(stb tinyexr PROPERTIES FOLDER "ThirdParty")
############## json
ADD_SUBDIRECTORY(lib/nlohmann)
############## member function trait
ADD_SUBDIRECTORY(lib/cpp-member-function-trait)
############## file dialog
IF(BTRC_BUILD_GUI)
ADD_SUBDIRECTORY(lib/portable-file-dialog)
ENDIF()
############## components
ADD_SUBDIRECTORY(src/common)
ADD_SUBDIRECTORY(src/core)
ADD_SUBDIRECTORY(src/factory)
ADD_SUBDIRECTORY(src/builtin)
ADD_SUBDIRECTORY(src/cli)
IF(BTRC_BUILD_GUI)
ADD_SUBDIRECTORY(src/gui)
ENDIF()