• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include_directories(
2	${CMAKE_CURRENT_SOURCE_DIR}
3	${CMAKE_CURRENT_BINARY_DIR}
4)
5
6if (WIN32)
7    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vulkan-${MAJOR}.def
8	    COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/loader/vk-loader-generate.py ${DisplayServer} win-def-file vulkan-${MAJOR}.dll all > ${CMAKE_CURRENT_BINARY_DIR}/vulkan-${MAJOR}.def
9	    DEPENDS ${PROJECT_SOURCE_DIR}/loader/vk-loader-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py)
10endif()
11
12# DEBUG enables runtime loader ICD verification
13set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
14set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
15
16set(NORMAL_LOADER_SRCS
17    loader.c
18    loader.h
19    vk_loader_platform.h
20    trampoline.c
21    wsi.c
22    wsi.h
23    debug_report.c
24    debug_report.h
25    table_ops.h
26    gpa_helper.h
27    cJSON.c
28    cJSON.h
29    murmurhash.c
30    murmurhash.h
31)
32
33set (OPT_LOADER_SRCS
34    dev_ext_trampoline.c
35)
36
37set (LOADER_SRCS ${NORMAL_LOADER_SRCS} ${OPT_LOADER_SRCS})
38
39if (WIN32)
40    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
41    # Build dev_ext_trampoline.c with -O2 to allow tail-call optimization.
42    # Build other C files with normal options
43    # setup two Cmake targets (loader-norm and loader-opt) for the different compilation flags
44    separate_arguments(LOCAL_C_FLAGS_DBG WINDOWS_COMMAND ${CMAKE_C_FLAGS_DEBUG})
45    set(CMAKE_C_FLAGS_DEBUG " ")
46    separate_arguments(LOCAL_C_FLAGS_REL WINDOWS_COMMAND ${CMAKE_C_FLAGS_RELEASE})
47
48    add_library(loader-norm OBJECT ${NORMAL_LOADER_SRCS} dirent_on_windows.c)
49    target_compile_options(loader-norm PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_DBG}>")
50    add_library(loader-opt OBJECT ${OPT_LOADER_SRCS})
51    target_compile_options(loader-opt PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_REL}>")
52    add_library(vulkan-${MAJOR} SHARED $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm> ${CMAKE_CURRENT_BINARY_DIR}/vulkan-${MAJOR}.def)
53    set_target_properties(vulkan-${MAJOR} PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/vulkan-${MAJOR}.def")
54    add_library(VKstatic.${MAJOR} STATIC $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm>)
55    set_target_properties(VKstatic.${MAJOR} PROPERTIES OUTPUT_NAME VKstatic.${MAJOR})
56    target_link_libraries(vulkan-${MAJOR} shlwapi)
57else()
58    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
59
60    add_library(vulkan SHARED ${LOADER_SRCS})
61    set_target_properties(vulkan PROPERTIES SOVERSION "1" VERSION "1.0.5")
62    target_link_libraries(vulkan -ldl -lpthread -lm)
63endif()
64