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(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
20 option(SKIP_GLSLANG_INSTALL "Skip installation" ${SKIP_GLSLANG_INSTALL})
21 if(NOT ${SKIP_GLSLANG_INSTALL})
22 set(ENABLE_GLSLANG_INSTALL ON)
25 option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
26 option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
28 option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
30 option(ENABLE_HLSL "Enables HLSL input support" ON)
32 option(ENABLE_OPT "Enables spirv-opt capability if present" ON)
34 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
35 set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
39 # make testing optional
42 if(ENABLE_AMD_EXTENSIONS)
43 add_definitions(-DAMD_EXTENSIONS)
44 endif(ENABLE_AMD_EXTENSIONS)
46 if(ENABLE_NV_EXTENSIONS)
47 add_definitions(-DNV_EXTENSIONS)
48 endif(ENABLE_NV_EXTENSIONS)
51 add_definitions(-DENABLE_HLSL)
55 set(CMAKE_DEBUG_POSTFIX "d")
57 include(ChooseMSVCCRT.cmake)
59 add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
61 add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
63 message("unknown platform")
66 if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
67 add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
68 -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions)
69 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
70 elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
71 add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
72 -Wunused-parameter -Wunused-value -Wunused-variable)
73 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
77 if(${CMAKE_VERSION} VERSION_LESS 3.1)
78 # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
79 # remove this block once CMake >=3.1 has fixated in the ecosystem
80 add_compile_options(-std=c++11)
82 set(CMAKE_CXX_STANDARD 11)
83 set(CMAKE_CXX_STANDARD_REQUIRED ON)
84 set(CMAKE_CXX_EXTENSIONS OFF)
87 function(glslang_set_link_args TARGET)
88 # For MinGW compiles, statically link against the GCC and C++ runtimes.
89 # This avoids the need to ship those runtimes as DLLs.
90 if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
91 set_target_properties(${TARGET} PROPERTIES
92 LINK_FLAGS "-static -static-libgcc -static-libstdc++")
94 endfunction(glslang_set_link_args)
96 # We depend on these for later projects, so they should come first.
97 add_subdirectory(External)
99 if(NOT TARGET SPIRV-Tools-opt)
104 message(STATUS "optimizer enabled")
105 add_definitions(-DENABLE_OPT=1)
108 message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL")
110 add_definitions(-DENABLE_OPT=0)
113 add_subdirectory(glslang)
114 add_subdirectory(OGLCompilersDLL)
115 if(ENABLE_GLSLANG_BINARIES)
116 add_subdirectory(StandAlone)
118 add_subdirectory(SPIRV)
120 add_subdirectory(hlsl)
122 add_subdirectory(gtests)