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)
5 cmake_policy(SET CMP0048 NEW)
7 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
9 # Adhere to GNU filesystem layout conventions
10 include(GNUInstallDirs)
12 option(SKIP_GLSLANG_INSTALL "Skip installation" ${SKIP_GLSLANG_INSTALL})
13 if(NOT ${SKIP_GLSLANG_INSTALL})
14 set(ENABLE_GLSLANG_INSTALL ON)
17 option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
18 option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
20 option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
22 option(ENABLE_HLSL "Enables HLSL input support" ON)
24 option(ENABLE_OPT "Enables spirv-opt capability if present" ON)
26 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
27 set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
31 # make testing optional
34 if(ENABLE_AMD_EXTENSIONS)
35 add_definitions(-DAMD_EXTENSIONS)
36 endif(ENABLE_AMD_EXTENSIONS)
38 if(ENABLE_NV_EXTENSIONS)
39 add_definitions(-DNV_EXTENSIONS)
40 endif(ENABLE_NV_EXTENSIONS)
43 add_definitions(-DENABLE_HLSL)
47 set(CMAKE_DEBUG_POSTFIX "d")
49 include(ChooseMSVCCRT.cmake)
51 add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
53 add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
55 message("unknown platform")
58 if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
59 add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
60 -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions)
61 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
62 elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
63 add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
64 -Wunused-parameter -Wunused-value -Wunused-variable)
65 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
69 if(${CMAKE_VERSION} VERSION_LESS 3.1)
70 # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
71 # remove this block once CMake >=3.1 has fixated in the ecosystem
72 add_compile_options(-std=c++11)
74 set(CMAKE_CXX_STANDARD 11)
75 set(CMAKE_CXX_STANDARD_REQUIRED ON)
76 set(CMAKE_CXX_EXTENSIONS OFF)
79 function(glslang_set_link_args TARGET)
80 # For MinGW compiles, statically link against the GCC and C++ runtimes.
81 # This avoids the need to ship those runtimes as DLLs.
82 if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
83 set_target_properties(${TARGET} PROPERTIES
84 LINK_FLAGS "-static -static-libgcc -static-libstdc++")
86 endfunction(glslang_set_link_args)
88 # We depend on these for later projects, so they should come first.
89 add_subdirectory(External)
91 if(NOT TARGET SPIRV-Tools-opt)
96 message(STATUS "optimizer enabled")
97 add_definitions(-DENABLE_OPT)
99 message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL")
102 add_subdirectory(glslang)
103 add_subdirectory(OGLCompilersDLL)
104 if(ENABLE_GLSLANG_BINARIES)
105 add_subdirectory(StandAlone)
107 add_subdirectory(SPIRV)
109 add_subdirectory(hlsl)
111 add_subdirectory(gtests)