David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 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) |
Andrew Woloszyn | db0eaf9 | 2016-05-05 14:45:53 -0400 | [diff] [blame] | 4 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 5 | |
David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 6 | # Adhere to GNU filesystem layout conventions |
| 7 | include(GNUInstallDirs) |
| 8 | |
d3x0r | f8f494f | 2017-07-04 05:54:57 -0700 | [diff] [blame] | 9 | option(SKIP_GLSLANG_INSTALL "Skip installation" ${SKIP_GLSLANG_INSTALL}) |
| 10 | if(NOT ${SKIP_GLSLANG_INSTALL}) |
| 11 | set(ENABLE_GLSLANG_INSTALL ON) |
| 12 | endif() |
| 13 | |
Dominik Witczak | daff1a2 | 2016-09-27 09:51:34 +0200 | [diff] [blame] | 14 | option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON) |
Henrik Rydgård | 868746a | 2016-12-20 01:56:00 +0100 | [diff] [blame] | 15 | option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON) |
Rex Xu | 9d93a23 | 2016-05-05 12:30:44 +0800 | [diff] [blame] | 16 | |
chaoc | 0ad6a4e | 2016-12-19 16:29:34 -0800 | [diff] [blame] | 17 | option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON) |
| 18 | |
Alex Szpakowski | ff21a25 | 2017-01-09 18:10:14 -0400 | [diff] [blame] | 19 | option(ENABLE_HLSL "Enables HLSL input support" ON) |
Alex Szpakowski | 84eabf7 | 2017-01-08 21:20:25 -0400 | [diff] [blame] | 20 | |
GregF | fd34f0e | 2017-09-21 16:50:39 -0600 | [diff] [blame] | 21 | option(ENABLE_OPT "Enables spirv-opt capability if present" ON) |
| 22 | |
David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 23 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32) |
| 24 | set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE) |
| 25 | endif() |
John Kessenich | cfc69d9 | 2017-04-28 22:04:24 -0600 | [diff] [blame] | 26 | |
| 27 | project(glslang) |
David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 28 | # make testing optional |
| 29 | include(CTest) |
David Seifert | 8f82426 | 2017-04-28 22:46:52 +0200 | [diff] [blame] | 30 | |
Rex Xu | 9d93a23 | 2016-05-05 12:30:44 +0800 | [diff] [blame] | 31 | if(ENABLE_AMD_EXTENSIONS) |
| 32 | add_definitions(-DAMD_EXTENSIONS) |
| 33 | endif(ENABLE_AMD_EXTENSIONS) |
| 34 | |
chaoc | 0ad6a4e | 2016-12-19 16:29:34 -0800 | [diff] [blame] | 35 | if(ENABLE_NV_EXTENSIONS) |
| 36 | add_definitions(-DNV_EXTENSIONS) |
| 37 | endif(ENABLE_NV_EXTENSIONS) |
| 38 | |
Alex Szpakowski | ff21a25 | 2017-01-09 18:10:14 -0400 | [diff] [blame] | 39 | if(ENABLE_HLSL) |
| 40 | add_definitions(-DENABLE_HLSL) |
| 41 | endif(ENABLE_HLSL) |
Alex Szpakowski | 84eabf7 | 2017-01-08 21:20:25 -0400 | [diff] [blame] | 42 | |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 43 | if(WIN32) |
Brad Davis | 1e194e8 | 2016-05-25 13:08:34 -0700 | [diff] [blame] | 44 | set(CMAKE_DEBUG_POSTFIX "d") |
DragoonX6 | 8155934 | 2017-03-12 04:44:55 +0100 | [diff] [blame] | 45 | if(MSVC) |
| 46 | include(ChooseMSVCCRT.cmake) |
| 47 | endif(MSVC) |
baldurk | 876a0e3 | 2015-11-16 18:03:28 +0100 | [diff] [blame] | 48 | add_definitions(-DGLSLANG_OSINCLUDE_WIN32) |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 49 | elseif(UNIX) |
baldurk | 876a0e3 | 2015-11-16 18:03:28 +0100 | [diff] [blame] | 50 | add_definitions(-DGLSLANG_OSINCLUDE_UNIX) |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 51 | else(WIN32) |
Eric Engestrom | 6a6d6dd | 2016-04-03 01:17:13 +0100 | [diff] [blame] | 52 | message("unknown platform") |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 53 | endif(WIN32) |
| 54 | |
David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 55 | if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") |
| 56 | add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs |
LoopDawg | 8004d36 | 2017-09-17 10:38:52 -0600 | [diff] [blame] | 57 | -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions) |
David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 58 | add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over. |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 59 | elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") |
David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 60 | add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs |
| 61 | -Wunused-parameter -Wunused-value -Wunused-variable) |
| 62 | add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over. |
| 63 | endif() |
| 64 | |
| 65 | # Request C++11 |
| 66 | if(${CMAKE_VERSION} VERSION_LESS 3.1) |
| 67 | # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD |
| 68 | # remove this block once CMake >=3.1 has fixated in the ecosystem |
| 69 | add_compile_options(-std=c++11) |
| 70 | else() |
| 71 | set(CMAKE_CXX_STANDARD 11) |
| 72 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 73 | set(CMAKE_CXX_EXTENSIONS OFF) |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 74 | endif() |
| 75 | |
David Neto | b37dc0e | 2016-06-02 14:37:24 -0400 | [diff] [blame] | 76 | function(glslang_set_link_args TARGET) |
| 77 | # For MinGW compiles, statically link against the GCC and C++ runtimes. |
| 78 | # This avoids the need to ship those runtimes as DLLs. |
David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 79 | if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") |
| 80 | set_target_properties(${TARGET} PROPERTIES |
| 81 | LINK_FLAGS "-static -static-libgcc -static-libstdc++") |
| 82 | endif() |
David Neto | b37dc0e | 2016-06-02 14:37:24 -0400 | [diff] [blame] | 83 | endfunction(glslang_set_link_args) |
| 84 | |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 85 | # We depend on these for later projects, so they should come first. |
| 86 | add_subdirectory(External) |
| 87 | |
GregF | fd34f0e | 2017-09-21 16:50:39 -0600 | [diff] [blame] | 88 | if(NOT TARGET SPIRV-Tools-opt) |
| 89 | set(ENABLE_OPT OFF) |
| 90 | endif() |
| 91 | |
| 92 | if(ENABLE_OPT) |
| 93 | message(STATUS "optimizer enabled") |
| 94 | add_definitions(-DENABLE_OPT) |
| 95 | elseif(ENABLE_HLSL) |
| 96 | message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL") |
| 97 | endif() |
| 98 | |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 99 | add_subdirectory(glslang) |
| 100 | add_subdirectory(OGLCompilersDLL) |
Henrik Rydgård | 868746a | 2016-12-20 01:56:00 +0100 | [diff] [blame] | 101 | if(ENABLE_GLSLANG_BINARIES) |
David Seifert | 22afc38 | 2017-04-29 10:57:36 +0200 | [diff] [blame] | 102 | add_subdirectory(StandAlone) |
Henrik Rydgård | 868746a | 2016-12-20 01:56:00 +0100 | [diff] [blame] | 103 | endif() |
John Kessenich | d49d524 | 2015-06-26 16:29:10 -0600 | [diff] [blame] | 104 | add_subdirectory(SPIRV) |
Alex Szpakowski | ff21a25 | 2017-01-09 18:10:14 -0400 | [diff] [blame] | 105 | if(ENABLE_HLSL) |
Alex Szpakowski | 84eabf7 | 2017-01-08 21:20:25 -0400 | [diff] [blame] | 106 | add_subdirectory(hlsl) |
John Kessenich | dc1a819 | 2017-01-11 14:50:16 -0700 | [diff] [blame] | 107 | endif(ENABLE_HLSL) |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 108 | add_subdirectory(gtests) |