blob: 1d98c9fef311a62b4e3116c83fd43bc739fc55ea [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
Dominik Witczakdaff1a22016-09-27 09:51:34 +02009option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
Henrik Rydgård868746a2016-12-20 01:56:00 +010010option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
Rex Xu9d93a232016-05-05 12:30:44 +080011
chaoc0ad6a4e2016-12-19 16:29:34 -080012option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
13
Alex Szpakowskiff21a252017-01-09 18:10:14 -040014option(ENABLE_HLSL "Enables HLSL input support" ON)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040015
David Seifert22afc382017-04-29 10:57:36 +020016if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
17 set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
18endif()
John Kessenichcfc69d92017-04-28 22:04:24 -060019
20project(glslang)
David Seifert22afc382017-04-29 10:57:36 +020021# make testing optional
22include(CTest)
David Seifert8f824262017-04-28 22:46:52 +020023
Rex Xu9d93a232016-05-05 12:30:44 +080024if(ENABLE_AMD_EXTENSIONS)
25 add_definitions(-DAMD_EXTENSIONS)
26endif(ENABLE_AMD_EXTENSIONS)
27
chaoc0ad6a4e2016-12-19 16:29:34 -080028if(ENABLE_NV_EXTENSIONS)
29 add_definitions(-DNV_EXTENSIONS)
30endif(ENABLE_NV_EXTENSIONS)
31
Alex Szpakowskiff21a252017-01-09 18:10:14 -040032if(ENABLE_HLSL)
33 add_definitions(-DENABLE_HLSL)
34endif(ENABLE_HLSL)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040035
John Kessenichd49d5242015-06-26 16:29:10 -060036if(WIN32)
Brad Davis1e194e82016-05-25 13:08:34 -070037 set(CMAKE_DEBUG_POSTFIX "d")
DragoonX681559342017-03-12 04:44:55 +010038 if(MSVC)
39 include(ChooseMSVCCRT.cmake)
40 endif(MSVC)
baldurk876a0e32015-11-16 18:03:28 +010041 add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
John Kessenichd49d5242015-06-26 16:29:10 -060042elseif(UNIX)
baldurk876a0e32015-11-16 18:03:28 +010043 add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
John Kessenichd49d5242015-06-26 16:29:10 -060044else(WIN32)
Eric Engestrom6a6d6dd2016-04-03 01:17:13 +010045 message("unknown platform")
John Kessenichd49d5242015-06-26 16:29:10 -060046endif(WIN32)
47
David Seifert22afc382017-04-29 10:57:36 +020048if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
49 add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
50 -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable)
51 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
John Kessenichd49d5242015-06-26 16:29:10 -060052elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
David Seifert22afc382017-04-29 10:57:36 +020053 add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
54 -Wunused-parameter -Wunused-value -Wunused-variable)
55 add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
56endif()
57
58# Request C++11
59if(${CMAKE_VERSION} VERSION_LESS 3.1)
60 # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
61 # remove this block once CMake >=3.1 has fixated in the ecosystem
62 add_compile_options(-std=c++11)
63else()
64 set(CMAKE_CXX_STANDARD 11)
65 set(CMAKE_CXX_STANDARD_REQUIRED ON)
66 set(CMAKE_CXX_EXTENSIONS OFF)
John Kessenichd49d5242015-06-26 16:29:10 -060067endif()
68
David Netob37dc0e2016-06-02 14:37:24 -040069function(glslang_set_link_args TARGET)
70 # For MinGW compiles, statically link against the GCC and C++ runtimes.
71 # This avoids the need to ship those runtimes as DLLs.
David Seifert22afc382017-04-29 10:57:36 +020072 if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
73 set_target_properties(${TARGET} PROPERTIES
74 LINK_FLAGS "-static -static-libgcc -static-libstdc++")
75 endif()
David Netob37dc0e2016-06-02 14:37:24 -040076endfunction(glslang_set_link_args)
77
Lei Zhang414eb602016-03-04 16:22:34 -050078# We depend on these for later projects, so they should come first.
79add_subdirectory(External)
80
John Kessenichd49d5242015-06-26 16:29:10 -060081add_subdirectory(glslang)
82add_subdirectory(OGLCompilersDLL)
Henrik Rydgård868746a2016-12-20 01:56:00 +010083if(ENABLE_GLSLANG_BINARIES)
David Seifert22afc382017-04-29 10:57:36 +020084 add_subdirectory(StandAlone)
Henrik Rydgård868746a2016-12-20 01:56:00 +010085endif()
John Kessenichd49d5242015-06-26 16:29:10 -060086add_subdirectory(SPIRV)
Alex Szpakowskiff21a252017-01-09 18:10:14 -040087if(ENABLE_HLSL)
Alex Szpakowski84eabf72017-01-08 21:20:25 -040088 add_subdirectory(hlsl)
John Kessenichdc1a8192017-01-11 14:50:16 -070089endif(ENABLE_HLSL)
Lei Zhang414eb602016-03-04 16:22:34 -050090add_subdirectory(gtests)