cocos2d-x-3rd-party-libs-bin
cocos2d-x-3rd-party-libs-bin copied to clipboard
Incorrect win32 IMPORTED configuration
From https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/Exporting-and-Importing-Targets On Windows a .dll and its .lib import library may be imported together:
add_library(bar SHARED IMPORTED)
set_property(TARGET bar PROPERTY IMPORTED_LOCATION c:/path/to/bar.dll)
set_property(TARGET bar PROPERTY IMPORTED_IMPLIB c:/path/to/bar.lib)
add_executable(myexe src1.c src2.c)
target_link_libraries(myexe bar)
I am not sure how it works right now but in our code SHARED libraries are added as STATIC and there is no IMPORTED_IMPLIB. In current code there is:
add_library(${target_name} STATIC IMPORTED GLOBAL)
set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/${platform_name}"
)
if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
CC_DEPEND_DLLS "${platform_spec_path}/lib${lib_name}.dll"
IMPORTED_LOCATION "${platform_spec_path}/lib${lib_name}.lib"
)
@drelaptop could you check it?
With IMPORTED_LOCATION set to dll file. Coping of dlls could be simplified to:
function(copy_imported_targets _target)
foreach(_dep ${ARGN})
if(WIN32)
add_custom_command(TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${_dep}> $<TARGET_FILE_DIR:${_target}>
COMMENT "Copying required DLL for dependency ${_dep}"
VERBATIM)
endif()
endforeach()
endfunction()
copy_imported_targets(app curl zlib ...)
thanks, I will check it after the modern cmake modified finish. the logic of source copy is complex too.