summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorTobias Frisch <jacki@thejackimonster.de>2024-10-04 10:34:12 +0200
committerGitHub <noreply@github.com>2024-10-04 16:34:12 +0800
commit25c17b9fcbf7a21e9fa19c4a8f08b0406437be24 (patch)
treea85a734b32ea4f27a9cd594586a328858965893b /cmake
parent9f246a43667b4893040669873400e2e3813328ff (diff)
Allow building using external dependencies (#5076)
* Add options to prevent usage of own submodules Signed-off-by: Jacki <jacki@thejackimonster.de> * Allow using external unordered dense headers Signed-off-by: Jacki <jacki@thejackimonster.de> * Link system wide installed unordered dense Signed-off-by: Jacki <jacki@thejackimonster.de> * Allow external header usage for lz4 and spirv Signed-off-by: Jacki <jacki@thejackimonster.de> * Add more options to disable targets Signed-off-by: Jacki <jacki@thejackimonster.de> * Add option to provide explizit path for spirv headers and remove earlier options that break the build process Signed-off-by: Jacki <jacki@thejackimonster.de> * Rename options to use common prefix Signed-off-by: Jacki <jacki@thejackimonster.de> * Fix indentation for the cmake changes Signed-off-by: Jacki <jacki@thejackimonster.de> * Add advanced_option function for cmake * Normalize includes between system and submodule dependencies Fix any before-accidentally-working problems * Add option for enabling/disabling slang-rhi Signed-off-by: Jacki <jacki@thejackimonster.de> * Pass correct include path for cpu tests * Correct include path --------- Signed-off-by: Jacki <jacki@thejackimonster.de> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/AutoOption.cmake5
-rw-r--r--cmake/SlangTarget.cmake14
2 files changed, 19 insertions, 0 deletions
diff --git a/cmake/AutoOption.cmake b/cmake/AutoOption.cmake
index 3f7cdee0e..d25ea17b8 100644
--- a/cmake/AutoOption.cmake
+++ b/cmake/AutoOption.cmake
@@ -42,3 +42,8 @@ function(enum_option name init description)
endforeach()
message(FATAL_ERROR "${name} must be one of ${enums}")
endfunction()
+
+function(advanced_option name description default)
+ option(${name} ${description} ${default})
+ mark_as_advanced(${name})
+endfunction()
diff --git a/cmake/SlangTarget.cmake b/cmake/SlangTarget.cmake
index e370a4987..5387cd2ce 100644
--- a/cmake/SlangTarget.cmake
+++ b/cmake/SlangTarget.cmake
@@ -55,10 +55,16 @@ function(slang_add_target dir type)
EXTRA_COMPILE_OPTIONS_PRIVATE
# Targets with which to link privately
LINK_WITH_PRIVATE
+ # Targets with which to link publicly, for example if their headers
+ # appear in our headers
+ LINK_WITH_PUBLIC
# Frameworks with which to link privately
LINK_WITH_FRAMEWORK
# Targets whose headers we use, but don't link with
INCLUDE_FROM_PRIVATE
+ # Targets whose headers we use in our headers, so need to make sure
+ # dependencies of this target also include them
+ INCLUDE_FROM_PUBLIC
# Any include directories other targets need to use this target
INCLUDE_DIRECTORIES_PUBLIC
# Any include directories this target only needs
@@ -214,6 +220,7 @@ function(slang_add_target dir type)
# Link and include from dependencies
#
target_link_libraries(${target} PRIVATE ${ARG_LINK_WITH_PRIVATE})
+ target_link_libraries(${target} PUBLIC ${ARG_LINK_WITH_PUBLIC})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
foreach(link_framework ${ARG_LINK_WITH_FRAMEWORK})
@@ -228,6 +235,13 @@ function(slang_add_target dir type)
$<TARGET_PROPERTY:${include_from},INTERFACE_INCLUDE_DIRECTORIES>
)
endforeach()
+ foreach(include_from ${ARG_INCLUDE_FROM_PUBLIC})
+ target_include_directories(
+ ${target}
+ PUBLIC
+ $<TARGET_PROPERTY:${include_from},INTERFACE_INCLUDE_DIRECTORIES>
+ )
+ endforeach()
#
# Set our exported include directories