Skip to content

Latest commit

 

History

History
140 lines (122 loc) · 4.57 KB

CMakeLists.txt

File metadata and controls

140 lines (122 loc) · 4.57 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
Feb 12, 2009
Feb 12, 2009
4
5
INCLUDE_DIRECTORIES(.)
Feb 12, 2009
Feb 12, 2009
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)
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 HG)
Nov 6, 2008
Nov 6, 2008
30
31
32
33
34
35
36
37
38
39
40
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
41
42
43
44
IF(CMAKE_COMPILER_IS_GNUCC)
ADD_DEFINITIONS(-Wall -ggdb3)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
Mar 28, 2008
Mar 28, 2008
45
46
# testparse uses this when I'm looking at memory usage patterns.
#ADD_DEFINITIONS(-DMOJOSHADER_DEBUG_MALLOC=1)
Mar 28, 2008
Mar 28, 2008
47
Apr 30, 2008
Apr 30, 2008
48
49
50
51
52
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
53
54
55
56
# We build lemon, then use it to generate parser C code.
ADD_EXECUTABLE(lemon "misc/lemon.c")
GET_TARGET_PROPERTY(LEMON lemon LOCATION)
ADD_CUSTOM_COMMAND(
Feb 28, 2009
Feb 28, 2009
57
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
Feb 28, 2009
Feb 28, 2009
58
59
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
DEPENDS lemon "${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c"
Feb 28, 2009
Feb 28, 2009
60
COMMAND "${LEMON}"
Feb 8, 2010
Feb 8, 2010
61
ARGS -q "-T${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
Feb 28, 2009
Feb 28, 2009
62
63
)
Dec 5, 2008
Dec 5, 2008
64
65
ADD_LIBRARY(mojoshader STATIC
mojoshader.c
Apr 5, 2009
Apr 5, 2009
66
mojoshader_common.c
May 22, 2011
May 22, 2011
67
mojoshader_effects.c
Feb 28, 2009
Feb 28, 2009
68
mojoshader_compiler.c
Feb 9, 2009
Feb 9, 2009
69
70
mojoshader_preprocessor.c
mojoshader_lexer.c
Dec 5, 2008
Dec 5, 2008
71
72
73
mojoshader_assembler.c
mojoshader_opengl.c
)
Jun 29, 2008
Jun 29, 2008
74
May 31, 2011
May 31, 2011
75
76
77
78
IF(UNIX)
SET(LIBM -lm)
ENDIF(UNIX)
Feb 28, 2009
Feb 28, 2009
79
80
SET_SOURCE_FILES_PROPERTIES(
mojoshader_compiler.c
Feb 28, 2009
Feb 28, 2009
81
PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
Feb 28, 2009
Feb 28, 2009
82
83
)
Feb 12, 2009
Feb 12, 2009
84
85
86
87
88
89
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
90
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c"
Feb 12, 2009
Feb 12, 2009
91
DEPENDS mojoshader_lexer.re
Feb 28, 2009
Feb 28, 2009
92
93
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
94
95
)
ENDIF(NOT RE2C)
Feb 11, 2009
Feb 11, 2009
96
Feb 21, 2014
Feb 21, 2014
97
98
99
100
101
102
103
104
IF(APPLE)
find_library(CARBON_FRAMEWORK Carbon) # Stupid Gestalt.
ENDIF(APPLE)
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
105
ADD_EXECUTABLE(glcaps utils/glcaps.c)
Feb 21, 2014
Feb 21, 2014
106
TARGET_LINK_LIBRARIES(glcaps ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
Feb 12, 2009
Feb 12, 2009
107
ADD_EXECUTABLE(bestprofile utils/bestprofile.c)
Feb 21, 2014
Feb 21, 2014
108
TARGET_LINK_LIBRARIES(bestprofile mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
Feb 12, 2009
Feb 12, 2009
109
ADD_EXECUTABLE(availableprofiles utils/availableprofiles.c)
Feb 21, 2014
Feb 21, 2014
110
111
TARGET_LINK_LIBRARIES(availableprofiles mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
ENDIF(SDL2)
Apr 22, 2008
Apr 22, 2008
112
Feb 28, 2009
Feb 28, 2009
113
ADD_EXECUTABLE(finderrors utils/finderrors.c)
Feb 21, 2014
Feb 21, 2014
114
115
TARGET_LINK_LIBRARIES(finderrors mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
IF(SDL2)
Feb 28, 2009
Feb 28, 2009
116
117
118
119
SET_SOURCE_FILES_PROPERTIES(
utils/finderrors.c
PROPERTIES COMPILE_FLAGS "-DFINDERRORS_COMPILE_SHADERS=1"
)
Feb 21, 2014
Feb 21, 2014
120
ENDIF(SDL2)
Feb 28, 2009
Feb 28, 2009
121
Feb 12, 2009
Feb 12, 2009
122
ADD_EXECUTABLE(testparse utils/testparse.c)
Feb 21, 2014
Feb 21, 2014
123
TARGET_LINK_LIBRARIES(testparse mojoshader ${LIBM} ${CARBON_FRAMEWORK})
Feb 12, 2009
Feb 12, 2009
124
ADD_EXECUTABLE(testoutput utils/testoutput.c)
Feb 21, 2014
Feb 21, 2014
125
TARGET_LINK_LIBRARIES(testoutput mojoshader ${LIBM} ${CARBON_FRAMEWORK})
Feb 19, 2009
Feb 19, 2009
126
ADD_EXECUTABLE(mojoshader-compiler utils/mojoshader-compiler.c)
Feb 21, 2014
Feb 21, 2014
127
TARGET_LINK_LIBRARIES(mojoshader-compiler mojoshader ${LIBM} ${CARBON_FRAMEWORK})
Feb 9, 2008
Feb 9, 2008
128
Apr 9, 2009
Apr 9, 2009
129
130
131
132
133
# Unit tests...
ADD_CUSTOM_TARGET(
test
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/run_tests.pl"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
Apr 9, 2009
Apr 9, 2009
134
DEPENDS mojoshader-compiler
Apr 9, 2009
Apr 9, 2009
135
COMMENT "Running unit tests..."
Apr 9, 2009
Apr 9, 2009
136
VERBATIM
Apr 9, 2009
Apr 9, 2009
137
138
)
Feb 9, 2008
Feb 9, 2008
139
# End of CMakeLists.txt ...