f1012f74d7318047acabb8773e0104d9e20b7578
[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 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
5
6 # Adhere to GNU filesystem layout conventions
7 include(GNUInstallDirs)
8
9 option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
10 option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
11
12 option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
13
14 option(ENABLE_HLSL "Enables HLSL input support" ON)
15
16 project(glslang)
17
18 if(ENABLE_AMD_EXTENSIONS)
19     add_definitions(-DAMD_EXTENSIONS)
20 endif(ENABLE_AMD_EXTENSIONS)
21
22 if(ENABLE_NV_EXTENSIONS)
23     add_definitions(-DNV_EXTENSIONS)
24 endif(ENABLE_NV_EXTENSIONS)
25
26 if(ENABLE_HLSL)
27     add_definitions(-DENABLE_HLSL)
28 endif(ENABLE_HLSL)
29
30 if(WIN32)
31     set(CMAKE_DEBUG_POSTFIX "d")
32     if(MSVC)
33         include(ChooseMSVCCRT.cmake)
34     endif(MSVC)
35     add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
36 elseif(UNIX)
37     add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
38 else(WIN32)
39     message("unknown platform")
40 endif(WIN32)
41
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.
50 endif()
51
52 # Request C++11
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)
57 else()
58     set(CMAKE_CXX_STANDARD 11)
59     set(CMAKE_CXX_STANDARD_REQUIRED ON)
60     set(CMAKE_CXX_EXTENSIONS OFF)
61 endif()
62
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++")
69     endif()
70 endfunction(glslang_set_link_args)
71
72 # We depend on these for later projects, so they should come first.
73 add_subdirectory(External)
74
75 add_subdirectory(glslang)
76 add_subdirectory(OGLCompilersDLL)
77 if(ENABLE_GLSLANG_BINARIES)
78     add_subdirectory(StandAlone)
79 endif()
80 add_subdirectory(SPIRV)
81 if(ENABLE_HLSL)
82     add_subdirectory(hlsl)
83 endif(ENABLE_HLSL)
84 add_subdirectory(gtests)