file-windows
file-windows copied to clipboard
make artifacts contain magic.h and libmagic.lib
I want to write a windows program that depends on libmagic(magic.h and libmagic.lib), so I added install to CMakeLists.txt.
libmagic can be used as a static library, but DllMain is defined in https://github.com/file/file/blob/87731415de/src/magic.c#L163.
DllMain only initialized _w32_dll_instance.
_w32_dll_instance is only used in get_default_magic.
In fact, when libmagic is used as a static library, only https://github.com/file/file/blob/87731415de/src/magic.c#L236 is enough.
update: I submitted this bug: https://bugs.astron.com/view.php?id=288
update2: Temporarily resolved the naming conflict by modifying the function name
update of update: accepted! https://github.com/file/file/commit/a24d50aec73ff53f8a081b814cb96d3ab8f2f0dc
Sorry, I noticed your comment on my code only after you closed this PR. I will rewrite the code and open a new PR.
For developers who use this project as a dynamic or static library, the install command at the end of the CMakeLists.txt file is necessary. Otherwise, cmake will not generate .cmake files for this project as a library. The cmake/Findpcre2.cmake file is also necessary, otherwise the result of cmake install will not include the content of pcre2.
Also, the suggestion of compiling file as a static library under Windows has been merged into the file source code. Therefore, the implementation solution in this project can be simplified significantly.