1 # increase to 3.1 once all major distributions
2 # include a version of CMake >= 3.1
3 cmake_minimum_required(VERSION 2.8.12)
4 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
6 # Adhere to GNU filesystem layout conventions
7 include(GNUInstallDirs)
9 option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
10 option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
12 option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
14 option(ENABLE_HLSL "Enables HLSL input support" ON)
18 if(ENABLE_AMD_EXTENSIONS)
19 add_definitions(-DAMD_EXTENSIONS)
20 endif(ENABLE_AMD_EXTENSIONS)
22 if(ENABLE_NV_EXTENSIONS)
23 add_definitions(-DNV_EXTENSIONS)
24 endif(ENABLE_NV_EXTENSIONS)
27 add_definitions(-DENABLE_HLSL)
31 set(CMAKE_DEBUG_POSTFIX "d")
33 include(ChooseMSVCCRT.cmake)
35 add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
37 add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
39 message("unknown platform")
42 if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
43 add_compile_options(-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_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
46 elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
47 add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
48 -Wunused-parameter -Wunused-value -Wunused-variable)
49 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
53 if(${CMAKE_VERSION} VERSION_LESS 3.1)
54 # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
55 # remove this block once CMake >=3.1 has fixated in the ecosystem
56 add_compile_options(-std=c++11)
58 set(CMAKE_CXX_STANDARD 11)
59 set(CMAKE_CXX_STANDARD_REQUIRED ON)
60 set(CMAKE_CXX_EXTENSIONS OFF)
63 function(glslang_set_link_args TARGET)
64 # For MinGW compiles, statically link against the GCC and C++ runtimes.
65 # This avoids the need to ship those runtimes as DLLs.
66 if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
67 set_target_properties(${TARGET} PROPERTIES
68 LINK_FLAGS "-static -static-libgcc -static-libstdc++")
70 endfunction(glslang_set_link_args)
72 # We depend on these for later projects, so they should come first.
73 add_subdirectory(External)
75 add_subdirectory(glslang)
76 add_subdirectory(OGLCompilersDLL)
77 if(ENABLE_GLSLANG_BINARIES)
78 add_subdirectory(StandAlone)
80 add_subdirectory(SPIRV)
82 add_subdirectory(hlsl)
84 add_subdirectory(gtests)