Skip to content

Commit 19b16ff

Browse files
committed
rejig cmake build files
1 parent 81e4b19 commit 19b16ff

File tree

6 files changed

+21
-14
lines changed

6 files changed

+21
-14
lines changed

CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ set(CMAKE_C_STANDARD 11)
1010
set(CMAKE_C_STANDARD_REQUIRED ON)
1111
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1212

13+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
14+
1315
if (MSVC)
1416
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
1517
endif()
@@ -99,20 +101,11 @@ endif()
99101

100102
include(CMakePackageConfigHelpers)
101103

102-
install(TARGETS api EXPORT shady_export_set)
103-
install(TARGETS shady EXPORT shady_export_set ARCHIVE DESTINATION ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
104-
105104
if (TARGET vcc)
106105
add_subdirectory(vcc-std)
107106
endif ()
108107

109-
if (TARGET runtime)
110-
install(TARGETS runtime EXPORT shady_export_set ARCHIVE DESTINATION ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
111-
endif()
112-
113-
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/shady DESTINATION include)
114108
install(EXPORT shady_export_set DESTINATION share/cmake/shady/ NAMESPACE shady:: FILE shady-targets.cmake)
115109

116110
configure_file(cmake/shady-config.cmake.in shady-config.cmake @ONLY)
117111
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/shady-config.cmake" DESTINATION share/cmake/shady)
118-
#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/shady-config.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/shady)

src/common/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
add_library(common STATIC list.c dict.c log.c portability.c util.c growy.c arena.c printer.c)
2-
target_include_directories(common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
32
target_link_libraries(common PRIVATE "$<BUILD_INTERFACE:murmur3>")
43
set_property(TARGET common PROPERTY POSITION_INDEPENDENT_CODE ON)
54

5+
# We need to export 'common' because otherwise when using static libraries we will not be able to resolve those symbols
6+
install(TARGETS common EXPORT shady_export_set)
7+
8+
# But we don't want projects outside this to be able to see these APIs and call into them
9+
# (Also we couldn't since the header files live with the source anyways)
10+
add_library(common_api INTERFACE)
11+
target_include_directories(common_api INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
12+
target_link_libraries(common INTERFACE "$<BUILD_INTERFACE:common_api>")
13+
614
add_executable(embedder embed.c)
715

816
function(embed_file TYPE NAME SRC)
@@ -14,3 +22,4 @@ function(embed_file TYPE NAME SRC)
1422
add_dependencies(${NAME} "${NAME}_h")
1523
target_include_directories(${NAME} INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
1624
endfunction()
25+

src/driver/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_library(driver driver.c cli.c)
2-
target_link_libraries(driver PUBLIC "$<BUILD_INTERFACE:api>")
3-
target_link_libraries(driver PUBLIC "$<BUILD_INTERFACE:shady>")
2+
target_link_libraries(driver PUBLIC "api")
3+
target_link_libraries(driver PUBLIC "shady")
44
set_target_properties(driver PROPERTIES OUTPUT_NAME "shady_driver")
55
install(TARGETS driver EXPORT shady_export_set)
66

src/runtime/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ add_subdirectory(cuda)
77

88
add_executable(runtime_test runtime_test.c)
99
target_link_libraries(runtime_test runtime)
10+
11+
install(TARGETS runtime EXPORT shady_export_set ARCHIVE DESTINATION ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})

src/shady/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ add_subdirectory(internal)
111111
add_subdirectory(emit)
112112

113113
target_link_libraries(shady PRIVATE "api")
114-
target_link_libraries(shady INTERFACE "$<BUILD_INTERFACE:common>")
115-
target_link_libraries(shady PRIVATE "$<BUILD_INTERFACE:SPIRV-Headers::SPIRV-Headers>")
114+
target_link_libraries(shady INTERFACE "common")
116115
target_link_libraries(shady PRIVATE "$<BUILD_INTERFACE:m>")
116+
117+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/shady DESTINATION include)
118+
install(TARGETS shady EXPORT shady_export_set ARCHIVE DESTINATION ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})

src/shady/api/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grammar_generated.h DESTINATION includ
1111
add_generated_file(FILE_NAME primops_generated.h TARGET_NAME generate-primops-headers SOURCES generator_primops.c)
1212
add_dependencies(api INTERFACE generate-primops-headers)
1313
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/primops_generated.h DESTINATION include)
14+
install(TARGETS api EXPORT shady_export_set)

0 commit comments

Comments
 (0)