forked from SaschaWillems/Vulkan
-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathCMakeLists.txt
64 lines (58 loc) · 2.05 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
macro(ADD_EXAMPLE_BINARY file)
if (ANDROID)
add_library(${TARGET_NAME} SHARED ${EXAMPLE})
add_dependencies(${TARGET_NAME} app-glue)
target_link_libraries(${TARGET_NAME} app-glue)
else()
add_executable(${TARGET_NAME} ${EXAMPLE})
endif()
if (("${TARGET_NAME}" STREQUAL "context") OR ("${TARGET_NAME}" STREQUAL "swapchain") OR ("${TARGET_NAME}" STREQUAL "triangle"))
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples/init")
else()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
endif()
endmacro()
macro(BUILD_EXAMPLES)
foreach(_FOLDER_NAME ${ARGN})
# disabling vr examples for now
if (TRUE)
if ("${_FOLDER_NAME}" STREQUAL "vr_oculus")
continue()
endif()
if ("${_FOLDER_NAME}" STREQUAL "vr_openvr")
continue()
endif()
endif()
file(GLOB EXAMPLES ${_FOLDER_NAME}/*.cpp)
foreach(EXAMPLE ${EXAMPLES})
get_filename_component(TARGET_NAME ${EXAMPLE} NAME_WE)
add_example_binary(${EXAMPLE})
add_dependencies(${TARGET_NAME} base)
target_include_directories(${TARGET_NAME} PUBLIC base)
target_link_libraries(${TARGET_NAME} base)
target_link_libraries(${TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})
endforeach()
endforeach()
endmacro()
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
build_examples(${SUBDIRS})
if (TARGET vr_oculus)
set(TARGET_NAME vr_oculus)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples/vr")
target_oculus()
endif()
if (TARGET vr_openvr)
set(TARGET_NAME vr_openvr)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples/vr")
target_openvr()
endif()