Skip to content
Merged
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
11 changes: 11 additions & 0 deletions cmake/omathConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ if (@OMATH_IMGUI_INTEGRATION@)
find_dependency(imgui CONFIG)
endif()

if (@OMATH_ENABLE_LUA@)
find_dependency(Lua)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Matching

find_package(Lua REQUIRED)

endif()

if (@OMATH_ENABLE_HOOKING@)
find_dependency(safetyhook CONFIG)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Matching

omath/CMakeLists.txt

Lines 128 to 134 in d4c86da

find_package(safetyhook CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE safetyhook::safetyhook)
if (WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE d3d9 d3d11 d3d12 dxgi opengl32 gdi32)
elseif (UNIX AND NOT APPLE)
find_package(OpenGL REQUIRED)

if (NOT WIN32 AND (UNIX AND NOT APPLE))
find_dependency(OpenGL)
endif()
endif()
Comment on lines +9 to +18

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since Lua, safetyhook, and OpenGL are linked as PRIVATE dependencies in CMakeLists.txt, they are only required by consumers when omath is built as a static library. If omath is built as a shared library (OMATH_BUILD_AS_SHARED_LIBRARY is ON), these dependencies are already linked into the shared library binary, and forcing consumers to find them via find_dependency is unnecessary and can cause configuration failures if those packages are not installed on the consumer's system.

We should wrap these find_dependency calls in a check for NOT @OMATH_BUILD_AS_SHARED_LIBRARY@ to avoid forcing shared library consumers to install these private dependencies.

if (NOT @OMATH_BUILD_AS_SHARED_LIBRARY@)
    if (@OMATH_ENABLE_LUA@)
        find_dependency(Lua)
    endif()

    if (@OMATH_ENABLE_HOOKING@)
        find_dependency(safetyhook CONFIG)
        if (NOT WIN32 AND (UNIX AND NOT APPLE))
            find_dependency(OpenGL)
        endif()
    endif()
endif()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think there can be header dependencies and similar still present even if PRIVATE?


# Load the targets for the omath library
include("${CMAKE_CURRENT_LIST_DIR}/omathTargets.cmake")
check_required_components(omath)
Loading