Skip to content

Commit 03b9825

Browse files
committed
Centralize more CMake settings (#17)
1 parent 3ec70da commit 03b9825

File tree

5 files changed

+21
-45
lines changed

5 files changed

+21
-45
lines changed

generator/vk_codegen/source_CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ target_include_directories(
5757

5858
lgl_set_build_options(${VK_LAYER})
5959

60-
target_compile_definitions(
61-
${VK_LAYER} PRIVATE
62-
$<$<PLATFORM_ID:Android>:VK_USE_PLATFORM_ANDROID_KHR=1>
63-
$<$<PLATFORM_ID:Android>:LGL_LOG_TAG="${LGL_LOG_TAG}">)
64-
6560
target_link_libraries(
6661
${VK_LAYER}
6762
lib_layer_framework

generator/vk_common/CMakeLists.txt

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,21 @@
2121
# SOFTWARE.
2222
# -----------------------------------------------------------------------------
2323

24-
set(BUILD_TARGET lib_layer_framework)
24+
set(LIB_BINARY lib_layer_framework)
2525

2626
add_library(
27-
${BUILD_TARGET} STATIC
27+
${LIB_BINARY} STATIC
2828
device_functions.cpp
2929
instance_functions.cpp)
3030

3131
target_include_directories(
32-
${BUILD_TARGET} PRIVATE
32+
${LIB_BINARY} PRIVATE
3333
# Note, this includes from the layer-specific tree
3434
${PROJECT_SOURCE_DIR}/source
3535
../)
3636

3737
target_include_directories(
38-
${BUILD_TARGET} SYSTEM PRIVATE
38+
${LIB_BINARY} SYSTEM PRIVATE
3939
../../khronos/vulkan/include)
4040

41-
lgl_set_build_options(${BUILD_TARGET})
42-
43-
# TODO: Log tag needs to come from child project
44-
target_compile_definitions(
45-
${BUILD_TARGET} PRIVATE
46-
$<$<PLATFORM_ID:Android>:VK_USE_PLATFORM_ANDROID_KHR=1>
47-
$<$<PLATFORM_ID:Android>:LGL_LOG_TAG="${LGL_LOG_TAG}">)
48-
49-
# TODO: Remove this?
50-
target_link_libraries(
51-
${BUILD_TARGET}
52-
$<$<PLATFORM_ID:Android>:log>)
41+
lgl_set_build_options(${LIB_BINARY})

layer_example/source/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ target_include_directories(
5858

5959
lgl_set_build_options(${VK_LAYER})
6060

61-
target_compile_definitions(
62-
${VK_LAYER} PRIVATE
63-
$<$<PLATFORM_ID:Android>:VK_USE_PLATFORM_ANDROID_KHR=1>
64-
$<$<PLATFORM_ID:Android>:LGL_LOG_TAG="${LGL_LOG_TAG}">)
65-
6661
target_link_libraries(
6762
${VK_LAYER}
6863
lib_layer_framework

source_common/compiler_helper.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ set(is_clangcl "$<AND:${is_msvc_fe},$<CXX_COMPILER_ID:Clang>>")
4242
# Compiler is upstream clang with the standard frontend
4343
set(is_clang "$<AND:${is_gnu_fe},$<CXX_COMPILER_ID:Clang,AppleClang>>")
4444

45-
# Utility macro to set standard compiler options
45+
# Utility macro to set standard compiler and linker options
4646
macro(lgl_set_build_options BUILD_TARGET_NAME)
4747

48+
# Layers are shared objects so must be position independent
49+
set_property(
50+
TARGET ${BUILD_TARGET_NAME}
51+
PROPERTY POSITION_INDEPENDENT_CODE ON)
52+
4853
target_compile_options(
4954
${BUILD_TARGET_NAME} PRIVATE
5055
# Minimized visibility warnings
@@ -61,7 +66,10 @@ macro(lgl_set_build_options BUILD_TARGET_NAME)
6166
$<${is_clang}:-Wdocumentation>
6267

6368
# Feature disabled
64-
$<${is_gnu_fe}:-fno-exceptions>
65-
$<${is_gnu_fe}:-fno-rtti>)
69+
$<${is_gnu_fe}:-fno-exceptions>)
6670

71+
target_compile_definitions(
72+
${BUILD_TARGET_NAME} PRIVATE
73+
$<$<PLATFORM_ID:Android>:VK_USE_PLATFORM_ANDROID_KHR=1>
74+
$<$<PLATFORM_ID:Android>:LGL_LOG_TAG="${LGL_LOG_TAG}">)
6775
endmacro()

source_common/framework/CMakeLists.txt

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,21 @@
2121
# SOFTWARE.
2222
# -----------------------------------------------------------------------------
2323

24-
set(BUILD_TARGET lib_layer_framework)
24+
set(LIB_BINARY lib_layer_framework)
2525

2626
add_library(
27-
${BUILD_TARGET} STATIC
27+
${LIB_BINARY} STATIC
2828
device_functions.cpp
2929
instance_functions.cpp)
3030

3131
target_include_directories(
32-
${BUILD_TARGET} PRIVATE
32+
${LIB_BINARY} PRIVATE
3333
# Note, this includes from the layer-specific tree
3434
${PROJECT_SOURCE_DIR}/source
3535
../)
3636

3737
target_include_directories(
38-
${BUILD_TARGET} SYSTEM PRIVATE
38+
${LIB_BINARY} SYSTEM PRIVATE
3939
../../khronos/vulkan/include)
4040

41-
lgl_set_build_options(${BUILD_TARGET})
42-
43-
# TODO: Log tag needs to come from child project
44-
target_compile_definitions(
45-
${BUILD_TARGET} PRIVATE
46-
$<$<PLATFORM_ID:Android>:VK_USE_PLATFORM_ANDROID_KHR=1>
47-
$<$<PLATFORM_ID:Android>:LGL_LOG_TAG="${LGL_LOG_TAG}">)
48-
49-
# TODO: Remove this?
50-
target_link_libraries(
51-
${BUILD_TARGET}
52-
$<$<PLATFORM_ID:Android>:log>)
41+
lgl_set_build_options(${LIB_BINARY})

0 commit comments

Comments
 (0)