blob: d4537201696587405f03a2b684771e5700befbc1 [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")
John Kessenichd49d5242015-06-26 16:29:10 -060031 include(ChooseMSVCCRT.cmake)
baldurk876a0e32015-11-16 18:03:28 +010032 add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
John Kessenichd49d5242015-06-26 16:29:10 -060033elseif(UNIX)
34 add_definitions(-fPIC)
baldurk876a0e32015-11-16 18:03:28 +010035 add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
John Kessenichd49d5242015-06-26 16:29:10 -060036else(WIN32)
Eric Engestrom6a6d6dd2016-04-03 01:17:13 +010037 message("unknown platform")
John Kessenichd49d5242015-06-26 16:29:10 -060038endif(WIN32)
39
40if(CMAKE_COMPILER_IS_GNUCXX)
LoopDawg6d478952016-07-18 10:11:05 -060041 add_definitions(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
42 -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable)
43 add_definitions(-Wno-reorder) # disable this from -Wall, since it happens all over.
John Kessenichd49d5242015-06-26 16:29:10 -060044 add_definitions(-std=c++11)
45elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
LoopDawg6d478952016-07-18 10:11:05 -060046 add_definitions(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
47 -Wunused-parameter -Wunused-value -Wunused-variable)
48 add_definitions(-Wno-reorder) # disable this from -Wall, since it happens all over.
John Kessenichd49d5242015-06-26 16:29:10 -060049 add_definitions(-std=c++11)
50endif()
51
David Netob37dc0e2016-06-02 14:37:24 -040052function(glslang_set_link_args TARGET)
53 # For MinGW compiles, statically link against the GCC and C++ runtimes.
54 # This avoids the need to ship those runtimes as DLLs.
55 if(WIN32)
56 if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
57 set_target_properties(${TARGET} PROPERTIES
58 LINK_FLAGS "-static -static-libgcc -static-libstdc++")
59 endif()
60 endif(WIN32)
61endfunction(glslang_set_link_args)
62
Lei Zhang414eb602016-03-04 16:22:34 -050063# We depend on these for later projects, so they should come first.
64add_subdirectory(External)
65
John Kessenichd49d5242015-06-26 16:29:10 -060066add_subdirectory(glslang)
67add_subdirectory(OGLCompilersDLL)
Henrik Rydgård868746a2016-12-20 01:56:00 +010068if(ENABLE_GLSLANG_BINARIES)
69 add_subdirectory(StandAlone)
70endif()
John Kessenichd49d5242015-06-26 16:29:10 -060071add_subdirectory(SPIRV)
Alex Szpakowskiff21a252017-01-09 18:10:14 -040072if(ENABLE_HLSL)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040073 add_subdirectory(hlsl)
John Kessenichdc1a8192017-01-11 14:50:16 -070074endif(ENABLE_HLSL)
Lei Zhang414eb602016-03-04 16:22:34 -050075add_subdirectory(gtests)