8000 cmake: fix output location of import libraries and DLLs · libgit2/libgit2@a3a3547 · GitHub
[go: up one dir, main page]

Skip to content

Commit a3a3547

Browse files
committed
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.
1 parent 8a43161 commit a3a3547

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ ADD_LIBRARY(git2 ${WIN_RC} ${GIT2INTERNAL_OBJECTS})
359359
TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS})
360360

361361
SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
362+
SET_TARGET_PROPERTIES(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
363+
SET_TARGET_PROPERTIES(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
362364

363365
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
364366
# Win64+MSVC+static libs = linker error

0 commit comments

Comments
 (0)
0