diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index f90728bc..3f43335d 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -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}" - "$<$:${SDL2_INCLUDE_DIRS}>" - - ${OPENGL_INCLUDE_DIR} - ${OPENGLES2_INCLUDE_DIR} - ${EGL_INCLUDE_DIR} - - "$<$:${ANDROID_NDK}/sources/android/native_app_glue>" - "$<$:${X11_INCLUDE_DIR}>" -) - -set(link_libs - "${ZLIB_LIBRARY}" - "${JPEG_LIBRARY}" - "${PNG_LIBRARY}" - "$<$:${SDL2_LIBRARIES}>" - - "$<$:${OPENGL_LIBRARIES}>" - "$<$:${OPENGLES_LIBRARY}>" - "$<$:${OPENGLES2_LIBRARIES}>" - ${EGL_LIBRARY} - - "$<$:-landroid -llog>" - ${COCOA_LIB} - ${IOKIT_LIB} - "$<$:gdi32>" - "$<$:winmm>" - "$<$:${X11_X11_LIB}>" - "$<$:${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. + "$<$:${OPENGL_LIBRARIES}>" + "$<$:${OPENGLES_LIBRARY}>" + "$<$:${OPENGLES2_LIBRARIES}>" + "${EGL_LIBRARY}" + JPEG::JPEG + PRIVATE + PNG::PNG +) + +if(USE_X11) + target_include_directories(IRRVIDEOOBJ PUBLIC "${X11_INCLUDE_DIR}") +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 "$" "$" "$" - 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> + + # 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. + "$<$:-landroid -llog>" + ${COCOA_LIB} + ${IOKIT_LIB} + "$<$:gdi32>" + "$<$:winmm>" +) if(WIN32) target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header