OSDN Git Service

Implement Int to Int4 conversion.
[android-x86/external-swiftshader.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2
3 project(SwiftShader C CXX)
4
5 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The type of build: Debug Release RelWithDebInfo." )
6
7 option(BUILD_EGL "Build the EGL library" 1)
8 if(WIN32)
9     option(BUILD_GL32 "Build the OpenGL 32 library" 1)
10 endif()
11 option(BUILD_GLESv2 "Build the OpenGL ES 2 library" 1)
12 option(BUILD_GLES_CM "Build the OpenGL ES 1.1 library" 1)
13
14 option(USE_GROUP_SOURCES "Group the source files in a folder tree for visual studio" 1)
15
16 option(BUILD_EXTRA_PROGRAMS "Build extra programs" 1)
17
18 # LLVM disallows calling cmake . from the main LLVM dir, the reason is that
19 # it builds header files that could overwrite the orignal ones. Here we
20 # want to include LLVM as a subdirectory and even though it wouldn't cause
21 # the problem, if cmake . is called from the main dir, the condition that
22 # LLVM checkes, "CMAKE_SOURCE_DIR == CMAKE_BINARY_DIR" will be true. So we
23 # disallow it ourselves too to. In addition if there are remining CMakeFiles
24 # and CMakeCache in the directory, cmake .. from a subdirectory will still
25 # try to build from the main directory so we instruct users to delete these
26 # files when they get the error.
27 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
28     message(FATAL_ERROR "In source builds are not allowed by LLVM, please create a build/ directory and build from there. You may have to delete the CMakeCache.txt file and CMakeFiles directory that are next to the CMakeLists.txt.")
29 endif()
30
31 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
32
33 ###########################################################
34 # Detect system
35 ###########################################################
36
37 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
38     set(LINUX ON)
39 elseif(WIN32)
40 elseif(APPLE)
41 else()
42     message(FATAL_ERROR "Platform is not supported")
43 endif()
44
45 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
46     set(ARCH "x86_64")
47 else()
48     set(ARCH "x86")
49 endif()
50
51 ###########################################################
52 # Convenience macros
53 ###########################################################
54
55 # Recursively calls source_group on the files of the directory
56 # so that Visual Studio has the files in a folder tree
57 macro(group_all_sources directory)
58     file(GLOB files RELATIVE ${CMAKE_SOURCE_DIR}/${directory} ${CMAKE_SOURCE_DIR}/${directory}/*)
59     foreach(file ${files})
60         if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/${directory}/${file})
61             group_all_sources(${directory}/${file})
62         else()
63             string(REPLACE "/" "\\" groupname ${directory})
64             source_group(${groupname} FILES ${CMAKE_SOURCE_DIR}/${directory}/${file})
65         endif()
66     endforeach()
67 endmacro()
68
69 # Takes target library and a directory where the export map is
70 # and add the linker options so that only the API symbols are
71 # exported.
72 macro(set_target_export_map TARGET DIR)
73     get_target_property(LINKFLAGS ${TARGET} LINK_FLAGS)
74     if(LINKFLAGS MATCHES "NOTFOUND")
75         set(LINKFLAGS "")
76     endif()
77     if(MSVC)
78         set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "/DEF:\"${DIR}/${TARGET}.def\"")
79     elseif(LINUX)
80         # Both hash-style are needed, because we want both gold and
81         # GNU ld to be able to read our libraries (maybe?).
82         # The version script only exports the API functions and
83         # hides all the others. Gc sections is used in combination
84         # with each functions being in its section, to reduce the
85         # binary size.
86         set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "${LINKFLAGS} -Wl,--hash-style=both,--version-script=${DIR}/exports.map,--gc-sections,--no-undefined")
87     endif()
88 endmacro()
89
90 if(USE_GROUP_SOURCES)
91     group_all_sources(src)
92 endif()
93
94 ###########################################################
95 # Directories
96 ###########################################################
97
98 set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
99 set(OPENGL_DIR ${SOURCE_DIR}/OpenGL)
100 set(OPENGL_COMPILER_DIR ${OPENGL_DIR}/compiler)
101 set(LLVM_DIR ${CMAKE_SOURCE_DIR}/third_party/LLVM)
102 set(TESTS_DIR ${CMAKE_SOURCE_DIR}/tests)
103 set(HELLO2_DIR ${CMAKE_SOURCE_DIR}/third_party/PowerVR_SDK/Examples/Beginner/01_HelloAPI/OGLES2)
104
105 ###########################################################
106 # Compile flags
107 ###########################################################
108
109 macro(set_cpp_flag FLAG)
110     if(${ARGC} GREATER 1)
111         set(CMAKE_CXX_FLAGS_${ARGV1} "${CMAKE_CXX_FLAGS_${ARGV1}} ${FLAG}")
112     else()
113         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
114     endif()
115 endmacro()
116
117 if(MSVC)
118     set_cpp_flag("/MP")
119     add_definitions(-D_CRT_SECURE_NO_WARNINGS)
120 else()
121     set_cpp_flag("--std=c++11")
122     set_cpp_flag("-Wall")
123     set_cpp_flag("-fexceptions")
124
125     # Don't allow symbols to be overridden by another module.
126     # This enables libGLES_CM and libGLESv2 to statically link LLVM.
127     set_cpp_flag("-fvisibility=protected")
128
129     # Remove xor, and, or and friends from the list of keywords, they are used
130     # by Reactor
131     set_cpp_flag("-fno-operator-names")
132
133     # LLVM headers requires these flags to be set
134     set_cpp_flag("-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS")
135
136     if(ARCH EQUAL "x86")
137         set_cpp_flag("-m32")
138         set_cpp_flag("-msse2")
139         set_cpp_flag("-march=i686")
140     endif()
141     if(ARCH EQUAL "x86_64")
142         set_cpp_flag("-m64")
143         set_cpp_flag("-fPIC")
144         set_cpp_flag("-march=core2")
145     endif()
146
147     # Use -g3 to have even more debug info
148     set_cpp_flag("-g -g3" DEBUG)
149     set_cpp_flag("-g -g3" RELWITHDEBINFO)
150     set_cpp_flag("-s" RELEASE)
151
152     # For distribution it is more important to be slim than super optimized
153     # so even in Release we use only -O2
154     set_cpp_flag("-O2 -Os" RELEASE)
155     set_cpp_flag("-O2 -Os" RELWITHDEBINFO)
156
157     set_cpp_flag("-DNDEBUG" RELEASE)
158     set_cpp_flag("-DNDEBUG" RELWITHDEBINFO)
159     set_cpp_flag("-DANGLE_DISABLE_TRACE" RELEASE)
160     set_cpp_flag("-DANGLE_DISABLE_TRACE" RELWITHDEBINFO)
161
162     # Put each variable and function in its own section so that when linking
163     # with -gc-sections unused functions and variables are removed.
164     set_cpp_flag("-ffunction-sections" RELEASE)
165     set_cpp_flag("-fdata-sections" RELEASE)
166     set_cpp_flag("-fomit-frame-pointer" RELEASE)
167 endif()
168
169 if( WIN32 )
170     add_definitions(-DWINVER=0x501 -DNOMINMAX -DSTRICT)
171     set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib")
172 endif()
173
174
175 ###########################################################
176 # LLVM
177 ###########################################################
178
179 set(LLVM_LIST
180     ${LLVM_DIR}/lib/Analysis/AliasAnalysis.cpp
181     ${LLVM_DIR}/lib/Analysis/AliasSetTracker.cpp
182     ${LLVM_DIR}/lib/Analysis/BasicAliasAnalysis.cpp
183     ${LLVM_DIR}/lib/Analysis/BranchProbabilityInfo.cpp
184     ${LLVM_DIR}/lib/Analysis/CaptureTracking.cpp
185     ${LLVM_DIR}/lib/Analysis/ConstantFolding.cpp
186     ${LLVM_DIR}/lib/Analysis/DIBuilder.cpp
187     ${LLVM_DIR}/lib/Analysis/DebugInfo.cpp
188     ${LLVM_DIR}/lib/Analysis/IVUsers.cpp
189     ${LLVM_DIR}/lib/Analysis/InstructionSimplify.cpp
190     ${LLVM_DIR}/lib/Analysis/Loads.cpp
191     ${LLVM_DIR}/lib/Analysis/LoopInfo.cpp
192     ${LLVM_DIR}/lib/Analysis/LoopPass.cpp
193     ${LLVM_DIR}/lib/Analysis/MemoryBuiltins.cpp
194     ${LLVM_DIR}/lib/Analysis/MemoryDependenceAnalysis.cpp
195     ${LLVM_DIR}/lib/Analysis/NoAliasAnalysis.cpp
196     ${LLVM_DIR}/lib/Analysis/PHITransAddr.cpp
197     ${LLVM_DIR}/lib/Analysis/PathNumbering.cpp
198     ${LLVM_DIR}/lib/Analysis/ProfileInfo.cpp
199     ${LLVM_DIR}/lib/Analysis/ScalarEvolution.cpp
200     ${LLVM_DIR}/lib/Analysis/ScalarEvolutionExpander.cpp
201     ${LLVM_DIR}/lib/Analysis/ScalarEvolutionNormalization.cpp
202     ${LLVM_DIR}/lib/Analysis/TypeBasedAliasAnalysis.cpp
203     ${LLVM_DIR}/lib/Analysis/ValueTracking.cpp
204     ${LLVM_DIR}/lib/CodeGen/AggressiveAntiDepBreaker.cpp
205     ${LLVM_DIR}/lib/CodeGen/AllocationOrder.cpp
206     ${LLVM_DIR}/lib/CodeGen/Analysis.cpp
207     ${LLVM_DIR}/lib/CodeGen/BranchFolding.cpp
208     ${LLVM_DIR}/lib/CodeGen/CalcSpillWeights.cpp
209     ${LLVM_DIR}/lib/CodeGen/CallingConvLower.cpp
210     ${LLVM_DIR}/lib/CodeGen/CodePlacementOpt.cpp
211     ${LLVM_DIR}/lib/CodeGen/CriticalAntiDepBreaker.cpp
212     ${LLVM_DIR}/lib/CodeGen/DeadMachineInstructionElim.cpp
213     ${LLVM_DIR}/lib/CodeGen/DwarfEHPrepare.cpp
214     ${LLVM_DIR}/lib/CodeGen/ELFCodeEmitter.cpp
215     ${LLVM_DIR}/lib/CodeGen/ELFWriter.cpp
216     ${LLVM_DIR}/lib/CodeGen/EdgeBundles.cpp
217     ${LLVM_DIR}/lib/CodeGen/ExecutionDepsFix.cpp
218     ${LLVM_DIR}/lib/CodeGen/ExpandISelPseudos.cpp
219     ${LLVM_DIR}/lib/CodeGen/ExpandPostRAPseudos.cpp
220     ${LLVM_DIR}/lib/CodeGen/GCMetadata.cpp
221     ${LLVM_DIR}/lib/CodeGen/GCStrategy.cpp
222     ${LLVM_DIR}/lib/CodeGen/InlineSpiller.cpp
223     ${LLVM_DIR}/lib/CodeGen/InterferenceCache.cpp
224     ${LLVM_DIR}/lib/CodeGen/IntrinsicLowering.cpp
225     ${LLVM_DIR}/lib/CodeGen/LLVMTargetMachine.cpp
226     ${LLVM_DIR}/lib/CodeGen/LatencyPriorityQueue.cpp
227     ${LLVM_DIR}/lib/CodeGen/LexicalScopes.cpp
228     ${LLVM_DIR}/lib/CodeGen/LiveDebugVariables.cpp
229     ${LLVM_DIR}/lib/CodeGen/LiveInterval.cpp
230     ${LLVM_DIR}/lib/CodeGen/LiveIntervalAnalysis.cpp
231     ${LLVM_DIR}/lib/CodeGen/LiveIntervalUnion.cpp
232     ${LLVM_DIR}/lib/CodeGen/LiveRangeCalc.cpp
233     ${LLVM_DIR}/lib/CodeGen/LiveRangeEdit.cpp
234     ${LLVM_DIR}/lib/CodeGen/LiveStackAnalysis.cpp
235     ${LLVM_DIR}/lib/CodeGen/LiveVariables.cpp
236     ${LLVM_DIR}/lib/CodeGen/LocalStackSlotAllocation.cpp
237     ${LLVM_DIR}/lib/CodeGen/MachineBasicBlock.cpp
238     ${LLVM_DIR}/lib/CodeGen/MachineCSE.cpp
239     ${LLVM_DIR}/lib/CodeGen/MachineDominators.cpp
240     ${LLVM_DIR}/lib/CodeGen/MachineFunction.cpp
241     ${LLVM_DIR}/lib/CodeGen/MachineFunctionAnalysis.cpp
242     ${LLVM_DIR}/lib/CodeGen/MachineFunctionPass.cpp
243     ${LLVM_DIR}/lib/CodeGen/MachineFunctionPrinterPass.cpp
244     ${LLVM_DIR}/lib/CodeGen/MachineInstr.cpp
245     ${LLVM_DIR}/lib/CodeGen/MachineLICM.cpp
246     ${LLVM_DIR}/lib/CodeGen/MachineLoopInfo.cpp
247     ${LLVM_DIR}/lib/CodeGen/MachineModuleInfo.cpp
248     ${LLVM_DIR}/lib/CodeGen/MachineModuleInfoImpls.cpp
249     ${LLVM_DIR}/lib/CodeGen/MachinePassRegistry.cpp
250     ${LLVM_DIR}/lib/CodeGen/MachineRegisterInfo.cpp
251     ${LLVM_DIR}/lib/CodeGen/MachineSSAUpdater.cpp
252     ${LLVM_DIR}/lib/CodeGen/MachineSink.cpp
253     ${LLVM_DIR}/lib/CodeGen/MachineVerifier.cpp
254     ${LLVM_DIR}/lib/CodeGen/ObjectCodeEmitter.cpp
255     ${LLVM_DIR}/lib/CodeGen/OptimizePHIs.cpp
256     ${LLVM_DIR}/lib/CodeGen/PHIElimination.cpp
257     ${LLVM_DIR}/lib/CodeGen/PHIEliminationUtils.cpp
258     ${LLVM_DIR}/lib/CodeGen/Passes.cpp
259     ${LLVM_DIR}/lib/CodeGen/PeepholeOptimizer.cpp
260     ${LLVM_DIR}/lib/CodeGen/PostRASchedulerList.cpp
261     ${LLVM_DIR}/lib/CodeGen/ProcessImplicitDefs.cpp
262     ${LLVM_DIR}/lib/CodeGen/PrologEpilogInserter.cpp
263     ${LLVM_DIR}/lib/CodeGen/PseudoSourceValue.cpp
264     ${LLVM_DIR}/lib/CodeGen/RegAllocBasic.cpp
265     ${LLVM_DIR}/lib/CodeGen/RegAllocFast.cpp
266     ${LLVM_DIR}/lib/CodeGen/RegAllocGreedy.cpp
267     ${LLVM_DIR}/lib/CodeGen/RegAllocLinearScan.cpp
268     ${LLVM_DIR}/lib/CodeGen/RegisterClassInfo.cpp
269     ${LLVM_DIR}/lib/CodeGen/RegisterCoalescer.cpp
270     ${LLVM_DIR}/lib/CodeGen/RegisterScavenging.cpp
271     ${LLVM_DIR}/lib/CodeGen/RenderMachineFunction.cpp
272     ${LLVM_DIR}/lib/CodeGen/ScheduleDAG.cpp
273     ${LLVM_DIR}/lib/CodeGen/ScheduleDAGEmit.cpp
274     ${LLVM_DIR}/lib/CodeGen/ScheduleDAGInstrs.cpp
275     ${LLVM_DIR}/lib/CodeGen/ScheduleDAGPrinter.cpp
276     ${LLVM_DIR}/lib/CodeGen/ScoreboardHazardRecognizer.cpp
277     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
278     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/FastISel.cpp
279     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
280     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
281     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
282     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
283     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
284     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
285     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
286     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
287     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
288     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
289     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp
290     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
291     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
292     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
293     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
294     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
295     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
296     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/TargetLowering.cpp
297     ${LLVM_DIR}/lib/CodeGen/SelectionDAG/TargetSelectionDAGInfo.cpp
298     ${LLVM_DIR}/lib/CodeGen/ShrinkWrapping.cpp
299     ${LLVM_DIR}/lib/CodeGen/SjLjEHPrepare.cpp
300     ${LLVM_DIR}/lib/CodeGen/SlotIndexes.cpp
301     ${LLVM_DIR}/lib/CodeGen/SpillPlacement.cpp
302     ${LLVM_DIR}/lib/CodeGen/Spiller.cpp
303     ${LLVM_DIR}/lib/CodeGen/SplitKit.cpp
304     ${LLVM_DIR}/lib/CodeGen/StackProtector.cpp
305     ${LLVM_DIR}/lib/CodeGen/StackSlotColoring.cpp
306     ${LLVM_DIR}/lib/CodeGen/StrongPHIElimination.cpp
307     ${LLVM_DIR}/lib/CodeGen/TailDuplication.cpp
308     ${LLVM_DIR}/lib/CodeGen/TargetInstrInfoImpl.cpp
309     ${LLVM_DIR}/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
310     ${LLVM_DIR}/lib/CodeGen/TwoAddressInstructionPass.cpp
311     ${LLVM_DIR}/lib/CodeGen/UnreachableBlockElim.cpp
312     ${LLVM_DIR}/lib/CodeGen/VirtRegMap.cpp
313     ${LLVM_DIR}/lib/CodeGen/VirtRegRewriter.cpp
314     ${LLVM_DIR}/lib/ExecutionEngine/ExecutionEngine.cpp
315     ${LLVM_DIR}/lib/ExecutionEngine/JIT/Intercept.cpp
316     ${LLVM_DIR}/lib/ExecutionEngine/JIT/JIT.cpp
317     ${LLVM_DIR}/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp
318     ${LLVM_DIR}/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp
319     ${LLVM_DIR}/lib/ExecutionEngine/JIT/JITEmitter.cpp
320     ${LLVM_DIR}/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
321     ${LLVM_DIR}/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp
322     ${LLVM_DIR}/lib/ExecutionEngine/TargetSelect.cpp
323     ${LLVM_DIR}/lib/MC/ELFObjectWriter.cpp
324     ${LLVM_DIR}/lib/MC/MCAsmBackend.cpp
325     ${LLVM_DIR}/lib/MC/MCAsmInfo.cpp
326     ${LLVM_DIR}/lib/MC/MCAsmInfoCOFF.cpp
327     ${LLVM_DIR}/lib/MC/MCAsmInfoDarwin.cpp
328     ${LLVM_DIR}/lib/MC/MCAsmStreamer.cpp
329     ${LLVM_DIR}/lib/MC/MCAssembler.cpp
330     ${LLVM_DIR}/lib/MC/MCCodeEmitter.cpp
331     ${LLVM_DIR}/lib/MC/MCCodeGenInfo.cpp
332     ${LLVM_DIR}/lib/MC/MCContext.cpp
333     ${LLVM_DIR}/lib/MC/MCDwarf.cpp
334     ${LLVM_DIR}/lib/MC/MCELF.cpp
335     ${LLVM_DIR}/lib/MC/MCELFObjectTargetWriter.cpp
336     ${LLVM_DIR}/lib/MC/MCELFStreamer.cpp
337     ${LLVM_DIR}/lib/MC/MCExpr.cpp
338     ${LLVM_DIR}/lib/MC/MCInst.cpp
339     ${LLVM_DIR}/lib/MC/MCInstPrinter.cpp
340     ${LLVM_DIR}/lib/MC/MCInstrAnalysis.cpp
341     ${LLVM_DIR}/lib/MC/MCLoggingStreamer.cpp
342     ${LLVM_DIR}/lib/MC/MCMachOStreamer.cpp
343     ${LLVM_DIR}/lib/MC/MCMachObjectTargetWriter.cpp
344     ${LLVM_DIR}/lib/MC/MCNullStreamer.cpp
345     ${LLVM_DIR}/lib/MC/MCObjectFileInfo.cpp
346     ${LLVM_DIR}/lib/MC/MCObjectStreamer.cpp
347     ${LLVM_DIR}/lib/MC/MCObjectWriter.cpp
348     ${LLVM_DIR}/lib/MC/MCSection.cpp
349     ${LLVM_DIR}/lib/MC/MCSectionCOFF.cpp
350     ${LLVM_DIR}/lib/MC/MCSectionELF.cpp
351     ${LLVM_DIR}/lib/MC/MCSectionMachO.cpp
352     ${LLVM_DIR}/lib/MC/MCStreamer.cpp
353     ${LLVM_DIR}/lib/MC/MCSubtargetInfo.cpp
354     ${LLVM_DIR}/lib/MC/MCSymbol.cpp
355     ${LLVM_DIR}/lib/MC/MCWin64EH.cpp
356     ${LLVM_DIR}/lib/MC/MachObjectWriter.cpp
357     ${LLVM_DIR}/lib/MC/SubtargetFeature.cpp
358     ${LLVM_DIR}/lib/MC/WinCOFFObjectWriter.cpp
359     ${LLVM_DIR}/lib/MC/WinCOFFStreamer.cpp
360     ${LLVM_DIR}/lib/Support/APFloat.cpp
361     ${LLVM_DIR}/lib/Support/APInt.cpp
362     ${LLVM_DIR}/lib/Support/Allocator.cpp
363     ${LLVM_DIR}/lib/Support/Atomic.cpp
364     ${LLVM_DIR}/lib/Support/BlockFrequency.cpp
365     ${LLVM_DIR}/lib/Support/BranchProbability.cpp
366     ${LLVM_DIR}/lib/Support/CommandLine.cpp
367     ${LLVM_DIR}/lib/Support/ConstantRange.cpp
368     ${LLVM_DIR}/lib/Support/CrashRecoveryContext.cpp
369     ${LLVM_DIR}/lib/Support/DAGDeltaAlgorithm.cpp
370     ${LLVM_DIR}/lib/Support/DataExtractor.cpp
371     ${LLVM_DIR}/lib/Support/Debug.cpp
372     ${LLVM_DIR}/lib/Support/DeltaAlgorithm.cpp
373     ${LLVM_DIR}/lib/Support/Disassembler.cpp
374     ${LLVM_DIR}/lib/Support/Dwarf.cpp
375     ${LLVM_DIR}/lib/Support/DynamicLibrary.cpp
376     ${LLVM_DIR}/lib/Support/Errno.cpp
377     ${LLVM_DIR}/lib/Support/ErrorHandling.cpp
378     ${LLVM_DIR}/lib/Support/FileUtilities.cpp
379     ${LLVM_DIR}/lib/Support/FoldingSet.cpp
380     ${LLVM_DIR}/lib/Support/FormattedStream.cpp
381     ${LLVM_DIR}/lib/Support/GraphWriter.cpp
382     ${LLVM_DIR}/lib/Support/Host.cpp
383     ${LLVM_DIR}/lib/Support/IncludeFile.cpp
384     ${LLVM_DIR}/lib/Support/IntEqClasses.cpp
385     ${LLVM_DIR}/lib/Support/IntervalMap.cpp
386     ${LLVM_DIR}/lib/Support/IsInf.cpp
387     ${LLVM_DIR}/lib/Support/IsNAN.cpp
388     ${LLVM_DIR}/lib/Support/ManagedStatic.cpp
389     ${LLVM_DIR}/lib/Support/Memory.cpp
390     ${LLVM_DIR}/lib/Support/MemoryBuffer.cpp
391     ${LLVM_DIR}/lib/Support/MemoryObject.cpp
392     ${LLVM_DIR}/lib/Support/Mutex.cpp
393     ${LLVM_DIR}/lib/Support/Path.cpp
394     ${LLVM_DIR}/lib/Support/PathV2.cpp
395     ${LLVM_DIR}/lib/Support/PrettyStackTrace.cpp
396     ${LLVM_DIR}/lib/Support/Process.cpp
397     ${LLVM_DIR}/lib/Support/Program.cpp
398     ${LLVM_DIR}/lib/Support/RWMutex.cpp
399     ${LLVM_DIR}/lib/Support/SearchForAddressOfSpecialSymbol.cpp
400     ${LLVM_DIR}/lib/Support/Signals.cpp
401     ${LLVM_DIR}/lib/Support/SmallPtrSet.cpp
402     ${LLVM_DIR}/lib/Support/SmallVector.cpp
403     ${LLVM_DIR}/lib/Support/SourceMgr.cpp
404     ${LLVM_DIR}/lib/Support/Statistic.cpp
405     ${LLVM_DIR}/lib/Support/StringExtras.cpp
406     ${LLVM_DIR}/lib/Support/StringMap.cpp
407     ${LLVM_DIR}/lib/Support/StringPool.cpp
408     ${LLVM_DIR}/lib/Support/StringRef.cpp
409     ${LLVM_DIR}/lib/Support/SystemUtils.cpp
410     ${LLVM_DIR}/lib/Support/TargetRegistry.cpp
411     ${LLVM_DIR}/lib/Support/ThreadLocal.cpp
412     ${LLVM_DIR}/lib/Support/Threading.cpp
413     ${LLVM_DIR}/lib/Support/TimeValue.cpp
414     ${LLVM_DIR}/lib/Support/Timer.cpp
415     ${LLVM_DIR}/lib/Support/ToolOutputFile.cpp
416     ${LLVM_DIR}/lib/Support/Triple.cpp
417     ${LLVM_DIR}/lib/Support/Twine.cpp
418     ${LLVM_DIR}/lib/Support/Valgrind.cpp
419     ${LLVM_DIR}/lib/Support/circular_raw_ostream.cpp
420     ${LLVM_DIR}/lib/Support/raw_os_ostream.cpp
421     ${LLVM_DIR}/lib/Support/raw_ostream.cpp
422     ${LLVM_DIR}/lib/Support/system_error.cpp
423     ${LLVM_DIR}/lib/TableGen/Error.cpp
424     ${LLVM_DIR}/lib/TableGen/Main.cpp
425     ${LLVM_DIR}/lib/TableGen/Record.cpp
426     ${LLVM_DIR}/lib/TableGen/TGLexer.cpp
427     ${LLVM_DIR}/lib/TableGen/TGParser.cpp
428     ${LLVM_DIR}/lib/TableGen/TableGenBackend.cpp
429     ${LLVM_DIR}/lib/Target/Mangler.cpp
430     ${LLVM_DIR}/lib/Target/TargetData.cpp
431     ${LLVM_DIR}/lib/Target/TargetELFWriterInfo.cpp
432     ${LLVM_DIR}/lib/Target/TargetFrameLowering.cpp
433     ${LLVM_DIR}/lib/Target/TargetInstrInfo.cpp
434     ${LLVM_DIR}/lib/Target/TargetLibraryInfo.cpp
435     ${LLVM_DIR}/lib/Target/TargetLoweringObjectFile.cpp
436     ${LLVM_DIR}/lib/Target/TargetMachine.cpp
437     ${LLVM_DIR}/lib/Target/TargetRegisterInfo.cpp
438     ${LLVM_DIR}/lib/Target/TargetSubtargetInfo.cpp
439     ${LLVM_DIR}/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
440     ${LLVM_DIR}/lib/Target/X86/InstPrinter/X86InstComments.cpp
441     ${LLVM_DIR}/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
442     ${LLVM_DIR}/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
443     ${LLVM_DIR}/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
444     ${LLVM_DIR}/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
445     ${LLVM_DIR}/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
446     ${LLVM_DIR}/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
447     ${LLVM_DIR}/lib/Target/X86/TargetInfo/X86TargetInfo.cpp
448     ${LLVM_DIR}/lib/Target/X86/Utils/X86ShuffleDecode.cpp
449     ${LLVM_DIR}/lib/Target/X86/X86CodeEmitter.cpp
450     ${LLVM_DIR}/lib/Target/X86/X86ELFWriterInfo.cpp
451     ${LLVM_DIR}/lib/Target/X86/X86FastISel.cpp
452     ${LLVM_DIR}/lib/Target/X86/X86FloatingPoint.cpp
453     ${LLVM_DIR}/lib/Target/X86/X86FrameLowering.cpp
454     ${LLVM_DIR}/lib/Target/X86/X86ISelDAGToDAG.cpp
455     ${LLVM_DIR}/lib/Target/X86/X86ISelLowering.cpp
456     ${LLVM_DIR}/lib/Target/X86/X86InstrInfo.cpp
457     ${LLVM_DIR}/lib/Target/X86/X86JITInfo.cpp
458     ${LLVM_DIR}/lib/Target/X86/X86RegisterInfo.cpp
459     ${LLVM_DIR}/lib/Target/X86/X86SelectionDAGInfo.cpp
460     ${LLVM_DIR}/lib/Target/X86/X86Subtarget.cpp
461     ${LLVM_DIR}/lib/Target/X86/X86TargetMachine.cpp
462     ${LLVM_DIR}/lib/Target/X86/X86TargetObjectFile.cpp
463     ${LLVM_DIR}/lib/Target/X86/X86VZeroUpper.cpp
464     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineAddSub.cpp
465     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
466     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineCalls.cpp
467     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineCasts.cpp
468     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineCompares.cpp
469     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
470     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
471     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombinePHI.cpp
472     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineSelect.cpp
473     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineShifts.cpp
474     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
475     ${LLVM_DIR}/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
476     ${LLVM_DIR}/lib/Transforms/InstCombine/InstructionCombining.cpp
477     ${LLVM_DIR}/lib/Transforms/Scalar/ADCE.cpp
478     ${LLVM_DIR}/lib/Transforms/Scalar/CodeGenPrepare.cpp
479     ${LLVM_DIR}/lib/Transforms/Scalar/DeadStoreElimination.cpp
480     ${LLVM_DIR}/lib/Transforms/Scalar/GVN.cpp
481     ${LLVM_DIR}/lib/Transforms/Scalar/LICM.cpp
482     ${LLVM_DIR}/lib/Transforms/Scalar/LoopStrengthReduce.cpp
483     ${LLVM_DIR}/lib/Transforms/Scalar/Reassociate.cpp
484     ${LLVM_DIR}/lib/Transforms/Scalar/Reg2Mem.cpp
485     ${LLVM_DIR}/lib/Transforms/Scalar/SCCP.cpp
486     ${LLVM_DIR}/lib/Transforms/Scalar/ScalarReplAggregates.cpp
487     ${LLVM_DIR}/lib/Transforms/Scalar/SimplifyCFGPass.cpp
488     ${LLVM_DIR}/lib/Transforms/Utils/AddrModeMatcher.cpp
489     ${LLVM_DIR}/lib/Transforms/Utils/BasicBlockUtils.cpp
490     ${LLVM_DIR}/lib/Transforms/Utils/BreakCriticalEdges.cpp
491     ${LLVM_DIR}/lib/Transforms/Utils/BuildLibCalls.cpp
492     ${LLVM_DIR}/lib/Transforms/Utils/DemoteRegToStack.cpp
493     ${LLVM_DIR}/lib/Transforms/Utils/InstructionNamer.cpp
494     ${LLVM_DIR}/lib/Transforms/Utils/LCSSA.cpp
495     ${LLVM_DIR}/lib/Transforms/Utils/Local.cpp
496     ${LLVM_DIR}/lib/Transforms/Utils/LoopSimplify.cpp
497     ${LLVM_DIR}/lib/Transforms/Utils/LowerInvoke.cpp
498     ${LLVM_DIR}/lib/Transforms/Utils/LowerSwitch.cpp
499     ${LLVM_DIR}/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
500     ${LLVM_DIR}/lib/Transforms/Utils/SSAUpdater.cpp
501     ${LLVM_DIR}/lib/Transforms/Utils/SimplifyCFG.cpp
502     ${LLVM_DIR}/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
503     ${LLVM_DIR}/lib/VMCore/AsmWriter.cpp
504     ${LLVM_DIR}/lib/VMCore/Attributes.cpp
505     ${LLVM_DIR}/lib/VMCore/BasicBlock.cpp
506     ${LLVM_DIR}/lib/VMCore/ConstantFold.cpp
507     ${LLVM_DIR}/lib/VMCore/Constants.cpp
508     ${LLVM_DIR}/lib/VMCore/DebugInfoProbe.cpp
509     ${LLVM_DIR}/lib/VMCore/DebugLoc.cpp
510     ${LLVM_DIR}/lib/VMCore/Dominators.cpp
511     ${LLVM_DIR}/lib/VMCore/Function.cpp
512     ${LLVM_DIR}/lib/VMCore/Globals.cpp
513     ${LLVM_DIR}/lib/VMCore/IRBuilder.cpp
514     ${LLVM_DIR}/lib/VMCore/InlineAsm.cpp
515     ${LLVM_DIR}/lib/VMCore/Instruction.cpp
516     ${LLVM_DIR}/lib/VMCore/Instructions.cpp
517     ${LLVM_DIR}/lib/VMCore/IntrinsicInst.cpp
518     ${LLVM_DIR}/lib/VMCore/LLVMContext.cpp
519     ${LLVM_DIR}/lib/VMCore/LLVMContextImpl.cpp
520     ${LLVM_DIR}/lib/VMCore/LeakDetector.cpp
521     ${LLVM_DIR}/lib/VMCore/Metadata.cpp
522     ${LLVM_DIR}/lib/VMCore/Module.cpp
523     ${LLVM_DIR}/lib/VMCore/Pass.cpp
524     ${LLVM_DIR}/lib/VMCore/PassManager.cpp
525     ${LLVM_DIR}/lib/VMCore/PassRegistry.cpp
526     ${LLVM_DIR}/lib/VMCore/PrintModulePass.cpp
527     ${LLVM_DIR}/lib/VMCore/Type.cpp
528     ${LLVM_DIR}/lib/VMCore/Use.cpp
529     ${LLVM_DIR}/lib/VMCore/User.cpp
530     ${LLVM_DIR}/lib/VMCore/Value.cpp
531     ${LLVM_DIR}/lib/VMCore/ValueSymbolTable.cpp
532     ${LLVM_DIR}/lib/VMCore/ValueTypes.cpp
533     ${LLVM_DIR}/lib/VMCore/Verifier.cpp
534 )
535
536 if(LINUX)
537     set(LLVM_INCLUDE_DIR ${LLVM_DIR}/include-linux)
538 elseif(APPLE)
539     set(LLVM_INCLUDE_DIR ${LLVM_DIR}/include-osx)
540 endif()
541
542 list(APPEND LLVM_INCLUDE_DIR
543     ${LLVM_DIR}/include
544     ${LLVM_DIR}/lib/Target/X86
545 )
546 add_library(llvm STATIC ${LLVM_LIST})
547 set_target_properties(llvm PROPERTIES
548     POSITION_INDEPENDENT_CODE 1
549     INCLUDE_DIRECTORIES "${LLVM_INCLUDE_DIR}"
550     COMPILE_DEFINITIONS "__STDC_CONSTANT_MACROS;__STDC_LIMIT_MACROS"
551     FOLDER "LLVM"
552 )
553
554 ###########################################################
555 # Include Directories
556 ###########################################################
557
558 set(COMMON_INCLUDE_DIR
559     ${SOURCE_DIR}
560     ${SOURCE_DIR}/Common
561     ${SOURCE_DIR}/Main
562     ${SOURCE_DIR}/Reactor
563     ${SOURCE_DIR}/Renderer
564     ${SOURCE_DIR}/Shader
565     ${CMAKE_SOURCE_DIR}/include
566     ${LLVM_INCLUDE_DIR}
567 )
568 set(OPENGL_INCLUDE_DIR
569     ${OPENGL_DIR}
570     ${COMMON_INCLUDE_DIR}
571 )
572
573 ###########################################################
574 # File Lists
575 ###########################################################
576
577 file(GLOB_RECURSE SWIFTSHADER_LIST
578     ${SOURCE_DIR}/Common/*.cpp
579     ${SOURCE_DIR}/Common/*.h
580     ${SOURCE_DIR}/Common/*.hpp
581     ${SOURCE_DIR}/Renderer/*.cpp
582     ${SOURCE_DIR}/Renderer/*.h
583     ${SOURCE_DIR}/Renderer/*.hpp
584     ${SOURCE_DIR}/Shader/*.cpp
585     ${SOURCE_DIR}/Shader/*.h
586     ${SOURCE_DIR}/Shader/*.hpp
587 )
588 list(APPEND SWIFTSHADER_LIST
589     ${SOURCE_DIR}/Main/Config.cpp
590     ${SOURCE_DIR}/Main/Config.hpp
591     ${SOURCE_DIR}/Main/FrameBuffer.cpp
592     ${SOURCE_DIR}/Main/FrameBuffer.hpp
593     ${SOURCE_DIR}/Main/SwiftConfig.cpp
594     ${SOURCE_DIR}/Main/SwiftConfig.hpp
595 )
596 list(REMOVE_ITEM SWIFTSHADER_LIST
597     ${SOURCE_DIR}/Common/DebugAndroid.cpp
598     ${SOURCE_DIR}/Common/DebugAndroid.hpp
599     ${SOURCE_DIR}/Common/GrallocAndroid.cpp
600     ${SOURCE_DIR}/Common/GrallocAndroid.hpp
601 )
602
603 set(REACTOR_LIST
604     ${SOURCE_DIR}/Reactor/Nucleus.cpp
605     ${SOURCE_DIR}/Reactor/Nucleus.hpp
606     ${SOURCE_DIR}/Reactor/Routine.cpp
607     ${SOURCE_DIR}/Reactor/Routine.hpp
608     ${SOURCE_DIR}/Reactor/RoutineManager.cpp
609     ${SOURCE_DIR}/Reactor/RoutineManager.hpp
610 )
611
612 file(GLOB_RECURSE EGL_LIST
613     ${OPENGL_DIR}/libEGL/*.cpp
614     ${OPENGL_DIR}/libEGL/*.h
615     ${OPENGL_DIR}/libEGL/*.hpp
616     ${OPENGL_DIR}/common/Object.cpp
617     ${OPENGL_DIR}/common/Object.hpp
618     ${OPENGL_DIR}/common/debug.cpp
619     ${OPENGL_DIR}/common/debug.h
620     ${CMAKE_SOURCE_DIR}/include/*.h
621 )
622
623 file(GLOB_RECURSE GL32_LIST
624     ${OPENGL_DIR}/libGL/*.cpp
625     ${OPENGL_DIR}/libGL/*.h
626     ${OPENGL_DIR}/libGL/*.hpp
627     ${OPENGL_DIR}/common/*.cpp
628     ${OPENGL_DIR}/common/*.h
629     ${OPENGL_DIR}/common/*.hpp
630     ${CMAKE_SOURCE_DIR}/include/GL/*.h
631 )
632
633 file(GLOB_RECURSE GLES2_LIST
634     ${OPENGL_DIR}/libGLESv2/*.cpp
635     ${OPENGL_DIR}/libGLESv2/*.h
636     ${OPENGL_DIR}/libGLESv2/*.hpp
637     ${OPENGL_DIR}/common/*.cpp
638     ${OPENGL_DIR}/common/*.h
639     ${OPENGL_DIR}/common/*.hpp
640     ${CMAKE_SOURCE_DIR}/include/KHR/*.h
641     ${CMAKE_SOURCE_DIR}/include/GLES2/*.h
642     ${CMAKE_SOURCE_DIR}/include/GLES3/*.h
643 )
644
645 file(GLOB_RECURSE GLES_CM_LIST
646     ${OPENGL_DIR}/libGLES_CM/*.cpp
647     ${OPENGL_DIR}/libGLES_CM/*.h
648     ${OPENGL_DIR}/libGLES_CM/*.hpp
649     ${OPENGL_DIR}/common/*.cpp
650     ${OPENGL_DIR}/common/*.h
651     ${OPENGL_DIR}/common/*.hpp
652     ${CMAKE_SOURCE_DIR}/include/KHR/*.h
653     ${CMAKE_SOURCE_DIR}/include/GLES/*.h
654 )
655
656 file(GLOB_RECURSE OPENGL_COMPILER_LIST
657     ${OPENGL_COMPILER_DIR}/*.cpp
658     ${OPENGL_COMPILER_DIR}/*.h
659     ${OPENGL_COMPILER_DIR}/*.hpp
660 )
661 file(GLOB_RECURSE OPENGL_COMPILER_OS_SPECIFIC_LIST
662     ${OPENGL_COMPILER_DIR}/ossource*.cpp
663     ${OPENGL_COMPILER_DIR}/ossource*.h
664     ${OPENGL_COMPILER_DIR}/ossource*.hpp
665 )
666 list(REMOVE_ITEM OPENGL_COMPILER_LIST ${OPENGL_COMPILER_OS_SPECIFIC_LIST})
667
668 ###########################################################
669 # Append OS specific files to lists
670 ###########################################################
671
672 if(WIN32)
673     list(APPEND SWIFTSHADER_LIST
674         ${SOURCE_DIR}/Main/FrameBufferDD.cpp
675         ${SOURCE_DIR}/Main/FrameBufferDD.hpp
676         ${SOURCE_DIR}/Main/FrameBufferGDI.cpp
677         ${SOURCE_DIR}/Main/FrameBufferGDI.hpp
678         ${SOURCE_DIR}/Main/FrameBufferWin.cpp
679         ${SOURCE_DIR}/Main/FrameBufferWin.hpp
680         ${SOURCE_DIR}/Reactor/DLL.cpp
681         ${SOURCE_DIR}/Reactor/DLL.hpp
682     )
683     list(APPEND OPENGL_COMPILER_LIST ${OPENGL_COMPILER_DIR}/ossource_win.cpp)
684     list(APPEND EGL_LIST ${OPENGL_DIR}/libEGL/libEGL.rc)
685     list(APPEND GL32_LIST ${OPENGL_DIR}/libGL/libGL.rc)
686     list(APPEND GLES2_LIST ${OPENGL_DIR}/libGLESv2/libGLESv2.rc)
687     list(APPEND GLES_CM_LIST ${OPENGL_DIR}/libGLES_CM/libGLES_CM.rc)
688 elseif(LINUX)
689     list(APPEND SWIFTSHADER_LIST
690         ${SOURCE_DIR}/Main/FrameBufferX11.cpp
691         ${SOURCE_DIR}/Main/FrameBufferX11.hpp
692         ${SOURCE_DIR}/Common/SharedLibrary.hpp
693         ${SOURCE_DIR}/Main/libX11.cpp
694         ${SOURCE_DIR}/Main/libX11.hpp
695     )
696     list(APPEND EGL_LIST
697         ${SOURCE_DIR}/Common/SharedLibrary.hpp
698         ${SOURCE_DIR}/Main/libX11.cpp
699         ${SOURCE_DIR}/Main/libX11.hpp
700     )
701     list(APPEND OPENGL_COMPILER_LIST
702         ${OPENGL_COMPILER_DIR}/ossource_posix.cpp
703     )
704 elseif(APPLE)
705     list(APPEND SWIFTSHADER_LIST
706         ${SOURCE_DIR}/Main/FrameBufferOSX.mm
707         ${SOURCE_DIR}/Main/FrameBufferOSX.hpp
708     )
709     list(APPEND EGL_LIST
710         ${OPENGL_DIR}/libEGL/OSXUtils.mm
711         ${OPENGL_DIR}/libEGL/OSXUtils.hpp
712     )
713     list(APPEND OPENGL_COMPILER_LIST
714         ${OPENGL_COMPILER_DIR}/ossource_posix.cpp
715     )
716 endif()
717
718 if(WIN32)
719     set(OS_LIBS odbc32 odbccp32 WS2_32 dxguid)
720 elseif(LINUX)
721     set(OS_LIBS dl pthread)
722 elseif(APPLE)
723     find_library(COCOA_FRAMEWORK Cocoa)
724     find_library(QUARTZ_FRAMEWORK Quartz)
725     set(OS_LIBS "${COCOA_FRAMEWORK}" "${QUARTZ_FRAMEWORK}")
726 endif()
727
728 ###########################################################
729 # SwiftShader Targets
730 ###########################################################
731
732 add_library(SwiftShader STATIC ${SWIFTSHADER_LIST})
733 set_target_properties(SwiftShader PROPERTIES
734     INCLUDE_DIRECTORIES "${COMMON_INCLUDE_DIR}"
735     POSITION_INDEPENDENT_CODE 1
736     FOLDER "Core"
737 )
738 target_link_libraries(SwiftShader ${OS_LIBS})
739
740 add_library(Reactor STATIC ${REACTOR_LIST})
741 set_target_properties(Reactor PROPERTIES
742     INCLUDE_DIRECTORIES "${COMMON_INCLUDE_DIR}"
743     POSITION_INDEPENDENT_CODE 1
744     FOLDER "Core"
745 )
746 target_link_libraries(Reactor llvm ${OS_LIBS})
747
748 add_library(GLCompiler STATIC ${OPENGL_COMPILER_LIST})
749 set_target_properties(GLCompiler PROPERTIES
750     INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
751     POSITION_INDEPENDENT_CODE 1
752     FOLDER "OpenGL"
753 )
754 target_link_libraries(GLCompiler ${OS_LIBS})
755
756 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
757     set(LIB_PREFIX "lib64")
758 else()
759     set(LIB_PREFIX "lib")
760 endif()
761
762 if(BUILD_EGL)
763     add_library(libEGL SHARED ${EGL_LIST})
764     set_target_properties(libEGL PROPERTIES
765         INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
766         FOLDER "OpenGL"
767         COMPILE_DEFINITIONS "EGL_EGLEXT_PROTOTYPES"
768         PREFIX ""
769     )
770     set_target_export_map(libEGL ${SOURCE_DIR}/OpenGL/libEGL)
771     target_link_libraries(libEGL ${OS_LIBS})
772     add_custom_command(
773         TARGET libEGL
774         POST_BUILD
775         COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:libEGL>/translator
776         COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libEGL> $<TARGET_FILE_DIR:libEGL>/translator/${LIB_PREFIX}EGL_translator${CMAKE_SHARED_LIBRARY_SUFFIX}
777     )
778 endif()
779
780 if(BUILD_GL32)
781     add_library(libGL SHARED ${GL32_LIST})
782     set_target_properties(libGL PROPERTIES
783         INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
784         FOLDER "OpenGL"
785         COMPILE_DEFINITIONS "GL_GLEXT_PROTOTYPES"
786         PREFIX ""
787     )
788     set_target_export_map(libGL ${SOURCE_DIR}/OpenGL/libGL)
789     target_link_libraries(libGL SwiftShader Reactor GLCompiler ${OS_LIBS})
790 endif()
791
792 if(BUILD_GLESv2)
793     add_library(libGLESv2 SHARED ${GLES2_LIST})
794     set_target_properties(libGLESv2 PROPERTIES
795         INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
796         FOLDER "OpenGL"
797         COMPILE_DEFINITIONS "GL_GLEXT_PROTOTYPES"
798         PREFIX ""
799     )
800     set_target_export_map(libGLESv2 ${SOURCE_DIR}/OpenGL/libGLESv2)
801     target_link_libraries(libGLESv2 SwiftShader Reactor GLCompiler ${OS_LIBS})
802     add_custom_command(
803         TARGET libGLESv2
804         POST_BUILD
805         COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:libGLESv2>/translator
806         COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libGLESv2> $<TARGET_FILE_DIR:libGLESv2>/translator/${LIB_PREFIX}GLES_V2_translator${CMAKE_SHARED_LIBRARY_SUFFIX}
807     )
808 endif()
809
810 if(BUILD_GLES_CM)
811     add_library(libGLES_CM SHARED ${GLES_CM_LIST})
812     set_target_properties(libGLES_CM PROPERTIES
813         INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
814         FOLDER "OpenGL"
815         COMPILE_DEFINITIONS "GL_GLEXT_PROTOTYPES"
816         PREFIX ""
817     )
818     set_target_export_map(libGLES_CM ${SOURCE_DIR}/OpenGL/libGLES_CM)
819     target_link_libraries(libGLES_CM SwiftShader Reactor GLCompiler ${OS_LIBS})
820     add_custom_command(
821         TARGET libGLES_CM
822         POST_BUILD
823         COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:libGLES_CM>/translator
824         COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libGLES_CM> $<TARGET_FILE_DIR:libGLES_CM>/translator/${LIB_PREFIX}GLES_CM_translator${CMAKE_SHARED_LIBRARY_SUFFIX}
825     )
826 endif()
827
828 ###########################################################
829 # Extra programs
830 ###########################################################
831
832 if(BUILD_EXTRA_PROGRAMS)
833     if(LINUX)
834         add_executable(OGLES2HelloAPI ${HELLO2_DIR}/OGLES2HelloAPI_LinuxX11.cpp)
835         target_link_libraries(OGLES2HelloAPI dl X11 EGL GLESv2)
836     elseif(APPLE)
837         add_executable(OGLES2HelloAPI MACOSX_BUNDLE
838             ${HELLO2_DIR}/OGLES2HelloAPI_OSX.mm
839             ${HELLO2_DIR}/Build/OSX/en.lproj/MainMenu.xib
840         )
841         set_target_properties(OGLES2HelloAPI PROPERTIES
842             INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/include"
843             COMPILE_DEFINITIONS "GL_GLEXT_PROTOTYPES"
844             MACOSX_BUNDLE_INFO_PLIST "${HELLO2_DIR}/Build/OSX/Info.plist"
845         )
846         target_link_libraries(OGLES2HelloAPI libEGL libGLESv2 ${OS_LIBS})
847         set_source_files_properties(${HELLO2_DIR}/Build/OSX/en.lproj/MainMenu.xib PROPERTIES
848             MACOSX_PACKAGE_LOCATION "Resources"
849         )
850     endif()
851 endif()