Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect win32 IMPORTED configuration #330

Open
crazyhappygame opened this issue Nov 7, 2018 · 3 comments
Open

Incorrect win32 IMPORTED configuration #330

crazyhappygame opened this issue Nov 7, 2018 · 3 comments
Assignees

Comments

@crazyhappygame
Copy link
Contributor

crazyhappygame commented Nov 7, 2018

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"
)
@crazyhappygame
Copy link
Contributor Author

@drelaptop could you check it?

@crazyhappygame
Copy link
Contributor Author

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 ...)

@drelaptop
Copy link
Contributor

thanks, I will check it after the modern cmake modified finish. the logic of source copy is complex too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants