Skip to content

Commit 9df3a15

Browse files
Install target (#320)
* install target * add SLANG_RHI_INSTALL * fix cmake warning --------- Co-authored-by: Simon Kallweit <[email protected]>
1 parent 5e57567 commit 9df3a15

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
cmake_minimum_required(VERSION 3.20)
2+
if(POLICY CMP0177)
3+
cmake_policy(SET CMP0177 NEW)
4+
endif()
25

36
project(slang-rhi)
47

@@ -14,6 +17,7 @@ include(CTest)
1417
include(CMakeDependentOption)
1518
include(FetchPackage)
1619
include(DetermineTargetArchitecture)
20+
include(GNUInstallDirs)
1721
include(CMakeRC)
1822

1923
# Determine the target architecture we build for.
@@ -42,6 +46,7 @@ option(SLANG_RHI_BUILD_SHARED "Build shared library" OFF)
4246
option(SLANG_RHI_BUILD_TESTS "Build tests" ${SLANG_RHI_MASTER_PROJECT})
4347
option(SLANG_RHI_BUILD_EXAMPLES "Build examples" ${SLANG_RHI_MASTER_PROJECT})
4448
option(SLANG_RHI_ENABLE_COVERAGE "Enable code coverage (clang only)" OFF)
49+
option(SLANG_RHI_INSTALL "Install library" ON)
4550

4651
# Configure coverage flags
4752
if(SLANG_RHI_ENABLE_COVERAGE)
@@ -155,6 +160,10 @@ macro(copy_file IN_FILE OUT_DIR)
155160
)
156161
list(APPEND SLANG_RHI_COPY_FILES ${OUT_FILE_1})
157162
endif()
163+
164+
if(SLANG_RHI_INSTALL)
165+
install(FILES ${IN_FILE} DESTINATION ${CMAKE_INSTALL_BINDIR}/${OUT_DIR})
166+
endif()
158167
endif()
159168
endmacro()
160169

@@ -372,6 +381,7 @@ if(SLANG_RHI_BUILD_TESTS OR SLANG_RHI_BUILD_EXAMPLES)
372381
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
373382
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
374383
set(GLFW_BUILD_WAYLAND OFF CACHE BOOL "" FORCE)
384+
set(GLFW_INSTALL OFF)
375385
FetchContent_MakeAvailable(glfw)
376386
endif()
377387

@@ -816,3 +826,21 @@ if(SLANG_RHI_ENABLE_COVERAGE)
816826
message(STATUS "Required tools: llvm-profdata, llvm-cov")
817827
endif()
818828
endif()
829+
830+
# Install
831+
if(SLANG_RHI_INSTALL)
832+
install(
833+
TARGETS slang-rhi
834+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
835+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
836+
)
837+
install(
838+
DIRECTORY include/
839+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
840+
FILES_MATCHING PATTERN "*.h"
841+
)
842+
install(
843+
FILES ${CMAKE_CURRENT_BINARY_DIR}/include/slang-rhi-config.h
844+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
845+
)
846+
endif()

0 commit comments

Comments
 (0)