blob: 32395c0598245f6223e328592d8bea968cf7bf7d [file] [log] [blame]
Wesley Griffinac39cdc2016-08-01 15:36:15 -04001cmake_minimum_required(VERSION 2.8.11)
Andrew Woloszyndb0eaf92016-05-05 14:45:53 -04002set_property(GLOBAL PROPERTY USE_FOLDERS ON)
John Kessenichd49d5242015-06-26 16:29:10 -06003
Dominik Witczakdaff1a22016-09-27 09:51:34 +02004option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
Henrik Rydgård868746a2016-12-20 01:56:00 +01005option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
Rex Xu9d93a232016-05-05 12:30:44 +08006
chaoc0ad6a4e2016-12-19 16:29:34 -08007option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
8
Alex Szpakowskiff21a252017-01-09 18:10:14 -04009option(ENABLE_HLSL "Enables HLSL input support" ON)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040010
Lei Zhang414eb602016-03-04 16:22:34 -050011enable_testing()
12
Chad Versace4cbf7482015-08-31 14:27:04 -070013set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix")
John Kessenichd49d5242015-06-26 16:29:10 -060014
15project(glslang)
16
Rex Xu9d93a232016-05-05 12:30:44 +080017if(ENABLE_AMD_EXTENSIONS)
18 add_definitions(-DAMD_EXTENSIONS)
19endif(ENABLE_AMD_EXTENSIONS)
20
chaoc0ad6a4e2016-12-19 16:29:34 -080021if(ENABLE_NV_EXTENSIONS)
22 add_definitions(-DNV_EXTENSIONS)
23endif(ENABLE_NV_EXTENSIONS)
24
Alex Szpakowskiff21a252017-01-09 18:10:14 -040025if(ENABLE_HLSL)
26 add_definitions(-DENABLE_HLSL)
27endif(ENABLE_HLSL)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040028
John Kessenichd49d5242015-06-26 16:29:10 -060029if(WIN32)
Brad Davis1e194e82016-05-25 13:08:34 -070030 set(CMAKE_DEBUG_POSTFIX "d")
DragoonX681559342017-03-12 04:44:55 +010031 if(MSVC)
32 include(ChooseMSVCCRT.cmake)
33 endif(MSVC)
baldurk876a0e32015-11-16 18:03:28 +010034 add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
John Kessenichd49d5242015-06-26 16:29:10 -060035elseif(UNIX)
36 add_definitions(-fPIC)
baldurk876a0e32015-11-16 18:03:28 +010037 add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
John Kessenichd49d5242015-06-26 16:29:10 -060038else(WIN32)
Eric Engestrom6a6d6dd2016-04-03 01:17:13 +010039 message("unknown platform")
John Kessenichd49d5242015-06-26 16:29:10 -060040endif(WIN32)
41
42if(CMAKE_COMPILER_IS_GNUCXX)
LoopDawg6d478952016-07-18 10:11:05 -060043 add_definitions(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
44 -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable)
45 add_definitions(-Wno-reorder) # disable this from -Wall, since it happens all over.
John Kessenichd49d5242015-06-26 16:29:10 -060046 add_definitions(-std=c++11)
47elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
LoopDawg6d478952016-07-18 10:11:05 -060048 add_definitions(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
49 -Wunused-parameter -Wunused-value -Wunused-variable)
50 add_definitions(-Wno-reorder) # disable this from -Wall, since it happens all over.
John Kessenichd49d5242015-06-26 16:29:10 -060051 add_definitions(-std=c++11)
52endif()
53
David Netob37dc0e2016-06-02 14:37:24 -040054function(glslang_set_link_args TARGET)
55 # For MinGW compiles, statically link against the GCC and C++ runtimes.
56 # This avoids the need to ship those runtimes as DLLs.
57 if(WIN32)
58 if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
59 set_target_properties(${TARGET} PROPERTIES
60 LINK_FLAGS "-static -static-libgcc -static-libstdc++")
61 endif()
62 endif(WIN32)
63endfunction(glslang_set_link_args)
64
Lei Zhang414eb602016-03-04 16:22:34 -050065# We depend on these for later projects, so they should come first.
66add_subdirectory(External)
67
John Kessenichd49d5242015-06-26 16:29:10 -060068add_subdirectory(glslang)
69add_subdirectory(OGLCompilersDLL)
Henrik Rydgård868746a2016-12-20 01:56:00 +010070if(ENABLE_GLSLANG_BINARIES)
71 add_subdirectory(StandAlone)
72endif()
John Kessenichd49d5242015-06-26 16:29:10 -060073add_subdirectory(SPIRV)
Alex Szpakowskiff21a252017-01-09 18:10:14 -040074if(ENABLE_HLSL)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040075 add_subdirectory(hlsl)
John Kessenichdc1a8192017-01-11 14:50:16 -070076endif(ENABLE_HLSL)
Lei Zhang414eb602016-03-04 16:22:34 -050077add_subdirectory(gtests)