195 lines
7.5 KiB
CMake
Executable file
195 lines
7.5 KiB
CMake
Executable file
vcpkg_from_github(
|
|
OUT_SOURCE_PATH SOURCE_PATH
|
|
REPO randombit/botan
|
|
REF fe62c1f5ce6c4379a52bd018c2ff68bed3024c4d # 2.19.1
|
|
SHA512 09c5fdb3a05978373fb1512a7a9b5c3d89e6e103d7fe86a0e126c417117950c2a63559dc06e8a9c895c892e9fc3888d7ed97686e15d8c2fd941ddb629af0e5a0
|
|
HEAD_REF master
|
|
PATCHES
|
|
fix-generate-build-path.patch
|
|
embed-debug-info.patch
|
|
)
|
|
|
|
if(CMAKE_HOST_WIN32)
|
|
vcpkg_find_acquire_program(JOM)
|
|
set(build_tool "${JOM}")
|
|
set(parallel_build "/J${VCPKG_CONCURRENCY}")
|
|
else()
|
|
find_program(MAKE make)
|
|
set(build_tool "${MAKE}")
|
|
set(parallel_build "-j${VCPKG_CONCURRENCY}")
|
|
endif()
|
|
|
|
vcpkg_find_acquire_program(PYTHON3)
|
|
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
|
|
set(ENV{PATH} "$ENV{PATH};${PYTHON3_DIR}")
|
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
|
set(BOTAN_FLAG_SHARED --enable-shared-library)
|
|
set(BOTAN_FLAG_STATIC --disable-static-library)
|
|
else()
|
|
set(BOTAN_FLAG_SHARED --disable-shared-library)
|
|
set(BOTAN_FLAG_STATIC --enable-static-library)
|
|
endif()
|
|
|
|
if(VCPKG_CRT_LINKAGE STREQUAL dynamic)
|
|
set(BOTAN_MSVC_RUNTIME "--msvc-runtime=MD")
|
|
else()
|
|
set(BOTAN_MSVC_RUNTIME "--msvc-runtime=MT")
|
|
endif()
|
|
|
|
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
|
set(BOTAN_FLAG_CPU x86)
|
|
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
|
set(BOTAN_FLAG_CPU x86_64)
|
|
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
|
|
set(BOTAN_FLAG_CPU arm32)
|
|
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
|
|
set(BOTAN_FLAG_CPU arm64)
|
|
else()
|
|
message(FATAL_ERROR "Unsupported architecture")
|
|
endif()
|
|
|
|
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
|
FEATURES
|
|
amalgamation BOTAN_AMALGAMATION
|
|
zlib BOTAN_WITH_ZLIB
|
|
)
|
|
|
|
function(BOTAN_BUILD BOTAN_BUILD_TYPE)
|
|
|
|
if(BOTAN_BUILD_TYPE STREQUAL "dbg")
|
|
set(BOTAN_FLAG_PREFIX "${CURRENT_PACKAGES_DIR}/debug")
|
|
set(BOTAN_FLAG_DEBUGMODE --debug-mode)
|
|
set(BOTAN_DEBUG_SUFFIX "")
|
|
set(BOTAN_MSVC_RUNTIME_SUFFIX "d")
|
|
else()
|
|
set(BOTAN_FLAG_DEBUGMODE)
|
|
set(BOTAN_FLAG_PREFIX "${CURRENT_PACKAGES_DIR}")
|
|
set(BOTAN_MSVC_RUNTIME_SUFFIX "")
|
|
endif()
|
|
|
|
message(STATUS "Configure ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}")
|
|
|
|
if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}")
|
|
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}")
|
|
endif()
|
|
make_directory("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}")
|
|
|
|
set(configure_arguments --cpu=${BOTAN_FLAG_CPU}
|
|
${BOTAN_FLAG_SHARED}
|
|
${BOTAN_FLAG_STATIC}
|
|
${BOTAN_FLAG_DEBUGMODE}
|
|
"--distribution-info=vcpkg ${TARGET_TRIPLET}"
|
|
--prefix=${BOTAN_FLAG_PREFIX}
|
|
--with-pkg-config
|
|
--link-method=copy
|
|
--with-debug-info)
|
|
if(CMAKE_HOST_WIN32)
|
|
list(APPEND configure_arguments ${BOTAN_MSVC_RUNTIME}${BOTAN_MSVC_RUNTIME_SUFFIX})
|
|
endif()
|
|
|
|
if(VCPKG_CXX_FLAGS)
|
|
list(APPEND configure_arguments --extra-cxxflags ${VCPKG_CXX_FLAGS})
|
|
endif()
|
|
|
|
if("-DBOTAN_AMALGAMATION=ON" IN_LIST FEATURE_OPTIONS)
|
|
list(APPEND configure_arguments --amalgamation)
|
|
endif()
|
|
if("-DBOTAN_WITH_ZLIB=ON" IN_LIST FEATURE_OPTIONS)
|
|
list(APPEND configure_arguments --with-zlib)
|
|
list(APPEND configure_arguments --with-external-includedir="${CURRENT_INSTALLED_DIR}/include")
|
|
list(APPEND configure_arguments --with-external-libdir="${CURRENT_INSTALLED_DIR}/lib")
|
|
endif()
|
|
|
|
vcpkg_execute_required_process(
|
|
COMMAND "${PYTHON3}" "${SOURCE_PATH}/configure.py" ${configure_arguments}
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}"
|
|
LOGNAME configure-${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE})
|
|
message(STATUS "Configure ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE} done")
|
|
|
|
message(STATUS "Build ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}")
|
|
vcpkg_execute_build_process(
|
|
COMMAND "${build_tool}" ${parallel_build}
|
|
NO_PARALLEL_COMMAND "${build_tool}"
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}"
|
|
LOGNAME build-${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE})
|
|
message(STATUS "Build ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE} done")
|
|
|
|
message(STATUS "Package ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}")
|
|
vcpkg_execute_required_process(
|
|
COMMAND "${PYTHON3}" "${SOURCE_PATH}/src/scripts/install.py"
|
|
--prefix=${BOTAN_FLAG_PREFIX}
|
|
--bindir=${BOTAN_FLAG_PREFIX}/bin
|
|
--libdir=${BOTAN_FLAG_PREFIX}/lib
|
|
--pkgconfigdir=${BOTAN_FLAG_PREFIX}/lib
|
|
--includedir=${BOTAN_FLAG_PREFIX}/include
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}"
|
|
LOGNAME install-${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE})
|
|
|
|
message(STATUS "Package ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE} done")
|
|
endfunction()
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
|
BOTAN_BUILD(rel)
|
|
endif()
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
BOTAN_BUILD(dbg)
|
|
endif()
|
|
|
|
file(RENAME "${CURRENT_PACKAGES_DIR}/include/botan-2/botan" "${CURRENT_PACKAGES_DIR}/include/botan")
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
|
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/pkgconfig")
|
|
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/botan-2.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/botan-2.pc")
|
|
if (VCPKG_TARGET_IS_WINDOWS)
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/botan-2.pc"
|
|
[[\lib]]
|
|
[[/lib]]
|
|
)
|
|
endif()
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/botan-2.pc"
|
|
[[${prefix}/include/botan-2]]
|
|
[[${prefix}/include]]
|
|
)
|
|
endif()
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig")
|
|
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/botan-2.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/botan-2.pc")
|
|
if (VCPKG_TARGET_IS_WINDOWS)
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/botan-2.pc"
|
|
[[\lib]]
|
|
[[/lib]]
|
|
)
|
|
endif()
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/botan-2.pc"
|
|
[[${prefix}/include/botan-2]]
|
|
[[${prefix}/include]]
|
|
)
|
|
endif()
|
|
vcpkg_fixup_pkgconfig()
|
|
|
|
vcpkg_copy_pdbs()
|
|
|
|
if(CMAKE_HOST_WIN32)
|
|
vcpkg_copy_tools(TOOL_NAMES botan-cli AUTO_CLEAN)
|
|
else()
|
|
vcpkg_copy_tools(TOOL_NAMES botan AUTO_CLEAN)
|
|
endif()
|
|
|
|
file(REMOVE_RECURSE
|
|
"${CURRENT_PACKAGES_DIR}/debug/include"
|
|
"${CURRENT_PACKAGES_DIR}/debug/share"
|
|
"${CURRENT_PACKAGES_DIR}/include/botan-2"
|
|
"${CURRENT_PACKAGES_DIR}/share/doc")
|
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
|
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
|
|
endif()
|
|
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/botan/build.h" "#define BOTAN_INSTALL_PREFIX R\"(${CURRENT_PACKAGES_DIR})\"" "")
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/botan/build.h" "#define BOTAN_INSTALL_LIB_DIR R\"(${CURRENT_PACKAGES_DIR}\\lib)\"" "")
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/botan/build.h" "#define BOTAN_INSTALL_LIB_DIR R\"(${CURRENT_PACKAGES_DIR}/lib)\"" "")
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/botan/build.h" "--prefix=${CURRENT_PACKAGES_DIR}" "")
|
|
|
|
file(INSTALL "${SOURCE_PATH}/license.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|