Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fmilib] Cleanup, de-vendor libs, fix linux #29834

Merged
merged 10 commits into from
Mar 15, 2023
48 changes: 0 additions & 48 deletions ports/fmilib/0001-remove-install-prefix.patch

This file was deleted.

20 changes: 0 additions & 20 deletions ports/fmilib/0002-include-sys-stat.h-for-mkdir.patch

This file was deleted.

50 changes: 50 additions & 0 deletions ports/fmilib/devendor-sublibs.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b01aba5..583e15b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,7 +230,7 @@ configure_file (
"${FMILibrary_BINARY_DIR}/fmilib_config.h"
)

-set(FMILIB_SHARED_SUBLIBS ${FMIXML_LIBRARIES} ${FMIZIP_LIBRARIES} ${FMICAPI_LIBRARIES} expat minizip zlib c99snprintf)
+set(FMILIB_SHARED_SUBLIBS ${FMIXML_LIBRARIES} ${FMIZIP_LIBRARIES} ${FMICAPI_LIBRARIES} c99snprintf)
set(FMILIB_SUBLIBS ${FMIIMPORT_LIBRARIES} ${JMUTIL_LIBRARIES} ${FMILIB_SHARED_SUBLIBS})
set(FMILIB_SHARED_SRC ${FMIIMPORTSOURCE} ${JMUTILSOURCE} ${FMIIMPORTHEADERS})

diff --git a/Config.cmake/fmixml.cmake b/Config.cmake/fmixml.cmake
index ddd3c1f..3bafac3 100644
--- a/Config.cmake/fmixml.cmake
+++ b/Config.cmake/fmixml.cmake
@@ -137,6 +137,7 @@ set(FMIXMLSOURCE
src/FMI2/fmi2_xml_variable.c
)

+if(0)
include(ExternalProject)

# The *_POSTFIX variables are set because it makes it easier to determine the name of
@@ -211,7 +212,10 @@ if(FMILIB_INSTALL_SUBLIBS)
DESTINATION lib)
endif()

+endif(0)
set(EXPAT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ExpatEx/install/include)
+find_package(expat CONFIG REQUIRED)
+add_library(expat ALIAS expat::expat)

include_directories("${EXPAT_INCLUDE_DIRS}" "${FMILIB_THIRDPARTYLIBS}/FMI/" "${FMIXMLGENDIR}/FMI1" "${FMIXMLGENDIR}/FMI2")

diff --git a/Config.cmake/fmizip.cmake b/Config.cmake/fmizip.cmake
index 091fc4d..c53555f 100644
--- a/Config.cmake/fmizip.cmake
+++ b/Config.cmake/fmizip.cmake
@@ -20,7 +20,8 @@ if(NOT FMIZIPDIR)

set(FMIZIP_LIBRARIES fmizip)

- add_subdirectory(Config.cmake/Minizip)
+ find_package(minizip CONFIG REQUIRED)
+ add_library(minizip ALIAS minizip::minizip)

include_directories("${FMIZIPDIR}/include" "${FMILIB_THIRDPARTYLIBS}/Minizip/minizip" "${FMILIB_THIRDPARTYLIBS}/FMI" "${FMILIB_THIRDPARTYLIBS}/Zlib/zlib-1.2.6" "${FMILibrary_BINARY_DIR}/zlib")

20 changes: 20 additions & 0 deletions ports/fmilib/fix-mergestaticlibs.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/Config.cmake/mergestaticlibs.cmake b/Config.cmake/mergestaticlibs.cmake
index 858a026..67eccb7 100644
--- a/Config.cmake/mergestaticlibs.cmake
+++ b/Config.cmake/mergestaticlibs.cmake
@@ -21,6 +21,15 @@ function(merge_static_libs outlib )
file(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";")

add_library(${outlib} STATIC ${dummyfile})
+ foreach(lib IN LISTS libs)
+ target_sources(${outlib} PRIVATE "$<TARGET_OBJECTS:${lib}>")
+ get_target_property(link_libs ${lib} INTERFACE_LINK_LIBRARIES)
+ if(link_libs)
+ list(REMOVE_ITEM link_libs ${libs})
+ target_link_libraries(${outlib} ${link_libs})
+ endif()
+ endforeach()
+ return()

if("${CMAKE_CFG_INTDIR}" STREQUAL ".")
set(multiconfig FALSE)
55 changes: 23 additions & 32 deletions ports/fmilib/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,47 @@ vcpkg_from_github(
SHA512 65c2dc11116737e4e2ee91a4ec58d2cf24003774fd6d9b8b1d6521f046be9e8f8a963ebedb50a161ad264927062f41ce757c84563cfe628d47614910e8730349
HEAD_REF master
PATCHES
0001-remove-install-prefix.patch
0002-include-sys-stat.h-for-mkdir.patch
0003-export-targets.patch
devendor-sublibs.diff
fix-mergestaticlibs.diff
unofficial-export.diff
)

