mirror of
https://github.com/minetest/irrlicht.git
synced 2024-12-25 18:20:30 +01:00
Set includes and libs on object targets
Instead of using the global `include_directories()` and `link_libraries()` calls use the target versions `target_include_directories()` and `target_include_libraries()` with `PRIVATE` keyword instead. The dependencies are libraries only, the headers are added to the build instructions in a separate call. So the `target_link_libraries()` calls are not needed for the object-libraries to be built.
This commit is contained in:
parent
78d1a3f73e
commit
924178ebf6
@ -64,8 +64,7 @@ else()
|
|||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Includes for object libraries.
|
set(link_includes
|
||||||
include_directories(
|
|
||||||
"${PROJECT_SOURCE_DIR}/include"
|
"${PROJECT_SOURCE_DIR}/include"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
|
||||||
@ -81,7 +80,6 @@ include_directories(
|
|||||||
${X11_INCLUDE_DIR}
|
${X11_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Libraries for object libraries.
|
|
||||||
set(link_libs
|
set(link_libs
|
||||||
"${ZLIB_LIBRARY}"
|
"${ZLIB_LIBRARY}"
|
||||||
"${JPEG_LIBRARY}"
|
"${JPEG_LIBRARY}"
|
||||||
@ -100,7 +98,6 @@ set(link_libs
|
|||||||
${X11_X11_LIB}
|
${X11_X11_LIB}
|
||||||
${X11_Xxf86vm_LIB}
|
${X11_Xxf86vm_LIB}
|
||||||
)
|
)
|
||||||
link_libraries(${link_libs})
|
|
||||||
|
|
||||||
# Source files
|
# Source files
|
||||||
|
|
||||||
@ -401,18 +398,15 @@ add_library(IRRGUIOBJ OBJECT
|
|||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build shared library" TRUE)
|
option(BUILD_SHARED_LIBS "Build shared library" TRUE)
|
||||||
|
|
||||||
# IrrlichtMt target
|
add_library(IrrlichtMt)
|
||||||
add_library(IrrlichtMt
|
foreach(object_lib
|
||||||
$<TARGET_OBJECTS:IRRMESHOBJ>
|
IRRMESHOBJ IRROBJ IRRPARTICLEOBJ IRRANIMOBJ IRRVIDEOOBJ IRRSWRENDEROBJ
|
||||||
$<TARGET_OBJECTS:IRROBJ>
|
IRRIOOBJ IRROTHEROBJ IRRGUIOBJ)
|
||||||
$<TARGET_OBJECTS:IRRPARTICLEOBJ>
|
# Set include directories for object library compilation
|
||||||
$<TARGET_OBJECTS:IRRANIMOBJ>
|
target_include_directories(${object_lib} PRIVATE ${link_includes})
|
||||||
$<TARGET_OBJECTS:IRRVIDEOOBJ>
|
# Add objects from object library to main library
|
||||||
$<TARGET_OBJECTS:IRRSWRENDEROBJ>
|
target_sources(IrrlichtMt PRIVATE $<TARGET_OBJECTS:${object_lib}>)
|
||||||
$<TARGET_OBJECTS:IRRIOOBJ>
|
endforeach()
|
||||||
$<TARGET_OBJECTS:IRROTHEROBJ>
|
|
||||||
$<TARGET_OBJECTS:IRRGUIOBJ>
|
|
||||||
)
|
|
||||||
|
|
||||||
# Alias target provides add_submodule compatibility
|
# Alias target provides add_submodule compatibility
|
||||||
add_library(IrrlichtMt::IrrlichtMt ALIAS IrrlichtMt)
|
add_library(IrrlichtMt::IrrlichtMt ALIAS IrrlichtMt)
|
||||||
@ -423,16 +417,7 @@ target_include_directories(IrrlichtMt
|
|||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt>"
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${ZLIB_INCLUDE_DIR}"
|
${link_includes}
|
||||||
"${JPEG_INCLUDE_DIR}"
|
|
||||||
"${PNG_INCLUDE_DIR}"
|
|
||||||
|
|
||||||
${OPENGL_INCLUDE_DIR}
|
|
||||||
${OPENGLES2_INCLUDE_DIR}
|
|
||||||
${EGL_INCLUDE_DIR}
|
|
||||||
|
|
||||||
"$<$<PLATFORM_ID:Android>:${ANDROID_NDK}/sources/android/native_app_glue>"
|
|
||||||
${X11_INCLUDE_DIR}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(IrrlichtMt PRIVATE ${link_libs})
|
target_link_libraries(IrrlichtMt PRIVATE ${link_libs})
|
||||||
|
Loading…
Reference in New Issue
Block a user