summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-11-19 17:05:48 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-11-19 17:05:48 +0000
commit7ad57ef87f4d69a8a0c84ef61016c3b4990b0d18 (patch)
treedeee7725987a99230660428d6027c2662c94fb5c
parentUpdated appveyor script (diff)
downloadDiligentCore-7ad57ef87f4d69a8a0c84ef61016c3b4990b0d18.tar.gz
DiligentCore-7ad57ef87f4d69a8a0c84ef61016c3b4990b0d18.zip
Updated install instructions for combining static library into one
-rw-r--r--BuildUtils.cmake69
-rw-r--r--CMakeLists.txt72
2 files changed, 76 insertions, 65 deletions
diff --git a/BuildUtils.cmake b/BuildUtils.cmake
index f2c97ad2..dc597e69 100644
--- a/BuildUtils.cmake
+++ b/BuildUtils.cmake
@@ -231,3 +231,72 @@ function(install_core_lib _TARGET)
)
endif()
endfunction()
+
+
+function(install_combined_static_lib COMBINED_LIB_NAME LIBS_LIST CUSTOM_TARGET_NAME CUSTOM_TARGET_FOLDER INSTALL_DESTINATION)
+
+ foreach(LIB ${LIBS_LIST})
+ list(APPEND COMBINED_LIB_TARGET_FILES $<TARGET_FILE:${LIB}>)
+ endforeach(LIB)
+
+ if(MSVC)
+ add_custom_command(
+ OUTPUT ${COMBINED_LIB_NAME}
+ COMMAND lib.exe /OUT:${COMBINED_LIB_NAME} ${COMBINED_LIB_TARGET_FILES}
+ DEPENDS ${LIBS_LIST}
+ COMMENT "Combining libraries..."
+ )
+ add_custom_target(${CUSTOM_TARGET_NAME} ALL DEPENDS ${COMBINED_LIB_NAME})
+ else()
+
+ if(PLATFORM_WIN32)
+ # do NOT use stock ar on MinGW
+ find_program(AR NAMES x86_64-w64-mingw32-gcc-ar)
+ else()
+ set(AR ${CMAKE_AR})
+ endif()
+
+ if(AR)
+ add_custom_command(
+ OUTPUT ${COMBINED_LIB_NAME}
+ # Delete all object files from current directory
+ COMMAND ${CMAKE_COMMAND} -E remove "*${CMAKE_C_OUTPUT_EXTENSION}"
+ DEPENDS ${LIBS_LIST}
+ COMMENT "Combining libraries..."
+ )
+
+ # Unpack all object files from all targets to current directory
+ foreach(LIB_TARGET ${COMBINED_LIB_TARGET_FILES})
+ add_custom_command(
+ OUTPUT ${COMBINED_LIB_NAME}
+ COMMAND ${AR} -x ${LIB_TARGET}
+ APPEND
+ )
+ endforeach()
+
+ # Pack object files to a combined library and delete them
+ add_custom_command(
+ OUTPUT ${COMBINED_LIB_NAME}
+ COMMAND ${AR} -crs ${COMBINED_LIB_NAME} "*${CMAKE_C_OUTPUT_EXTENSION}"
+ COMMAND ${CMAKE_COMMAND} -E remove "*${CMAKE_C_OUTPUT_EXTENSION}"
+ APPEND
+ )
+
+ add_custom_target(${CUSTOM_TARGET_NAME} ALL DEPENDS ${COMBINED_LIB_NAME})
+ else()
+ message("ar command is not found")
+ endif()
+ endif()
+
+ if(TARGET ${CUSTOM_TARGET_NAME})
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${COMBINED_LIB_NAME}"
+ DESTINATION ${INSTALL_DESTINATION}
+ )
+ set_target_properties(${CUSTOM_TARGET_NAME} PROPERTIES
+ FOLDER ${CUSTOM_TARGET_FOLDER}
+ )
+ else()
+ message("Unable to find librarian tool. Combined ${COMBINED_LIB_NAME} static library will not be produced.")
+ endif()
+
+endfunction()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3d1f98f..3fbe9f57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -297,74 +297,16 @@ add_subdirectory(Platforms)
add_subdirectory(Common)
add_subdirectory(Graphics)
-
# Installation instructions
if(INSTALL_DILIGENT_CORE)
- set(COMBINED_CORE_LIB_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}DiligentCore${CMAKE_STATIC_LIBRARY_SUFFIX}")
-
- foreach(CORE_LIB ${DILIGENT_CORE_INSTALL_LIBS_LIST})
- list(APPEND CORE_LIB_TARGET_FILES $<TARGET_FILE:${CORE_LIB}>)
- endforeach(CORE_LIB)
-
- if(MSVC)
- add_custom_command(
- OUTPUT ${COMBINED_CORE_LIB_NAME}
- COMMAND lib.exe /OUT:${COMBINED_CORE_LIB_NAME} ${CORE_LIB_TARGET_FILES}
- DEPENDS ${DILIGENT_CORE_INSTALL_LIBS_LIST}
- COMMENT "Combining core libraries..."
- )
- add_custom_target(DiligentCore-static ALL DEPENDS ${COMBINED_CORE_LIB_NAME})
- else()
-
- if(PLATFORM_WIN32)
- # do NOT use stock ar on MinGW
- find_program(AR NAMES x86_64-w64-mingw32-gcc-ar)
- else()
- set(AR ${CMAKE_AR})
- endif()
- if(AR)
- add_custom_command(
- OUTPUT ${COMBINED_CORE_LIB_NAME}
- # Delete all object files from current directory
- COMMAND ${CMAKE_COMMAND} -E remove "*${CMAKE_C_OUTPUT_EXTENSION}"
- DEPENDS ${DILIGENT_CORE_INSTALL_LIBS_LIST}
- COMMENT "Combining core libraries..."
- )
-
- # Unpack all object files from all targets to current directory
- foreach(CORE_LIB_TARGET ${CORE_LIB_TARGET_FILES})
- add_custom_command(
- OUTPUT ${COMBINED_CORE_LIB_NAME}
- COMMAND ${AR} -x ${CORE_LIB_TARGET}
- APPEND
- )
- endforeach()
-
- # Pack object files to a combined library and delete them
- add_custom_command(
- OUTPUT ${COMBINED_CORE_LIB_NAME}
- COMMAND ${AR} -crs ${COMBINED_CORE_LIB_NAME} "*${CMAKE_C_OUTPUT_EXTENSION}"
- COMMAND ${CMAKE_COMMAND} -E remove "*${CMAKE_C_OUTPUT_EXTENSION}"
- APPEND
- )
-
- add_custom_target(DiligentCore-static ALL DEPENDS ${COMBINED_CORE_LIB_NAME})
- else()
- message("ar command is not found")
- endif()
- endif()
-
- if(TARGET DiligentCore-static)
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${COMBINED_CORE_LIB_NAME}"
- DESTINATION "lib/${DILIGENT_CORE_DIR}/$<CONFIG>"
- )
- set_target_properties(DiligentCore-static PROPERTIES
- FOLDER DiligentCore
- )
- else()
- message("Unable to find librarian tool. Combined DiligentCore static library will not be produced.")
- endif()
+ install_combined_static_lib(
+ "${CMAKE_STATIC_LIBRARY_PREFIX}DiligentCore${CMAKE_STATIC_LIBRARY_SUFFIX}"
+ "${DILIGENT_CORE_INSTALL_LIBS_LIST}"
+ DiligentCore-static # Custom target name
+ DiligentCore # Folder
+ "lib/${DILIGENT_CORE_DIR}/$<CONFIG>" # Install destination
+ )
install(FILES License.txt DESTINATION "Licenses/${DILIGENT_CORE_DIR}" RENAME DiligentEngine-License.txt)
endif(INSTALL_DILIGENT_CORE)