# Note that if you have configured and built both static and shared library on Windows
# but want to link with the static library compile time define "FMILIB_BUILDING_LIBRARY" must be set.
if ((NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") AND VCPKG_LIBRARY_LINKAGE STREQUAL static)
SET(FMILIB_BUILDING_LIBRARY ON)
else()
SET(FMILIB_BUILDING_LIBRARY OFF)
endif()

# Use static run-time libraries (/MT or /MTd code generation flags)
# This is only used when generating Microsoft Visual Studio solutions. If the options is on then the library will
# be built against static runtime, otherwise - dynamic runtime (/MD or /MDd). Make sure the client code is using
# matching runtime
if ((NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") AND VCPKG_CRT_LINKAGE STREQUAL static)
SET(FMILIB_BUILD_WITH_STATIC_RTLIB ON)
else()
SET(FMILIB_BUILD_WITH_STATIC_RTLIB OFF)
endif()

# On LINUX position independent code (-fPIC) must be used on all files to be linked into a shared library (.so file).
# On other systems this is not needed (either is default or relocation is done). Set this option to OFF if you
# are building an application on Linux and use static library only
if ((VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux" OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin") AND VCPKG_LIBRARY_LINKAGE STREQUAL static)
SET(FMILIB_BUILD_FOR_SHARED_LIBS OFF)
else()
SET(FMILIB_BUILD_FOR_SHARED_LIBS ON)
endif()
file(REMOVE RECURSE
"${SOURCE_PATH}/ThirdParty/Expat"
"${SOURCE_PATH}/ThirdParty/Minizip"
"${SOURCE_PATH}/ThirdParty/Zlib"
)

string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FMILIB_BUILD_WITH_STATIC_RTLIB)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-Wno-dev
-DFMILIB_BUILD_TESTS=OFF
-DFMILIB_BUILD_STATIC_LIB=${BUILD_STATIC}
-DFMILIB_BUILD_SHARED_LIB=${BUILD_SHARED}
-DFMILIB_BUILDING_LIBRARY=${FMILIB_BUILDING_LIBRARY}
-DFMILIB_BUILD_WITH_STATIC_RTLIB=${FMILIB_BUILD_WITH_STATIC_RTLIB}
-DFMILIB_GENERATE_DOXYGEN_DOC=OFF
OPTIONS_DEBUG
"-DFMILIB_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug"
OPTIONS_RELEASE
"-DFMILIB_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}"
MAYBE_UNUSED_VARIABLES
FMILIB_BUILDING_LIBRARY
FMILIB_BUILD_WITH_STATIC_RTLIB
)

vcpkg_cmake_install()
vcpkg_copy_pdbs()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/unofficial-fmilib-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-fmilib")
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-fmilib)

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

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md")
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f3c11f1..2461ecb 100644
index 583e15b..0319e3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -299,10 +299,18 @@ endif()
@@ -300,10 +300,17 @@ endif()

file(COPY "${FMILIBRARYHOME}/Config.cmake/fmilib.h" DESTINATION "${FMILibrary_BINARY_DIR}")

-install(TARGETS ${FMILIB_TARGETS}
+TARGET_INCLUDE_DIRECTORIES(${FMILIB_TARGETS} INTERFACE $<INSTALL_INTERFACE:include>)
+
+install(TARGETS ${FMILIB_TARGETS} EXPORT unofficial-fmilib-config
+target_include_directories(${FMILIB_TARGETS} INTERFACE $<INSTALL_INTERFACE:include>)
install(TARGETS ${FMILIB_TARGETS}
+ EXPORT unofficial-fmilib-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
- RUNTIME DESTINATION lib
+ RUNTIME DESTINATION bin
+)
+
+install(EXPORT unofficial-fmilib-config
+ FILE unofficial-fmilib-config.cmake
+install(EXPORT unofficial-fmilib-targets
+ FILE unofficial-fmilib-targets.cmake
+ NAMESPACE unofficial::fmilib::
+ DESTINATION share/unofficial-fmilib
)
Expand Down
4 changes: 4 additions & 0 deletions ports/fmilib/unofficial-fmilib-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include(CMakeFindDependencyMacro)
find_dependency(expat CONFIG)
find_dependency(minizip CONFIG)
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-fmilib-targets.cmake")
4 changes: 4 additions & 0 deletions ports/fmilib/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "fmilib",
"version": "2.4.1",
"port-version": 1,
"description": "FMI library is intended as a foundation for applications interfacing FMUs (Functional Mockup Units) that follow FMI Standard. This version of the library supports FMI 1.0 and FMI2.0.",
"homepage": "https://www.fmi-standard.org/",
"license": "BSD-3-Clause",
"supports": "!uwp",
"dependencies": [
"expat",
"minizip",
{
"name": "vcpkg-cmake",
"host": true
Expand Down
4 changes: 0 additions & 4 deletions scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ fluidlite:x64-windows=skip
fluidlite:x86-windows=skip
fmi4cpp:arm-uwp=fail
fmi4cpp:x64-uwp=fail
fmilib:arm64-windows=fail
fmilib:arm-uwp=fail
fmilib:x64-linux=fail
fmilib:x64-uwp=fail
fontconfig:x64-uwp=fail
fontconfig:arm-uwp=fail
foonathan-memory:arm64-windows=fail
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,7 @@
},
"fmilib": {
"baseline": "2.4.1",
"port-version": 0
"port-version": 1
},
"fmt": {
"baseline": "9.1.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/f-/fmilib.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "aa8b7d569a23fd953d1e4de558a034a6d9f95e33",
"version": "2.4.1",
"port-version": 1
},
{
"git-tree": "34b7f7cc468b8eecb267b5fd750cb1e602d36248",
"version": "2.4.1",
Expand Down