From f26434ae761bc768034e92164553a08532ae6563 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Wed, 4 Dec 2024 20:59:11 +0000 Subject: [PATCH 1/2] Cleanup cmake settings --- generator/vk_common/CMakeLists.txt | 21 +++++---------------- source_common/compiler_helper.cmake | 8 ++++++-- source_common/framework/CMakeLists.txt | 21 +++++---------------- 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/generator/vk_common/CMakeLists.txt b/generator/vk_common/CMakeLists.txt index 0ca2695..327e476 100644 --- a/generator/vk_common/CMakeLists.txt +++ b/generator/vk_common/CMakeLists.txt @@ -21,32 +21,21 @@ # SOFTWARE. # ----------------------------------------------------------------------------- -set(BUILD_TARGET lib_layer_framework) +set(LIB_BINARY lib_layer_framework) add_library( - ${BUILD_TARGET} STATIC + ${LIB_BINARY} STATIC device_functions.cpp instance_functions.cpp) target_include_directories( - ${BUILD_TARGET} PRIVATE + ${LIB_BINARY} PRIVATE # Note, this includes from the layer-specific tree ${PROJECT_SOURCE_DIR}/source ../) target_include_directories( - ${BUILD_TARGET} SYSTEM PRIVATE + ${LIB_BINARY} SYSTEM PRIVATE ../../khronos/vulkan/include) -lgl_set_build_options(${BUILD_TARGET}) - -# TODO: Log tag needs to come from child project -target_compile_definitions( - ${BUILD_TARGET} PRIVATE - $<$:VK_USE_PLATFORM_ANDROID_KHR=1> - $<$:LGL_LOG_TAG="${LGL_LOG_TAG}">) - -# TODO: Remove this? -target_link_libraries( - ${BUILD_TARGET} - $<$:log>) +lgl_set_build_options(${LIB_BINARY}) diff --git a/source_common/compiler_helper.cmake b/source_common/compiler_helper.cmake index 3859219..d5a37a8 100644 --- a/source_common/compiler_helper.cmake +++ b/source_common/compiler_helper.cmake @@ -61,7 +61,11 @@ macro(lgl_set_build_options BUILD_TARGET_NAME) $<${is_clang}:-Wdocumentation> # Feature disabled - $<${is_gnu_fe}:-fno-exceptions> - $<${is_gnu_fe}:-fno-rtti>) + $<${is_gnu_fe}:-fno-exceptions>) + + target_compile_definitions( + ${BUILD_TARGET_NAME} PRIVATE + $<$:VK_USE_PLATFORM_ANDROID_KHR=1> + $<$:LGL_LOG_TAG="${LGL_LOG_TAG}">) endmacro() diff --git a/source_common/framework/CMakeLists.txt b/source_common/framework/CMakeLists.txt index 0ca2695..327e476 100644 --- a/source_common/framework/CMakeLists.txt +++ b/source_common/framework/CMakeLists.txt @@ -21,32 +21,21 @@ # SOFTWARE. # ----------------------------------------------------------------------------- -set(BUILD_TARGET lib_layer_framework) +set(LIB_BINARY lib_layer_framework) add_library( - ${BUILD_TARGET} STATIC + ${LIB_BINARY} STATIC device_functions.cpp instance_functions.cpp) target_include_directories( - ${BUILD_TARGET} PRIVATE + ${LIB_BINARY} PRIVATE # Note, this includes from the layer-specific tree ${PROJECT_SOURCE_DIR}/source ../) target_include_directories( - ${BUILD_TARGET} SYSTEM PRIVATE + ${LIB_BINARY} SYSTEM PRIVATE ../../khronos/vulkan/include) -lgl_set_build_options(${BUILD_TARGET}) - -# TODO: Log tag needs to come from child project -target_compile_definitions( - ${BUILD_TARGET} PRIVATE - $<$:VK_USE_PLATFORM_ANDROID_KHR=1> - $<$:LGL_LOG_TAG="${LGL_LOG_TAG}">) - -# TODO: Remove this? -target_link_libraries( - ${BUILD_TARGET} - $<$:log>) +lgl_set_build_options(${LIB_BINARY}) From 92c8abcbc85e803c37f95c206829286a6fcc8b73 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Wed, 4 Dec 2024 21:00:57 +0000 Subject: [PATCH 2/2] Centralized use of -fPIC --- source_common/compiler_helper.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source_common/compiler_helper.cmake b/source_common/compiler_helper.cmake index d5a37a8..351795e 100644 --- a/source_common/compiler_helper.cmake +++ b/source_common/compiler_helper.cmake @@ -42,9 +42,14 @@ set(is_clangcl "$>") # Compiler is upstream clang with the standard frontend set(is_clang "$>") -# Utility macro to set standard compiler options +# Utility macro to set standard compiler and linker options macro(lgl_set_build_options BUILD_TARGET_NAME) + # Layers are shared objects so must be position independent + set_property( + TARGET ${BUILD_TARGET_NAME} + PROPERTY POSITION_INDEPENDENT_CODE ON) + target_compile_options( ${BUILD_TARGET_NAME} PRIVATE # Minimized visibility warnings @@ -67,5 +72,4 @@ macro(lgl_set_build_options BUILD_TARGET_NAME) ${BUILD_TARGET_NAME} PRIVATE $<$:VK_USE_PLATFORM_ANDROID_KHR=1> $<$:LGL_LOG_TAG="${LGL_LOG_TAG}">) - endmacro()