Merge branch 'missing_descriptor_indexing_extension' of https://github.com/jeffbolznv...
[platform/upstream/glslang.git] / CMakeLists.txt
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 if (POLICY CMP0048)
5   cmake_policy(SET CMP0048 NEW)
6 endif()
7 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
8
9 # Adhere to GNU filesystem layout conventions
10 include(GNUInstallDirs)
11
12 option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
13
14 set(LIB_TYPE STATIC)
15
16 if(BUILD_SHARED_LIBS)
17     set(LIB_TYPE SHARED)
18 endif()
19
20 option(SKIP_GLSLANG_INSTALL "Skip installation" ${SKIP_GLSLANG_INSTALL})
21 if(NOT ${SKIP_GLSLANG_INSTALL})
22   set(ENABLE_GLSLANG_INSTALL ON)
23 endif()
24
25 option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
26 option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
27
28 option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
29
30 option(ENABLE_HLSL "Enables HLSL input support" ON)
31
32 option(ENABLE_OPT "Enables spirv-opt capability if present" ON)
33
34 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
35     set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
36 endif()
37
38 project(glslang)
39 # make testing optional
40 include(CTest)
41
42 if(ENABLE_AMD_EXTENSIONS)
43     add_definitions(-DAMD_EXTENSIONS)
44 endif(ENABLE_AMD_EXTENSIONS)
45
46 if(ENABLE_NV_EXTENSIONS)
47     add_definitions(-DNV_EXTENSIONS)
48 endif(ENABLE_NV_EXTENSIONS)
49
50 if(ENABLE_HLSL)
51     add_definitions(-DENABLE_HLSL)
52 endif(ENABLE_HLSL)
53
54 if(WIN32)
55     set(CMAKE_DEBUG_POSTFIX "d")
56     if(MSVC)
57         include(ChooseMSVCCRT.cmake)
58     endif(MSVC)
59     add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
60 elseif(UNIX)
61     add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
62 else(WIN32)
63     message("unknown platform")
64 endif(WIN32)
65
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.
74 endif()
75
76 # Request C++11
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)
81 else()
82     set(CMAKE_CXX_STANDARD 11)
83     set(CMAKE_CXX_STANDARD_REQUIRED ON)
84     set(CMAKE_CXX_EXTENSIONS OFF)
85 endif()
86
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++")
93     endif()
94 endfunction(glslang_set_link_args)
95
96 # We depend on these for later projects, so they should come first.
97 add_subdirectory(External)
98
99 if(NOT TARGET SPIRV-Tools-opt)
100     set(ENABLE_OPT OFF)
101 endif()
102
103 if(ENABLE_OPT)
104     message(STATUS "optimizer enabled")
105     add_definitions(-DENABLE_OPT=1)
106 else()
107     if(ENABLE_HLSL)
108         message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL")
109     endif()
110     add_definitions(-DENABLE_OPT=0)
111 endif()
112
113 add_subdirectory(glslang)
114 add_subdirectory(OGLCompilersDLL)
115 if(ENABLE_GLSLANG_BINARIES)
116     add_subdirectory(StandAlone)
117 endif()
118 add_subdirectory(SPIRV)
119 if(ENABLE_HLSL)
120     add_subdirectory(hlsl)
121 endif(ENABLE_HLSL)
122 add_subdirectory(gtests)