Skip to content

Commit 0327124

Browse files
authored
Make library inkcpp_shared public (#140)
### Context Currently, using `add_subdirectory` or `FetchContent` in a CMake project fails to compile. The compiler reports missing headers from the **_inkcpp_shared_** library. A workaround is to explicitly link it: > target_link_libraries(inkcpp_sample PRIVATE inkcpp inkcpp_compiler **inkcpp_shared**) However, this is only a quick fix. ### Problem **_inkcpp_shared_** is a header-only library defined as an `INTERFACE` target and is used in the public headers of the **_inkcpp_** and **_inkcpp_compiler_** projects. However, both projects link **_inkcpp_shared_** as a `PRIVATE` dependency, which prevents its headers from being propagated to consumers. This issue is not visible when **_inkcpp_** is installed, because the public headers from **_inkcpp_shared_** are copied during installation. ### Solution To fix the problem, **_inkcpp_shared_** should be linked `PUBLIC` so that its headers are properly propagated as part of the public API of both **_inkcpp_** and **_inkcpp_compiler_**.
1 parent 763a119 commit 0327124

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

inkcpp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ target_include_directories(inkcpp PUBLIC
5252
set_target_properties(inkcpp PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
5353

5454
# Make sure the include directory is included
55-
target_link_libraries(inkcpp_o PRIVATE inkcpp_shared)
56-
target_link_libraries(inkcpp PRIVATE inkcpp_shared)
55+
target_link_libraries(inkcpp_o PUBLIC inkcpp_shared)
56+
target_link_libraries(inkcpp PUBLIC inkcpp_shared)
5757
# Make sure this project and all dependencies use the C++17 standard
5858
target_compile_features(inkcpp PUBLIC cxx_std_17)
5959

inkcpp_compiler/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ target_include_directories(inkcpp_compiler PUBLIC
2222
FILE(GLOB PUBLIC_HEADERS "include/*")
2323
set_target_properties(inkcpp_compiler PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
2424

25-
target_link_libraries(inkcpp_compiler PRIVATE inkcpp_shared)
26-
target_link_libraries(inkcpp_compiler_o PRIVATE inkcpp_shared)
25+
target_link_libraries(inkcpp_compiler PUBLIC inkcpp_shared)
26+
target_link_libraries(inkcpp_compiler_o PUBLIC inkcpp_shared)
2727

2828
# Unreal installation
2929
list(REMOVE_ITEM SOURCES "json.hpp")

0 commit comments

Comments
 (0)