Specify all source fools directly on IrrlichtMt

This commit is contained in:
JosiahWI 2022-10-17 21:01:12 -05:00
parent 60e70c3cc5
commit 4feaf17871
No known key found for this signature in database
GPG Key ID: C7BB8573A4ABC4B9

View File

@ -118,61 +118,25 @@ else()
endif() endif()
endif() endif()
set(link_includes add_library(IrrlichtMt)
"${PROJECT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${ZLIB_INCLUDE_DIR}" # alias allows for consistent target name with add_subdirectory
"${JPEG_INCLUDE_DIR}" add_library(IrrlichtMt::IrrlichtMt ALIAS IrrlichtMt)
"${PNG_INCLUDE_DIR}"
"${SDL2_INCLUDE_DIRS}"
${OPENGL_INCLUDE_DIR} target_sources(IrrlichtMt PRIVATE
${OPENGLES2_INCLUDE_DIR} # IRRMESHLOADER
${EGL_INCLUDE_DIR}
"$<$<PLATFORM_ID:Android>:${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}
"$<$<PLATFORM_ID:Android>:native_app_glue -landroid -llog>"
${COCOA_LIB}
${IOKIT_LIB}
"$<$<PLATFORM_ID:Windows>:gdi32>"
"$<$<PLATFORM_ID:Windows>:winmm>"
${X11_X11_LIB}
${X11_Xi_LIB}
)
# Source files
set(IRRMESHLOADER
CB3DMeshFileLoader.cpp CB3DMeshFileLoader.cpp
COBJMeshFileLoader.cpp COBJMeshFileLoader.cpp
CXMeshFileLoader.cpp CXMeshFileLoader.cpp
CGLTFMeshFileLoader.cpp CGLTFMeshFileLoader.cpp
)
add_library(IRRMESHOBJ OBJECT #IRRMESH
CSkinnedMesh.cpp CSkinnedMesh.cpp
CBoneSceneNode.cpp CBoneSceneNode.cpp
CMeshSceneNode.cpp CMeshSceneNode.cpp
CAnimatedMeshSceneNode.cpp CAnimatedMeshSceneNode.cpp
${IRRMESHLOADER}
)
add_library(IRROBJ OBJECT #IRR
CBillboardSceneNode.cpp CBillboardSceneNode.cpp
CCameraSceneNode.cpp CCameraSceneNode.cpp
CDummyTransformationSceneNode.cpp CDummyTransformationSceneNode.cpp
@ -181,9 +145,8 @@ add_library(IRROBJ OBJECT
CSceneCollisionManager.cpp CSceneCollisionManager.cpp
CSceneManager.cpp CSceneManager.cpp
CMeshCache.cpp CMeshCache.cpp
)
set(IRRDRVROBJ #IRRDRVR
CNullDriver.cpp CNullDriver.cpp
COpenGLCacheHandler.cpp COpenGLCacheHandler.cpp
COpenGLDriver.cpp COpenGLDriver.cpp
@ -203,9 +166,8 @@ set(IRRDRVROBJ
CEGLManager.cpp CEGLManager.cpp
CSDLManager.cpp CSDLManager.cpp
mt_opengl_loader.cpp mt_opengl_loader.cpp
)
set(IRRIMAGEOBJ #IRRIMAGE
CColorConverter.cpp CColorConverter.cpp
CImage.cpp CImage.cpp
CImageLoaderBMP.cpp CImageLoaderBMP.cpp
@ -214,15 +176,11 @@ set(IRRIMAGEOBJ
CImageLoaderTGA.cpp CImageLoaderTGA.cpp
CImageWriterJPG.cpp CImageWriterJPG.cpp
CImageWriterPNG.cpp CImageWriterPNG.cpp
)
add_library(IRRVIDEOOBJ OBJECT # IRRVIDEO
CFPSCounter.cpp CFPSCounter.cpp
${IRRDRVROBJ}
${IRRIMAGEOBJ}
)
add_library(IRRIOOBJ OBJECT # IRRI
CFileList.cpp CFileList.cpp
CFileSystem.cpp CFileSystem.cpp
CLimitReadFile.cpp CLimitReadFile.cpp
@ -231,9 +189,8 @@ add_library(IRRIOOBJ OBJECT
CWriteFile.cpp CWriteFile.cpp
CZipReader.cpp CZipReader.cpp
CAttributes.cpp CAttributes.cpp
)
add_library(IRROTHEROBJ OBJECT # IRROTHER
CIrrDeviceSDL.cpp CIrrDeviceSDL.cpp
CIrrDeviceLinux.cpp CIrrDeviceLinux.cpp
CIrrDeviceStub.cpp CIrrDeviceStub.cpp
@ -242,25 +199,8 @@ add_library(IRROTHEROBJ OBJECT
COSOperator.cpp COSOperator.cpp
Irrlicht.cpp Irrlicht.cpp
os.cpp os.cpp
)
if(ANDROID) # IRRGUI
target_sources(IRROTHEROBJ PRIVATE
Android/CIrrDeviceAndroid.cpp
Android/CAndroidAssetReader.cpp
Android/CAndroidAssetFileArchive.cpp
Android/CKeyEventWrapper.cpp
)
elseif(APPLE)
# Build all IRROTHEROBJ sources as objc++, including the .cpp's
set_target_properties(IRROTHEROBJ PROPERTIES COMPILE_OPTIONS "-xobjective-c++")
target_sources(IRROTHEROBJ PRIVATE
CIrrDeviceOSX.mm
CNSOGLManager.mm
)
endif()
add_library(IRRGUIOBJ OBJECT
CGUIButton.cpp CGUIButton.cpp
CGUICheckBox.cpp CGUICheckBox.cpp
CGUIComboBox.cpp CGUIComboBox.cpp
@ -278,20 +218,44 @@ add_library(IRRGUIOBJ OBJECT
CGUIImageList.cpp CGUIImageList.cpp
) )
if(ANDROID)
target_sources(IrrlichtMt PRIVATE
Android/CIrrDeviceAndroid.cpp
Android/CAndroidAssetReader.cpp
Android/CAndroidAssetFileArchive.cpp
Android/CKeyEventWrapper.cpp
)
elseif(APPLE)
target_sources(IrrlichtMt PRIVATE
CIrrDeviceOSX.mm
CNSOGLManager.mm
)
# build all IRROTHEROBJ sources as objc++, including the .cpp's
set_source_files_properties(
CIrrDeviceSDL.cpp
CIrrDeviceLinux.cpp
CIrrDeviceStub.cpp
CIrrDeviceWin32.cpp
CLogger.cpp
COSOperator.cpp
Irrlicht.cpp
os.cpp
leakHunter.cpp
CProfiler.cpp
CIrrDeviceOSX.mm
CNSOGLManager.mm
PROPERTIES
COMPILE_FLAGS "-xobjective-c++"
)
endif()
# Library # Library
add_library(IrrlichtMt) # Propagate static library flag to lib users, only needed for Windows
foreach(object_lib if(NOT BUILD_SHARED_LIBS)
IRRMESHOBJ IRROBJ IRRVIDEOOBJ target_compile_definitions(IrrlichtMt INTERFACE _IRR_STATIC_LIB_)
IRRIOOBJ IRROTHEROBJ IRRGUIOBJ) endif()
# Set include directories for object library compilation
target_include_directories(${object_lib} PRIVATE ${link_includes})
# Add objects from object library to main library
target_sources(IrrlichtMt PRIVATE $<TARGET_OBJECTS:${object_lib}>)
endforeach()
# Alias target provides add_submodule compatibility
add_library(IrrlichtMt::IrrlichtMt ALIAS IrrlichtMt)
target_include_directories(IrrlichtMt target_include_directories(IrrlichtMt
PUBLIC PUBLIC
@ -299,19 +263,43 @@ 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
${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}
"$<$<PLATFORM_ID:Android>:${ANDROID_NDK}/sources/android/native_app_glue>"
${X11_INCLUDE_DIR}
) )
target_link_libraries(IrrlichtMt target_link_libraries(IrrlichtMt
PRIVATE PRIVATE
"${ZLIB_LIBRARY}"
"${JPEG_LIBRARY}"
"${PNG_LIBRARY}"
"${SDL2_LIBRARIES}"
tinygltf::tinygltf tinygltf::tinygltf
${link_libs}
)
# Propagate static library flag to lib users, only needed for Windows ${OPENGL_LIBRARIES}
if(NOT BUILD_SHARED_LIBS) ${OPENGLES_LIBRARY}
target_compile_definitions(IrrlichtMt INTERFACE _IRR_STATIC_LIB_) ${OPENGLES2_LIBRARIES}
endif() ${EGL_LIBRARY}
"$<$<PLATFORM_ID:Android>:native_app_glue -landroid -llog>"
${COCOA_LIB}
${IOKIT_LIB}
"$<$<PLATFORM_ID:Windows>:gdi32>"
"$<$<PLATFORM_ID:Windows>:winmm>"
${X11_X11_LIB}
${X11_Xi_LIB}
)
set_target_properties(IrrlichtMt PROPERTIES set_target_properties(IrrlichtMt PROPERTIES
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}