SHARE
TWEET

Untitled

a guest May 23rd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cmake_minimum_required(VERSION 3.7)
  2. project(vulkanengine)
  3.  
  4. set(SOURCE_FILES main.cpp sdl_render.cpp vmath.cpp bitfont.cpp animation.cpp vulkan_render.cpp)
  5. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  6. # Find SDL2 and OpenGL
  7. set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
  8. find_package(SDL2 REQUIRED COMPONENTS main)
  9. find_package(SDL2_image REQUIRED)
  10. find_package(Vulkan REQUIRED)
  11.  
  12.  
  13.  
  14. include_directories(${SDL2_INCLUDE_DIRS} ${SDL2main_INCLUDE_DIRS}  ${SDL2_IMAGE_INCLUDE_DIRS} ${CMAKE_BINARY_DIR})
  15. add_executable(vulkanengine ${SOURCE_FILES})
  16. target_link_libraries(vulkanengine ${SDL2_LIBS} ${SDL2_IMAGE_LIBRARIES})
  17.  
  18. target_compile_definitions(vulkanengine PRIVATE VK_USE_PLATFORM_WIN32_KHR)
  19. target_link_libraries(vulkanengine Vulkan::Vulkan)
  20.  
  21.  
  22. # Copy SDL2 DLLs to output folder on Windows
  23. if(WIN32)
  24.     foreach(DLL ${SDL2_DLLS})
  25.         add_custom_command(TARGET vulkanengine POST_BUILD COMMAND
  26.             ${CMAKE_COMMAND} -E copy_if_different ${DLL} $<TARGET_FILE_DIR:vulkanengine>)
  27.     endforeach()
  28.     foreach(IMGDLL ${SDL2_IMAGE_DLLS})
  29.         add_custom_command(TARGET vulkanengine POST_BUILD COMMAND
  30.             ${CMAKE_COMMAND} -E copy_if_different ${IMGDLL} $<TARGET_FILE_DIR:vulkanengine>)
  31.     endforeach()
  32. endif()
  33.  
  34. if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "AMD64")
  35.   set(GLSL_VALIDATOR "$ENV{VULKAN_SDK}/Bin/glslangValidator.exe")
  36. else()
  37.   set(GLSL_VALIDATOR "$ENV{VULKAN_SDK}/Bin32/glslangValidator.exe")
  38. endif()
  39.  
  40. file(GLOB_RECURSE GLSL_SOURCE_FILES
  41.     "${Project_SOURCE_DIR}/*.frag"
  42.     "${Project_SOURCE_DIR}/*.vert"
  43.     )
  44. message(STATUS "TEST")
  45.  
  46. foreach(GLSL ${GLSL_SOURCE_FILES})
  47.   message(STATUS "BUILDING SHADER")
  48.   get_filename_component(FILE_NAME ${GLSL} NAME)
  49.   set(SPIRV "${PROJECT_SOURCE_DIR}/../assets/shaders/${FILE_NAME}.spv")
  50.   message(STATUS ${GLSL})
  51.   add_custom_command(
  52.     OUTPUT ${SPIRV}
  53.     #COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_SOURCE_DIR}/assets/shaders/"
  54.     COMMAND ${GLSL_VALIDATOR} -V ${GLSL} -o ${SPIRV}
  55.     DEPENDS ${GLSL})
  56.   list(APPEND SPIRV_BINARY_FILES ${SPIRV})
  57. endforeach(GLSL)
  58.  
  59.  
  60.  
  61. add_custom_target(
  62.     Shaders
  63.     DEPENDS ${SPIRV_BINARY_FILES}
  64.     )
  65.  
  66. add_dependencies(vulkanengine Shaders)
  67.  
  68. #add_custom_command(TARGET vulkanengine POST_BUILD
  69. #    COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:vulkanengine>/shaders/"
  70. #    COMMAND ${CMAKE_COMMAND} -E copy_directory
  71. #        "${PROJECT_SOURCE_DIR}/assets/shaders"
  72. #        "$<TARGET_FILE_DIR:vulkanengine>/shaders"
  73. #        )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top