-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
I want to adopt vcpkg as my primary mechanism of handling dependencies but in order to do so I need to add a few dependency ports for packages I did not write. I'm fairly new to vcpkg so I'd like some help with adding a port to a clone of vcpkg for libsbml.
I'm actually having reasonable success in that I am able to get libsbml to build on x86-windows
, x64-windows
and x64-linux
. However, I currently have two problems:
Firstly, when I build using the three toolchains above the message that I receive is this:
...
Building package libsbml[core]:x64-windows... done
Installing package libsbml[core]:x64-windows...
Installing package libsbml[core]:x64-windows... done
Elapsed time for package libsbml:x64-windows: 3.512 min
Total elapsed time: 4.676 min
The package libsbml:x64-windows provides CMake targets:
find_package(cmake CONFIG REQUIRED)
target_link_libraries(main PRIVATE libsbml libsbml-static)
Rather than the expected
Building package libsbml[core]:x64-windows... done
Installing package libsbml[core]:x64-windows...
Installing package libsbml[core]:x64-windows... done
Elapsed time for package libsbml:x64-windows: 3.512 min
Total elapsed time: 4.676 min
The package libsbml:x64-windows provides CMake targets:
find_package(libsbml CONFIG REQUIRED)
target_link_libraries(main PRIVATE libsbml libsbml-static)
I suspect the culprit is this line: vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake TARGET_PATH share/libsbml/cmake)
(see below) but I'm not sure how to debug, or even if there is a bug.
My second problem is that building with x64-windows
will build both static and dynamic libraries and put them into the same place:
(base) PS D:\vcpkg\installed\x64-windows\lib> ls libsbml*
Directory: D:\vcpkg\installed\x64-windows\lib
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 24/07/2020 11:02 193139944 libsbml-static.lib
-a---- 24/07/2020 11:02 2499768 libsbml.lib
My understanding is that the static library should only be built when using x64-windows-static
. But, when I build with this toolchain I get the following:
-- Building x64-windows-static-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:136 (message):
Command failed: D:/vcpkg/downloads/tools/cmake-3.17.2-windows/cmake-3.17.2-win32-x86/bin/cmake.exe --build . --config Debug --target install -- -v
Working Directory: D:/vcpkg/buildtrees/libsbml/x64-windows-static-dbg
See logs for more information:
D:\vcpkg\buildtrees\libsbml\install-x64-windows-static-dbg-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_build_cmake.cmake:91 (vcpkg_execute_build_process)
scripts/cmake/vcpkg_install_cmake.cmake:24 (vcpkg_build_cmake)
ports/libsbml/portfile.cmake:15 (vcpkg_install_cmake)
scripts/ports.cmake:79 (include)
Where D:\vcpkg\buildtrees\libsbml\install-x64-windows-static-dbg-out.log
:
...
[442/443] cmd.exe /C "cd . && D:\vcpkg\downloads\tools\cmake-3.17.2-windows\cmake-3.17.2-win32-x86\bin\cmake.exe -E vs_link_dll --intdir=src\CMakeFiles\libsbml.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x64\link.exe @CMakeFiles\libsbml.rsp /out:src\libsbml.dll /implib:src\libsbml.lib /pdb:src\libsbml.pdb /dll /version:5.18 /machine:x64 /nologo /debug /INCREMENTAL && cd ."
FAILED: src/libsbml.dll src/libsbml.lib
cmd.exe /C "cd . && D:\vcpkg\downloads\tools\cmake-3.17.2-windows\cmake-3.17.2-win32-x86\bin\cmake.exe -E vs_link_dll --intdir=src\CMakeFiles\libsbml.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x64\link.exe @CMakeFiles\libsbml.rsp /out:src\libsbml.dll /implib:src\libsbml.lib /pdb:src\libsbml.pdb /dll /version:5.18 /machine:x64 /nologo /debug /INCREMENTAL && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x64\link.exe @CMakeFiles\libsbml.rsp /out:src\libsbml.dll /implib:src\libsbml.lib /pdb:src\libsbml.pdb /dll /version:5.18 /machine:x64 /nologo /debug /INCREMENTAL /MANIFEST /MANIFESTFILE:src\CMakeFiles\libsbml.dir/intermediate.manifest src\CMakeFiles\libsbml.dir/manifest.res" failed (exit code 1120) with the following output:
Creating library src\libsbml.lib and object src\libsbml.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
libxml2.lib(xzlib.c.obj) : error LNK2019: unresolved external symbol lzma_code referenced in function xz_decomp
libxml2.lib(xzlib.c.obj) : error LNK2019: unresolved external symbol lzma_end referenced in function __libxml2_xzclose
libxml2.lib(xzlib.c.obj) : error LNK2019: unresolved external symbol lzma_properties_decode referenced in function is_format_lzma
libxml2.lib(xzlib.c.obj) : error LNK2019: unresolved external symbol lzma_auto_decoder referenced in function xz_head
libiconv.lib(iconv.c.obj) : error LNK2019: unresolved external symbol locale_charset referenced in function libiconv_open
src\libsbml.dll : fatal error LNK1120: 5 unresolved externals
ninja: build stopped: subcommand failed.
I'm hoping someone here can help me fix these issues to get a "proper" vcpkg port that works as it should.
When asking a question please also include where you looked for an answer (so we can update the documentation if needed).
- I found this thread when looking for how to pass /NODEFAULT to the linker.
- I found this thread when looking at resolving the linker errors. I have added liblzma to the dependencies in the CONTROL file but this did not resolve the dependency issues.
Based on these, I suspect that one of the dependencies or more of the dependencies were built with the wrong runtime and therefore including liblzma as a dependency does nothing, but this is only speculation.
Here are the files to reproduce the above:
#CONTROL
Source: libsbml
Version: 5.18.0
Description: A free, open-source programming library to help you read, write, manipulate, translate, and validate SBML files and data streams
Build-Depends: zlib, libxml2, bzip2, libiconv, check, liblzma, libxslt
Port-Version: 1
Feature: nol3v2extendedmath
Description: Disable the ENABLE_L3V2EXTENDEDMATH option
Feature: nolayout
Description: Disable the ENABLE_LAYOUT option
Feature: bzip
Description: Enable the WITH_BZIP2 option
Feature: check
Description: Enable the WITH_CHECK option
Feature: nocppnamespace
Description: Disable the WITH_CPP_NAMESPACE option
Feature: csharp
Description: Enable the WITH_CSHARP option
Feature: examples
Description: Enable the WITH_EXAMPLES option
Feature: expat
Description: Enable the WITH_EXPAT option
Feature: java
Description: Enable the WITH_JAVA option
Feature: javascript
Description: Enable the WITH_JAVASCRIPT option
Feature: nolibxml
Description: Disable the WITH_LIBXML option
Feature: matlab
Description: Enable the WITH_MATLAB option
Feature: octave
Description: Enable the WITH_OCTAVE option
Feature: perl
Description: Enable the WITH_PERL option
Feature: php
Description: Enable the WITH_PHP option
Feature: python
Description: Enable the WITH_PYTHON option
Feature: r
Description: Enable the WITH_R option
Feature: xerces
Description: Enable the WITH_XERCES option
Feature: swig
Description: Enable the WITH_SWIG option
Feature: nozlib
Description: Disable the WITH_ZLIB option
# portfile.cmake
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO opencor/libsbml
REF v5.18.0
SHA512 7d48de4ab40018ba92206daf4f5e5376050c4497b589cdf86de0875e3986b5e6b27c4ae178df627d208e037cf32d8ab3d04e33a52e5e077db14999f4fb601ea5
HEAD_REF master
)
###################################################
# user options
#
if ("nol3v2extendedmath" IN_LIST FEATURES)
set(ENABLE_L3V2EXTENDEDMATH OFF)
else ()
set(ENABLE_L3V2EXTENDEDMATH ON)
endif ()
if ("nolayout" IN_LIST FEATURES)
set(ENABLE_LAYOUT OFF)
else ()
set(ENABLE_LAYOUT ON)
endif ()
if ("bzip" IN_LIST FEATURES)
set(WITH_BZIP2 ON)
else ()
set(WITH_BZIP2 OFF)
endif ()
if ("check" IN_LIST FEATURES)
set(WITH_CHECK ON)
else ()
set(WITH_CHECK OFF)
endif ()
if ("nocppnamespace" IN_LIST FEATURES)
set(WITH_CPP_NAMESPACE OFF)
else ()
set(WITH_CPP_NAMESPACE ON)
endif ()
if ("csharp" IN_LIST FEATURES)
set(WITH_CSHARP ON)
else ()
set(WITH_CSHARP OFF)
endif ()
if ("examples" IN_LIST FEATURES)
set(WITH_EXAMPLES ON)
else ()
set(WITH_EXAMPLES OFF)
endif ()
if ("expat" IN_LIST FEATURES)
set(WITH_EXPAT ON)
else ()
set(WITH_EXPAT OFF)
endif ()
if ("java" IN_LIST FEATURES)
set(WITH_JAVA ON)
else ()
set(WITH_JAVA OFF)
endif ()
if ("javascript" IN_LIST FEATURES)
set(WITH_JAVASCRIPT ON)
else ()
set(WITH_JAVASCRIPT OFF)
endif ()
if ("nolibxml" IN_LIST FEATURES)
set(WITH_LIBXML OFF)
else ()
set(WITH_LIBXML ON)
endif ()
if ("matlab" IN_LIST FEATURES)
set(WITH_MATLAB ON)
else ()
set(WITH_MATLAB OFF)
endif ()
if ("octave" IN_LIST FEATURES)
set(WITH_OCTAVE ON)
else ()
set(WITH_OCTAVE OFF)
endif ()
if ("perl" IN_LIST FEATURES)
set(WITH_PERL ON)
else ()
set(WITH_PERL OFF)
endif ()
if ("php" IN_LIST FEATURES)
set(WITH_PHP ON)
else ()
set(WITH_PHP OFF)
endif ()
if ("python" IN_LIST FEATURES)
set(WITH_PYTHON ON)
else ()
set(WITH_PYTHON OFF)
endif ()
if ("r" IN_LIST FEATURES)
set(WITH_R ON)
else ()
set(WITH_R OFF)
endif ()
if ("xerces" IN_LIST FEATURES)
set(WITH_XERCES ON)
else ()
set(WITH_XERCES OFF)
endif ()
if ("swig" IN_LIST FEATURES)
set(WITH_SWIG ON)
else ()
set(WITH_SWIG OFF)
endif ()
if ("nozlib" IN_LIST FEATURES)
set(WITH_ZLIB OFF)
else ()
set(WITH_ZLIB ON)
endif ()
if (${VCPKG_LIBRARY_LINKAGE} STREQUAL "static")
set(WITH_STATIC_RUNTIME ON)
set(BUILD_SHARED_LIBS OFF)
else ()
set(WITH_STATIC_RUNTIME OFF)
set(BUILD_SHARED_LIBS ON)
endif ()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DWITH_CPP_NAMESPACE:BOOL=ON
-DENABLE_L3V2EXTENDEDMATH:BOOL=${ENABLE_L3V2EXTENDEDMATH}
-DENABLE_LAYOUT:BOOL=${ENABLE_LAYOUT}
-DWITH_BZIP2:BOOL=${WITH_BZIP2}
-DWITH_CHECK:BOOL=${WITH_CHECK}
-DWITH_CPP_NAMESPACE:BOOL=${WITH_CPP_NAMESPACE}
-DWITH_CSHARP:BOOL=${WITH_CSHARP}
-DWITH_EXAMPLES:BOOL=${WITH_EXAMPLES}
-DWITH_EXPAT:BOOL=${WITH_EXPAT}
-DWITH_JAVA:BOOL=${WITH_JAVA}
-DWITH_JAVASCRIPT:BOOL=${WITH_JAVASCRIPT}
-DWITH_LIBXML:BOOL=${WITH_LIBXML}
-DWITH_MATLAB:BOOL=${WITH_MATLAB}
-DWITH_OCTAVE:BOOL=${WITH_OCTAVE}
-DWITH_PERL:BOOL=${WITH_PERL}
-DWITH_PHP:BOOL=${WITH_PHP}
-DWITH_PYTHON:BOOL=${WITH_PYTHON}
-DWITH_R:BOOL=${WITH_R}
-DWITH_STATIC_RUNTIME:BOOL=${WITH_STATIC_RUNTIME}
-DWITH_XERCES:BOOL=${WITH_XERCES}
-DWITH_SWIG:BOOL=${WITH_SWIG}
-DWITH_ZLIB:BOOL=${WITH_ZLIB}
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
)
vcpkg_install_cmake(ADD_BIN_TO_PATH)
# remove include files for libsbml
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/libsbml/cmake")
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake TARGET_PATH share/libsbml/cmake)
set(LICENSE_FILE "${CURRENT_PACKAGES_DIR}/LICENSE.txt")
if (NOT EXISTS "${LICENSE_FILE}")
message(STATUS "LICENSE file not found at ${LICENSE_fILE}")
set(LICENSE_FILE "${CURRENT_PACKAGES_DIR}/share/libsbml/LICENSE.txt")
message(STATUS "Setting LICENSE to ${LICENSE_FILE}")
if (NOT EXISTS "${LICENSE_FILE}")
message(FATAL_ERROR "libsbml LICENSE.txt not found at ${LICENSE_FILE}")
endif ()
endif ()
configure_file("${LICENSE_FILE}" "${CURRENT_PACKAGES_DIR}/share/libsbml/copyright" COPYONLY)
set(FILES_TO_REMOVE
"${CURRENT_PACKAGES_DIR}/COPYING.txt"
"${CURRENT_PACKAGES_DIR}/FUNDING.txt"
"${CURRENT_PACKAGES_DIR}/LICENSE.txt"
"${CURRENT_PACKAGES_DIR}/NEWS.txt"
"${CURRENT_PACKAGES_DIR}/OLD_NEWS.txt"
"${CURRENT_PACKAGES_DIR}/README.txt"
"${CURRENT_PACKAGES_DIR}/VERSION.txt"
"${CURRENT_PACKAGES_DIR}/debug/COPYING.txt"
"${CURRENT_PACKAGES_DIR}/debug/FUNDING.txt"
"${CURRENT_PACKAGES_DIR}/debug/LICENSE.txt"
"${CURRENT_PACKAGES_DIR}/debug/NEWS.txt"
"${CURRENT_PACKAGES_DIR}/debug/OLD_NEWS.txt"
"${CURRENT_PACKAGES_DIR}/debug/README.txt"
"${CURRENT_PACKAGES_DIR}/debug/VERSION.txt"
)
foreach (f ${FILES_TO_REMOVE})
file(REMOVE ${f})
endforeach ()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
vcpkg_copy_pdbs()