Skip to content

Commit

Permalink
[vcpkg] Add vcpkg_from_sourceforge (1/2) (#11899)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackBoosY committed Jun 26, 2020
1 parent 81ae2ed commit a0e0c57
Show file tree
Hide file tree
Showing 83 changed files with 528 additions and 502 deletions.
63 changes: 63 additions & 0 deletions docs/maintainers/vcpkg_from_sourceforge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# vcpkg_from_sourceforge

Download and extract a project from sourceforge.

## Usage:
```cmake
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO <cunit/CUnit>
[REF <2.1-3>]
SHA512 <547b417109332...>
FILENAME <CUnit-2.1-3.tar.bz2>
[DISABLE_SSL]
[NO_REMOVE_ONE_LEVEL]
[PATCHES <patch1.patch> <patch2.patch>...]
)
```

## Parameters:
### OUT_SOURCE_PATH
Specifies the out-variable that will contain the extracted location.

This should be set to `SOURCE_PATH` by convention.

### REPO
The organization or user and repository (optional) on sourceforge.

### REF
A stable version number that will not change contents.

### FILENAME
The local name for the file. Files are shared between ports, so the file may need to be renamed to make it clearly attributed to this port and avoid conflicts.

For example, we can get the download link:
https://sourceforge.net/settings/mirror_choices?projectname=mad&filename=libmad/0.15.1b/libmad-0.15.1b.tar.gz&selected=nchc
So the REPO is `mad/libmad`, the REF is `0.15.1b`, and the FILENAME is `libmad-0.15.1b.tar.gz`

For some special links:
https://sourceforge.net/settings/mirror_choices?projectname=soxr&filename=soxr-0.1.3-Source.tar.xz&selected=nchc
The REPO is `soxr`, REF is not exist, and the FILENAME is `soxr-0.1.3-Source.tar.xz`

### SHA512
The SHA512 hash that should match the archive.

### PATCHES
A list of patches to be applied to the extracted sources.

Relative paths are based on the port directory.

### DISABLE_SSL
Disable ssl when downloading source.

### NO_REMOVE_ONE_LEVEL
Specifies that the default removal of the top level folder should not occur.

## Examples:

* [cunit](https://github.com/Microsoft/vcpkg/blob/master/ports/cunit/portfile.cmake)
* [polyclipping](https://github.com/Microsoft/vcpkg/blob/master/ports/polyclipping/portfile.cmake)
* [tinyfiledialogs](https://github.com/Microsoft/vcpkg/blob/master/ports/tinyfiledialogs/portfile.cmake)

## Source
[scripts/cmake/vcpkg_from_sourceforge.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_from_sourceforge.cmake)
3 changes: 2 additions & 1 deletion ports/argtable2/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Source: argtable2
Version: 2.13-4
Version: 2.13-5
Homepage: http://argtable.sourceforge.net
Description: Argtable is an ANSI C library for parsing GNU style command line options with a minimum of fuss.
18 changes: 6 additions & 12 deletions ports/argtable2/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
include(vcpkg_common_functions)

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_download_distfile(ARCHIVE
URLS "http://prdownloads.sourceforge.net/argtable/argtable2-13.tar.gz"
FILENAME "argtable-2.13.zip"
SHA512 3d8303f3ba529e3241d918c0127a16402ece951efb964d14a06a3a7d29a252812ad3c44e96da28798871e9923e73a2cfe7ebc84139c1397817d632cae25c4585
)

vcpkg_extract_source_archive_ex(
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
PATCHES
fix-install-dirs.patch
REPO argtable/argtable
REF argtable-2.13
FILENAME "argtable2-13.tar.gz"
SHA512 3d8303f3ba529e3241d918c0127a16402ece951efb964d14a06a3a7d29a252812ad3c44e96da28798871e9923e73a2cfe7ebc84139c1397817d632cae25c4585
PATCHES fix-install-dirs.patch
)

vcpkg_configure_cmake(
Expand Down
2 changes: 1 addition & 1 deletion ports/cunit/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: cunit
Version: 2.1.3-3
Version: 2.1.3-4
Homepage: https://sourceforge.net/projects/cunit/
Description: CUnit is a lightweight system for writing, administering, and running unit tests in C. It provides C programmers a basic testing functionality with a flexible variety of user interfaces
19 changes: 7 additions & 12 deletions ports/cunit/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
include(vcpkg_common_functions)

vcpkg_download_distfile(ARCHIVE
URLS "http://downloads.sourceforge.net/project/cunit/CUnit/2.1-3/CUnit-2.1-3.tar.bz2"
FILENAME "CUnit-2.1-3.tar.bz2"
SHA512 547b417109332446dfab8fda17bf4ccd2da841dc93f824dc90a20635bcf1fb80fb2176500d8a0906940f3f3d3e2f77b2d70a71090c9ab84ad9af43f3582bc487
)

vcpkg_extract_source_archive_ex(
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
REPO cunit/CUnit
REF 2.1-3
FILENAME "CUnit-2.1-3.tar.bz2"
SHA512 547b417109332446dfab8fda17bf4ccd2da841dc93f824dc90a20635bcf1fb80fb2176500d8a0906940f3f3d3e2f77b2d70a71090c9ab84ad9af43f3582bc487
)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
Expand All @@ -21,6 +16,6 @@ vcpkg_configure_cmake(

vcpkg_install_cmake()

file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/cunit RENAME copyright)

vcpkg_copy_pdbs()

file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
52 changes: 52 additions & 0 deletions ports/epsilon/0003-Fix-build-error.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/makefile.vc b/makefile.vc
index cd0fc5a..7ce6861 100644
--- a/makefile.vc
+++ b/makefile.vc
@@ -32,6 +32,12 @@ epsilon.lib: $(LIBOBJ)

$(EPSILON_DLL): epsilon_i.lib

+!IFNDEF DEBUG
+POPTLIB=$(LIBPATH)popt.lib
+!ELSE
+POPTLIB=$(LIBPATH)poptd.lib
+!ENDIF
+
epsilon_i.lib: $(LIBOBJ)
link /debug /dll /def:libepsilon.def /out:$(EPSILON_DLL) \
/implib:epsilon_i.lib $(LIBOBJ)
@@ -48,8 +54,8 @@ $(EPSILON_EXE): $(EPSILON_DLL) src\epsilon.obj \
src\cmd_truncate_file.obj src\cmd_decode_file.obj \
src\cmd_encode_file.obj src\misc.obj \
src\psi.obj src\pbm.obj \
- ..\popt\lib\libpopt.lib
- /Fe$(EPSILON_EXE)
+ $(POPTLIB) \
+ /Fe"$(EPSILON_EXE)"
if exist $(EPSILON_EXE).manifest mt -manifest \
$(EPSILON_EXE).manifest -outputresource:$(EPSILON_EXE);1

@@ -71,8 +77,9 @@ install: all
-mkdir $(INSTDIR)\bin
-mkdir $(INSTDIR)\lib
-mkdir $(INSTDIR)\include
+ -mkdir $(INSTDIR)\tools
copy *.dll $(INSTDIR)\bin
copy *.lib $(INSTDIR)\lib
- copy *.exe $(INSTDIR)\bin
+ copy *.exe $(INSTDIR)\tools
copy lib\epsilon.h $(INSTDIR)\include

diff --git a/src/misc.h b/src/misc.h
index 9023dce..d8ce602 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -30,7 +30,7 @@ extern "C" {
#endif

/* Use _snprintf instead of snprintf under MSVC compiler */
-#if defined(_WIN32) && !defined(__MINGW32__)
+#if 0
#define snprintf _snprintf
#endif

5 changes: 3 additions & 2 deletions ports/epsilon/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Source: epsilon
Version: 0.9.2-1
Version: 0.9.2-2
Homepage: https://sourceforge.net/projects/epsilon-project/
Description: EPSILON is an Open Source wavelet image compressor, that is aimed on parallel and robust image processing.
Description: EPSILON is an Open Source wavelet image compressor, that is aimed on parallel and robust image processing.
Build-Depends: libpopt
106 changes: 28 additions & 78 deletions ports/epsilon/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
include(vcpkg_common_functions)
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)

vcpkg_download_distfile(ARCHIVE
URLS "https://downloads.sourceforge.net/project/epsilon-project/epsilon/0.9.2/epsilon-0.9.2.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fepsilon-project%2Ffiles%2Fepsilon%2F0.9.2%2Fepsilon-0.9.2.tar.gz%2Fdownload%3Fuse_mirror%3Dayera"
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO epsilon-project/epsilon
REF 0.9.2
FILENAME "epsilon-0.9.2.tar.gz"
SHA512 95f427c68a4a4eb784f7d484d87fc573133983510f6b030663f88955e2446490a07b1343ae4668251b466f67cf9a79bd834b933c57c5ed12327f32174f20ac0f)

# Extract source into archictecture specific directory, because GDALs' nmake based build currently does not
# support out of source builds.
set(SOURCE_PATH_DEBUG ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-debug/epsilon-0.9.2)
set(SOURCE_PATH_RELEASE ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-release/epsilon-0.9.2)
file(REMOVE_RECURSE ${SOURCE_PATH_DEBUG} ${SOURCE_PATH_RELEASE}) # to be sure that the patches can be properly applied, we always clean the buildtrees folder
foreach(BUILD_TYPE debug release)
vcpkg_extract_source_archive(${ARCHIVE} ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-${BUILD_TYPE})
vcpkg_apply_patches(
SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-${BUILD_TYPE}/epsilon-0.9.2
PATCHES
${CMAKE_CURRENT_LIST_DIR}/0001-VS2015-provides-snprintf.patch
${CMAKE_CURRENT_LIST_DIR}/0002-Add-CFLAGS-for-CRT-selection-and-warning-supression.patch
)
endforeach()
SHA512 95f427c68a4a4eb784f7d484d87fc573133983510f6b030663f88955e2446490a07b1343ae4668251b466f67cf9a79bd834b933c57c5ed12327f32174f20ac0f
PATCHES
0001-VS2015-provides-snprintf.patch
0002-Add-CFLAGS-for-CRT-selection-and-warning-supression.patch
0003-Fix-build-error.patch
)

find_program(NMAKE nmake REQUIRED)
if (VCPKG_CRT_LINKAGE STREQUAL static)
set(CL_FLAGS_REL "/MT /Ox /fp:precise")
set(CL_FLAGS_DBG "/MTd /Zi")
Expand All @@ -31,68 +22,27 @@ else()
set(TARGET_LIB epsilon_i.lib)
endif()

################
# Release build
################
message(STATUS "Building ${TARGET_TRIPLET}-rel")
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" INST_DIR_REL)
vcpkg_execute_required_process(
COMMAND ${NMAKE} -f makefile.vc
"INSTDIR=\"${INST_DIR_REL}\""
MSVC_VER=1900
CRT_FLAGS=${CL_FLAGS_REL}
INSTALLED_ROOT=${CURRENT_INSTALLED_DIR}
${TARGET_LIB}
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
LOGNAME nmake-build-${TARGET_TRIPLET}-release
)
message(STATUS "Building ${TARGET_TRIPLET}-rel done")

################
# Debug build
################
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}/debug" INST_DIR_DBG)
vcpkg_execute_required_process(
COMMAND ${NMAKE} /G -f makefile.vc
"INSTDIR=\"${INST_DIR_DBG}\""
vcpkg_install_nmake(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
INSTALLED_ROOT="${CURRENT_INSTALLED_DIR}"
OPTIONS_DEBUG
INSTDIR="${CURRENT_PACKAGES_DIR}/debug"
MSVC_VER=1900
CRT_FLAGS=${CL_FLAGS_DBG}
DEBUG=1
INSTALLED_ROOT=${CURRENT_INSTALLED_DIR}
${TARGET_LIB}
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
LOGNAME nmake-build-${TARGET_TRIPLET}-debug
LIBPATH="${CURRENT_INSTALLED_DIR}/debug/lib/"
OPTIONS_RELEASE
INSTDIR="${CURRENT_PACKAGES_DIR}"
MSVC_VER=1900
CRT_FLAGS=${CL_FLAGS_REL}
${TARGET_LIB}
LIBPATH="${CURRENT_INSTALLED_DIR}/lib/"
)
message(STATUS "Building ${TARGET_TRIPLET}-dbg done")

message(STATUS "Packaging ${TARGET_TRIPLET}")
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/lib)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/lib)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/include)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/epsilon/filters)
if (VCPKG_CRT_LINKAGE STREQUAL dynamic)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/bin)
file(INSTALL ${SOURCE_PATH_RELEASE}/epsilon.dll
DESTINATION ${CURRENT_PACKAGES_DIR}/bin/)
file(INSTALL ${SOURCE_PATH_DEBUG}/epsilon.dll
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin/)
file(INSTALL ${SOURCE_PATH_RELEASE}/epsilon_i.lib
DESTINATION ${CURRENT_PACKAGES_DIR}/lib/)
file(INSTALL ${SOURCE_PATH_DEBUG}/epsilon_i.lib
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/)
else()
file(INSTALL ${SOURCE_PATH_RELEASE}/epsilon.lib
DESTINATION ${CURRENT_PACKAGES_DIR}/lib/)
file(INSTALL ${SOURCE_PATH_DEBUG}/epsilon.lib
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/)
endif()
file(COPY ${SOURCE_PATH_RELEASE}/lib/epsilon.h
DESTINATION ${CURRENT_PACKAGES_DIR}/include/)
file(GLOB FILTERS ${SOURCE_PATH_RELEASE}/filters/*.filter)
file(INSTALL ${FILTERS}
DESTINATION ${CURRENT_PACKAGES_DIR}/share/epsilon/filters/)
vcpkg_copy_pdbs()
file(INSTALL ${SOURCE_PATH_RELEASE}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/epsilon/ RENAME copyright)
message(STATUS "Packaging ${TARGET_TRIPLET} done")

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
2 changes: 1 addition & 1 deletion ports/freeglut/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: freeglut
Version: 3.2.1-1
Version: 3.2.1-2
Homepage: https://sourceforge.net/projects/freeglut/
Description: Open source implementation of GLUT with source and binary backwards compatibility.
21 changes: 9 additions & 12 deletions ports/freeglut/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
vcpkg_download_distfile(ARCHIVE
URLS "http://downloads.sourceforge.net/project/freeglut/freeglut/3.2.1/freeglut-3.2.1.tar.gz"
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO freeglut/freeglut
REF 3.2.1
FILENAME "freeglut-3.2.1.tar.gz"
SHA512 aced4bbcd36269ce6f4ee1982e0f9e3fffbf18c94f785d3215ac9f4809b992e166c7ada496ed6174e13d77c0f7ef3ca4c57d8a282e96cbbe6ff086339ade3b08
)

vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
PATCHES
use_targets_to_export_x11_dependency.patch
macOS_Xquartz.patch
gcc10.patch
fix-debug-macro.patch
PATCHES
use_targets_to_export_x11_dependency.patch
macOS_Xquartz.patch
gcc10.patch
fix-debug-macro.patch
)

if(NOT VCPKG_TARGET_IS_WINDOWS)
Expand Down
2 changes: 1 addition & 1 deletion ports/freeimage/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: freeimage
Version: 3.18.0-9
Version: 3.18.0-10
Build-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp (!uwp), libraw, jxrlib, openexr
Homepage: https://sourceforge.net/projects/freeimage/
Description: Support library for graphics image formats
Loading

0 comments on commit a0e0c57

Please sign in to comment.