mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
Also applies to *_BINARY_DIR.
This effectively reverts 84083dcc8b,
which broke all users of libgit2 that use it as a CMake subdirectory
(via `add_subdirectory()`). This is because CMAKE_SOURCE_DIR refers
to the root-most CMake directory, which in the case of
`add_subdirectory()` is a parent project to libgit2 and thus the paths
don't make any sense to the configuration files. Corollary,
CMAKE_SOURCE_DIR only makes sense if the CMake project is always the
root project - which can rarely be guaranteed.
In all honesty, CMake should deprecate and eventually remove
CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. It's been the source of headaches
and confusion for years, they're rarely useful over
CMAKE_CURRENT_(SOURCE|BINARY)_DIR or PROJECT_(SOURCE|BINARY)_DIR,
and they cause a lot of confusing configuration and source
code layouts to boot.
Any time they are used, they break `add_subdirectory()` almost 100% of
the time, cause confusing error messages, and hide subtle bugs.
25 lines
741 B
CMake
25 lines
741 B
CMake
find_program(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
|
|
if(NOT DLLTOOL)
|
|
message(FATAL_ERROR "Could not find dlltool command")
|
|
endif()
|
|
|
|
set(LIBWINHTTP_PATH "${PROJECT_BINARY_DIR}/deps/winhttp")
|
|
set(LIBWINHTTP_PATH ${LIBWINHTTP_PATH} PARENT_SCOPE)
|
|
file(MAKE_DIRECTORY ${LIBWINHTTP_PATH})
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
set(WINHTTP_DEF "winhttp64.def")
|
|
else()
|
|
set(WINHTTP_DEF "winhttp.def")
|
|
endif()
|
|
|
|
add_custom_command(
|
|
OUTPUT ${LIBWINHTTP_PATH}/libwinhttp.a
|
|
COMMAND ${DLLTOOL} -d ${WINHTTP_DEF} -k -D winhttp.dll -l libwinhttp.a
|
|
DEPENDS ${WINHTTP_DEF}
|
|
WORKING_DIRECTORY ${LIBWINHTTP_PATH})
|
|
|
|
set_source_files_properties(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/transports/winhttp.c
|
|
PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a)
|