-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
130 lines (107 loc) · 3.34 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
# Project Info
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
cmake_policy(VERSION 3.6)
project(CrossShader
VERSION 1.0.0.0
LANGUAGES C CXX
)
enable_language(C)
enable_language(CXX)
# =============================================================
# CMake Settings
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_SUPPRESS_REGENERATION true)
set(DCMAKE_GENERATOR_PLATFORM "x64")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX d)
endif()
# =============================================================
# Core Dependencies
# GLSLang
add_subdirectory(external/glslang)
# SPRIV-Cross
add_subdirectory(external/spirv-cross)
set_property(TARGET spirv-cross spirv-cross-core spirv-cross-cpp spirv-cross-glsl spirv-cross-hlsl spirv-cross-msl spirv-cross-reflect spirv-cross-util PROPERTY FOLDER "spirv")
# DirectX Compiler
add_subdirectory(external/directxshadercompiler)
# =============================================================
# Sources
file(GLOB_RECURSE FILE_SOURCES RELATIVE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/*.mm
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
)
# Solution Filters
foreach(source IN LISTS FILE_SOURCES)
get_filename_component(source_path "${source}" PATH)
string(REPLACE "/" "\\" source_path_msvc "${source_path}")
string(REPLACE "src" "" source_path_final "${source_path_msvc}")
source_group("${source_path_final}" FILES "${source}")
endforeach()
# =============================================================
# Finalize App
add_executable(
${PROJECT_NAME}
"${FILE_SOURCES}"
)
# =============================================================
# Finish Dependencies
target_link_libraries(
${PROJECT_NAME}
glslang
#glslangValidator
#spirv-remap
glslang-default-resource-limits
OGLCompiler
OSDependent
SPIRV
SPVRemapper
HLSL
#spirv-cross
spirv-cross-core
spirv-cross-cpp
spirv-cross-glsl
spirv-cross-hlsl
spirv-cross-msl
spirv-cross-reflect
spirv-cross-util
)
add_dependencies(
${PROJECT_NAME}
glslang
#glslangValidator
#spirv-remap
glslang-default-resource-limits
OGLCompiler
OSDependent
SPIRV
SPVRemapper
HLSL
#spirv-cross
spirv-cross-core
spirv-cross-cpp
spirv-cross-glsl
spirv-cross-hlsl
spirv-cross-msl
spirv-cross-reflect
spirv-cross-util
)
# =============================================================
# Final Settings
if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "--bind -s ALLOW_MEMORY_GROWTH=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -O2 -Wall -s MODULARIZE=1")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-pthread")
endif()