Fix further configuration issues with libsyncthing
* Can not use BUNDLED_TARGETS because syncthinginternal is only an imported target * Use INSTALL_INTERFACE generator expression to specify path of libsyncthinginternal.a for installation (imported target can not be exported apparently)
This commit is contained in:
parent
495140cdf9
commit
e2037aebc1
|
@ -128,8 +128,9 @@ add_custom_command(OUTPUT "${SYNCTHING_PATH}/lib/auto/gui.files.go"
|
|||
COMMENT "Building Syncthing's assets")
|
||||
|
||||
# compile Syncthing as static library
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h"
|
||||
set(SYNCTHINGINTERNAL_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a")
|
||||
set(SYNCTHINGINTERNAL_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h")
|
||||
add_custom_command(OUTPUT "${SYNCTHINGINTERNAL_LIBRARY_PATH}" "${SYNCTHINGINTERNAL_HEADER_PATH}"
|
||||
COMMAND "CC=${CMAKE_C_COMPILER}"
|
||||
"CXX=${CMAKE_CXX_COMPILER}"
|
||||
"AR=${CMAKE_C_COMPILER_AR}"
|
||||
|
@ -143,37 +144,41 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
|
|||
-v -buildmode
|
||||
c-archive
|
||||
-o
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
|
||||
-ldflags "${GO_LINKER_FLAGS}"
|
||||
"${SYNCTHINGINTERNAL_LIBRARY_PATH}"
|
||||
-ldflags
|
||||
"${GO_LINKER_FLAGS}"
|
||||
./c-bindings
|
||||
&&
|
||||
"${CMAKE_RANLIB}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
|
||||
"${SYNCTHINGINTERNAL_LIBRARY_PATH}"
|
||||
DEPENDS ${SRC_FILES_SYNCTHING}
|
||||
WORKING_DIRECTORY "${SYNCTHING_PATH}"
|
||||
COMMENT "Building Syncthing itself")
|
||||
|
||||
# apply basic config
|
||||
include(BasicConfig)
|
||||
|
||||
# add imported target for library generated by the Go build system
|
||||
add_library(syncthinginternal STATIC IMPORTED)
|
||||
set_property(TARGET syncthinginternal
|
||||
PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a")
|
||||
set_property(TARGET syncthinginternal
|
||||
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SYNCTHING_PATH}/c-bindings")
|
||||
set_property(TARGET syncthinginternal PROPERTY IMPORTED_LOCATION "${SYNCTHINGINTERNAL_LIBRARY_PATH}")
|
||||
set_property(TARGET syncthinginternal PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SYNCTHING_PATH}/c-bindings")
|
||||
|
||||
# add additional libraries (not sure if go build could provide this list somehow to make this more generic)
|
||||
if (WIN32)
|
||||
set(SYNCTHING_INTERNAL_LIBS ws2_32 winmm)
|
||||
elseif (UNIX)
|
||||
set(SYNCTHING_INTERNAL_LIBS pthread)
|
||||
endif ()
|
||||
foreach (LIBRARY ${SYNCTHING_INTERNAL_LIBS})
|
||||
find_library(SYNCTHING_INTERNAL_LIBRARY_PATH_${LIBRARY} ${LIBRARY})
|
||||
set_property(TARGET syncthinginternal APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES ${SYNCTHING_INTERNAL_LIBRARY_PATH_${LIBRARY}})
|
||||
endforeach ()
|
||||
# add additional libraries (not sure if go build could provide this list somehow to make this more generic)
|
||||
if (WIN32)
|
||||
set(SYNCTHING_INTERNAL_LIBS ws2_32 winmm)
|
||||
elseif (UNIX)
|
||||
set(SYNCTHING_INTERNAL_LIBS pthread)
|
||||
endif ()
|
||||
foreach (LIBRARY ${SYNCTHING_INTERNAL_LIBS})
|
||||
find_library(SYNCTHING_INTERNAL_LIBRARY_PATH_${LIBRARY} ${LIBRARY})
|
||||
set_property(TARGET syncthinginternal
|
||||
APPEND
|
||||
PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES ${SYNCTHING_INTERNAL_LIBRARY_PATH_${LIBRARY}})
|
||||
endforeach ()
|
||||
|
||||
# depend on that imported target
|
||||
list(APPEND PRIVATE_LIBRARIES syncthinginternal)
|
||||
set(BUNDLED_TARGET syncthinginternal)
|
||||
list(APPEND PRIVATE_LIBRARIES $<BUILD_INTERFACE:syncthinginternal>
|
||||
$<INSTALL_INTERFACE:${LIB_INSTALL_DESTINATION}/libsyncthinginternal.a>)
|
||||
|
||||
# find c++utilities
|
||||
find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED)
|
||||
|
@ -186,9 +191,14 @@ else ()
|
|||
endif ()
|
||||
|
||||
# include modules to apply configuration
|
||||
include(BasicConfig)
|
||||
include(WindowsResources)
|
||||
include(LibraryTarget)
|
||||
include(TestTarget)
|
||||
include(Doxygen)
|
||||
include(ConfigHeader)
|
||||
|
||||
# create install target for static libsyncthinginternal.a if we're also creating a static libsyncthing.a note: Not possible
|
||||
# to add syncthinginternal to BUNDLED_TARGETS because it is an import library which apparently can not be exported.
|
||||
if (NOT BUILD_SHARED_LIBS AND NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
|
||||
install(FILES "${SYNCTHINGINTERNAL_LIBRARY_PATH}" DESTINATION "lib${SELECTED_LIB_SUFFIX}" COMPONENT binary)
|
||||
endif ()
|
||||
|
|
Loading…
Reference in New Issue