Make test suite optional by using CTest
[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 # make testing optional
19 include(CTest)
20
21 if(ENABLE_AMD_EXTENSIONS)
22     add_definitions(-DAMD_EXTENSIONS)
23 endif(ENABLE_AMD_EXTENSIONS)
24
25 if(ENABLE_NV_EXTENSIONS)
26     add_definitions(-DNV_EXTENSIONS)
27 endif(ENABLE_NV_EXTENSIONS)
28
29 if(ENABLE_HLSL)
30     add_definitions(-DENABLE_HLSL)
31 endif(ENABLE_HLSL)
32
33 if(WIN32)
34     set(CMAKE_DEBUG_POSTFIX "d")
35     if(MSVC)
36         include(ChooseMSVCCRT.cmake)
37     endif(MSVC)
38     add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
39 elseif(UNIX)
40     add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
41 else(WIN32)
42     message("unknown platform")
43 endif(WIN32)
44
45 if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
46     add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
47                         -Wunused-parameter -Wunused-value  -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable)
48     add_compile_options(-Wno-reorder)  # disable this from -Wall, since it happens all over.
49 elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
50     add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
51                         -Wunused-parameter -Wunused-value  -Wunused-variable)
52     add_compile_options(-Wno-reorder)  # disable this from -Wall, since it happens all over.
53 endif()
54
55 # Request C++11
56 if(${CMAKE_VERSION} VERSION_LESS 3.1)
57     # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
58     # remove this block once CMake >=3.1 has fixated in the ecosystem
59     add_compile_options(-std=c++11)
60 else()
61     set(CMAKE_CXX_STANDARD 11)
62     set(CMAKE_CXX_STANDARD_REQUIRED ON)
63     set(CMAKE_CXX_EXTENSIONS OFF)
64 endif()
65
66 function(glslang_set_link_args TARGET)
67     # For MinGW compiles, statically link against the GCC and C++ runtimes.
68     # This avoids the need to ship those runtimes as DLLs.
69     if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
70         set_target_properties(${TARGET} PROPERTIES
71                               LINK_FLAGS "-static -static-libgcc -static-libstdc++")
72     endif()
73 endfunction(glslang_set_link_args)
74
75 # We depend on these for later projects, so they should come first.
76 add_subdirectory(External)
77
78 add_subdirectory(glslang)
79 add_subdirectory(OGLCompilersDLL)
80 if(ENABLE_GLSLANG_BINARIES)
81     add_subdirectory(StandAlone)
82 endif()
83 add_subdirectory(SPIRV)
84 if(ENABLE_HLSL)
85     add_subdirectory(hlsl)
86 endif(ENABLE_HLSL)
87 add_subdirectory(gtests)