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

Add IMPORTED_IMPLIB property to each CMake Module #2425

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

y-guyon
Copy link
Collaborator

@y-guyon y-guyon commented Sep 1, 2024

Apply cmake-format.

Fixes #2423.

@y-guyon y-guyon requested a review from vrabaud September 1, 2024 09:25
@@ -51,6 +51,6 @@ if(AOM_LIBRARY)
else()
add_library(aom SHARED IMPORTED GLOBAL)
endif()
set_target_properties(aom PROPERTIES IMPORTED_LOCATION "${AOM_LIBRARY}")
set_target_properties(aom PROPERTIES IMPORTED_LOCATION "${AOM_LIBRARY}" IMPORTED_IMPLIB "${AOM_LIBRARY}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yannis: Thank you for writing a fix. Note that this comment is just a comment, not a request for change.

According to CMake documentation, IMPORTED_LOCATION is the pathname of the DLL and IMPORTED_IMPLIB is the pathname of the import library. So the file names are different (.dll vs. .lib) and the files may be installed in different subdirectories (bin vs. lib, as @vtorri noted in #2423 (comment)).

Perhaps the CMake documentation about this is incomplete and setting IMPORTED_LOCATION and IMPORTED_IMPLIB to the same value also works. Perhaps setting IMPORTED_IMPLIB to the pathname of some file is better than not setting it. I don't know. I am just reporting what I found in the CMake documentation.

Here are the relevant excerpts:

https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED_LOCATION.html

IMPORTED_LOCATION

Full path to the main file on disk for an IMPORTED target.

Set this to the location of an IMPORTED target file on disk. [...] For DLLs this is the location of the .dll part of the library. [...]

https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED_IMPLIB.html

IMPORTED_IMPLIB

Full path to the import library for an IMPORTED target.

This property may be set:

  • On DLL platforms, to the location of the .lib part of the DLL.

https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#importing-libraries

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 PRIVATE bar)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a comment in a CMake issue that apparently matches what @vtorri reported in #2423 (comment) and explains why this pull request works:

https://gitlab.kitware.com/cmake/cmake/-/issues/22446#note_1444129

On a related note, MinGW can directly link with DLLs, without the need for an import library. It would be great if, when building with a MinGW toolchain, IMPORTED_IMPLIB were optional and IMPORTED_LOCATION were used if it is absent. (As a workaround, specifying the path to the DLL as IMPORTED_IMPLIB seems to work, but only by accident.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for investigating.

@y-guyon y-guyon merged commit 85979a7 into AOMediaCodec:main Sep 2, 2024
35 checks passed
@y-guyon y-guyon deleted the implib branch September 2, 2024 13:31
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

Successfully merging this pull request may close these issues.

Can not cross-compile for Windows
3 participants