This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
Specify dependencies on object library targets #282
Draft
JosiahWI
wants to merge
1
commit into
minetest:master
Choose a base branch
from
JosiahWI:refactor/cmake-link-libraries
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,42 +297,10 @@ elseif(NOT USE_SDL2) | |
endif() | ||
endif() | ||
|
||
set(link_includes | ||
"${PROJECT_SOURCE_DIR}/include" | ||
"${CMAKE_CURRENT_SOURCE_DIR}" | ||
|
||
"${ZLIB_INCLUDE_DIR}" | ||
"${JPEG_INCLUDE_DIR}" | ||
"${PNG_INCLUDE_DIR}" | ||
"$<$<BOOL:${USE_SDL2}>:${SDL2_INCLUDE_DIRS}>" | ||
|
||
${OPENGL_INCLUDE_DIR} | ||
${OPENGLES2_INCLUDE_DIR} | ||
${EGL_INCLUDE_DIR} | ||
|
||
"$<$<PLATFORM_ID:Android>:${ANDROID_NDK}/sources/android/native_app_glue>" | ||
"$<$<BOOL:${USE_X11}>:${X11_INCLUDE_DIR}>" | ||
) | ||
|
||
set(link_libs | ||
"${ZLIB_LIBRARY}" | ||
"${JPEG_LIBRARY}" | ||
"${PNG_LIBRARY}" | ||
"$<$<BOOL:${USE_SDL2}>:${SDL2_LIBRARIES}>" | ||
|
||
"$<$<BOOL:${OPENGL_DIRECT_LINK}>:${OPENGL_LIBRARIES}>" | ||
"$<$<BOOL:${OPENGLES_DIRECT_LINK}>:${OPENGLES_LIBRARY}>" | ||
"$<$<BOOL:${OPENGLES2_DIRECT_LINK}>:${OPENGLES2_LIBRARIES}>" | ||
${EGL_LIBRARY} | ||
|
||
"$<$<PLATFORM_ID:Android>:-landroid -llog>" | ||
${COCOA_LIB} | ||
${IOKIT_LIB} | ||
"$<$<PLATFORM_ID:Windows>:gdi32>" | ||
"$<$<PLATFORM_ID:Windows>:winmm>" | ||
"$<$<BOOL:${USE_X11}>:${X11_X11_LIB}>" | ||
"$<$<BOOL:${USE_X11}>:${X11_Xi_LIB}>" | ||
) | ||
# These includes are needed across the whole project, so they | ||
# are included globally so we do not have to include them for | ||
# each new OBJECT library target. | ||
include_directories("${PROJECT_SOURCE_DIR}/include") | ||
|
||
# Source files | ||
|
||
|
@@ -406,6 +374,23 @@ add_library(IRRVIDEOOBJ OBJECT | |
${IRRIMAGEOBJ} | ||
) | ||
|
||
target_link_libraries(IRRVIDEOOBJ | ||
PUBLIC | ||
# TODO Create imported targets if they do not already exist, | ||
# and only link the correct one for the enabled backend. | ||
"$<$<BOOL:${OPENGL_DIRECT_LINK}>:${OPENGL_LIBRARIES}>" | ||
"$<$<BOOL:${OPENGLES_DIRECT_LINK}>:${OPENGLES_LIBRARY}>" | ||
"$<$<BOOL:${OPENGLES2_DIRECT_LINK}>:${OPENGLES2_LIBRARIES}>" | ||
"${EGL_LIBRARY}" | ||
JPEG::JPEG | ||
PRIVATE | ||
PNG::PNG | ||
) | ||
|
||
if(USE_X11) | ||
target_include_directories(IRRVIDEOOBJ PUBLIC "${X11_INCLUDE_DIR}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could be a generator expression instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will be obsolete, though, once I change it to use a target. |
||
endif() | ||
|
||
if(USE_SDLGL) | ||
target_sources(IRRVIDEOOBJ PRIVATE | ||
OpenGL/Driver.cpp | ||
|
@@ -448,6 +433,11 @@ add_library(IRRIOOBJ OBJECT | |
CAttributes.cpp | ||
) | ||
|
||
target_link_libraries(IRRIOOBJ | ||
PRIVATE | ||
ZLIB::ZLIB | ||
) | ||
|
||
add_library(IRROTHEROBJ OBJECT | ||
CIrrDeviceSDL.cpp | ||
CIrrDeviceLinux.cpp | ||
|
@@ -459,6 +449,24 @@ add_library(IRROTHEROBJ OBJECT | |
os.cpp | ||
) | ||
|
||
if(USE_SDL2) | ||
target_link_libraries(IRROTHEROBJ | ||
PUBLIC | ||
SDL2::SDL2 | ||
) | ||
endif() | ||
|
||
if(USE_X11) | ||
target_include_directories(IRROTHEROBJ PUBLIC "${X11_INCLUDE_DIR}") | ||
target_link_libraries(IRROTHEROBJ | ||
PUBLIC | ||
# TODO Create imported targets if they do not already | ||
# exist. | ||
"${X11_X11_LIB}" | ||
"${X11_Xi_LIB}" | ||
) | ||
endif() | ||
|
||
if(ENABLE_OPENGL3) | ||
target_compile_definitions(IRROTHEROBJ PRIVATE ENABLE_OPENGL3) | ||
endif() | ||
|
@@ -529,11 +537,27 @@ target_include_directories(IrrlichtMt | |
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>" | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" | ||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt>" | ||
PRIVATE | ||
${link_includes} | ||
) | ||
|
||
target_link_libraries(IrrlichtMt PRIVATE ${link_libs}) | ||
target_link_libraries(IrrlichtMt | ||
PRIVATE | ||
# FIXME this will not propogate dependencies to IrrlichtMt | ||
# dependants, but I do not want to clutter the export with | ||
# object libraries, either. | ||
<$BUILD_INTERFACE:IRROBJ> | ||
<$BUILD_INTERFACE:IRROTHEROBJ> | ||
<$BUILD_INTERFACE:IRRVIDEOOBJ> | ||
Comment on lines
+547
to
+549
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a portable solution. I will probably end up including these in the export for the time being. |
||
|
||
# TODO These need to be linked to the appropriate object | ||
# library targets. I have an MSVC build on another computer | ||
# I can test the Windows ones with. I do not yet know how to | ||
# test the Android and OS X ones. | ||
"$<$<PLATFORM_ID:Android>:-landroid -llog>" | ||
${COCOA_LIB} | ||
${IOKIT_LIB} | ||
"$<$<PLATFORM_ID:Windows>:gdi32>" | ||
"$<$<PLATFORM_ID:Windows>:winmm>" | ||
) | ||
|
||
if(WIN32) | ||
target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by which logic is public/private decided here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually base it on whether the dependency is included from a public header. I will double check all of these before taking it out of draft.