Commit a3a35473 by Patrick Steinhardt

cmake: fix output location of import libraries and DLLs

As observed by Edward Thomson, the libgit2 DLL built by Windows will not
end up in the top-level build directory but instead inside of the 'src/'
subdirectory. While confusing at first because we are actually setting
the LIBRARY_OUTPUT_DIRECTORY to the project's binary directory, the
manual page of LIBRARY_OUTPUT_DIRECTORY clears this up:

    There are three kinds of target files that may be built: archive,
    library, and runtime. Executables are always treated as runtime
    targets. Static libraries are always treated as archive targets.
    Module libraries are always treated as library targets. For non-DLL
    platforms shared libraries are treated as library targets. For DLL
    platforms the DLL part of a shared library is treated as a runtime
    target and the corresponding import library is treated as an archive
    target. All Windows-based systems including Cygwin are DLL
    platforms.

So in fact, DLLs and import libraries are not treated as libraries at
all by CMake but instead as runtime and archive targets. To fix the
issue, we can thus simply set the variables RUNTIME_OUTPUT_DIRECTORY and
ARCHIVE_OUTPUT_DIRECTORY to the project's root binary directory.
parent 8a43161b
......@@ -359,6 +359,8 @@ ADD_LIBRARY(git2 ${WIN_RC} ${GIT2INTERNAL_OBJECTS})
TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS})
SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
SET_TARGET_PROPERTIES(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
SET_TARGET_PROPERTIES(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
# Win64+MSVC+static libs = linker error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment