From 5c91425d7c07566ee5cc0e77ac703d0a89335b8a Mon Sep 17 00:00:00 2001 From: Joakim Haugen Date: Wed, 10 Apr 2024 14:23:46 +0200 Subject: [PATCH] Feature conan recipe (#1) * Add conan recipe and workflows * Only build Release and one compiler on each platform --- .gitattributes | 1 + .github/workflows/ci-conan-gcc.yml | 51 ++++++ .github/workflows/ci-conan-msvc.yml | 46 +++++ .gitignore | 9 + README.md | 51 ++++++ conandata.yml | 14 ++ conanfile.py | 117 +++++++++++++ fmuchk.cmake | 24 +++ patches/0001-add-revised-license.patch | 82 +++++++++ patches/0002-make-conan-changes.patch | 234 +++++++++++++++++++++++++ test_package/CMakeLists.txt | 13 ++ test_package/conanfile.py | 34 ++++ 12 files changed, 676 insertions(+) create mode 100644 .gitattributes create mode 100755 .github/workflows/ci-conan-gcc.yml create mode 100755 .github/workflows/ci-conan-msvc.yml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 conandata.yml create mode 100644 conanfile.py create mode 100644 fmuchk.cmake create mode 100644 patches/0001-add-revised-license.patch create mode 100644 patches/0002-make-conan-changes.patch create mode 100644 test_package/CMakeLists.txt create mode 100644 test_package/conanfile.py 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..61419ec --- /dev/null +++ b/.github/workflows/ci-conan-gcc.yml @@ -0,0 +1,51 @@ +--- +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.0.4] + build_type: [Release] + profile: [gcc] + compiler_version: [12] + 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 \ + --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..dc13183 --- /dev/null +++ b/.github/workflows/ci-conan-msvc.yml @@ -0,0 +1,46 @@ +--- +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.0.4] + build_type: [Release] + profile: [msvc17] + compiler_version: [193] + 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 ` + --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..0360db9 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +[![Linux GCC](https://github.com/sintef-ocean/conan-fmu-compliance-checker/workflows/Linux%20GCC/badge.svg)](https://github.com/sintef-ocean/conan-fmu-compliance-checker/actions?query=workflow%3A"Linux+GCC") +[![Windows MSVC](https://github.com/sintef-ocean/conan-fmu-compliance-checker/workflows/Windows%20MSVC/badge.svg)](https://github.com/sintef-ocean/conan-fmu-compliance-checker/actions?query=workflow%3A"Windows+MSVC") + +[Conan.io](https://conan.io) recipe for [Modelica tools' FMUComplianceChecker](https://github.com/modelica-tools/FMUComplianceChecker). + +## 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*: + ``` + [options] + eprosima-fmu-compliance-checker:with_tools=True + + [tool_requires] + cmake/[>=3.25.0] + fmu-compliance-checker/2.0.4@sintef/stable + [layout] + cmake_layout + + [generators] + CMakeDeps + CMakeToolchain + VirtualBuildEnv + + ``` + + A command line tool `fmuCheck.linux64` or `fmuCheck.win64` is available to check FMUs when virtual environment is active. + There is also a convenience executable target `FMUComplianceChecker::executable` for CMake users that can be used, + as well as `add_fmu_compliance_check(testName fmuPath)`, which adds an `add_test()` using the executable target. + ``` + find_package(FMUComplianceChecker REQUIRED CONFIG) + add_fmu_compliance_check("MyFMU_is_compliant" ${PATH_TO_FMU}) + ``` + +## Package options + +| Option | Allowed values | Default | +|--------|----------------|---------| +| fPIC | [True, False] | True | + +To build and run tests, set `tools.build:skip_test=False` in `global.conf`, in `[conf]` or +`--conf` as part of `conan install`. + +## Known recipe issues diff --git a/conandata.yml b/conandata.yml new file mode 100644 index 0000000..23fda90 --- /dev/null +++ b/conandata.yml @@ -0,0 +1,14 @@ +sources: + "2.0.4": + url: + - "https://github.com/modelica-tools/FMUComplianceChecker/archive/refs/tags/2.0.4.tar.gz" + sha256: "361a1995fe498f5399092cff119c78a4500abbb7b9ca8c77d48a7de72c294f59" +patches: + "2.0.4": + - patch_file: "patches/0001-add-revised-license.patch" + patch_description: "Add a fixed license" + patch_type: "backport" + patch_source: "https://github.com/modelica-tools/FMUComplianceChecker/pull/36" + - patch_file: "patches/0002-make-conan-changes.patch" + patch_description: "Use fmilibrary as conan requirement and do conanisation changes" + patch_type: "conan" diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..607448c --- /dev/null +++ b/conanfile.py @@ -0,0 +1,117 @@ +from os import path +import posixpath +from conan import ConanFile, conan_version +from conan.tools.microsoft import is_msvc_static_runtime, is_msvc +from conan.tools.files import ( + apply_conandata_patches, export_conandata_patches, get, copy, save, rename) +from conan.tools.scm import Version +from conan.tools.env import Environment +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +required_conan_version = ">=2.0" + + +class PackageConan(ConanFile): + name = "fmu-compliance-checker" + description = "short description" + license = "BSD-3-Clause" + url = "https://github.com/sintef-ocean/conan-fmu-compliance-checker" + homepage = "https://github.com/modelica-tools/FMUComplianceChecker" + topics = ("fmi", "fmi-standard", "compliance") + package_type = "application" + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + copy(self, "fmuchk.cmake", self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + self.options["fmilib/*"].with_fmus = True + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("fmi1/1.0.1") + self.requires("fmi2/2.0.4") + self.requires("fmilib/2.4.1@sintef/testing") + #self.requires("fmilib/2.4.1") # Pending fmilib on conan center index + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if is_msvc(self): + tc.variables["FMUCHK_BUILD_WITH_STATIC_RTLIB"] = is_msvc_static_runtime(self) + + copy(self, "*.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")) + copy(self, "*.fmu", self.dependencies["fmilib"].cpp_info.resdirs[0], + path.join(self.build_folder, "fmus"), keep_path=False) + + tc.variables["FMUCHK_INSTALL_PREFIX"] = posixpath.join(self.build_folder, "install").replace("\\", "/") + tc.variables["FMUCHK_FMI_STANDARD_HEADERS"] = posixpath.join(self.build_folder, "fmis").replace("\\", "/") + tc.variables["FMUCHK_FMIL"] = str(self.build_folder).replace("\\", "/") + + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + 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() + + cmake.install() # It installs to build folder + + def package(self): + copy(self, pattern="LICENSE", dst=path.join(self.package_folder, "licenses"), + src=self.source_folder) + + copy(self, pattern="*", dst=path.join(self.package_folder, "bin"), + src=path.join(self.build_folder, "install"), keep_path=False) + + # This removes a lint hook error + save(self, path.join(self.package_folder, "bin", "fmuCheckExecutable"), + "The executable is named fmuCheck.{os}{arch}") + + copy(self, "fmuchk.cmake", self.export_sources_folder, + path.join(self.package_folder, "res")) + + def package_info(self): + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = ["res"] + self.cpp_info.includedirs = [] + self.cpp_info.builddirs = ["res"] + + self.cpp_info.set_property("cmake_build_modules", + [path.join("res", "fmuchk.cmake")]) + + self.cpp_info.set_property("cmake_file_name", "FMUComplianceChecker") diff --git a/fmuchk.cmake b/fmuchk.cmake new file mode 100644 index 0000000..74c0384 --- /dev/null +++ b/fmuchk.cmake @@ -0,0 +1,24 @@ +if(NOT TARGET FMUComplianceChecker::executable) + if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + set(_os "darwin") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set(_os "linux") + elseif(WIN32) + set(_os "win") + else() + message(FATAL_ERROR "Unknown or unsupported platform: ${CMAKE_SYSTEM_NAME}") + endif() + math(EXPR _wordSize 8*${CMAKE_SIZEOF_VOID_P}) + add_executable(FMUComplianceChecker::executable IMPORTED GLOBAL) + set_target_properties(FMUComplianceChecker::executable + PROPERTIES + IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/../bin/fmuCheck.${_os}${_wordSize}") +endif() + +message(STATUS "Add macro 'add_fmu_compliance_check'") +macro(add_fmu_compliance_check testName fmuPath) + add_test( + NAME "${testName}" + COMMAND FMUComplianceChecker::executable "${fmuPath}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +endmacro() diff --git a/patches/0001-add-revised-license.patch b/patches/0001-add-revised-license.patch new file mode 100644 index 0000000..c629c6a --- /dev/null +++ b/patches/0001-add-revised-license.patch @@ -0,0 +1,82 @@ +From 021bd889f090b7d7813739f1c72c28e07bff66ad Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Tue, 23 May 2023 10:37:36 +0200 +Subject: [PATCH] add revised license + +--- + LICENCE.md | 26 -------------------------- + LICENSE | 29 +++++++++++++++++++++++++++++ + 2 files changed, 29 insertions(+), 26 deletions(-) + delete mode 100644 LICENCE.md + create mode 100644 LICENSE + +diff --git a/LICENCE.md b/LICENCE.md +deleted file mode 100644 +index ab0935b..0000000 +--- a/LICENCE.md ++++ /dev/null +@@ -1,26 +0,0 @@ +-Licence information for FMI Compliance Checker (FMUChecker) application. +- +-Copyright (c) 2014, Modelon AB +-All rights reserved. +- +-Redistribution and use in source and binary forms, with or without +-modification, are permitted provided that the following conditions are met: +- * Redistributions of source code must retain the above copyright +- notice, this list of conditions and the following disclaimer. +- * Redistributions in binary form must reproduce the above copyright +- notice, this list of conditions and the following disclaimer in the +- documentation and/or other materials provided with the distribution. +- * Neither the name of the Modelon AB nor the +- names of its contributors may be used to endorse or promote products +- derived from this software without specific prior written permission. +- +-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +-DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +diff --git a/LICENSE b/LICENSE +new file mode 100644 +index 0000000..4f01481 +--- /dev/null ++++ b/LICENSE +@@ -0,0 +1,29 @@ ++BSD 3-Clause License ++ ++Copyright (c) 2014, Modelon AB ++All rights reserved. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are met: ++ ++* Redistributions of source code must retain the above copyright notice, this ++ list of conditions and the following disclaimer. ++ ++* Redistributions in binary form must reproduce the above copyright notice, ++ this list of conditions and the following disclaimer in the documentation ++ and/or other materials provided with the distribution. ++ ++* Neither the name of the copyright holder nor the names of its ++ contributors may be used to endorse or promote products derived from ++ this software without specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE ++FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ++CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +-- +2.30.2 + diff --git a/patches/0002-make-conan-changes.patch b/patches/0002-make-conan-changes.patch new file mode 100644 index 0000000..2ab6372 --- /dev/null +++ b/patches/0002-make-conan-changes.patch @@ -0,0 +1,234 @@ +From 97826523796035a2a9497b370d5c4f2f42856924 Mon Sep 17 00:00:00 2001 +From: Joakim Haugen +Date: Thu, 25 May 2023 19:31:05 +0200 +Subject: [PATCH] Make conan changes + +--- + CMakeLists.txt | 130 +++++++++++++++++++++++++------------------------ + 1 file changed, 67 insertions(+), 63 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b2534c9..7cdf27f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -95,6 +95,7 @@ if("${tmp}" STREQUAL "") + endif() + message(STATUS "Will use standard headers from:\n ${FMI_STANDARD_HEADERS_DIR}") + # Add FMIL as imported library ++if(FALSE) + include(ExternalProject) + + set(FMIL_SETTINGS +@@ -173,7 +174,10 @@ getVersionSVN("${FMUCHK_HOME}" FMUCHK_VERSION) + message(STATUS "Checker version: ${FMUCHK_VERSION}") + getVersionSVN("${FMUCHK_HOME}/FMIL" FMIL_VERSION) + message(STATUS "FMIL version: ${FMIL_VERSION}") +-file(WRITE ${CMAKE_BINARY_DIR}/VERSION-FMUChecker.txt ++endif() ++set(FMUCHK_VERSION 2.0.4) ++set(FMIL_VERSION 2.4.1) ++file(WRITE ${CMAKE_BINARY_DIR}/VERSION-FMUChecker.txt + "FMI checker version:${FMUCHK_VERSION} + FMI library version:${FMIL_VERSION} + ") +@@ -204,13 +208,13 @@ set(HEADERS + ${FMUCHK_HOME}/include/fmuChecker.h) + + include_directories( +- ${FMUCHK_BUILD}/FMIL/install/include/ + include/Common/ + include + ${CMAKE_BINARY_DIR}) + ++find_package(fmilib CONFIG REQUIRED) + add_executable(${fmuCheck} ${SOURCE} ${HEADERS}) +-target_link_libraries(${fmuCheck} fmilib) ++target_link_libraries(${fmuCheck} fmilib::fmilib) + if(WIN32) + target_link_libraries(${fmuCheck} Shlwapi) + endif(WIN32) +@@ -228,35 +232,35 @@ else() + endif() + + file(GLOB_RECURSE TEST_FMUS "${FMUCHK_TEST_FMUS_DIR_NORMALIZED}/*.fmu" ) +- +-set(BAD_FMUS +- ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_malformed_mf.fmu +- ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall_malformed_mf.fmu) +- +-set(ALL_TEST_FMUS +- ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall_cs.fmu +- ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall_cs_tc.fmu +- ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall_me.fmu +- ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_cs.fmu +- ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_me.fmu ++ ++set(BAD_FMUS ++ ${FMUCHK_FMIL}/fmus/BouncingBall2_malformed_mf.fmu ++ ${FMUCHK_FMIL}/fmus/BouncingBall_malformed_mf.fmu) ++ ++set(ALL_TEST_FMUS ++ ${FMUCHK_FMIL}/fmus/BouncingBall_cs.fmu ++ ${FMUCHK_FMIL}/fmus/BouncingBall_cs_tc.fmu ++ ${FMUCHK_FMIL}/fmus/BouncingBall_me.fmu ++ ${FMUCHK_FMIL}/fmus/BouncingBall2_cs.fmu ++ ${FMUCHK_FMIL}/fmus/BouncingBall2_me.fmu + ${TEST_FMUS}) + + ENABLE_TESTING() + + set(TEST_OUT_DIR ${FMUCHK_BUILD}/TestOutput) +-file(MAKE_DIRECTORY ${TEST_OUT_DIR}) ++file(MAKE_DIRECTORY ${TEST_OUT_DIR}) + +-add_test( +- NAME Test_FMIL +- WORKING_DIRECTORY ${FMUCHK_BUILD}/FMIL/build +- COMMAND ${CMAKE_CTEST_COMMAND} -C $) ++#add_test( ++# NAME Test_FMIL ++# WORKING_DIRECTORY ${FMUCHK_BUILD}/FMIL/build ++# COMMAND ${CMAKE_CTEST_COMMAND} -C $) + +-add_test( +- NAME Build_before_test +- COMMAND "${CMAKE_COMMAND}" --build ${FMUCHK_BUILD} --config $) ++#add_test( ++# NAME Build_before_test ++# COMMAND "${CMAKE_COMMAND}" --build ${FMUCHK_BUILD} --config $) + +-SET_TESTS_PROPERTIES ( +- Build_before_test PROPERTIES DEPENDS Test_FMIL) ++#SET_TESTS_PROPERTIES ( ++# Build_before_test PROPERTIES DEPENDS Test_FMIL) + + + set(TEST_COMMAND_LINE_PARSING OFF) +@@ -283,49 +287,49 @@ if(TEST_COMMAND_LINE_PARSING) + endif() + + add_test( +- NAME check_with_default_params +- COMMAND ${fmuCheck} ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall_cs.fmu) ++ NAME check_with_default_params ++ COMMAND ${fmuCheck} ${FMUCHK_FMIL}/fmus/BouncingBall_cs.fmu) + +-set_tests_properties ( +- check_with_default_params +- PROPERTIES DEPENDS Build_before_test) ++#set_tests_properties ( ++# check_with_default_params ++# PROPERTIES DEPENDS Build_before_test) + + add_test( + NAME check_require_me +- COMMAND ${fmuCheck} -k me ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_me.fmu) +-set_tests_properties ( +- check_require_me +- PROPERTIES DEPENDS Build_before_test) ++ COMMAND ${fmuCheck} -k me ${FMUCHK_FMIL}/fmus/BouncingBall2_me.fmu) ++#set_tests_properties ( ++# check_require_me ++# PROPERTIES DEPENDS Build_before_test) + + add_test( + NAME check_require_me_fail +- COMMAND ${fmuCheck} -k me ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_cs.fmu) +-set_tests_properties ( +- check_require_me_fail +- PROPERTIES DEPENDS Build_before_test ++ COMMAND ${fmuCheck} -k me ${FMUCHK_FMIL}/fmus/BouncingBall2_cs.fmu) ++#set_tests_properties ( ++# check_require_me_fail ++# PROPERTIES DEPENDS Build_before_test + # WILL_FAIL TRUE # non-fatal error ==> zero exit code currently +-) ++#) + + add_test( + NAME check_require_cs +- COMMAND ${fmuCheck} -k cs ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_cs.fmu) +-set_tests_properties ( +- check_require_cs +- PROPERTIES DEPENDS Build_before_test) ++ COMMAND ${fmuCheck} -k cs ${FMUCHK_FMIL}/fmus/BouncingBall2_cs.fmu) ++#set_tests_properties ( ++# check_require_cs ++# PROPERTIES DEPENDS Build_before_test) + + add_test( + NAME check_require_cs_fail +- COMMAND ${fmuCheck} -k cs ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_me.fmu) +-set_tests_properties ( +- check_require_cs_fail +- PROPERTIES DEPENDS Build_before_test ++ COMMAND ${fmuCheck} -k cs ${FMUCHK_FMIL}/fmus/BouncingBall2_me.fmu) ++#set_tests_properties ( ++# check_require_cs_fail ++# PROPERTIES DEPENDS Build_before_test + # WILL_FAIL TRUE # non-fatal error ==> zero exit code currently +-) ++#) + + add_test( + NAME check_require_me_cs_fail +- COMMAND ${fmuCheck} -k cs -k me ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_me.fmu) +-set_tests_properties ( ++ COMMAND ${fmuCheck} -k cs -k me ${FMUCHK_FMIL}/fmus/BouncingBall2_me.fmu) ++set_tests_properties ( + check_require_me_cs_fail + PROPERTIES DEPENDS Build_before_test + # WILL_FAIL TRUE # non-fatal error ==> zero exit code currently +@@ -333,17 +337,17 @@ set_tests_properties ( + + add_test( + NAME check_xml_on_me +- COMMAND ${fmuCheck} -k xml ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_me.fmu) +-set_tests_properties ( +- check_xml_on_me +- PROPERTIES DEPENDS Build_before_test) ++ COMMAND ${fmuCheck} -k xml ${FMUCHK_FMIL}/fmus/BouncingBall2_me.fmu) ++#set_tests_properties ( ++# check_xml_on_me ++# PROPERTIES DEPENDS Build_before_test) + + add_test( + NAME check_xml_on_cs +- COMMAND ${fmuCheck} -k xml ${FMUCHK_BUILD}/FMIL/build/Testing/BouncingBall2_cs.fmu) +-set_tests_properties ( +- check_xml_on_cs +- PROPERTIES DEPENDS Build_before_test) ++ COMMAND ${fmuCheck} -k xml ${FMUCHK_FMIL}/fmus/BouncingBall2_cs.fmu) ++#set_tests_properties ( ++# check_xml_on_cs ++# PROPERTIES DEPENDS Build_before_test) + + foreach(fmu ${BAD_FMUS}) + string(REPLACE "/" "_" testname "check_${fmu}") +@@ -353,9 +357,9 @@ foreach(fmu ${BAD_FMUS}) + WORKING_DIRECTORY ${TEST_OUT_DIR} + COMMAND ${fmuCheck} -t ${TEST_OUT_DIR} -l 6 -o ${testname}.csv -e ${testname}.log ${fmu} ) + set_tests_properties(${testname} PROPERTIES WILL_FAIL TRUE) +- set_tests_properties ( +- ${testname} +- PROPERTIES DEPENDS Build_before_test) ++# set_tests_properties ( ++# ${testname} ++# PROPERTIES DEPENDS Build_before_test) + endforeach(fmu) + + foreach(fmu ${ALL_TEST_FMUS}) +@@ -365,7 +369,7 @@ foreach(fmu ${ALL_TEST_FMUS}) + NAME ${testname} + WORKING_DIRECTORY ${TEST_OUT_DIR} + COMMAND ${fmuCheck} -t ${TEST_OUT_DIR} -l 6 -o ${testname}.csv -e ${testname}.log ${fmu} ) +- set_tests_properties ( +- ${testname} +- PROPERTIES DEPENDS Build_before_test) ++ #set_tests_properties ( ++ # ${testname} ++ # PROPERTIES DEPENDS Build_before_test) + endforeach(fmu) +-- +2.30.2 + diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 0000000..6aa6c6d --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.15) + +project(test_package C) + +find_package(FMUComplianceChecker REQUIRED CONFIG) + +if(NOT TARGET FMUComplianceChecker::executable) + message(FATAL_ERROR "Executable target not defined") +endif() + +get_target_property(_fmuchk FMUComplianceChecker::executable IMPORTED_LOCATION) + +file(WRITE ${CMAKE_BINARY_DIR}/fmuchk ${_fmuchk}) diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..0b3f305 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,34 @@ +from os import path +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake, CMakeDeps + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tested_name = str(self.tested_reference_str).split("/")[0] + deps = CMakeDeps(self) + deps.build_context_activated = [tested_name] + deps.build_context_build_modules = [tested_name] + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + + + def test(self): + if can_run(self): + f = open(path.join(self.build_folder, "fmuchk"), "r") + exe_name = f.readline() + f.close() + self.run(exe_name)