Revert "Modernise CMake"
[platform/upstream/glslang.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.11)
2 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
3
4 option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
5 option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
6
7 option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
8
9 option(ENABLE_HLSL "Enables HLSL input support" ON)
10
11 enable_testing()
12
13 set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix")
14
15 project(glslang)
16
17 if(ENABLE_AMD_EXTENSIONS)
18     add_definitions(-DAMD_EXTENSIONS)
19 endif(ENABLE_AMD_EXTENSIONS)
20
21 if(ENABLE_NV_EXTENSIONS)
22     add_definitions(-DNV_EXTENSIONS)
23 endif(ENABLE_NV_EXTENSIONS)
24
25 if(ENABLE_HLSL)
26     add_definitions(-DENABLE_HLSL)
27 endif(ENABLE_HLSL)
28
29 if(WIN32)
30     set(CMAKE_DEBUG_POSTFIX "d")
31     if(MSVC)
32         include(ChooseMSVCCRT.cmake)
33     endif(MSVC)
34     add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
35 elseif(UNIX)
36     add_definitions(-fPIC)
37     add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
38 else(WIN32)
39     message("unknown platform")
40 endif(WIN32)
41
42 if(CMAKE_COMPILER_IS_GNUCXX)
43     add_definitions(-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_definitions(-Wno-reorder)  # disable this from -Wall, since it happens all over.
46     add_definitions(-std=c++11)
47 elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
48     add_definitions(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
49       -Wunused-parameter -Wunused-value  -Wunused-variable)
50     add_definitions(-Wno-reorder)  # disable this from -Wall, since it happens all over.
51     add_definitions(-std=c++11)
52 endif()
53
54 function(glslang_set_link_args TARGET)
55     # For MinGW compiles, statically link against the GCC and C++ runtimes.
56     # This avoids the need to ship those runtimes as DLLs.
57     if(WIN32)
58         if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
59             set_target_properties(${TARGET} PROPERTIES
60                     LINK_FLAGS "-static -static-libgcc -static-libstdc++")
61         endif()
62     endif(WIN32)
63 endfunction(glslang_set_link_args)
64
65 # We depend on these for later projects, so they should come first.
66 add_subdirectory(External)
67
68 add_subdirectory(glslang)
69 add_subdirectory(OGLCompilersDLL)
70 if(ENABLE_GLSLANG_BINARIES)
71         add_subdirectory(StandAlone)
72 endif()
73 add_subdirectory(SPIRV)
74 if(ENABLE_HLSL)
75     add_subdirectory(hlsl)
76 endif(ENABLE_HLSL)
77 add_subdirectory(gtests)