blob: 9bc94b01a9fef521c3d9cf9f9505551097f2c656 [file] [log] [blame]
David Seifert22afc382017-04-29 10:57:36 +02001# increase to 3.1 once all major distributions
2# include a version of CMake >= 3.1
3cmake_minimum_required(VERSION 2.8.12)
Andrew Woloszyndb0eaf92016-05-05 14:45:53 -04004set_property(GLOBAL PROPERTY USE_FOLDERS ON)
John Kessenichd49d5242015-06-26 16:29:10 -06005
David Seifert22afc382017-04-29 10:57:36 +02006# Adhere to GNU filesystem layout conventions
7include(GNUInstallDirs)
8
d3x0rf8f494f2017-07-04 05:54:57 -07009option(SKIP_GLSLANG_INSTALL "Skip installation" ${SKIP_GLSLANG_INSTALL})
10if(NOT ${SKIP_GLSLANG_INSTALL})
11 set(ENABLE_GLSLANG_INSTALL ON)
12endif()
13
Dominik Witczakdaff1a22016-09-27 09:51:34 +020014option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
Henrik Rydgård868746a2016-12-20 01:56:00 +010015option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
Rex Xu9d93a232016-05-05 12:30:44 +080016
chaoc0ad6a4e2016-12-19 16:29:34 -080017option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
18
Alex Szpakowskiff21a252017-01-09 18:10:14 -040019option(ENABLE_HLSL "Enables HLSL input support" ON)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040020
David Seifert22afc382017-04-29 10:57:36 +020021if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
22 set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
23endif()
John Kessenichcfc69d92017-04-28 22:04:24 -060024
25project(glslang)
David Seifert22afc382017-04-29 10:57:36 +020026# make testing optional
27include(CTest)
David Seifert8f824262017-04-28 22:46:52 +020028
Rex Xu9d93a232016-05-05 12:30:44 +080029if(ENABLE_AMD_EXTENSIONS)
30 add_definitions(-DAMD_EXTENSIONS)
31endif(ENABLE_AMD_EXTENSIONS)
32
chaoc0ad6a4e2016-12-19 16:29:34 -080033if(ENABLE_NV_EXTENSIONS)
34 add_definitions(-DNV_EXTENSIONS)
35endif(ENABLE_NV_EXTENSIONS)
36
Alex Szpakowskiff21a252017-01-09 18:10:14 -040037if(ENABLE_HLSL)
38 add_definitions(-DENABLE_HLSL)
39endif(ENABLE_HLSL)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040040
John Kessenichd49d5242015-06-26 16:29:10 -060041if(WIN32)
Brad Davis1e194e82016-05-25 13:08:34 -070042 set(CMAKE_DEBUG_POSTFIX "d")
DragoonX681559342017-03-12 04:44:55 +010043 if(MSVC)
44 include(ChooseMSVCCRT.cmake)
45 endif(MSVC)
baldurk876a0e32015-11-16 18:03:28 +010046 add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
John Kessenichd49d5242015-06-26 16:29:10 -060047elseif(UNIX)
baldurk876a0e32015-11-16 18:03:28 +010048 add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
John Kessenichd49d5242015-06-26 16:29:10 -060049else(WIN32)
Eric Engestrom6a6d6dd2016-04-03 01:17:13 +010050 message("unknown platform")
John Kessenichd49d5242015-06-26 16:29:10 -060051endif(WIN32)
52
David Seifert22afc382017-04-29 10:57:36 +020053if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
54 add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
55 -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable)
56 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
John Kessenichd49d5242015-06-26 16:29:10 -060057elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
David Seifert22afc382017-04-29 10:57:36 +020058 add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
59 -Wunused-parameter -Wunused-value -Wunused-variable)
60 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
61endif()
62
63# Request C++11
64if(${CMAKE_VERSION} VERSION_LESS 3.1)
65 # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
66 # remove this block once CMake >=3.1 has fixated in the ecosystem
67 add_compile_options(-std=c++11)
68else()
69 set(CMAKE_CXX_STANDARD 11)
70 set(CMAKE_CXX_STANDARD_REQUIRED ON)
71 set(CMAKE_CXX_EXTENSIONS OFF)
John Kessenichd49d5242015-06-26 16:29:10 -060072endif()
73
David Netob37dc0e2016-06-02 14:37:24 -040074function(glslang_set_link_args TARGET)
75 # For MinGW compiles, statically link against the GCC and C++ runtimes.
76 # This avoids the need to ship those runtimes as DLLs.
David Seifert22afc382017-04-29 10:57:36 +020077 if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
78 set_target_properties(${TARGET} PROPERTIES
79 LINK_FLAGS "-static -static-libgcc -static-libstdc++")
80 endif()
David Netob37dc0e2016-06-02 14:37:24 -040081endfunction(glslang_set_link_args)
82
Lei Zhang414eb602016-03-04 16:22:34 -050083# We depend on these for later projects, so they should come first.
84add_subdirectory(External)
85
John Kessenichd49d5242015-06-26 16:29:10 -060086add_subdirectory(glslang)
87add_subdirectory(OGLCompilersDLL)
Henrik Rydgård868746a2016-12-20 01:56:00 +010088if(ENABLE_GLSLANG_BINARIES)
David Seifert22afc382017-04-29 10:57:36 +020089 add_subdirectory(StandAlone)
Henrik Rydgård868746a2016-12-20 01:56:00 +010090endif()
John Kessenichd49d5242015-06-26 16:29:10 -060091add_subdirectory(SPIRV)
Alex Szpakowskiff21a252017-01-09 18:10:14 -040092if(ENABLE_HLSL)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040093 add_subdirectory(hlsl)
John Kessenichdc1a8192017-01-11 14:50:16 -070094endif(ENABLE_HLSL)
Lei Zhang414eb602016-03-04 16:22:34 -050095add_subdirectory(gtests)