CMakeLists.txt 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. cmake_minimum_required(VERSION 3.7.1)
  2. set(DEFAULT_BUILD_TYPE "Debug")
  3. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  4. set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
  5. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
  6. endif()
  7. set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
  8. set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
  9. set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
  10. project(VulkanEngine)
  11. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  12. file(GLOB INCLUDES "${INCLUDE_DIR}/*.hpp")
  13. file(GLOB SOURCES "${SOURCE_DIR}/*.cpp")
  14. if(NOT VK_LIBRARY)
  15. message(WARNING "Vulkan library not found please specify it with -DVK_LIBRARY='Path to your vulkan lib' or use the cmake-gui to set it")
  16. set(VK_LIBRARY "" CACHE FILEPATH "Path to your Vulkan library file")
  17. set(ERROR "YES")
  18. endif()
  19. if(NOT VK_INCLUDE_DIR)
  20. message(WARNING "Vulkan include directory not found please specify it with -DVK_INCLUDE_DIR='Path to your vulkan include dirrectory' or use the cmake-gui to set it")
  21. set(VK_INCLUDE_DIR "" CACHE PATH "Path to your Vulkan include directory")
  22. set(ERROR "YES")
  23. endif()
  24. if(NOT GLM_INCLUDE_DIR)
  25. message(WARNING "Can't find GLM include directory. Specify it with -DVK_INCLUDE_DIR='/path/to/glm' or use the cmake-gui")
  26. set(GLM_INCLUDE_DIR "" CACHE PATH "Path to GLM include folder")
  27. set(ERROR "YES")
  28. endif()
  29. set(CMAKE_SUPPRESS_REGENERATION true)
  30. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
  31. set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
  32. if(ERROR)
  33. message(FATAL_ERROR "Error occured check output")
  34. endif()
  35. include_directories(${INCLUDE_DIR} ${VK_INCLUDE_DIR} ${GLM_INCLUDE_DIR})
  36. add_executable(VulkanEngine ${SOURCES} ${INCLUDES})
  37. target_link_libraries(VulkanEngine ${VK_LIBRARY})
  38. set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT VulkanEngine)
  39. set_target_properties(VulkanEngine PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/")