set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
-set(LOADER_SRCS
+set(NORMAL_LOADER_SRCS
loader.c
loader.h
vk_loader_platform.h
gpa_helper.h
cJSON.c
cJSON.h
- dev_ext_trampoline.c
murmurhash.c
murmurhash.h
)
+set (OPT_LOADER_SRCS
+ dev_ext_trampoline.c
+)
+
+set (LOADER_SRCS ${NORMAL_LOADER_SRCS} ${OPT_LOADER_SRCS})
if (WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
- # Build dev_ext_trampoline with -O2 to allow tail-call optimization.
- # We have to disable Real Time Checks when we specify -O2.
- # Unfortunately, this also disables them for all of the loader.
- STRING (REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
- STRING (REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
- set_source_files_properties(dev_ext_trampoline.c PROPERTIES COMPILE_FLAGS -O2)
-
- add_library(vulkan-${MAJOR} SHARED ${LOADER_SRCS} dirent_on_windows.c ${CMAKE_CURRENT_BINARY_DIR}/vulkan-${MAJOR}.def)
+ # Build dev_ext_trampoline.c with -O2 to allow tail-call optimization.
+ # Build other C files with normal options
+ # setup two Cmake targets (loader-norm and loader-opt) for the different compilation flags
+ separate_arguments(LOCAL_C_FLAGS_DBG WINDOWS_COMMAND ${CMAKE_C_FLAGS_DEBUG})
+ set(CMAKE_C_FLAGS_DEBUG " ")
+ separate_arguments(LOCAL_C_FLAGS_REL WINDOWS_COMMAND ${CMAKE_C_FLAGS_RELEASE})
+
+ add_library(loader-norm OBJECT ${NORMAL_LOADER_SRCS} dirent_on_windows.c)
+ target_compile_options(loader-norm PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_DBG}>")
+ add_library(loader-opt OBJECT ${OPT_LOADER_SRCS})
+ target_compile_options(loader-opt PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_REL}>")
+ add_library(vulkan-${MAJOR} SHARED $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm> ${CMAKE_CURRENT_BINARY_DIR}/vulkan-${MAJOR}.def)
set_target_properties(vulkan-${MAJOR} PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/vulkan-${MAJOR}.def")
- add_library(VKstatic.${MAJOR} STATIC ${LOADER_SRCS} dirent_on_windows.c)
+ add_library(VKstatic.${MAJOR} STATIC $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm>)
set_target_properties(VKstatic.${MAJOR} PROPERTIES OUTPUT_NAME VKstatic.${MAJOR})
target_link_libraries(vulkan-${MAJOR} shlwapi)
else()