-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
84 lines (68 loc) · 2.33 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
cmake_minimum_required(VERSION 3.2)
project(VmaSample)
# C++11
set(CMAKE_CXX_STANDARD 11)
#main dir
set(VMASAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
#cmake module path
list(APPEND CMAKE_MODULE_PATH "${VMASAMPLE_DIR}/cmake-modules")
find_package(Vulkan REQUIRED)
#external libs
#SDL Lib
SET(SDL_STATIC ON CACHE BOOL "" FORCE)
SET(SDL_SHARED OFF CACHE BOOL "" FORCE)
add_subdirectory("${VMASAMPLE_DIR}/external/sdl2" EXCLUDE_FROM_ALL)
#Source code
file(GLOB VMASAMPLE_SRC "${VMASAMPLE_DIR}/src/*.cpp" "${VMASAMPLE_DIR}/src/*.h")
#includes
set(VMASAMPLE_INCLUDES
${VMASAMPLE_DIR}/src
${VMASAMPLE_DIR}/external/sdl2/include
${VMASAMPLE_DIR}/external/VulkanMemoryAllocator
${VMASAMPLE_DIR}/external/mathfu-1.1.0/include
${VULKAN_INCLUDE_DIR}
)
#Libs
set (VMASAMPLE_LIBS SDL2main SDL2-static ${VULKAN_LIBRARY} )
#Libs - apple
if(APPLE)
set(VMASAMPLE_LIBS ${VMASAMPLE_LIBS}
"-framework Cocoa"
"-framework IOKit"
"-framework CoreVideo"
"-framework QuartzCore"
"-framework Metal"
)
endif()
#Executable
if(APPLE)
add_executable(VmaSample MACOSX_BUNDLE ${VMASAMPLE_SRC})
elseif(WIN32)
add_executable(VmaSample WIN32 ${VMASAMPLE_SRC})
else()
add_executable(VmaSample ${VMASAMPLE_SRC})
endif()
target_link_libraries(VmaSample ${VMASAMPLE_LIBS})
target_include_directories(VmaSample PRIVATE ${VMASAMPLE_INCLUDES})
#Target properties
#single config
set_target_properties(VmaSample PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${VMASAMPLE_DIR}/bin")
#multi-config
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set_target_properties(VmaSample PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${VMASAMPLE_DIR}/bin")
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
set_target_properties(VmaSample PROPERTIES DEBUG_POSTFIX "_debug")
if(WIN32)
target_compile_definitions(VmaSample PRIVATE VK_USE_PLATFORM_WIN32_KHR)
elseif(APPLE)
target_compile_definitions(VmaSample PRIVATE VK_USE_PLATFORM_MACOS_MVK)
elseif(UNIX)
target_compile_definitions(VmaSample PRIVATE VK_USE_PLATFORM_XLIB_KHR)
endif()
#Project solution folders
source_group("Source" REGULAR_EXPRESSION ${VMASAMPLE_DIR}/src/.*)
# Set Visual Studio startup project(cmake 3.6+)
if((${CMAKE_VERSION} VERSION_EQUAL 3.6.0) OR (${CMAKE_VERSION} VERSION_GREATER 3.6.0) AND MSVC)
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT VmaSample )
endif()