diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fae8897 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* eol=lf diff --git a/.github/workflows/ci-conan-gcc.yml b/.github/workflows/ci-conan-gcc.yml new file mode 100755 index 0000000..6bccbaf --- /dev/null +++ b/.github/workflows/ci-conan-gcc.yml @@ -0,0 +1,53 @@ +--- +name: Linux GCC + +on: [push, workflow_dispatch] + +env: + CONAN_UPLOAD: ${{ secrets.CONAN_URL }} + CONAN_PASSWORD_SINTEF: ${{ secrets.CONAN_PASSWORD }} + CONAN_LOGIN_USERNAME_SINTEF: ${{ secrets.CONAN_USER }} + CONFIG_URL: https://github.com/sintef-ocean/conan-configs.git + +jobs: + conan-with-gcc: + name: Conan + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + version: [2.4.1, 3.0-a.3] + build_type: [Debug, Release] + profile: [gcc] + compiler_version: [10, 11, 12] + with_fmus: ["with_fmus=True", "with_fmus=False"] + channel: ["${{ (github.head_ref || github.ref_name) == 'master' && 'stable' || 'testing' }}"] + container: + image: conanio/gcc${{ matrix.compiler_version }}-ubuntu18.04 + options: -u 0 + steps: + - uses: actions/checkout@v3 + - name: Install prerequisites + run: | + sudo apt-get update + sudo apt-get install -y jq + pip3 install --upgrade setuptools pip + pip3 install --upgrade conan~=2.0 + - name: Configure Conan and package name + run: | + conan remote add sintef ${{ env.CONAN_UPLOAD }} + echo "pkg_name=$(conan inspect -f json . | jq .name -r)" >> $GITHUB_ENV + - name: Conan create + run: | + git config --global --add safe.directory '*' + conan config install ${{ env.CONFIG_URL }} --type git -sf conan2.0 + conan config install ${{ env.CONFIG_URL }} --type git -sf profiles -tf profiles + conan create -s build_type=${{ matrix.build_type }} \ + -s compiler.version=${{ matrix.compiler_version }} \ + -pr:b=${{ matrix.profile }} -pr:h=${{ matrix.profile }} \ + --conf tools.build:skip_test=False \ + -o ${{ env.pkg_name }}/*:${{ matrix.with_fmus }} \ + --version ${{ matrix.version }} --user sintef --channel ${{ matrix.channel }} \ + -b missing -b outdated -b ${{ env.pkg_name }}* . + - name: Conan upload + run: conan upload --confirm -r sintef ${{ env.pkg_name }}* --force diff --git a/.github/workflows/ci-conan-msvc.yml b/.github/workflows/ci-conan-msvc.yml new file mode 100755 index 0000000..7262fa3 --- /dev/null +++ b/.github/workflows/ci-conan-msvc.yml @@ -0,0 +1,48 @@ +--- +name: Windows MSVC + +on: [push, workflow_dispatch] + +env: + CONAN_UPLOAD: ${{ secrets.CONAN_URL }} + CONAN_PASSWORD_SINTEF: ${{ secrets.CONAN_PASSWORD }} + CONAN_LOGIN_USERNAME_SINTEF: ${{ secrets.CONAN_USER }} + CONFIG_URL: https://github.com/sintef-ocean/conan-configs.git + +jobs: + conan-with-msvc: + name: Conan + runs-on: windows-2022 + strategy: + fail-fast: false + matrix: + version: [2.4.1, 3.0-a.3] + build_type: [Debug, Release] + profile: [msvc17] + compiler_version: [192, 193] + with_fmus: ["with_fmus=True", "with_fmus=False"] + channel: ["${{ (github.head_ref || github.ref_name) == 'master' && 'stable' || 'testing' }}"] + steps: + - uses: actions/checkout@v4 + - name: Install prerequisites + run: | + pip3 install --upgrade setuptools pip + pip3 install --upgrade conan~=2.0 + - name: Configure Conan + run: | + conan remote add sintef ${{ env.CONAN_UPLOAD }} + $pkg_name=conan inspect -f json . | jq .name -r + echo "pkg_name=$pkg_name" >> $Env:GITHUB_ENV + - name: Conan create + run: | + conan config install ${{ env.CONFIG_URL }} --type git -sf conan2.0 + conan config install ${{ env.CONFIG_URL }} --type git -sf profiles -tf profiles + conan create -s build_type=${{ matrix.build_type }} ` + -s compiler.version=${{ matrix.compiler_version }} ` + -pr:b=${{ matrix.profile }} -pr:h=${{ matrix.profile }} ` + --conf tools.build:skip_test=False ` + -o ${{ env.pkg_name }}/*:${{ matrix.with_fmus }} ` + --version ${{ matrix.version }} --user sintef --channel ${{ matrix.channel }} ` + -b missing -b outdated -b ${{ env.pkg_name }}* . + - name: Conan upload + run: conan upload --confirm -r sintef ${{ env.pkg_name }}* --force diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad5c0b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*~ +test_package/build/ +*.pyc +*.swp +*.swo +__pycache__ +temp/ +CMakeUserPresets.json +build/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e880c98 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +[![Linux GCC](https://github.com/sintef-ocean/conan-fmilibrary/workflows/Linux%20GCC/badge.svg)](https://github.com/sintef-ocean/conan-fmilibrary/actions?query=workflow%3A"Linux+GCC") +[![Windows MSVC](https://github.com/sintef-ocean/conan-fmilibrary/workflows/Windows%20MSVC/badge.svg)](https://github.com/sintef-ocean/conan-fmilibrary/actions?query=workflow%3A"Windows+MSVC") + +[Conan.io](https://conan.io) recipe for [fmi-library](https://github.com/modelon-community/fmi-library). + +## How to use this package + +1. Add remote to conan's package [remotes](https://docs.conan.io/2/reference/commands/remote.html) + + ```bash + $ conan remote add sintef https://artifactory.smd.sintef.no/artifactory/api/conan/conan-local + ``` + +2. Using [*conanfile.txt*](https://docs.conan.io/2/reference/conanfile_txt.html) and *cmake* in your project. + + Add *conanfile.txt*: + ``` + [requires] + fmilib/2.4.1@sintef/stable + + [options] + fmilib:with_fmus=True + + [tool_requires] + cmake/[>=3.25.0] + + [layout] + cmake_layout + + [generators] + CMakeDeps + CMakeToolchain + VirtualBuildEnv + + ``` + Insert into your *CMakeLists.txt* something like the following lines: + ```cmake + cmake_minimum_required(VERSION 3.15) + project(TheProject CXX) + + find_package(fmilib REQUIRED) + + add_executable(the_executor code.cpp) + target_link_libraries(the_executor fmilibrary::fmilibrary) + ``` + Install and build e.g. a Release configuration (linux): + ```bash + $ conan install . -s build_type=Release -pr:b=default + $ source build/Release/generators/conanbuild.sh + $ cmake --preset conan-release + $ cmake --build build/Release + $ source build/Release/generators/deactivate_conanbuild.sh + ``` + +## Package options + +| Option | Allowed values | Default | +|-----------|----------------|---------| +| shared | [True, False] | False | +| fPIC | [True, False] | True | +| with_fmus | [True, False] | False | + +## Known recipe issues diff --git a/conandata.yml b/conandata.yml new file mode 100644 index 0000000..7c33dcf --- /dev/null +++ b/conandata.yml @@ -0,0 +1,48 @@ +sources: + "3.0-a.3": + url: + - "https://github.com/modelon-community/fmi-library/archive/refs/tags/3.0a3.tar.gz" + sha256: "bd9eeccc0a43e3a4acd1e03d864f8d53d42fad3ea1a3d4aef2f7e91eace5dea0" + "2.4.1": + url: + - "https://github.com/modelon-community/fmi-library/archive/refs/tags/2.4.1.tar.gz" + sha256: "8199d3e9423494b714b9c4e42f055248457a7c9162df3d4652000aa9a10b8316" +patches: + "3.0-a.3": + - patch_file: "patches/3.0-a.3-001-conanize-build-scripts.patch" + patch_description: "Conanize build scripts to externalize dependencies" + patch_type: "conan" + - patch_file: "patches/2.4.1-002-add-minizip-tools-as-functions.patch" + patch_description: "Add minizip and miniunz as functions instead of executables" + patch_type: "conan" + - patch_file: "patches/3.0-a.3-003-use-catch2-from-conan.patch" + patch_description: "Use conan catch2 over bundled variant" + patch_type: "conan" + - patch_file: "patches/3.0-a.3-004-build-static-c99-snprintf.patch" + patch_description: "Always build c99snprintf as static library" + patch_type: "bugfix" + patch_source: "https://github.com/open-simulation-platform/conan-fmilibrary/blob/master/build-static-c99snprintf.patch" + "2.4.1": + - patch_file: "patches/2.4.1-001-static-c99snprintf.patch" + patch_description: "Always build c99snprintf as static library" + patch_type: "bugfix" + patch_source: "https://github.com/open-simulation-platform/conan-fmilibrary/blob/master/build-static-c99snprintf.patch" + - patch_file: "patches/2.4.1-002-add-minizip-tools-as-functions.patch" + patch_description: "Add minizip and miniunz as functions instead of executables" + patch_type: "conan" + - patch_file: "patches/2.4.1-003-use-expat-from-conan.patch" + patch_description: "Use expat from conan instead of internal" + patch_type: "conan" + - patch_file: "patches/2.4.1-004-use-minizip-and-zlib-from-conan.patch" + patch_description: "Use minizip (and zlib) from conan instead of internal" + patch_type: "conan" + - patch_file: "patches/2.4.1-005-ensure-conan-friendly-cmakelists.patch" + patch_description: "Do minor changes to CMakeLists for conan friendliness" + patch_type: "conan" + - patch_file: "patches/2.4.1-006-link-external-targets.patch" + patch_description: "Link external targets no longer merged in fmilib" + patch_type: "conan" + - patch_file: "patches/2.4.1-007-add-missing-stdlib.h-include.patch" + patch_description: "exit() is defined in stdlib.h" + patch_type: "bugfix" + patch_source: "https://github.com/modelon-community/fmi-library/issues/95" diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..a8ab123 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,172 @@ +from os import path +import posixpath +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.build import check_min_cppstd +from conan.tools.microsoft import is_msvc_static_runtime, is_msvc +from conan.tools.files import ( + apply_conandata_patches, export_conandata_patches, + get, copy, rename, rm, rmdir + ) +from conan.tools.scm import Version +from conan.tools.env import Environment +from conan.tools.env import VirtualRunEnv +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +required_conan_version = ">=1.53.0" + + +class PackageConan(ConanFile): + name = "fmilib" + description = "C library for importing FMUs" + license = "BSD-3-Clause" + url = "https://github.com/sintef-ocean/conan-fmilibrary" + homepage = "https://github.com/modelon-community/fmi-library" + topics = ("fmi", "fmi-standard", "fmu") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_fmus": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_fmus": False + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("fmi1/1.0.1") + self.requires("fmi2/2.0.4") + if Version(self.version).major > 2: + self.requires("fmi3/3.0.1") + self.requires("expat/2.6.2") + self.requires("minizip/1.3.1") + self.requires("zlib/[>=1.2.11 <2]") + # c99_snprintf -> should be externalised + + def build_requirements(self): + if Version(self.version).major > 2 and self.options.with_fmus: + self.test_requires("catch2/2.13.10") + + def validate(self): + # https://github.com/modelon-community/fmi-library/issues/93 + if self.settings.arch not in ["x86", "x86_64"] and Version(self.version).major < 3: + raise ConanInvalidConfiguration( + f"{self.ref} does not support architecture " + f"'{self.settings.arch}' on {self.settings.os}") + + if Version(self.version).major > 2 and self.options.with_fmus: + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + + tc = CMakeToolchain(self) + tc.variables["FMILIB_BUILD_STATIC_LIB"] = not self.options.shared + tc.variables["FMILIB_BUILD_SHARED_LIB"] = self.options.shared + tc.variables["FMILIB_BUILD_TESTS"] = self.options.with_fmus + tc.variables["FMILIB_FMI_STANDARD_HEADERS"] = posixpath.join(self.build_folder, "fmis").replace("\\", "/") + tc.variables["FMILIB_GENERATE_DOXYGEN_DOC"] = False + tc.variables["FMILIB_FIND_PACKAGE_ZLIB"] = True + + # The variable is an option only if the following condition is true + if not self.options.shared and not self.settings.os in ["Windows", "Macos"]: + tc.variables["FMILIB_BUILD_FOR_SHARED_LIBS"] = self.options.get_safe("fPIC", False) + + if is_msvc(self): + tc.variables["FMILIB_BUILD_WITH_STATIC_RTLIB"] = is_msvc_static_runtime(self) + + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0026"] = "OLD" + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0045"] = "OLD" + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0046"] = "OLD" + + tc.generate() + + cd = CMakeDeps(self) + cd.generate() + + vre = VirtualRunEnv(self) + vre.generate(scope="build") + + def build(self): + apply_conandata_patches(self) + + copy(self, "fmiModel*.h", self.dependencies["fmi1"].cpp_info.components["modex"].includedirs[0], + path.join(self.build_folder, "fmis", "FMI1")) + copy(self, "fmiPlatformTypes.h", self.dependencies["fmi1"].cpp_info.components["cosim"].includedirs[0], + path.join(self.build_folder, "fmis", "FMI1")) + copy(self, "fmiFunctions.h", self.dependencies["fmi1"].cpp_info.components["cosim"].includedirs[0], + path.join(self.build_folder, "fmis", "FMI1")) + copy(self, "*.h", self.dependencies["fmi2"].cpp_info.includedirs[0], + path.join(self.build_folder, "fmis", "FMI2")) + if Version(self.version).major > 2: + copy(self, "*.h", self.dependencies["fmi3"].cpp_info.includedirs[0], + path.join(self.build_folder, "fmis", "FMI3")) + + cmake = CMake(self) + cmake.configure() + cmake.build() + + if not self.conf.get("tools.build:skip_test", default=True): + env = Environment() + env.define("CTEST_OUTPUT_ON_FAILURE", "ON") + with env.vars(self).apply(): + cmake.test() + + def package(self): + copy(self, pattern="LICENSE.md", dst=path.join(self.package_folder, "licenses"), + src=self.source_folder) + copy(self, pattern="FMILIB_Acknowledgements.txt", + dst=path.join(self.package_folder, "licenses"), + src=self.source_folder) + copy(self, pattern="*.fmu", dst=path.join(self.package_folder, "res", "fmus"), + src=path.join(self.build_folder, "Testing"), keep_path=False) + + cmake = CMake(self) + cmake.install() + + copy(self, pattern="*.dll", dst=path.join(self.package_folder, "bin"), + src=path.join(self.package_folder, "lib"), keep_path=False) + rm(self, "*.dll", path.join(self.package_folder, "lib")) + + fix_apple_shared_install_name(self) + + rmdir(self, path.join(self.package_folder, "doc")) + + def package_info(self): + if self.options.shared: + self.cpp_info.libs = ["fmilib_shared"] + else: + self.cpp_info.libs = ["fmilib"] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("dl") + + if self.settings.os in ["Windows"]: + self.cpp_info.system_libs.append("shlwapi") + + self.cpp_info.resdirs = ["res"] + self.cpp_info.set_property("cmake_target_aliases", ["fmilibrary::fmilibrary"]) diff --git a/patches/2.4.1-001-static-c99snprintf.patch b/patches/2.4.1-001-static-c99snprintf.patch new file mode 100644 index 0000000..e9a5302 --- /dev/null +++ b/patches/2.4.1-001-static-c99snprintf.patch @@ -0,0 +1,25 @@ +From e4ad54090e455289ac23a45867b17c8dca88e704 Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Tue, 19 Sep 2023 08:59:53 +0200 +Subject: [PATCH] Link c99snprintf statically + +--- + ThirdParty/c99_snprintf/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ThirdParty/c99_snprintf/CMakeLists.txt b/ThirdParty/c99_snprintf/CMakeLists.txt +index 6f513b4..6c9b676 100644 +--- a/ThirdParty/c99_snprintf/CMakeLists.txt ++++ b/ThirdParty/c99_snprintf/CMakeLists.txt +@@ -119,7 +119,7 @@ add_definitions(${DEFINES}) + + file(WRITE ${CMAKE_BINARY_DIR}/c99snprintf_defs "${DEFINES}") + +-add_library(c99snprintf c99-snprintf_1.1/snprintf.c) ++add_library(c99snprintf STATIC c99-snprintf_1.1/snprintf.c) + + if(CYGWIN) + message("not tested") +-- +2.30.2 + diff --git a/patches/2.4.1-002-add-minizip-tools-as-functions.patch b/patches/2.4.1-002-add-minizip-tools-as-functions.patch new file mode 100644 index 0000000..e858d71 --- /dev/null +++ b/patches/2.4.1-002-add-minizip-tools-as-functions.patch @@ -0,0 +1,1265 @@ +From 150530fed42e0193f0ccac73971bdce2d277b368 Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Thu, 7 Dec 2023 15:42:49 +0100 +Subject: [PATCH 1/6] add minizip tools as functions + +--- + src/ZIP/include/miniunz.h | 11 + + src/ZIP/include/minizip.h | 12 + + src/ZIP/src/miniunz.c | 670 ++++++++++++++++++++++++++++++++++++++ + src/ZIP/src/minizip.c | 529 ++++++++++++++++++++++++++++++ + 4 files changed, 1222 insertions(+) + create mode 100644 src/ZIP/include/miniunz.h + create mode 100644 src/ZIP/include/minizip.h + create mode 100644 src/ZIP/src/miniunz.c + create mode 100644 src/ZIP/src/minizip.c + +diff --git a/src/ZIP/include/miniunz.h b/src/ZIP/include/miniunz.h +new file mode 100644 +index 0000000..d958b3d +--- /dev/null ++++ b/src/ZIP/include/miniunz.h +@@ -0,0 +1,11 @@ ++#ifndef MINIUNZ_H ++#define MINIUNZ_H ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++ int miniunz(int argc , char *argv[]); /* Renamed the main function */ ++#ifdef __cplusplus ++} ++#endif ++#endif /* End of header file MINIUNZ_H */ +diff --git a/src/ZIP/include/minizip.h b/src/ZIP/include/minizip.h +new file mode 100644 +index 0000000..767dbde +--- /dev/null ++++ b/src/ZIP/include/minizip.h +@@ -0,0 +1,12 @@ ++#ifndef MINIZIP_H ++#define MINIZIP_H ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++ int minizip(int argc , char *argv[]); /* Renamed the main function */ ++ ++#ifdef __cplusplus ++} ++#endif ++#endif /* End of header file MINIZIP_H */ +diff --git a/src/ZIP/src/miniunz.c b/src/ZIP/src/miniunz.c +new file mode 100644 +index 0000000..7a73f6a +--- /dev/null ++++ b/src/ZIP/src/miniunz.c +@@ -0,0 +1,670 @@ ++/* ++ miniunz.c ++ Version 1.1, February 14h, 2010 ++ sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) ++ ++ Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) ++ ++ Modifications of Unzip for Zip64 ++ Copyright (C) 2007-2008 Even Rouault ++ ++ Modifications for Zip64 support on both zip and unzip ++ Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) ++*/ ++ ++#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) ++ #ifndef __USE_FILE_OFFSET64 ++ #define __USE_FILE_OFFSET64 ++ #endif ++ #ifndef __USE_LARGEFILE64 ++ #define __USE_LARGEFILE64 ++ #endif ++ #ifndef _LARGEFILE64_SOURCE ++ #define _LARGEFILE64_SOURCE ++ #endif ++ #ifndef _FILE_OFFSET_BIT ++ #define _FILE_OFFSET_BIT 64 ++ #endif ++#endif ++ ++#ifdef __APPLE__ ++// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions ++#define FOPEN_FUNC(filename, mode) fopen(filename, mode) ++#define FTELLO_FUNC(stream) ftello(stream) ++#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) ++#else ++#define FOPEN_FUNC(filename, mode) fopen64(filename, mode) ++#define FTELLO_FUNC(stream) ftello64(stream) ++#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) ++#endif ++ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifdef _WIN32 ++# include ++# include ++#else ++# include ++# include ++#include ++#include ++#endif ++ ++ ++#include "unzip.h" ++ ++#define CASESENSITIVITY (0) ++#define WRITEBUFFERSIZE (8192) ++#define MAXFILENAME (256) ++ ++#ifdef _WIN32 ++#define USEWIN32IOAPI ++#include "iowin32.h" ++#endif ++ ++/* MODIFICATION Replace all stdout prints with this function for better control */ ++static int minizip_printf( const char * format, ... ) ++{ ++ return 1; ++} ++ ++/* ++ mini unzip, demo of unzip package ++ ++ usage : ++ Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir] ++ ++ list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT ++ if it exists ++*/ ++ ++ ++/* change_file_date : change the date/time of a file ++ filename : the filename of the file where date/time must be modified ++ dosdate : the new date at the MSDos format (4 bytes) ++ tmu_date : the SAME new date at the tm_unz format */ ++void change_file_date(filename,dosdate,tmu_date) ++ const char *filename; ++ uLong dosdate; ++ tm_unz tmu_date; ++{ ++#ifdef _WIN32 ++ HANDLE hFile; ++ FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; ++ ++ hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE, ++ 0,NULL,OPEN_EXISTING,0,NULL); ++ GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); ++ DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); ++ LocalFileTimeToFileTime(&ftLocal,&ftm); ++ SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); ++ CloseHandle(hFile); ++#else ++#if defined(__unix) || defined(__APPLE__) ++ (void)dosdate; ++ struct utimbuf ut; ++ struct tm newdate; ++ newdate.tm_sec = tmu_date.tm_sec; ++ newdate.tm_min=tmu_date.tm_min; ++ newdate.tm_hour=tmu_date.tm_hour; ++ newdate.tm_mday=tmu_date.tm_mday; ++ newdate.tm_mon=tmu_date.tm_mon; ++ if (tmu_date.tm_year > 1900) ++ newdate.tm_year=tmu_date.tm_year - 1900; ++ else ++ newdate.tm_year=tmu_date.tm_year ; ++ newdate.tm_isdst=-1; ++ ++ ut.actime=ut.modtime=mktime(&newdate); ++ utime(filename,&ut); ++#endif ++#endif ++} ++ ++ ++/* mymkdir and change_file_date are not 100 % portable ++ As I don't know well Unix, I wait feedback for the unix portion */ ++ ++int mymkdir(dirname) ++ const char* dirname; ++{ ++ int ret=0; ++#ifdef _WIN32 ++ ret = _mkdir(dirname); ++#elif __unix ++ ret = mkdir (dirname,0775); ++#elif __APPLE__ ++ ret = mkdir (dirname,0775); ++#else ++#error Unknown platform ++#endif ++ return ret; ++} ++ ++int makedir (newdir) ++ char *newdir; ++{ ++ char *buffer ; ++ char *p; ++ size_t len = strlen(newdir); ++ ++ if (len == 0) ++ return 0; ++ ++ buffer = (char*)malloc(len+1); ++ if (buffer==NULL) ++ { ++ minizip_printf("Error allocating memory\n"); ++ return UNZ_INTERNALERROR; ++ } ++ strcpy(buffer,newdir); ++ ++ if (buffer[len-1] == '/') { ++ buffer[len-1] = '\0'; ++ } ++ if (mymkdir(buffer) == 0) ++ { ++ free(buffer); ++ return 1; ++ } ++ ++ p = buffer+1; ++ while (1) ++ { ++ char hold; ++ ++ while(*p && *p != '\\' && *p != '/') ++ p++; ++ hold = *p; ++ *p = 0; ++ if ((mymkdir(buffer) == -1) && (errno == ENOENT)) ++ { ++ minizip_printf("couldn't create directory %s\n",buffer); ++ free(buffer); ++ return 0; ++ } ++ if (hold == 0) ++ break; ++ *p++ = hold; ++ } ++ free(buffer); ++ return 1; ++} ++ ++static void do_banner() ++{ ++ /*printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); ++ printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");*/ ++} ++ ++static void do_help() ++{ ++ printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ ++ " -e Extract without pathname (junk paths)\n" \ ++ " -x Extract with pathname\n" \ ++ " -v list files\n" \ ++ " -l list files\n" \ ++ " -d directory to extract into\n" \ ++ " -o overwrite files without prompting\n" \ ++ " -p extract crypted file using password\n\n"); ++} ++ ++static void Display64BitsSize(ZPOS64_T n, int size_char) ++{ ++ /* to avoid compatibility problem , we do here the conversion */ ++ char number[21]; ++ int offset=19; ++ int pos_string = 19; ++ number[20]=0; ++ for (;;) { ++ number[offset]=(char)((n%10)+'0'); ++ if (number[offset] != '0') ++ pos_string=offset; ++ n/=10; ++ if (offset==0) ++ break; ++ offset--; ++ } ++ { ++ int size_display_string = 19-pos_string; ++ while (size_char > size_display_string) ++ { ++ size_char--; ++ minizip_printf(" "); ++ } ++ } ++ ++ minizip_printf("%s",&number[pos_string]); ++} ++ ++static int do_list(uf) ++ unzFile uf; ++{ ++ uLong i; ++ unz_global_info64 gi; ++ int err; ++ ++ err = unzGetGlobalInfo64(uf,&gi); ++ if (err!=UNZ_OK) ++ minizip_printf("error %d with zipfile in unzGetGlobalInfo \n",err); ++ minizip_printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); ++ minizip_printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); ++ for (i=0;i0) ++ ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size); ++ ++ /* display a '*' if the file is crypted */ ++ if ((file_info.flag & 1) != 0) ++ charCrypt='*'; ++ ++ if (file_info.compression_method==0) ++ string_method="Stored"; ++ else ++ if (file_info.compression_method==Z_DEFLATED) ++ { ++ uInt iLevel=(uInt)((file_info.flag & 0x6)/2); ++ if (iLevel==0) ++ string_method="Defl:N"; ++ else if (iLevel==1) ++ string_method="Defl:X"; ++ else if ((iLevel==2) || (iLevel==3)) ++ string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ ++ } ++ else ++ if (file_info.compression_method==Z_BZIP2ED) ++ { ++ string_method="BZip2 "; ++ } ++ else ++ string_method="Unkn. "; ++ ++ Display64BitsSize(file_info.uncompressed_size,7); ++ minizip_printf(" %6s%c",string_method,charCrypt); ++ Display64BitsSize(file_info.compressed_size,7); ++ minizip_printf(" %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", ++ ratio, ++ (uLong)file_info.tmu_date.tm_mon + 1, ++ (uLong)file_info.tmu_date.tm_mday, ++ (uLong)file_info.tmu_date.tm_year % 100, ++ (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, ++ (uLong)file_info.crc,filename_inzip); ++ if ((i+1)='a') && (rep<='z')) ++ rep -= 0x20; ++ } ++ while ((rep!='Y') && (rep!='N') && (rep!='A')); ++ } ++ ++ if (rep == 'N') ++ skip = 1; ++ ++ if (rep == 'A') ++ *popt_overwrite=1; ++ } ++ ++ if ((skip==0) && (err==UNZ_OK)) ++ { ++ fout=FOPEN_FUNC(write_filename,"wb"); ++ /* some zipfile don't contain directory alone before file */ ++ if ((fout==NULL) && ((*popt_extract_without_path)==0) && ++ (filename_withoutpath!=(char*)filename_inzip)) ++ { ++ char c=*(filename_withoutpath-1); ++ *(filename_withoutpath-1)='\0'; ++ makedir(write_filename); ++ *(filename_withoutpath-1)=c; ++ fout=FOPEN_FUNC(write_filename,"wb"); ++ } ++ ++ if (fout==NULL) ++ { ++ minizip_printf("error opening %s\n",write_filename); ++ } ++ } ++ ++ if (fout!=NULL) ++ { ++ minizip_printf(" extracting: %s\n",write_filename); ++ ++ do ++ { ++ err = unzReadCurrentFile(uf,buf,size_buf); ++ if (err<0) ++ { ++ minizip_printf("error %d with zipfile in unzReadCurrentFile\n",err); ++ break; ++ } ++ if (err>0) ++ if (fwrite(buf,(unsigned)err,1,fout)!=1) ++ { ++ minizip_printf("error in writing extracted file\n"); ++ err=UNZ_ERRNO; ++ break; ++ } ++ } ++ while (err>0); ++ if (fout) ++ fclose(fout); ++ ++ if (err==0) ++ change_file_date(write_filename,file_info.dosDate, ++ file_info.tmu_date); ++ } ++ ++ if (err==UNZ_OK) ++ { ++ err = unzCloseCurrentFile (uf); ++ if (err!=UNZ_OK) ++ { ++ minizip_printf("error %d with zipfile in unzCloseCurrentFile\n",err); ++ } ++ } ++ else ++ unzCloseCurrentFile(uf); /* don't lose the error */ ++ } ++ ++ free(buf); ++ return err; ++} ++ ++ ++int do_extract(uf,opt_extract_without_path,opt_overwrite,password) ++ unzFile uf; ++ int opt_extract_without_path; ++ int opt_overwrite; ++ const char* password; ++{ ++ uLong i; ++ unz_global_info64 gi; ++ int err; ++ ++ err = unzGetGlobalInfo64(uf,&gi); ++ if (err!=UNZ_OK) ++ minizip_printf("error %d with zipfile in unzGetGlobalInfo \n",err); ++ ++ for (i=0;i ++#include ++#include ++#include ++#include ++#include ++ ++#ifdef _WIN32 ++# include ++# include ++#else ++# include ++# include ++# include ++# include ++#endif ++ ++#include "zip.h" ++ ++#ifdef _WIN32 ++ #define USEWIN32IOAPI ++ #include "iowin32.h" ++#endif ++ ++ ++ ++#define WRITEBUFFERSIZE (16384) ++#define MAXFILENAME (256) ++ ++/* MODIFICATION Replace all stdout prints with this function for better control */ ++static int minizip_printf( const char * format, ... ) ++{ ++ return 1; ++} ++ ++#ifdef _WIN32 ++int filetime(f, tmzip, dt) ++ const char *f; /* name of file to get info on */ ++ tm_zip *tmzip; /* return value: access, modific. and creation times */ ++ uLong *dt; /* dostime */ ++{ ++ int ret = 0; ++ { ++ FILETIME ftLocal; ++ HANDLE hFind; ++ WIN32_FIND_DATAA ff32; ++ ++ hFind = FindFirstFileA(f,&ff32); ++ if (hFind != INVALID_HANDLE_VALUE) ++ { ++ FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); ++ FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); ++ FindClose(hFind); ++ ret = 1; ++ } ++ } ++ return ret; ++} ++#else ++#if defined(__unix) || defined(__APPLE__) ++int filetime(f, tmzip, dt) ++ const char *f; /* name of file to get info on */ ++ tm_zip *tmzip; /* return value: access, modific. and creation times */ ++ uLong *dt; /* dostime */ ++{ ++ (void)dt; ++ int ret=0; ++ struct stat s; /* results of stat() */ ++ struct tm* filedate; ++ time_t tm_t=0; ++ ++ if (strcmp(f,"-")!=0) ++ { ++ char name[MAXFILENAME+1]; ++ size_t len = strlen(f); ++ if (len > MAXFILENAME) ++ len = MAXFILENAME; ++ ++ strncpy(name, f,MAXFILENAME-1); ++ /* strncpy doesnt append the trailing NULL, of the string is too long. */ ++ name[ MAXFILENAME ] = '\0'; ++ ++ if (name[len - 1] == '/') ++ name[len - 1] = '\0'; ++ /* not all systems allow stat'ing a file with / appended */ ++ if (stat(name,&s)==0) ++ { ++ tm_t = s.st_mtime; ++ ret = 1; ++ } ++ } ++ filedate = localtime(&tm_t); ++ ++ tmzip->tm_sec = filedate->tm_sec; ++ tmzip->tm_min = filedate->tm_min; ++ tmzip->tm_hour = filedate->tm_hour; ++ tmzip->tm_mday = filedate->tm_mday; ++ tmzip->tm_mon = filedate->tm_mon ; ++ tmzip->tm_year = filedate->tm_year; ++ ++ return ret; ++} ++#else ++uLong filetime(f, tmzip, dt) ++ const char *f; /* name of file to get info on */ ++ tm_zip *tmzip; /* return value: access, modific. and creation times */ ++ uLong *dt; /* dostime */ ++{ ++ return 0; ++} ++#endif ++#endif ++ ++ ++ ++ ++static int check_exist_file(filename) ++ const char* filename; ++{ ++ FILE* ftestexist; ++ int ret = 1; ++ ftestexist = FOPEN_FUNC(filename,"rb"); ++ if (ftestexist==NULL) ++ ret = 0; ++ else ++ fclose(ftestexist); ++ return ret; ++} ++ ++static void do_banner() ++{ ++ /* ++ minizip_printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n"); ++ minizip_printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n"); ++ */ ++} ++ ++static void do_help() ++{ ++ minizip_printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \ ++ " -o Overwrite existing file.zip\n" \ ++ " -a Append to existing file.zip\n" \ ++ " -0 Store only\n" \ ++ " -1 Compress faster\n" \ ++ " -9 Compress better\n\n" \ ++ " -j exclude path. store only the file name.\n\n"); ++} ++ ++/* calculate the CRC32 of a file, ++ because to encrypt a file, we need known the CRC32 of the file before */ ++int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) ++{ ++ unsigned long calculate_crc=0; ++ int err=ZIP_OK; ++ FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); ++ ++ unsigned long size_read = 0; ++ /* unsigned long total_read = 0; */ ++ if (fin==NULL) ++ { ++ err = ZIP_ERRNO; ++ } ++ ++ if (err == ZIP_OK) ++ do ++ { ++ err = ZIP_OK; ++ size_read = fread(buf,1,size_buf,fin); ++ if (size_read < size_buf) ++ if (feof(fin)==0) ++ { ++ minizip_printf("error in reading %s\n",filenameinzip); ++ err = ZIP_ERRNO; ++ } ++ ++ if (size_read>0) ++ calculate_crc = crc32_z(calculate_crc,buf,size_read); ++ /* total_read += size_read; */ ++ ++ } while ((err == ZIP_OK) && (size_read>0)); ++ ++ if (fin) ++ fclose(fin); ++ ++ *result_crc=calculate_crc; ++ minizip_printf("file %s crc %lx\n", filenameinzip, calculate_crc); ++ return err; ++} ++ ++int isLargeFile(const char* filename) ++{ ++ int largeFile = 0; ++ ZPOS64_T pos = 0; ++ FILE* pFile = FOPEN_FUNC(filename, "rb"); ++ ++ if(pFile != NULL) ++ { ++ FSEEKO_FUNC(pFile, 0, SEEK_END); ++ pos = (ZPOS64_T)FTELLO_FUNC(pFile); ++ ++ minizip_printf("File : %s is %lld bytes\n", filename, pos); ++ ++ if(pos >= 0xffffffff) ++ largeFile = 1; ++ ++ fclose(pFile); ++ } ++ ++ return largeFile; ++} ++ ++int minizip(argc,argv) ++ int argc; ++ char *argv[]; ++{ ++ int i; ++ int opt_overwrite=0; ++ int opt_compress_level=Z_DEFAULT_COMPRESSION; ++ int opt_exclude_path=0; ++ int zipfilenamearg = 0; ++ char filename_try[MAXFILENAME+16]; ++ int zipok; ++ int err=0; ++ size_t size_buf=0; ++ void* buf=NULL; ++ const char* password=NULL; ++ ++ ++ do_banner(); ++ if (argc==1) ++ { ++ do_help(); ++ return 0; ++ } ++ else ++ { ++ for (i=1;i='0') && (c<='9')) ++ opt_compress_level = c-'0'; ++ if ((c=='j') || (c=='J')) ++ opt_exclude_path = 1; ++ ++ if (((c=='p') || (c=='P')) && (i+1='a') && (rep<='z')) ++ rep -= 0x20; ++ } ++ while ((rep!='Y') && (rep!='N') && (rep!='A')); ++ if (rep=='N') ++ zipok = 0; ++ if (rep=='A') ++ opt_overwrite = 2; ++ } ++ } ++ ++ if (zipok==1) ++ { ++ zipFile zf; ++ int errclose; ++# ifdef USEWIN32IOAPI ++ zlib_filefunc64_def ffunc; ++ fill_win32_filefunc64A(&ffunc); ++ zf = zipOpen2_64(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc); ++# else ++ zf = zipOpen64(filename_try,(opt_overwrite==2) ? 2 : 0); ++# endif ++ ++ if (zf == NULL) ++ { ++ minizip_printf("error opening %s\n",filename_try); ++ err= ZIP_ERRNO; ++ } ++ else ++ minizip_printf("creating %s\n",filename_try); ++ ++ for (i=zipfilenamearg+1;(i='0') || (argv[i][1]<='9'))) && ++ (strlen(argv[i]) == 2))) ++ { ++ FILE * fin; ++ size_t size_read; ++ const char* filenameinzip = argv[i]; ++ const char *savefilenameinzip; ++ zip_fileinfo zi; ++ unsigned long crcFile=0; ++ int zip64 = 0; ++ ++ zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = ++ zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; ++ zi.dosDate = 0; ++ zi.internal_fa = 0; ++ zi.external_fa = 0; ++ filetime(filenameinzip,&zi.tmz_date,&zi.dosDate); ++ ++/* ++ err = zipOpenNewFileInZip(zf,filenameinzip,&zi, ++ NULL,0,NULL,0,NULL / * comment * /, ++ (opt_compress_level != 0) ? Z_DEFLATED : 0, ++ opt_compress_level); ++*/ ++ if ((password != NULL) && (err==ZIP_OK)) ++ err = getFileCrc(filenameinzip,buf,size_buf,&crcFile); ++ ++ zip64 = isLargeFile(filenameinzip); ++ ++ /* The path name saved, should not include a leading slash. */ ++ /*if it did, windows/xp and dynazip couldn't read the zip file. */ ++ savefilenameinzip = filenameinzip; ++ while( savefilenameinzip[0] == '\\' || savefilenameinzip[0] == '/' ) ++ { ++ savefilenameinzip++; ++ } ++ ++ /*should the zip file contain any path at all?*/ ++ if( opt_exclude_path ) ++ { ++ const char *tmpptr; ++ const char *lastslash = 0; ++ for( tmpptr = savefilenameinzip; *tmpptr; tmpptr++) ++ { ++ if( *tmpptr == '\\' || *tmpptr == '/') ++ { ++ lastslash = tmpptr; ++ } ++ } ++ if( lastslash != NULL ) ++ { ++ savefilenameinzip = lastslash+1; /* base filename follows last slash. */ ++ } ++ } ++ ++ /**/ ++ err = zipOpenNewFileInZip3_64(zf,savefilenameinzip,&zi, ++ NULL,0,NULL,0,NULL /* comment*/, ++ (opt_compress_level != 0) ? Z_DEFLATED : 0, ++ opt_compress_level,0, ++ /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */ ++ -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, ++ password,crcFile, zip64); ++ ++ if (err != ZIP_OK) ++ minizip_printf("error in opening %s in zipfile\n",filenameinzip); ++ else ++ { ++ fin = FOPEN_FUNC(filenameinzip,"rb"); ++ if (fin==NULL) ++ { ++ err=ZIP_ERRNO; ++ minizip_printf("error in opening %s for reading\n",filenameinzip); ++ } ++ } ++ ++ if (err == ZIP_OK) ++ do ++ { ++ err = ZIP_OK; ++ size_read = fread(buf,1,size_buf,fin); ++ if (size_read < size_buf) ++ if (feof(fin)==0) ++ { ++ minizip_printf("error in reading %s\n",filenameinzip); ++ err = ZIP_ERRNO; ++ } ++ ++ if (size_read>0) ++ { ++ err = zipWriteInFileInZip (zf,buf,(unsigned)size_read); ++ if (err<0) ++ { ++ minizip_printf("error in writing %s in the zipfile\n", ++ filenameinzip); ++ } ++ ++ } ++ } while ((err == ZIP_OK) && (size_read>0)); ++ ++ if (fin) ++ fclose(fin); ++ ++ if (err<0) ++ err=ZIP_ERRNO; ++ else ++ { ++ err = zipCloseFileInZip(zf); ++ if (err!=ZIP_OK) ++ minizip_printf("error in closing %s in the zipfile\n", ++ filenameinzip); ++ } ++ } ++ } ++ errclose = zipClose(zf,NULL); ++ if (errclose != ZIP_OK) ++ minizip_printf("error in closing %s\n",filename_try); ++ } ++ else ++ { ++ do_help(); ++ } ++ ++ free(buf); ++ return 0; ++} +-- +2.30.2 + diff --git a/patches/2.4.1-003-use-expat-from-conan.patch b/patches/2.4.1-003-use-expat-from-conan.patch new file mode 100644 index 0000000..054b820 --- /dev/null +++ b/patches/2.4.1-003-use-expat-from-conan.patch @@ -0,0 +1,110 @@ +From e35f4b274bf51228e3928491d7205350a0593280 Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Thu, 7 Dec 2023 15:43:28 +0100 +Subject: [PATCH 2/6] use expat from conan + +--- + Config.cmake/fmixml.cmake | 81 ++------------------------------------- + 1 file changed, 3 insertions(+), 78 deletions(-) + +diff --git a/Config.cmake/fmixml.cmake b/Config.cmake/fmixml.cmake +index ddd3c1f..7aa7ffa 100644 +--- a/Config.cmake/fmixml.cmake ++++ b/Config.cmake/fmixml.cmake +@@ -137,83 +137,8 @@ set(FMIXMLSOURCE + src/FMI2/fmi2_xml_variable.c + ) + +-include(ExternalProject) +- +-# The *_POSTFIX variables are set because it makes it easier to determine the name of +-# the lib expat will produce at configure time. Note that Expat has some special handling +-# for it for MSVC which this in effect negates. https://github.com/libexpat/libexpat/pull/316 +-set(EXPAT_SETTINGS +- -DEXPAT_BUILD_TOOLS:BOOLEAN=OFF +- -DEXPAT_BUILD_EXAMPLES:BOOLEAN=OFF +- -DEXPAT_BUILD_TESTS:BOOLEAN=OFF +- -DEXPAT_SHARED_LIBS:BOOLEAN=OFF +- -DEXPAT_DTD:BOOLEAN=OFF +- -DEXPAT_NS:BOOLEAN=OFF +- -DEXPAT_MSVC_STATIC_CRT:BOOLEAN=${FMILIB_BUILD_WITH_STATIC_RTLIB} +- -DCMAKE_DEBUG_POSTFIX:STRING= +- -DCMAKE_RELEASE_POSTFIX:STRING= +- -DCMAKE_MINSIZEREL_POSTFIX:STRING= +- -DCMAKE_RELWITHDEBINFO_POSTFIX:STRING= +- -DCMAKE_POSITION_INDEPENDENT_CODE:BOOLEAN=ON +- -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} +- -DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} +- -DCMAKE_LINK_LIBRARY_FLAG:STRING=${CMAKE_LINK_LIBRARY_FLAG} +- -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS} +- -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} +- -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/ExpatEx/install +-) +- +-ExternalProject_Add( +- expatex +- PREFIX "${FMIXML_EXPAT_DIR}" +- SOURCE_DIR "${FMIXML_EXPAT_DIR}" +- CMAKE_CACHE_ARGS ${EXPAT_SETTINGS} +- BINARY_DIR ${CMAKE_BINARY_DIR}/ExpatEx +- INSTALL_DIR ${CMAKE_BINARY_DIR}/ExpatEx/install +- TMP_DIR ${CMAKE_BINARY_DIR}/ExpatEx/tmp +- STAMP_DIR ${CMAKE_BINARY_DIR}/ExpatEx/stamp +-) +- +-ExternalProject_Add_Step( +- expatex dependent_reconfigure +- DEPENDEES configure +- DEPENDERS build +- COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${EXPAT_SETTINGS} ${FMIXML_EXPAT_DIR}" +- COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${EXPAT_SETTINGS} "${FMIXML_EXPAT_DIR}" +- DEPENDS ${CMAKE_BINARY_DIR}/CMakeCache.txt +- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ExpatEx +-) +- +-add_dependencies(expatex ${CMAKE_BINARY_DIR}/CMakeCache.txt ${FMILIBRARYHOME}/CMakeLists.txt) +- +- +-if(MSVC) +- # Expat uses special naming with MSVC, which is mirrored here. +- set(EXPAT_LIB_PREFIX lib) +-else() +- set(EXPAT_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX}) +-endif() +- +-set(expatlib "${CMAKE_BINARY_DIR}/ExpatEx/${CMAKE_CFG_INTDIR}/${EXPAT_LIB_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}") +- +-add_library(expat STATIC IMPORTED) +- +-set_target_properties( +- expat PROPERTIES +- IMPORTED_LOCATION "${expatlib}" +-) +- +-add_dependencies(expat expatex) +- +-if(FMILIB_INSTALL_SUBLIBS) +- install(FILES +- "${CMAKE_BINARY_DIR}/ExpatEx/install/lib/${CMAKE_STATIC_LIBRARY_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}" +- DESTINATION lib) +-endif() +- +-set(EXPAT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ExpatEx/install/include) +- +-include_directories("${EXPAT_INCLUDE_DIRS}" "${FMILIB_THIRDPARTYLIBS}/FMI/" "${FMIXMLGENDIR}/FMI1" "${FMIXMLGENDIR}/FMI2") ++find_package(expat CONFIG REQUIRED) ++include_directories("${FMILIB_THIRDPARTYLIBS}/FMI/" "${FMIXMLGENDIR}/FMI1" "${FMIXMLGENDIR}/FMI2") + + PREFIXLIST(FMIXMLSOURCE ${FMIXMLDIR}/) + PREFIXLIST(FMIXMLHEADERS ${FMIXMLDIR}/) +@@ -232,6 +157,6 @@ if(MSVC) + target_compile_definitions(fmixml PUBLIC XML_STATIC) + endif() + +-target_link_libraries(fmixml ${JMUTIL_LIBRARIES} expat) ++target_link_libraries(fmixml ${JMUTIL_LIBRARIES} expat::expat) + + endif(NOT FMIXMLDIR) +-- +2.30.2 + diff --git a/patches/2.4.1-004-use-minizip-and-zlib-from-conan.patch b/patches/2.4.1-004-use-minizip-and-zlib-from-conan.patch new file mode 100644 index 0000000..05a8c56 --- /dev/null +++ b/patches/2.4.1-004-use-minizip-and-zlib-from-conan.patch @@ -0,0 +1,56 @@ +From e006938706d06379f899edbe3fc8fe2367fec1f6 Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Thu, 7 Dec 2023 15:44:54 +0100 +Subject: [PATCH 3/6] use minizip and zlib from conan + +--- + Config.cmake/fmizip.cmake | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +diff --git a/Config.cmake/fmizip.cmake b/Config.cmake/fmizip.cmake +index 091fc4d..213b5f8 100644 +--- a/Config.cmake/fmizip.cmake ++++ b/Config.cmake/fmizip.cmake +@@ -19,28 +19,33 @@ if(NOT FMIZIPDIR) + # set(DOXYFILE_EXTRA_SOURCES "${DOXYFILE_EXTRA_SOURCES} \"${FMIZIPDIR}/include\"") + + set(FMIZIP_LIBRARIES fmizip) +- +- add_subdirectory(Config.cmake/Minizip) +- +- include_directories("${FMIZIPDIR}/include" "${FMILIB_THIRDPARTYLIBS}/Minizip/minizip" "${FMILIB_THIRDPARTYLIBS}/FMI" "${FMILIB_THIRDPARTYLIBS}/Zlib/zlib-1.2.6" "${FMILibrary_BINARY_DIR}/zlib") ++ ++ #add_subdirectory(Config.cmake/Minizip) ++ ++ include_directories("${FMIZIPDIR}/include" "${FMILIB_THIRDPARTYLIBS}/FMI") + + set(FMIZIPSOURCE + ${FMIZIPDIR}/src/fmi_zip_unzip.c + ${FMIZIPDIR}/src/fmi_zip_zip.c ++ ${FMIZIPDIR}/src/minizip.c ++ ${FMIZIPDIR}/src/miniunz.c + ) + + set(FMIZIPHEADERS + # src/fmi_zip_unzip_impl.h + ${FMIZIPDIR}/include/FMI/fmi_zip_unzip.h + ${FMIZIPDIR}/include/FMI/fmi_zip_zip.h ++ ${FMIZIPDIR}/include/minizip.h ++ ${FMIZIPDIR}/include/miniunz.h + ) + + #include_directories("${FMILIB_THIRDPARTYLIBS}/zlib/lib/VS2005/win32") + +-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DZLIB_STATIC") ++find_package(minizip CONFIG REQUIRED) ++find_package(ZLIB CONFIG REQUIRED) + + add_library(fmizip ${FMILIBKIND} ${FMIZIPSOURCE} ${FMIZIPHEADERS}) + +-target_link_libraries(fmizip minizip jmutils) ++target_link_libraries(fmizip minizip::minizip ZLIB::ZLIB jmutils) + + endif(NOT FMIZIPDIR) +-- +2.30.2 + diff --git a/patches/2.4.1-005-ensure-conan-friendly-cmakelists.patch b/patches/2.4.1-005-ensure-conan-friendly-cmakelists.patch new file mode 100644 index 0000000..5aceb35 --- /dev/null +++ b/patches/2.4.1-005-ensure-conan-friendly-cmakelists.patch @@ -0,0 +1,34 @@ +From 698a0134e382e3f82d8ae3f06cbbeb3ad7fc9873 Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Thu, 7 Dec 2023 15:45:38 +0100 +Subject: [PATCH 4/6] ensure conan friendly cmakelists + +--- + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b01aba5..56ca3ee 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -200,7 +200,7 @@ endif() + + add_subdirectory(ThirdParty/c99_snprintf) + +-SET(CMAKE_MODULE_PATH ${FMILIBRARYHOME}/Config.cmake) ++list(APPEND CMAKE_MODULE_PATH ${FMILIBRARYHOME}/Config.cmake) + + include(jmutil) + include(fmixml) +@@ -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}) + +-- +2.30.2 + diff --git a/patches/2.4.1-006-link-external-targets.patch b/patches/2.4.1-006-link-external-targets.patch new file mode 100644 index 0000000..c28f79b --- /dev/null +++ b/patches/2.4.1-006-link-external-targets.patch @@ -0,0 +1,47 @@ +From 306cb206e8a62c82e6cb66e6c2e545980e1a2546 Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Thu, 7 Dec 2023 15:46:12 +0100 +Subject: [PATCH 5/6] link external targets + +--- + Config.cmake/runtime_test.cmake | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Config.cmake/runtime_test.cmake b/Config.cmake/runtime_test.cmake +index d61137f..0765268 100644 +--- a/Config.cmake/runtime_test.cmake ++++ b/Config.cmake/runtime_test.cmake +@@ -26,7 +26,7 @@ endif() + + #Create function that zipz the dummy FMUs + add_executable (compress_test_fmu_zip ${RTTESTDIR}/compress_test_fmu_zip.c) +-target_link_libraries (compress_test_fmu_zip ${FMIZIP_LIBRARIES}) ++target_link_libraries (compress_test_fmu_zip ${FMIZIP_LIBRARIES} minizip::minizip) + + set_target_properties( + jm_vector_test jm_locale_test compress_test_fmu_zip +@@ -116,7 +116,7 @@ function(compress_fmu OUTPUT_FOLDER_T MODEL_IDENTIFIER_T FILE_NAME_CS_ME_EXT_T T + + endfunction(compress_fmu) + +-set(FMILIBFORTEST fmilib) ++set(FMILIBFORTEST fmilib minizip::minizip expat::expat) + + if(FMILIB_BUILD_SHARED_LIB AND (FMILIB_LINK_TEST_TO_SHAREDLIB OR NOT FMILIB_BUILD_STATIC_LIB)) + set(FMILIBFORTEST fmilib_shared) +@@ -128,10 +128,10 @@ endif() + message(STATUS "Tests will be linked with ${FMILIBFORTEST}" ) + + add_executable (fmi_zip_zip_test ${RTTESTDIR}/FMI1/fmi_zip_zip_test.c ) +-target_link_libraries (fmi_zip_zip_test ${FMIZIP_LIBRARIES}) ++target_link_libraries (fmi_zip_zip_test ${FMIZIP_LIBRARIES} minizip::minizip) + + add_executable (fmi_zip_unzip_test ${RTTESTDIR}/FMI1/fmi_zip_unzip_test.c ) +-target_link_libraries (fmi_zip_unzip_test ${FMIZIP_LIBRARIES}) ++target_link_libraries (fmi_zip_unzip_test ${FMIZIP_LIBRARIES} minizip::minizip) + + add_executable (fmi_import_test + ${RTTESTDIR}/fmi_import_test.c +-- +2.30.2 + diff --git a/patches/2.4.1-007-add-missing-stdlib.h-include.patch b/patches/2.4.1-007-add-missing-stdlib.h-include.patch new file mode 100644 index 0000000..8d8ce9b --- /dev/null +++ b/patches/2.4.1-007-add-missing-stdlib.h-include.patch @@ -0,0 +1,23 @@ +From af5133fa4eba5c9eb8338bb4284383183d1ef3cd Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Thu, 7 Dec 2023 15:46:39 +0100 +Subject: [PATCH 6/6] add missing stdlib.h include + +--- + Test/jm_locale_test.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Test/jm_locale_test.c b/Test/jm_locale_test.c +index 5970c65..40f711d 100644 +--- a/Test/jm_locale_test.c ++++ b/Test/jm_locale_test.c +@@ -1,5 +1,6 @@ + #include + #include ++#include + #include + #include + +-- +2.30.2 + diff --git a/patches/3.0-a.3-001-conanize-build-scripts.patch b/patches/3.0-a.3-001-conanize-build-scripts.patch new file mode 100644 index 0000000..3bb8357 --- /dev/null +++ b/patches/3.0-a.3-001-conanize-build-scripts.patch @@ -0,0 +1,168 @@ +From a59c6d32b1b09f6f83667cdff17ec4c556c2fe7f Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Wed, 10 Apr 2024 12:16:31 +0200 +Subject: [PATCH 1/2] Conanize build scripts + +--- + CMakeLists.txt | 7 ++++--- + Config.cmake/fmixml.cmake | 7 +++++-- + Config.cmake/fmizip.cmake | 11 +++++++---- + Config.cmake/runtime_test.cmake | 10 +++++----- + 4 files changed, 21 insertions(+), 14 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3f60635..8018d16 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -46,7 +46,7 @@ set_property(GLOBAL PROPERTY PROPERTYPREDEFINED_TARGETS_FOLDER Global) + set(CMAKE_SOURCE_DIR ${FMILibrary_SOURCE_DIR}) + set(CMAKE_BINARY_DIR ${FMILibrary_BINARY_DIR}) + +-set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Config.cmake) ++list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Config.cmake) + + # User configuration options and parameters + set(FMILIB_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/../install CACHE PATH "Prefix prepended to install directories") +@@ -282,6 +282,7 @@ include(fmizlib) + include(fmizip) + include(fmiimport) + if(FMILIB_BUILD_TESTS) ++ enable_testing() + include(runtime_test) + # Configuration depends on values set in all the different test*.cmake files, + # so can't be done until here. +@@ -291,7 +292,7 @@ if(FMILIB_BUILD_TESTS) + ) + endif() + +-set(FMILIB_SHARED_SUBLIBS fmixml fmizip fmicapi expat minizip zlib c99snprintf) ++set(FMILIB_SHARED_SUBLIBS fmixml fmizip fmicapi c99snprintf) + set(FMILIB_SUBLIBS fmiimport jmutils ${FMILIB_SHARED_SUBLIBS}) + # XXX: Unclear why we create intermediate sublibs instead of just giving everything as source. + # Probably also wouldn't get problems with using PRIVATE/PUBLIC on linking sublibs on Windows. +@@ -462,7 +463,7 @@ if(FMILIB_GENERATE_DOXYGEN_DOC) + + set(DOXYFILE_STRIP_FROM_PATH "${CMAKE_SOURCE_DIR}") + +- set(CMAKE_MODULE_PATH ${FMILIB_THIRDPARTYLIBS}/CMakeModules) ++ list(APPEND CMAKE_MODULE_PATH ${FMILIB_THIRDPARTYLIBS}/CMakeModules) + + include(UseDoxygen/UseDoxygen) + endif(FMILIB_GENERATE_DOXYGEN_DOC) +diff --git a/Config.cmake/fmixml.cmake b/Config.cmake/fmixml.cmake +index 5cb743f..504a3f6 100644 +--- a/Config.cmake/fmixml.cmake ++++ b/Config.cmake/fmixml.cmake +@@ -179,6 +179,7 @@ set(FMIXMLSOURCE + src/FMI3/fmi3_xml_terminals_and_icons.c + ) + ++if(FALSE) + include(ExternalProject) + + # The *_POSTFIX variables are set because it makes it easier to determine the name of +@@ -265,6 +266,9 @@ endif() + + set(EXPAT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ExpatEx/install/include) + ++endif() ++find_package(expat CONFIG REQUIRED) ++ + PREFIXLIST(FMIXMLSOURCE ${FMIXMLDIR}/) + PREFIXLIST(FMIXMLHEADERS ${FMIXMLDIR}/) + +@@ -282,12 +286,11 @@ if(MSVC) + target_compile_definitions(fmixml PUBLIC XML_STATIC) + endif() + target_link_libraries(fmixml +- PRIVATE expat ++ PRIVATE expat::expat + PUBLIC jmutils + ) + target_include_directories(fmixml + PRIVATE +- ${EXPAT_INCLUDE_DIRS} + ${FMILIB_THIRDPARTYLIBS}/FMI/ + ${FMIXMLGENDIR}/FMI1 + ${FMIXMLGENDIR}/FMI2 +diff --git a/Config.cmake/fmizip.cmake b/Config.cmake/fmizip.cmake +index dc83c99..1a68a0f 100644 +--- a/Config.cmake/fmizip.cmake ++++ b/Config.cmake/fmizip.cmake +@@ -18,26 +18,29 @@ include(jmutil) + + # set(DOXYFILE_EXTRA_SOURCES "${DOXYFILE_EXTRA_SOURCES} \"${FMIZIPDIR}/include\"") + +-add_subdirectory(Config.cmake/Minizip) +- + set(FMIZIPSOURCE + ${FMIZIPDIR}/src/fmi_zip_unzip.c + ${FMIZIPDIR}/src/fmi_zip_zip.c ++ ${FMIZIPDIR}/src/minizip.c ++ ${FMIZIPDIR}/src/miniunz.c + ) + + set(FMIZIPHEADERS + ${FMIZIPDIR}/include/FMI/fmi_zip_unzip.h + ${FMIZIPDIR}/include/FMI/fmi_zip_zip.h ++ ${FMIZIPDIR}/include/minizip.h ++ ${FMIZIPDIR}/include/miniunz.h + ) + ++find_package(minizip CONFIG REQUIRED) ++ + add_library(fmizip STATIC ${FMIZIPSOURCE} ${FMIZIPHEADERS}) + target_link_libraries(fmizip +- PRIVATE minizip ++ PRIVATE minizip::minizip + PUBLIC jmutils + ) + target_include_directories(fmizip + PRIVATE +- ${FMILIB_THIRDPARTYLIBS}/Minizip/minizip + ${FMILIB_THIRDPARTYLIBS}/FMI + PUBLIC + ${FMILIB_CONFIG_INCLUDE_DIR} +diff --git a/Config.cmake/runtime_test.cmake b/Config.cmake/runtime_test.cmake +index 5d00e9f..92eaa7d 100644 +--- a/Config.cmake/runtime_test.cmake ++++ b/Config.cmake/runtime_test.cmake +@@ -43,10 +43,10 @@ add_library(fmi_testutil STATIC ${FMIL_TEST_DIR}/fmi_testutil.c) + target_link_libraries(fmi_testutil PRIVATE jmutils) # Uses jm_vector + if(FMILIB_BUILD_SHARED_LIB AND (FMILIB_LINK_TEST_TO_SHAREDLIB OR NOT FMILIB_BUILD_STATIC_LIB)) + set(FMILIBFORTEST fmilib_shared fmi_testutil) +- target_link_libraries(fmi_testutil PRIVATE fmilib_shared) ++ target_link_libraries(fmi_testutil PRIVATE fmilib_shared minizip::minizip expat::expat) + else() + set(FMILIBFORTEST fmilib fmi_testutil) +- target_link_libraries(fmi_testutil PRIVATE fmilib) ++ target_link_libraries(fmi_testutil PRIVATE fmilib minizip::minizip expat::expat) + endif() + + # Convenience: By setting this to PUBLIC, all tests that link with fmi_testutil +@@ -72,7 +72,7 @@ endif() + + #Create function that zips the dummy FMUs + add_executable(compress_test_fmu_zip ${FMIL_TEST_DIR}/compress_test_fmu_zip.c) +-target_link_libraries(compress_test_fmu_zip fmizip) ++target_link_libraries(compress_test_fmu_zip fmizip minizip::minizip) + target_include_directories(compress_test_fmu_zip PRIVATE ${FMIL_TEST_INCLUDE_DIRS}) + + #Path to the executable +@@ -150,11 +150,11 @@ function(compress_fmu OUTPUT_FOLDER_T MODEL_IDENTIFIER_T FILE_NAME_CS_ME_EXT_T T + endfunction(compress_fmu) + + add_executable(fmi_zip_zip_test ${FMIL_TEST_DIR}/fmi_zip_zip_test.c ) +-target_link_libraries(fmi_zip_zip_test fmizip) ++target_link_libraries(fmi_zip_zip_test fmizip minizip::minizip) + target_include_directories(fmi_zip_zip_test PRIVATE ${FMIL_TEST_INCLUDE_DIRS}) + + add_executable(fmi_zip_unzip_test ${FMIL_TEST_DIR}/fmi_zip_unzip_test.c ) +-target_link_libraries(fmi_zip_unzip_test fmizip) ++target_link_libraries(fmi_zip_unzip_test fmizip minizip::minizip) + target_include_directories(fmi_zip_unzip_test PRIVATE ${FMIL_TEST_INCLUDE_DIRS}) + + add_executable(fmi_import_test +-- +2.39.2 + diff --git a/patches/3.0-a.3-003-use-catch2-from-conan.patch b/patches/3.0-a.3-003-use-catch2-from-conan.patch new file mode 100644 index 0000000..9a74583 --- /dev/null +++ b/patches/3.0-a.3-003-use-catch2-from-conan.patch @@ -0,0 +1,37 @@ +From c2ef84513eca09447dabddac4aeb55748ca8736b Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Wed, 10 Apr 2024 12:35:40 +0200 +Subject: [PATCH 2/2] Use catch2 from conan + +--- + Config.cmake/runtime_test.cmake | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/Config.cmake/runtime_test.cmake b/Config.cmake/runtime_test.cmake +index 92eaa7d..05ce84e 100644 +--- a/Config.cmake/runtime_test.cmake ++++ b/Config.cmake/runtime_test.cmake +@@ -195,13 +195,17 @@ add_test(ctest_fmi_zip_zip_test fmi_zip_zip_test) + # ------------------------------------------------------------------------------ + + set(CMAKE_CXX_STANDARD 11) # Required by Catch2 +-add_library(Catch INTERFACE) ++find_package(Catch2 REQUIRED CONFIG) + + # Catch2 consists of only headers, but we still want to compile its main function + # in a separate object file so we don't need to do it for each test. + add_library(catch2_main STATIC ${FMIL_TEST_DIR}/catch2_main.cpp) +-target_link_libraries(catch2_main PUBLIC Catch) +-target_include_directories(catch2_main PUBLIC ${FMILIB_THIRDPARTYLIBS}/Catch2/single_include/catch2) ++target_link_libraries(catch2_main PUBLIC Catch2::Catch2) ++target_compile_features(catch2_main PRIVATE cxx_std_11) ++ ++get_target_property(CUSTOM_CATCH2_INCLUDE Catch2::Catch2 INTERFACE_INCLUDE_DIRECTORIES) ++list(TRANSFORM CUSTOM_CATCH2_INCLUDE APPEND "/catch2") ++target_include_directories(catch2_main PUBLIC ${CUSTOM_CATCH2_INCLUDE}) + + # Creates a Catch2 test. + # +-- +2.39.2 + diff --git a/patches/3.0-a.3-004-build-static-c99-snprintf.patch b/patches/3.0-a.3-004-build-static-c99-snprintf.patch new file mode 100644 index 0000000..3f6c830 --- /dev/null +++ b/patches/3.0-a.3-004-build-static-c99-snprintf.patch @@ -0,0 +1,274 @@ +From 331b2eb08a9cc82ab2ff5024a8acbae4396aec6a Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Wed, 10 Apr 2024 13:04:08 +0200 +Subject: [PATCH] Build static c99_snprintf + +--- + ThirdParty/c99_snprintf/CMakeLists.txt | 257 ++++++++++++------------- + 1 file changed, 128 insertions(+), 129 deletions(-) + +diff --git a/ThirdParty/c99_snprintf/CMakeLists.txt b/ThirdParty/c99_snprintf/CMakeLists.txt +index f3825f9..362c76f 100644 +--- a/ThirdParty/c99_snprintf/CMakeLists.txt ++++ b/ThirdParty/c99_snprintf/CMakeLists.txt +@@ -1,129 +1,128 @@ +-# Copyright (C) 2012 Modelon AB +- +-# This program is free software: you can redistribute it and/or modify +-# it under the terms of the BSD style license. +- +-# This program is distributed in the hope that it will be useful, +-# but WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-# FMILIB_License.txt file for more details. +- +-# You should have received a copy of the FMILIB_License.txt file +-# along with this program. If not, contact Modelon AB . +- +-if(NOT C99SNPRINTFDIR) +- set(C99SNPRINTFDIR ${CMAKE_SOURCE_DIR}/ThirdParty/c99_snprintf) +- set(C99SNPRINTF_LIBRARIES c99snprintf) +- +-INCLUDE (CheckIncludeFiles) +-CHECK_INCLUDE_FILES(stdarg.h HAVE_STDARG_H) +-CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H) +-CHECK_INCLUDE_FILES(stddef.h HAVE_STDDEF_H) +-CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H) +-CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H) +-CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H) +-CHECK_INCLUDE_FILES(locale.h HAVE_LOCALE_H) +- +-INCLUDE (CheckSymbolExists) +-INCLUDE (CheckFunctionExists) +-CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF_SYM) +-CHECK_SYMBOL_EXISTS(vasprintf stdio.h HAVE_VASPRINTF_SYM) +-CHECK_SYMBOL_EXISTS(asprintf stdio.h HAVE_ASPRINTF_SYM) +-CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF_FCN) +-CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF_FCN) +-CHECK_FUNCTION_EXISTS(asprintf HAVE_ASPRINTF_FCN) +- +-FMIL_EVAL_CONDITION(HAVE_SNPRINTF HAVE_SNPRINTF_SYM OR HAVE_SNPRINTF_FCN) +-FMIL_EVAL_CONDITION(HAVE_VASPRINTF HAVE_VASPRINTF_SYM OR HAVE_VASPRINTF_FCN) +-FMIL_EVAL_CONDITION(HAVE_ASPRINTF HAVE_ASPRINTF_SYM OR HAVE_ASPRINTF_FCN) +- +-CHECK_FUNCTION_EXISTS(localeconv HAVE_LOCALECONV) +- +- INCLUDE (CheckTypeSize) +- # SET(CMAKE_EXTRA_INCLUDE_FILES header) +-#CHECK_TYPE_SIZE(type variable) +-# SET(CMAKE_EXTRA_INCLUDE_FILES) +- CHECK_TYPE_SIZE("long double" HAVE_LONG_DOUBLE) +- CHECK_TYPE_SIZE("long long int" HAVE_LONG_LONG_INT) +- CHECK_TYPE_SIZE("unsigned long long int" HAVE_UNSIGNED_LONG_LONG_INT) +- +-SET(CMAKE_EXTRA_INCLUDE_FILES locale.h) +-CHECK_TYPE_SIZE("struct lconv" LCONV) +-SET(CMAKE_EXTRA_INCLUDE_FILES) +-include(CheckStructHasMember) +-CHECK_STRUCT_HAS_MEMBER ("struct lconv" decimal_point locale.h HAVE_LCONV_DECIMAL_POINT) +-CHECK_STRUCT_HAS_MEMBER ("struct lconv" thousands_sep locale.h HAVE_LCONV_THOUSANDS_SEP) +-INCLUDE (CheckSymbolExists) +- +-CHECK_TYPE_SIZE(intmax_t HAVE_INTMAX_T) +-CHECK_TYPE_SIZE(uintmax_t HAVE_UINTMAX_T) +-CHECK_TYPE_SIZE(uintptr_t HAVE_UINTPTR_T) +-CHECK_TYPE_SIZE(ptrdiff_t HAVE_PTRDIFF_T) +- +-include(CheckSymbolExists) +-CHECK_SYMBOL_EXISTS(va_copy stdarg.h HAVE_VA_COPY) +-CHECK_SYMBOL_EXISTS(__va_copy stdarg.h HAVE___VA_COPY) +- +-set(CHECKS +- HAVE_SNPRINTF +- HAVE_VASPRINTF +- HAVE_ASPRINTF +- HAVE_STDARG_H +- HAVE_STDDEF_H +- HAVE_STDINT_H +- HAVE_STDLIB_H +- HAVE_INTTYPES_H +- HAVE_LOCALE_H +- HAVE_LOCALECONV +- HAVE_LCONV_DECIMAL_POINT +- HAVE_LCONV_THOUSANDS_SEP +- HAVE_LONG_DOUBLE +- HAVE_LONG_LONG_INT +- HAVE_UNSIGNED_LONG_LONG_INT +- HAVE_INTMAX_T +- HAVE_UINTMAX_T +- HAVE_UINTPTR_T +- HAVE_PTRDIFF_T +- HAVE_VA_COPY +- HAVE___VA_COPY) +- +-foreach(check ${CHECKS}) +- if(${${check}}) +- set(DEFINES ${DEFINES} -D${check}=${${check}}) +- endif() +-endforeach() +- +-if(NOT HAVE_VSNPRINTF) +- set(DEFINES ${DEFINES} -Drpl_vsnprintf=jm_rpl_vsnprintf) +-endif() +- +-if(NOT HAVE_SNPRINTF) +- set(DEFINES ${DEFINES} +- -Dsnprintf=jm_rpl_snprintf +- -Drpl_snprintf=jm_rpl_snprintf) +-endif() +- +-if(NOT HAVE_VASPRINTF) +- set(DEFINES ${DEFINES} +- -Dvasprintf=jm_rpl_vasprintf +- -Drpl_vasprintf=jm_rpl_vasprintf) +-endif() +- +-if(NOT HAVE_ASPRINTF) +- set(DEFINES ${DEFINES} +- -Dasprintf=jm_rpl_asprintf +- -Drpl_asprintf=jm_rpl_asprintf) +-endif() +- +-add_definitions(${DEFINES}) +- +-file(WRITE ${CMAKE_BINARY_DIR}/c99snprintf_defs "${DEFINES}") +- +-add_library(c99snprintf c99-snprintf_1.1/snprintf.c) +- +-if(CYGWIN) +-message("not tested") +-endif(CYGWIN) +- +-endif() +- ++# Copyright (C) 2012 Modelon AB ++ ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the BSD style license. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# FMILIB_License.txt file for more details. ++ ++# You should have received a copy of the FMILIB_License.txt file ++# along with this program. If not, contact Modelon AB . ++ ++if(NOT C99SNPRINTFDIR) ++ set(C99SNPRINTFDIR ${CMAKE_SOURCE_DIR}/ThirdParty/c99_snprintf) ++ set(C99SNPRINTF_LIBRARIES c99snprintf) ++ ++INCLUDE (CheckIncludeFiles) ++CHECK_INCLUDE_FILES(stdarg.h HAVE_STDARG_H) ++CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H) ++CHECK_INCLUDE_FILES(stddef.h HAVE_STDDEF_H) ++CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H) ++CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H) ++CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H) ++CHECK_INCLUDE_FILES(locale.h HAVE_LOCALE_H) ++ ++INCLUDE (CheckSymbolExists) ++INCLUDE (CheckFunctionExists) ++CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF_SYM) ++CHECK_SYMBOL_EXISTS(vasprintf stdio.h HAVE_VASPRINTF_SYM) ++CHECK_SYMBOL_EXISTS(asprintf stdio.h HAVE_ASPRINTF_SYM) ++CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF_FCN) ++CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF_FCN) ++CHECK_FUNCTION_EXISTS(asprintf HAVE_ASPRINTF_FCN) ++ ++FMIL_EVAL_CONDITION(HAVE_SNPRINTF HAVE_SNPRINTF_SYM OR HAVE_SNPRINTF_FCN) ++FMIL_EVAL_CONDITION(HAVE_VASPRINTF HAVE_VASPRINTF_SYM OR HAVE_VASPRINTF_FCN) ++FMIL_EVAL_CONDITION(HAVE_ASPRINTF HAVE_ASPRINTF_SYM OR HAVE_ASPRINTF_FCN) ++ ++CHECK_FUNCTION_EXISTS(localeconv HAVE_LOCALECONV) ++ ++ INCLUDE (CheckTypeSize) ++ # SET(CMAKE_EXTRA_INCLUDE_FILES header) ++#CHECK_TYPE_SIZE(type variable) ++# SET(CMAKE_EXTRA_INCLUDE_FILES) ++ CHECK_TYPE_SIZE("long double" HAVE_LONG_DOUBLE) ++ CHECK_TYPE_SIZE("long long int" HAVE_LONG_LONG_INT) ++ CHECK_TYPE_SIZE("unsigned long long int" HAVE_UNSIGNED_LONG_LONG_INT) ++ ++SET(CMAKE_EXTRA_INCLUDE_FILES locale.h) ++CHECK_TYPE_SIZE("struct lconv" LCONV) ++SET(CMAKE_EXTRA_INCLUDE_FILES) ++include(CheckStructHasMember) ++CHECK_STRUCT_HAS_MEMBER ("struct lconv" decimal_point locale.h HAVE_LCONV_DECIMAL_POINT) ++CHECK_STRUCT_HAS_MEMBER ("struct lconv" thousands_sep locale.h HAVE_LCONV_THOUSANDS_SEP) ++INCLUDE (CheckSymbolExists) ++ ++CHECK_TYPE_SIZE(intmax_t HAVE_INTMAX_T) ++CHECK_TYPE_SIZE(uintmax_t HAVE_UINTMAX_T) ++CHECK_TYPE_SIZE(uintptr_t HAVE_UINTPTR_T) ++CHECK_TYPE_SIZE(ptrdiff_t HAVE_PTRDIFF_T) ++ ++include(CheckSymbolExists) ++CHECK_SYMBOL_EXISTS(va_copy stdarg.h HAVE_VA_COPY) ++CHECK_SYMBOL_EXISTS(__va_copy stdarg.h HAVE___VA_COPY) ++ ++set(CHECKS ++ HAVE_SNPRINTF ++ HAVE_VASPRINTF ++ HAVE_ASPRINTF ++ HAVE_STDARG_H ++ HAVE_STDDEF_H ++ HAVE_STDINT_H ++ HAVE_STDLIB_H ++ HAVE_INTTYPES_H ++ HAVE_LOCALE_H ++ HAVE_LOCALECONV ++ HAVE_LCONV_DECIMAL_POINT ++ HAVE_LCONV_THOUSANDS_SEP ++ HAVE_LONG_DOUBLE ++ HAVE_LONG_LONG_INT ++ HAVE_UNSIGNED_LONG_LONG_INT ++ HAVE_INTMAX_T ++ HAVE_UINTMAX_T ++ HAVE_UINTPTR_T ++ HAVE_PTRDIFF_T ++ HAVE_VA_COPY ++ HAVE___VA_COPY) ++ ++foreach(check ${CHECKS}) ++ if(${${check}}) ++ set(DEFINES ${DEFINES} -D${check}=${${check}}) ++ endif() ++endforeach() ++ ++if(NOT HAVE_VSNPRINTF) ++ set(DEFINES ${DEFINES} -Drpl_vsnprintf=jm_rpl_vsnprintf) ++endif() ++ ++if(NOT HAVE_SNPRINTF) ++ set(DEFINES ${DEFINES} ++ -Dsnprintf=jm_rpl_snprintf ++ -Drpl_snprintf=jm_rpl_snprintf) ++endif() ++ ++if(NOT HAVE_VASPRINTF) ++ set(DEFINES ${DEFINES} ++ -Dvasprintf=jm_rpl_vasprintf ++ -Drpl_vasprintf=jm_rpl_vasprintf) ++endif() ++ ++if(NOT HAVE_ASPRINTF) ++ set(DEFINES ${DEFINES} ++ -Dasprintf=jm_rpl_asprintf ++ -Drpl_asprintf=jm_rpl_asprintf) ++endif() ++ ++add_definitions(${DEFINES}) ++ ++file(WRITE ${CMAKE_BINARY_DIR}/c99snprintf_defs "${DEFINES}") ++ ++add_library(c99snprintf STATIC c99-snprintf_1.1/snprintf.c) ++ ++if(CYGWIN) ++message("not tested") ++endif(CYGWIN) ++ ++endif() +-- +2.39.2 + diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 0000000..c2ddba8 --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) + +project(test_package LANGUAGES C) + +find_package(fmilib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE fmilibrary::fmilibrary) diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..ef5d704 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/test_package/test_package.c b/test_package/test_package.c new file mode 100644 index 0000000..a1f640d --- /dev/null +++ b/test_package/test_package.c @@ -0,0 +1,8 @@ +#include + +int main() { + fmi_import_context_t* c = fmi_import_allocate_context(jm_get_default_callbacks()); + int e = (c == NULL) ? 1 : 0; + fmi_import_free_context(c); + return e; +}