Spaces:
Running
on
Zero
Running
on
Zero
File size: 7,102 Bytes
5f9d349 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# Copyright (C) 2020, Inria
# GRAPHDECO research group, https://team.inria.fr/graphdeco
# All rights reserved.
#
# This software is free for non-commercial, research and evaluation use
# under the terms of the LICENSE.md file.
#
# For inquiries contact [email protected] and/or [email protected]
# NOTE
# This feature is used to easily download, store and link external dependencies. This
# requires to prepare pre-compiled libraries (to download). For now, packages have
# only be prepare for Windows 64-bit with Visual Studio 2012. (You should re-build
# everything if you want to use another version of Visual Studio/ another compiler).
# NOTE ABOUT UNIX SYSTEMS
# There is no need for "searching mechanism". This function is discard and your
# libraries should be installed is the standard folders that are:
#
# /usr/include/
# /usr/lib/
# /usr/lib64/
# for packages downloaded using apt-get/yum
#
# /usr/local/include/
# /usr/local/lib/
# /usr/local/lib64/
# for packages manually installed ("make install")
#
# if you encounter problems when linking (e.g. lib not found even if it is installed),
# please check these folders are in your search PATH environment variables.
set(EXTLIBS_PACKAGE_FOLDER "${CMAKE_SOURCE_DIR}/extlibs")
function(sibr_addlibrary)
if(NOT WIN32)
return()
endif()
file(MAKE_DIRECTORY ${EXTLIBS_PACKAGE_FOLDER})
cmake_parse_arguments(args "VCID" "VERBOSE;TIMEOUT;DEFAULT_USE;NAME;VERSION;MSVC11;MSVC12;MSVC14;MSVC17" "MULTI_SET;SET" ${ARGN})
if (NOT "${args_VERSION}" MATCHES "")
message(WARNING "VERSION is not implemented yet")
endif()
set(lcname "")
set(ucname "")
string(TOLOWER "${args_NAME}" lcname)
string(TOUPPER "${args_NAME}" ucname)
set(LIB_PACKAGE_FOLDER "${EXTLIBS_PACKAGE_FOLDER}/${lcname}")
win3rdParty(${ucname}
$<args_VCID:VCID>
VERBOSE ${args_VERBOSE}
TIMEOUT ${args_TIMEOUT}
DEFAULT_USE ${args_DEFAULT_USE}
MSVC11 "${LIB_PACKAGE_FOLDER}" "${args_MSVC11}"
MSVC12 "${LIB_PACKAGE_FOLDER}" "${args_MSVC12}"
MSVC14 "${LIB_PACKAGE_FOLDER}" "${args_MSVC14}" # TODO SV: make sure to build this library if required
MSVC17 "${LIB_PACKAGE_FOLDER}" "${args_MSVC17}"
SET ${args_SET}
MULTI_SET ${args_MULTI_SET}
)
# Add include/ directory
# and lib/ directories
# TODO SV: paths not matching with current hierarchy. example: libraw/libraw-0.17.1/include
# SR: The link directories will also be used to lookup for dependency DLLs to copy in the install directory.
# Some libraries put the DLLs in the bin/ directory, so we include those.
file(GLOB subdirs RELATIVE ${LIB_PACKAGE_FOLDER} ${LIB_PACKAGE_FOLDER}/*)
set(dirlist "")
foreach(dir ${subdirs})
if(IS_DIRECTORY ${LIB_PACKAGE_FOLDER}/${dir})
# message("adding ${LIB_PACKAGE_FOLDER}/${dir}/include/ to the include directories")
include_directories("${LIB_PACKAGE_FOLDER}/${dir}/include/")
# message("adding ${LIB_PACKAGE_FOLDER}/${dir}/lib[64] to the link directories")
link_directories("${LIB_PACKAGE_FOLDER}/${dir}/")
link_directories("${LIB_PACKAGE_FOLDER}/${dir}/lib/")
link_directories("${LIB_PACKAGE_FOLDER}/${dir}/lib64/")
link_directories("${LIB_PACKAGE_FOLDER}/${dir}/bin/")
endif()
endforeach()
endfunction()
include(FetchContent)
include(git_describe)
function(sibr_gitlibrary)
cmake_parse_arguments(args "" "TARGET;GIT_REPOSITORY;GIT_TAG;ROOT_DIR;SOURCE_DIR" "INCLUDE_DIRS" ${ARGN})
if(NOT args_TARGET)
message(FATAL "Error on sibr_gitlibrary : please define your target name.")
return()
endif()
if(NOT args_ROOT_DIR)
set(args_ROOT_DIR ${args_TARGET})
endif()
if(NOT args_SOURCE_DIR)
set(args_SOURCE_DIR ${args_TARGET})
endif()
if(args_GIT_REPOSITORY AND args_GIT_TAG)
if(EXISTS ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/${args_SOURCE_DIR}/.git)
git_describe(
PATH ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/${args_SOURCE_DIR}
GIT_URL SIBR_GITLIBRARY_URL
GIT_BRANCH SIBR_GITLIBRARY_BRANCH
GIT_COMMIT_HASH SIBR_GITLIBRARY_COMMIT_HASH
GIT_TAG SIBR_GITLIBRARY_TAG
)
if((SIBR_GITLIBRARY_URL STREQUAL args_GIT_REPOSITORY) AND
((SIBR_GITLIBRARY_BRANCH STREQUAL args_GIT_TAG) OR
(SIBR_GITLIBRARY_TAG STREQUAL args_GIT_TAG) OR
(SIBR_GITLIBRARY_COMMIT_HASH STREQUAL args_GIT_TAG)))
message(STATUS "Library ${args_TARGET} already available, skipping.")
set(SIBR_GITLIBRARY_DECLARED ON)
else()
message(STATUS "Adding library ${args_TARGET} from git...")
endif()
endif()
FetchContent_Declare(${args_TARGET}
GIT_REPOSITORY ${args_GIT_REPOSITORY}
GIT_TAG ${args_GIT_TAG}
GIT_SHALLOW ON
SOURCE_DIR ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/${args_SOURCE_DIR}
SUBBUILD_DIR ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/subbuild
BINARY_DIR ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/build
)
FetchContent_GetProperties(${args_TARGET})
string(TOLOWER "<name>" lcTargetName)
if((NOT SIBR_GITLIBRARY_DECLARED) AND (NOT ${lcTargetName}_POPULATED))
message(STATUS "Populating library ${args_TARGET}...")
FetchContent_Populate(${args_TARGET} QUIET
GIT_REPOSITORY ${args_GIT_REPOSITORY}
GIT_TAG ${args_GIT_TAG}
SOURCE_DIR ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/${args_SOURCE_DIR}
SUBBUILD_DIR ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/subbuild
BINARY_DIR ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/build
)
endif()
add_subdirectory(${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/${args_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/extlibs/${args_ROOT_DIR}/build)
get_target_property(type ${args_TARGET} TYPE)
if(NOT (type STREQUAL "INTERFACE_LIBRARY"))
set_target_properties(${args_TARGET} PROPERTIES FOLDER "extlibs")
endif()
list(APPEND ${args_TARGET}_INCLUDE_DIRS ${EXTLIBS_PACKAGE_FOLDER}/${args_ROOT_DIR})
list(APPEND ${args_TARGET}_INCLUDE_DIRS ${EXTLIBS_PACKAGE_FOLDER}/${args_ROOT_DIR}/${args_SOURCE_DIR})
foreach(args_INCLUDE_DIR ${args_INCLUDE_DIRS})
list(APPEND ${args_TARGET}_INCLUDE_DIRS ${EXTLIBS_PACKAGE_FOLDER}/${args_ROOT_DIR}/${args_SOURCE_DIR}/${args_INCLUDE_DIR})
endforeach()
include_directories(${${args_TARGET}_INCLUDE_DIRS})
else()
message(FATAL "Error on sibr_gitlibrary for target ${args_TARGET}: missing git tag or git url.")
endif()
endfunction() |