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)
16 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
17 set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
21 # make testing optional
24 if(ENABLE_AMD_EXTENSIONS)
25 add_definitions(-DAMD_EXTENSIONS)
26 endif(ENABLE_AMD_EXTENSIONS)
28 if(ENABLE_NV_EXTENSIONS)
29 add_definitions(-DNV_EXTENSIONS)
30 endif(ENABLE_NV_EXTENSIONS)
33 add_definitions(-DENABLE_HLSL)
37 set(CMAKE_DEBUG_POSTFIX "d")
39 include(ChooseMSVCCRT.cmake)
41 add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
43 add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
45 message("unknown platform")
48 if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
49 add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
50 -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable)
51 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
52 elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
53 add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
54 -Wunused-parameter -Wunused-value -Wunused-variable)
55 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
59 if(${CMAKE_VERSION} VERSION_LESS 3.1)
60 # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
61 # remove this block once CMake >=3.1 has fixated in the ecosystem
62 add_compile_options(-std=c++11)
64 set(CMAKE_CXX_STANDARD 11)
65 set(CMAKE_CXX_STANDARD_REQUIRED ON)
66 set(CMAKE_CXX_EXTENSIONS OFF)
69 function(glslang_set_link_args TARGET)
70 # For MinGW compiles, statically link against the GCC and C++ runtimes.
71 # This avoids the need to ship those runtimes as DLLs.
72 if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
73 set_target_properties(${TARGET} PROPERTIES
74 LINK_FLAGS "-static -static-libgcc -static-libstdc++")
76 endfunction(glslang_set_link_args)
78 # We depend on these for later projects, so they should come first.
79 add_subdirectory(External)
81 add_subdirectory(glslang)
82 add_subdirectory(OGLCompilersDLL)
83 if(ENABLE_GLSLANG_BINARIES)
84 add_subdirectory(StandAlone)
86 add_subdirectory(SPIRV)
88 add_subdirectory(hlsl)
90 add_subdirectory(gtests)