fix-top-cmakelist.diff 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 212a82e..afede0f 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -21,23 +21,116 @@ function(install_tools_lib _TARGET)
  6. if(TARGET_TYPE STREQUAL STATIC_LIBRARY)
  7. list(APPEND DILIGENT_TOOLS_INSTALL_LIBS_LIST ${_TARGET})
  8. set(DILIGENT_TOOLS_INSTALL_LIBS_LIST ${DILIGENT_TOOLS_INSTALL_LIBS_LIST} CACHE INTERNAL "Diligent tools libraries installation list")
  9. + install(TARGETS ${_TARGET}
  10. + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  11. + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  12. + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
  13. + )
  14. + if (DILIGENT_INSTALL_PDB)
  15. + install(FILES $<TARGET_PDB_FILE:${_TARGET}> DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL)
  16. + endif()
  17. elseif(TARGET_TYPE STREQUAL SHARED_LIBRARY)
  18. install(TARGETS ${_TARGET}
  19. - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_TOOLS_DIR}/$<CONFIG>"
  20. - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_TOOLS_DIR}/$<CONFIG>"
  21. - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_TOOLS_DIR}/$<CONFIG>"
  22. + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  23. + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  24. + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
  25. )
  26. if (DILIGENT_INSTALL_PDB)
  27. - install(FILES $<TARGET_PDB_FILE:${_TARGET}> DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_TOOLS_DIR}/$<CONFIG>" OPTIONAL)
  28. + install(FILES $<TARGET_PDB_FILE:${_TARGET}> DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL)
  29. endif()
  30. endif()
  31. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/interface")
  32. install(DIRECTORY interface
  33. - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${TARGET_RELATIVE_PATH}/"
  34. + DESTINATION "include/DiligentTools/${TARGET_RELATIVE_PATH}"
  35. )
  36. endif()
  37. endfunction()
  38. +include(FindPkgConfig)
  39. +include(BuildUtils.cmake)
  40. +add_library(Diligent-PublicBuildSettings INTERFACE)
  41. +if(PLATFORM_WIN32)
  42. + set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on Win32 platform")
  43. + set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Win32 platform")
  44. + set(WEBGPU_SUPPORTED TRUE CACHE INTERNAL "WebGPU is supported on Win32 platform")
  45. + set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Win32 platform")
  46. + target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_WIN32=1)
  47. +elseif(PLATFORM_UNIVERSAL_WINDOWS)
  48. + set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Universal Windows platform")
  49. + target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_UNIVERSAL_WINDOWS=1)
  50. +elseif(PLATFORM_ANDROID)
  51. + set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on Android platform")
  52. + set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Android platform")
  53. + set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Android platform")
  54. + target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_ANDROID=1)
  55. +elseif(PLATFORM_LINUX)
  56. + set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on Linux platform")
  57. + set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Linux platform")
  58. + set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Linux platform")
  59. + target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_LINUX=1)
  60. +elseif(PLATFORM_MACOS)
  61. + set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on MacOS platform")
  62. + set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is enabled through MoltenVK on MacOS platform")
  63. + set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on MacOS platform")
  64. + target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_MACOS=1 PLATFORM_APPLE=1)
  65. +elseif(PLATFORM_IOS)
  66. + set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on iOS platform")
  67. + target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_IOS=1 PLATFORM_APPLE=1)
  68. +elseif(PLATFORM_TVOS)
  69. + target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_TVOS=1 PLATFORM_APPLE=1)
  70. +elseif(PLATFORM_WEB)
  71. + set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on Web platform")
  72. + set(WEBGPU_SUPPORTED TRUE CACHE INTERNAL "WebGPU is supported on Web platform")
  73. + set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Web platform")
  74. + target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_WEB=1 PLATFORM_EMSCRIPTEN=1)
  75. +else()
  76. + message(FATAL_ERROR "No PLATFORM_XXX variable defined. Make sure that 'DiligentCore' folder is processed first")
  77. +endif()
  78. +target_compile_definitions(Diligent-PublicBuildSettings
  79. +INTERFACE
  80. + D3D11_SUPPORTED=$<BOOL:${D3D11_SUPPORTED}>
  81. + D3D12_SUPPORTED=$<BOOL:${D3D12_SUPPORTED}>
  82. + GL_SUPPORTED=$<BOOL:${GL_SUPPORTED}>
  83. + GLES_SUPPORTED=$<BOOL:${GLES_SUPPORTED}>
  84. + VULKAN_SUPPORTED=$<BOOL:${VULKAN_SUPPORTED}>
  85. + METAL_SUPPORTED=$<BOOL:${METAL_SUPPORTED}>
  86. + WEBGPU_SUPPORTED=$<BOOL:${WEBGPU_SUPPORTED}>
  87. +)
  88. +add_library(Diligent-BuildSettings INTERFACE)
  89. +if (PLATFORM_WEB)
  90. + target_compile_options(Diligent-BuildSettings INTERFACE
  91. + "-pthread"
  92. + "-mbulk-memory"
  93. + )
  94. +endif()
  95. +target_link_libraries(Diligent-BuildSettings INTERFACE Diligent-PublicBuildSettings)
  96. +if(PLATFORM_WIN32)
  97. + set(Diligent-TargetPlatform Diligent-Win32Platform)
  98. +elseif(PLATFORM_UNIVERSAL_WINDOWS)
  99. + set(Diligent-TargetPlatform Diligent-UniversalWindowsPlatform)
  100. +elseif(PLATFORM_ANDROID)
  101. + set(Diligent-TargetPlatform Diligent-AndroidPlatform)
  102. +elseif(PLATFORM_LINUX)
  103. + set(Diligent-TargetPlatform Diligent-LinuxPlatform)
  104. +elseif(PLATFORM_MACOS OR PLATFORM_IOS OR PLATFORM_TVOS)
  105. + set(Diligent-TargetPlatform Diligent-ApplePlatform)
  106. +elseif(PLATFORM_WEB)
  107. + set(Diligent-TargetPlatform Diligent-EmscriptenPlatform)
  108. +else()
  109. + message(FATAL_ERROR "No PLATFORM_XXX variable defined. Make sure that 'DiligentCore' folder is processed first")
  110. +endif()
  111. +add_library(Diligent-PlatformInterface INTERFACE)
  112. +target_include_directories(Diligent-PlatformInterface INTERFACE ${diligentcore_INCLUDEDIR}/DiligentCore/Platforms/interface)
  113. +add_library(Diligent-GraphicsEngineInterface INTERFACE)
  114. +target_include_directories(Diligent-GraphicsEngineInterface
  115. +INTERFACE
  116. + ${diligentcore_INCLUDEDIR}/Graphics/GraphicsEngine/interface
  117. +)
  118. +target_link_libraries(Diligent-GraphicsEngineInterface
  119. +INTERFACE
  120. + Diligent-Primitives
  121. + Diligent-PublicBuildSettings
  122. +)
  123. add_subdirectory(ThirdParty)
  124. add_subdirectory(TextureLoader)
  125. @@ -46,7 +139,6 @@ add_subdirectory(Imgui)
  126. add_subdirectory(NativeApp)
  127. if((PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_MACOS) AND GL_SUPPORTED)
  128. - add_subdirectory(HLSL2GLSLConverter)
  129. endif()
  130. add_subdirectory(RenderStateNotation)
  131. @@ -55,7 +147,6 @@ if((PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_MACOS) AND ARCHIVER_SUPPORTED A
  132. add_subdirectory(RenderStatePackager)
  133. endif()
  134. -add_subdirectory(Tests)
  135. # Installation instructions
  136. if(DILIGENT_INSTALL_TOOLS)
  137. @@ -65,10 +156,9 @@ if(DILIGENT_INSTALL_TOOLS)
  138. "${DILIGENT_TOOLS_INSTALL_LIBS_LIST}"
  139. DiligentTools-static # Custom target name
  140. DiligentTools # Folder
  141. - "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_TOOLS_DIR}/$<CONFIG>" # Install destination
  142. + "${CMAKE_INSTALL_LIBDIR}" # Install destination
  143. )
  144. endif()
  145. # Create a custom target to run source code formatting validation command
  146. -add_format_validation_target(DiligentTools "${CMAKE_CURRENT_SOURCE_DIR}" DiligentTools)