For MinGW, statically link exes against basic runtimes
[platform/upstream/glslang.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.12)
2 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
3
4 enable_testing()
5
6 set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix")
7
8 project(glslang)
9
10 if(WIN32)
11     set(CMAKE_DEBUG_POSTFIX "d")
12     include(ChooseMSVCCRT.cmake)
13     add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
14 elseif(UNIX)
15     add_definitions(-fPIC)
16     add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
17 else(WIN32)
18     message("unknown platform")
19 endif(WIN32)
20
21 if(CMAKE_COMPILER_IS_GNUCXX)
22     add_definitions(-std=c++11)
23 elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
24     add_definitions(-std=c++11)
25 endif()
26
27 function(glslang_set_link_args TARGET)
28     # For MinGW compiles, statically link against the GCC and C++ runtimes.
29     # This avoids the need to ship those runtimes as DLLs.
30     if(WIN32)
31         if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
32             set_target_properties(${TARGET} PROPERTIES
33                     LINK_FLAGS "-static -static-libgcc -static-libstdc++")
34         endif()
35     endif(WIN32)
36 endfunction(glslang_set_link_args)
37
38 # We depend on these for later projects, so they should come first.
39 add_subdirectory(External)
40
41 add_subdirectory(glslang)
42 add_subdirectory(OGLCompilersDLL)
43 add_subdirectory(StandAlone)
44 add_subdirectory(SPIRV)
45 add_subdirectory(hlsl)
46 add_subdirectory(gtests)