Skip to content

Latest commit

 

History

History
263 lines (237 loc) · 9.39 KB

CMakeLists.txt

File metadata and controls

263 lines (237 loc) · 9.39 KB
 
Feb 28, 2009
Feb 28, 2009
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
Mar 22, 2008
Mar 22, 2008
2
PROJECT(MojoShader)
Mar 28, 2008
Mar 28, 2008
3
Jan 1, 2016
Jan 1, 2016
4
5
6
7
OPTION(BUILD_SHARED "Build MojoShader as a shared library" OFF)
OPTION(PROFILE_D3D "Build MojoShader with support for the D3D profile" ON)
OPTION(PROFILE_BYTECODE "Build MojoShader with support for the BYTECODE profile" ON)
OPTION(PROFILE_GLSL120 "Build MojoShader with support for the GLSL120 profile" ON)
Apr 7, 2019
Apr 7, 2019
8
OPTION(PROFILE_GLSLES "Build MojoShader with support for the GLSLES profile" ON)
Jan 1, 2016
Jan 1, 2016
9
10
11
OPTION(PROFILE_GLSL "Build MojoShader with support for the GLSL profile" ON)
OPTION(PROFILE_ARB1 "Build MojoShader with support for the ARB1 profile" ON)
OPTION(PROFILE_ARB1_NV "Build MojoShader with support for the ARB1_NV profile" ON)
May 29, 2016
May 29, 2016
12
OPTION(PROFILE_METAL "Build MojoShader with support for the Metal profile" ON)
Dec 31, 2019
Dec 31, 2019
13
OPTION(PROFILE_SPIRV "Build MojoShader with support for the SPIR-V profile" ON)
Dec 31, 2019
Dec 31, 2019
14
OPTION(PROFILE_GLSPIRV "Build MojoShader with support for the ARB_gl_spirv profile" ON)
May 28, 2016
May 28, 2016
15
OPTION(EFFECT_SUPPORT "Build MojoShader with support for Effect framework files" ON)
Apr 27, 2019
Apr 27, 2019
16
OPTION(COMPILER_SUPPORT "Build MojoShader with support for HLSL source files" OFF)
Jan 1, 2016
Jan 1, 2016
17
18
19
20
OPTION(FLIP_VIEWPORT "Build MojoShader with the ability to flip the GL viewport" OFF)
OPTION(DEPTH_CLIPPING "Build MojoShader with the ability to simulate [0, 1] depth clipping" OFF)
OPTION(XNA4_VERTEXTEXTURE "Build MojoShader with XNA4 vertex texturing behavior" OFF)
Feb 12, 2009
Feb 12, 2009
21
22
INCLUDE_DIRECTORIES(.)
Feb 19, 2019
Feb 19, 2019
23
# If Mercurial is installed and we are in a mercurial repository, include the rev# and changeset as version information.
Feb 12, 2009
Feb 12, 2009
24
25
26
27
28
29
30
FIND_PROGRAM(HG hg DOC "Path to hg command line app: http://www.selenic.com/mercurial/")
IF(NOT HG)
MESSAGE(STATUS "Mercurial (hg) not found. You can go on, but version info will be wrong.")
SET(MOJOSHADER_VERSION -1)
SET(MOJOSHADER_CHANGESET "???")
ELSE(NOT HG)
MARK_AS_ADVANCED(HG)
Feb 19, 2019
Feb 19, 2019
31
32
# See if we are in an hg repository.
Feb 12, 2009
Feb 12, 2009
33
EXECUTE_PROCESS(
Feb 19, 2019
Feb 19, 2019
34
COMMAND hg root
Feb 12, 2009
Feb 12, 2009
35
36
37
38
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE HGVERSION_RC
ERROR_QUIET
)
Feb 19, 2019
Feb 19, 2019
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
IF(NOT HGVERSION_RC EQUAL 0)
MESSAGE(STATUS "Mercurial (hg) repository not found. You can go on, but version info will be wrong.")
SET(MOJOSHADER_VERSION -1)
SET(MOJOSHADER_CHANGESET "???")
ELSE(NOT HGVERSION_RC EQUAL 0)
# Query the rev and changeset.
EXECUTE_PROCESS(
COMMAND hg tip --template {rev}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE HGVERSION_RC
OUTPUT_VARIABLE MOJOSHADER_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
EXECUTE_PROCESS(
COMMAND hg tip --template hg-{rev}:{node|short}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE HGVERSION_RC
OUTPUT_VARIABLE MOJOSHADER_CHANGESET
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ENDIF(NOT HGVERSION_RC EQUAL 0)
Feb 12, 2009
Feb 12, 2009
62
ENDIF(NOT HG)
Nov 6, 2008
Nov 6, 2008
63
64
65
66
67
68
69
70
71
72
73
WRITE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_version.h"
"/* This file was autogenerated. Do not edit! */\n"
"#ifndef _INCL_MOJOSHADER_VERSION_H_\n"
"#define _INCL_MOJOSHADER_VERSION_H_\n"
"#define MOJOSHADER_VERSION ${MOJOSHADER_VERSION}\n"
"#define MOJOSHADER_CHANGESET \"${MOJOSHADER_CHANGESET}\"\n"
"#endif\n"
)
Mar 28, 2008
Mar 28, 2008
74
75
76
77
IF(CMAKE_COMPILER_IS_GNUCC)
ADD_DEFINITIONS(-Wall -ggdb3)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
Mar 28, 2008
Mar 28, 2008
78
79
# testparse uses this when I'm looking at memory usage patterns.
#ADD_DEFINITIONS(-DMOJOSHADER_DEBUG_MALLOC=1)
Mar 28, 2008
Mar 28, 2008
80
Apr 30, 2008
Apr 30, 2008
81
82
83
84
85
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS=1)
ADD_DEFINITIONS(-TP) # force .c files to compile as C++.
ENDIF(MSVC)
Feb 28, 2009
Feb 28, 2009
86
# We build lemon, then use it to generate parser C code.
May 17, 2018
May 17, 2018
87
88
89
90
91
92
93
94
95
96
97
IF(COMPILER_SUPPORT)
ADD_EXECUTABLE(lemon "misc/lemon.c")
GET_TARGET_PROPERTY(LEMON lemon LOCATION)
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
DEPENDS lemon "${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c"
COMMAND "${LEMON}"
ARGS -q "-T${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
)
ENDIF(COMPILER_SUPPORT)
Feb 28, 2009
Feb 28, 2009
98
Jan 1, 2016
Jan 1, 2016
99
IF(APPLE)
Feb 19, 2019
Feb 19, 2019
100
101
102
IF(NOT IOS)
find_library(CARBON_FRAMEWORK Carbon) # Stupid Gestalt.
ENDIF(NOT IOS)
Jan 1, 2016
Jan 1, 2016
103
104
105
106
107
108
109
110
111
112
113
ENDIF(APPLE)
IF(NOT PROFILE_D3D)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_D3D=0)
ENDIF(NOT PROFILE_D3D)
IF(NOT PROFILE_BYTECODE)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_BYTECODE=0)
ENDIF(NOT PROFILE_BYTECODE)
IF(NOT PROFILE_GLSL120)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSL120=0)
ENDIF(NOT PROFILE_GLSL120)
Apr 7, 2019
Apr 7, 2019
114
115
116
IF(NOT PROFILE_GLSLES)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSLES=0)
ENDIF(NOT PROFILE_GLSLES)
Jan 1, 2016
Jan 1, 2016
117
118
119
120
121
122
123
124
125
IF(NOT PROFILE_GLSL)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSL=0)
ENDIF(NOT PROFILE_GLSL)
IF(NOT PROFILE_ARB1)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_ARB1=0)
ENDIF(NOT PROFILE_ARB1)
IF(NOT PROFILE_ARB1_NV)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_ARB1_NV=0)
ENDIF(NOT PROFILE_ARB1_NV)
May 29, 2016
May 29, 2016
126
127
IF(NOT PROFILE_METAL)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_METAL=0)
May 17, 2018
May 17, 2018
128
ENDIF(NOT PROFILE_METAL)
Dec 31, 2019
Dec 31, 2019
129
130
131
IF(NOT PROFILE_SPIRV)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_SPIRV=0)
ENDIF(NOT PROFILE_SPIRV)
Dec 31, 2019
Dec 31, 2019
132
133
134
IF(NOT PROFILE_GLSPIRV)
ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSPIRV=0)
ENDIF(NOT PROFILE_GLSPIRV)
Jan 1, 2016
Jan 1, 2016
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
IF(EFFECT_SUPPORT)
IF(UNIX)
SET(LIBM -lm)
ENDIF(UNIX)
ADD_DEFINITIONS(-DMOJOSHADER_EFFECT_SUPPORT)
ENDIF(EFFECT_SUPPORT)
IF(FLIP_VIEWPORT)
ADD_DEFINITIONS(-DMOJOSHADER_FLIP_RENDERTARGET)
ENDIF(FLIP_VIEWPORT)
IF(DEPTH_CLIPPING)
ADD_DEFINITIONS(-DMOJOSHADER_DEPTH_CLIPPING)
ENDIF(DEPTH_CLIPPING)
IF(XNA4_VERTEXTEXTURE)
ADD_DEFINITIONS(-DMOJOSHADER_XNA4_VERTEX_TEXTURES)
ENDIF(XNA4_VERTEXTEXTURE)
IF(BUILD_SHARED)
SET(LIBRARY_FORMAT SHARED)
ELSE(BUILD_SHARED)
SET(LIBRARY_FORMAT STATIC)
ENDIF(BUILD_SHARED)
ADD_LIBRARY(mojoshader ${LIBRARY_FORMAT}
Dec 5, 2008
Dec 5, 2008
162
mojoshader.c
Apr 5, 2009
Apr 5, 2009
163
mojoshader_common.c
Dec 5, 2008
Dec 5, 2008
164
mojoshader_opengl.c
Apr 23, 2019
Apr 23, 2019
165
166
167
168
169
profiles/mojoshader_profile_arb1.c
profiles/mojoshader_profile_bytecode.c
profiles/mojoshader_profile_d3d.c
profiles/mojoshader_profile_glsl.c
profiles/mojoshader_profile_metal.c
Dec 31, 2019
Dec 31, 2019
170
profiles/mojoshader_profile_spirv.c
Apr 23, 2019
Apr 23, 2019
171
profiles/mojoshader_profile_common.c
Dec 5, 2008
Dec 5, 2008
172
)
May 17, 2018
May 17, 2018
173
174
175
176
177
178
179
180
181
182
183
184
185
IF(EFFECT_SUPPORT)
TARGET_SOURCES(mojoshader PRIVATE
mojoshader_effects.c
)
ENDIF(EFFECT_SUPPORT)
IF(COMPILER_SUPPORT)
TARGET_SOURCES(mojoshader PRIVATE
mojoshader_compiler.c
mojoshader_preprocessor.c
mojoshader_lexer.c
mojoshader_assembler.c
)
ENDIF(COMPILER_SUPPORT)
Jan 1, 2016
Jan 1, 2016
186
187
188
IF(BUILD_SHARED)
TARGET_LINK_LIBRARIES(mojoshader ${LIBM} ${CARBON_FRAMEWORK})
ENDIF(BUILD_SHARED)
May 31, 2011
May 31, 2011
189
Feb 28, 2009
Feb 28, 2009
190
191
SET_SOURCE_FILES_PROPERTIES(
mojoshader_compiler.c
Feb 28, 2009
Feb 28, 2009
192
PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
Feb 28, 2009
Feb 28, 2009
193
194
)
Feb 12, 2009
Feb 12, 2009
195
196
197
198
199
200
FIND_PROGRAM(RE2C re2c DOC "Path to re2c command line app: http://re2c.org/")
IF(NOT RE2C)
MESSAGE(STATUS "re2c missing. You can go on, but can't rebuild the lexer.")
ELSE(NOT RE2C)
MARK_AS_ADVANCED(RE2C)
ADD_CUSTOM_COMMAND(
Feb 28, 2009
Feb 28, 2009
201
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c"
Feb 12, 2009
Feb 12, 2009
202
DEPENDS mojoshader_lexer.re
Feb 28, 2009
Feb 28, 2009
203
204
COMMAND "${RE2C}"
ARGS -is --no-generation-date -o "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.re"
Feb 12, 2009
Feb 12, 2009
205
206
)
ENDIF(NOT RE2C)
Feb 11, 2009
Feb 11, 2009
207
Feb 21, 2014
Feb 21, 2014
208
209
210
211
find_path(SDL2_INCLUDE_DIR SDL.h PATH_SUFFIXES include/SDL2)
find_library(SDL2 NAMES SDL2 PATH_SUFFIXES lib)
IF(SDL2)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
Feb 12, 2009
Feb 12, 2009
212
ADD_EXECUTABLE(glcaps utils/glcaps.c)
Feb 21, 2014
Feb 21, 2014
213
TARGET_LINK_LIBRARIES(glcaps ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
Feb 12, 2009
Feb 12, 2009
214
ADD_EXECUTABLE(bestprofile utils/bestprofile.c)
Feb 21, 2014
Feb 21, 2014
215
TARGET_LINK_LIBRARIES(bestprofile mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
Feb 12, 2009
Feb 12, 2009
216
ADD_EXECUTABLE(availableprofiles utils/availableprofiles.c)
Feb 21, 2014
Feb 21, 2014
217
218
TARGET_LINK_LIBRARIES(availableprofiles mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
ENDIF(SDL2)
Apr 22, 2008
Apr 22, 2008
219
May 17, 2018
May 17, 2018
220
221
222
223
224
225
226
227
228
229
IF(COMPILER_SUPPORT)
ADD_EXECUTABLE(finderrors utils/finderrors.c)
TARGET_LINK_LIBRARIES(finderrors mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
IF(SDL2)
SET_SOURCE_FILES_PROPERTIES(
utils/finderrors.c
PROPERTIES COMPILE_FLAGS "-DFINDERRORS_COMPILE_SHADERS=1"
)
ENDIF(SDL2)
ENDIF(COMPILER_SUPPORT)
Feb 28, 2009
Feb 28, 2009
230
Dec 31, 2019
Dec 31, 2019
231
232
233
234
235
236
237
FIND_PATH(SPIRV_TOOLS_INCLUDE_DIR "spirv-tools/libspirv.h" PATH_SUFFIXES "include")
FIND_LIBRARY(SPIRV_TOOLS_LIBRARY NAMES SPIRV-Tools-shared)
IF(SPIRV_TOOLS_INCLUDE_DIR AND SPIRV_TOOLS_LIBRARY)
INCLUDE_DIRECTORIES(${SPIRV_TOOLS_INCLUDE_DIR})
ADD_DEFINITIONS(-DMOJOSHADER_HAS_SPIRV_TOOLS)
ENDIF(SPIRV_TOOLS_INCLUDE_DIR AND SPIRV_TOOLS_LIBRARY)
Feb 12, 2009
Feb 12, 2009
238
ADD_EXECUTABLE(testparse utils/testparse.c)
Feb 21, 2014
Feb 21, 2014
239
TARGET_LINK_LIBRARIES(testparse mojoshader ${LIBM} ${CARBON_FRAMEWORK})
Dec 31, 2019
Dec 31, 2019
240
241
242
IF(SPIRV_TOOLS_INCLUDE_DIR AND SPIRV_TOOLS_LIBRARY)
TARGET_LINK_LIBRARIES(testparse ${SPIRV_TOOLS_LIBRARY})
ENDIF(SPIRV_TOOLS_INCLUDE_DIR AND SPIRV_TOOLS_LIBRARY)
Feb 12, 2009
Feb 12, 2009
243
ADD_EXECUTABLE(testoutput utils/testoutput.c)
Feb 21, 2014
Feb 21, 2014
244
TARGET_LINK_LIBRARIES(testoutput mojoshader ${LIBM} ${CARBON_FRAMEWORK})
May 17, 2018
May 17, 2018
245
246
247
248
IF(COMPILER_SUPPORT)
ADD_EXECUTABLE(mojoshader-compiler utils/mojoshader-compiler.c)
TARGET_LINK_LIBRARIES(mojoshader-compiler mojoshader ${LIBM} ${CARBON_FRAMEWORK})
ENDIF(COMPILER_SUPPORT)
Feb 9, 2008
Feb 9, 2008
249
Apr 9, 2009
Apr 9, 2009
250
# Unit tests...
May 17, 2018
May 17, 2018
251
252
253
254
255
256
257
258
259
260
IF(COMPILER_SUPPORT)
ADD_CUSTOM_TARGET(
test
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/run_tests.pl"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS mojoshader-compiler
COMMENT "Running unit tests..."
VERBATIM
)
ENDIF(COMPILER_SUPPORT)
Apr 9, 2009
Apr 9, 2009
261
Feb 9, 2008
Feb 9, 2008
262
# End of CMakeLists.txt ...