CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. if (POLICY CMP0048)
  5. cmake_policy(SET CMP0048 NEW)
  6. endif()
  7. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  8. # Adhere to GNU filesystem layout conventions
  9. include(GNUInstallDirs)
  10. option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
  11. set(LIB_TYPE STATIC)
  12. if(BUILD_SHARED_LIBS)
  13. set(LIB_TYPE SHARED)
  14. endif()
  15. option(SKIP_GLSLANG_INSTALL "Skip installation" ${SKIP_GLSLANG_INSTALL})
  16. if(NOT ${SKIP_GLSLANG_INSTALL})
  17. set(ENABLE_GLSLANG_INSTALL ON)
  18. endif()
  19. option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
  20. option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
  21. option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
  22. option(ENABLE_HLSL "Enables HLSL input support" ON)
  23. option(ENABLE_OPT "Enables spirv-opt capability if present" ON)
  24. if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
  25. set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
  26. endif()
  27. project(glslang)
  28. # make testing optional
  29. include(CTest)
  30. if(ENABLE_AMD_EXTENSIONS)
  31. add_definitions(-DAMD_EXTENSIONS)
  32. endif(ENABLE_AMD_EXTENSIONS)
  33. if(ENABLE_NV_EXTENSIONS)
  34. add_definitions(-DNV_EXTENSIONS)
  35. endif(ENABLE_NV_EXTENSIONS)
  36. if(ENABLE_HLSL)
  37. add_definitions(-DENABLE_HLSL)
  38. endif(ENABLE_HLSL)
  39. if(WIN32)
  40. set(CMAKE_DEBUG_POSTFIX "d")
  41. if(MSVC)
  42. include(ChooseMSVCCRT.cmake)
  43. endif(MSVC)
  44. add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
  45. elseif(UNIX)
  46. add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
  47. else(WIN32)
  48. message("unknown platform")
  49. endif(WIN32)
  50. if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
  51. add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
  52. -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions)
  53. add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
  54. elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
  55. add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
  56. -Wunused-parameter -Wunused-value -Wunused-variable)
  57. add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
  58. endif()
  59. # Request C++11
  60. if(${CMAKE_VERSION} VERSION_LESS 3.1)
  61. # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
  62. # remove this block once CMake >=3.1 has fixated in the ecosystem
  63. add_compile_options(-std=c++11)
  64. else()
  65. set(CMAKE_CXX_STANDARD 11)
  66. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  67. set(CMAKE_CXX_EXTENSIONS OFF)
  68. endif()
  69. function(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.
  72. 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()
  76. endfunction(glslang_set_link_args)
  77. # We depend on these for later projects, so they should come first.
  78. add_subdirectory(External)
  79. if(NOT TARGET SPIRV-Tools-opt)
  80. set(ENABLE_OPT OFF)
  81. endif()
  82. if(ENABLE_OPT)
  83. message(STATUS "optimizer enabled")
  84. add_definitions(-DENABLE_OPT=1)
  85. else()
  86. if(ENABLE_HLSL)
  87. message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL")
  88. endif()
  89. add_definitions(-DENABLE_OPT=0)
  90. endif()
  91. add_subdirectory(glslang)
  92. add_subdirectory(OGLCompilersDLL)
  93. if(ENABLE_GLSLANG_BINARIES)
  94. add_subdirectory(StandAlone)
  95. endif()
  96. add_subdirectory(SPIRV)
  97. if(ENABLE_HLSL)
  98. add_subdirectory(hlsl)
  99. endif(ENABLE_HLSL)
  100. add_subdirectory(gtests)