|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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}" |
|
MSVC17 "${LIB_PACKAGE_FOLDER}" "${args_MSVC17}" |
|
SET ${args_SET} |
|
MULTI_SET ${args_MULTI_SET} |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file(GLOB subdirs RELATIVE ${LIB_PACKAGE_FOLDER} ${LIB_PACKAGE_FOLDER}/*) |
|
set(dirlist "") |
|
foreach(dir ${subdirs}) |
|
if(IS_DIRECTORY ${LIB_PACKAGE_FOLDER}/${dir}) |
|
|
|
include_directories("${LIB_PACKAGE_FOLDER}/${dir}/include/") |
|
|
|
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) |
|
include(install_runtime) |
|
|
|
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") |
|
|
|
ibr_install_target(${args_TARGET} |
|
COMPONENT ${args_TARGET}_install |
|
) |
|
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() |