From 80a662035e0bc4df2e1eaf1eb5d3d4ee7d3c1082 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 18 Jan 2019 08:32:46 -0800 Subject: Updated combined core library build and install cmake instructions --- CMakeLists.txt | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e05059ee..02cee561 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,26 +271,45 @@ add_subdirectory(Graphics) # Installation instructions +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 $) endforeach(CORE_LIB) -set(COMBINED_CORE_LIB_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}DiligentCore${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(MSVC) find_program(LIB_EXE NAMES lib.exe) if(LIB_EXE) - add_custom_target(DiligentCore-static ALL - COMMAND ${LIB_EXE} /OUT:"${COMBINED_CORE_LIB_NAME}" ${CORE_LIB_TARGET_FILES} + 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 libs..." + COMMENT "Combining core libraries..." ) + add_custom_target(DiligentCore-static ALL DEPENDS ${COMBINED_CORE_LIB_NAME}) else() message("Unable to find lib.exe") endif() 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} + COMMAND ${AR} -crs ${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() + message("ar command is not found") + endif() endif() if(TARGET DiligentCore-static) @@ -300,4 +319,6 @@ if(TARGET DiligentCore-static) set_target_properties(DiligentCore-static PROPERTIES FOLDER Core ) +else() + message("Unable to find librarian tool. Combined DiligentCore static library will not be produced.") endif() -- cgit v1.2.3