@@ -338,3 +338,43 @@ install(DIRECTORY "${slang_SOURCE_DIR}/docs/" DESTINATION share/doc/slang)
338
338
install (DIRECTORY "${slang_SOURCE_DIR} /include" DESTINATION .)
339
339
340
340
include (CPack)
341
+
342
+ # Write basic package config version file using standard CMakePackageConfigHelpers utility
343
+ include (CMakePackageConfigHelpers)
344
+ write_basic_package_version_file(
345
+ "${PROJECT_NAME} ConfigVersion.cmake"
346
+ VERSION ${PROJECT_VERSION}
347
+ COMPATIBILITY SameMajorVersion
348
+ )
349
+
350
+ # Write SlangConfig.cmake which should allow find_pacakage(SLANG) to work correctly
351
+ # SlangConfig.cmake will define slang::slang target that can be linked with using
352
+ # target_link_libraries. It will also define SLANG_EXECUTABLE export variable that
353
+ # should point to slangc if SLANG_ENABLE_SLANGC is ON.
354
+ configure_package_config_file(
355
+ "${PROJECT_SOURCE_DIR} /cmake/SlangConfig.cmake.in"
356
+ "${PROJECT_BINARY_DIR} /${PROJECT_NAME} Config.cmake"
357
+ INSTALL_DESTINATION cmake
358
+ )
359
+
360
+ # Conditionally handle the case for Emscripten where slang does not create linkable
361
+ # targets. In this case do not export the targets. Otherwise, just export the
362
+ # slang target, as this is the library that is required to use the compiler. This possibly
363
+ # should later be expanded to include slang-rhi targets if some program intends to use them,
364
+ # but possibly wait for a future request before expanding this export set.
365
+ if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" )
366
+ install (TARGETS slang EXPORT SlangExportTarget)
367
+ install (
368
+ EXPORT SlangExportTarget
369
+ FILE ${PROJECT_NAME} Targets.cmake
370
+ NAMESPACE ${PROJECT_NAME} ::
371
+ DESTINATION cmake
372
+ )
373
+ endif ()
374
+
375
+ install (
376
+ FILES
377
+ "${PROJECT_BINARY_DIR} /${PROJECT_NAME} Config.cmake"
378
+ "${PROJECT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake"
379
+ DESTINATION cmake
380
+ )
0 commit comments