Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMake] Install library #13

Merged
merged 1 commit into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ std::vector<uint32_t> binary;
int err = translator.translate(binary, &srcgen);
```

## Installation

To install the library, first check you're building with the right CMake variables set:
* `CMAKE_INSTALL_PREFIX` - Location of the final package.
* `BUILD_SHARED_LIBS` - Whether to build spirv2clc as a shared library or a static library.
Note that a static library build at the moment requires the user
to manually provide the SPIR-V dependencies as static libraries
in the target project (where you want to embed spirv2clc).
* `CMAKE_POSITION_INDEPENDENT_CODE` - Whether to enable `fPIC` or similar flags
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to always enable PIC on the library. This will be required by the layer being introduced by #14. I'll tweak this after merging.

when building the library. Ensure this matches the target project.

To install the library after a successful build, run the following command:
```sh
cmake --install .
```

After the installation step you can use spirv2clc as an `IMPORTED` library
in your target project.

# Running with test layer

A layer that enables a round-trip translation of OpenCL C programs to SPIR-V and
Expand Down
24 changes: 24 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,27 @@ set_target_properties(libspirv2clc PROPERTIES
target_link_libraries(libspirv2clc SPIRV-Tools-opt)

generate_export_header(libspirv2clc)

install(TARGETS libspirv2clc
RUNTIME DESTINATION lib COMPONENT libraries
LIBRARY DESTINATION lib COMPONENT libraries
ARCHIVE DESTINATION lib COMPONENT libraries
)
install(FILES
"${PROJECT_SOURCE_DIR}/include/spirv2clc.h"
"${CMAKE_CURRENT_BINARY_DIR}/libspirv2clc_export.h"
DESTINATION include
COMPONENT headers
)
install(DIRECTORY "${SPIRV_TOOLS_DIR}/include"
DESTINATION .
COMPONENT headers
FILES_MATCHING
PATTERN "spirv-tools/libspirv.h"
)
install(DIRECTORY "${SPIRV-Headers_SOURCE_DIR}/include"
DESTINATION .
COMPONENT headers
FILES_MATCHING
PATTERN "spirv/unified1/spirv.h"
)