diff --git a/.github/workflows/ci-clang-tidy.yml b/.github/workflows/ci-clang-tidy.yml index 658d3090..a9147356 100644 --- a/.github/workflows/ci-clang-tidy.yml +++ b/.github/workflows/ci-clang-tidy.yml @@ -124,12 +124,13 @@ jobs: sed -i.backup '/^\[settings\]$/,/^\[/ s/^build_type=.*/build_type=${{ matrix.build_type }}/' ~/.conan2/profiles/default conan profile show -pr default - run: echo "std_format=$([ "${{ matrix.formatting }}" == "std::format" ] && echo "True" || echo "False")" >> $GITHUB_ENV + - run: echo "import_std=$([ "${{ matrix.config.cxx_modules }}" == "True" ] && [ "${{ matrix.config.contracts }}" == "none" ] && [ "${{ matrix.formatting }}" == "std::format" ] && echo "True" || echo "False")" >> $GITHUB_ENV - name: Run clang-tidy shell: bash run: | conan build . -b missing -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config" \ -c user.mp-units.build:all=True -c user.mp-units.analyze:clang-tidy=True -c tools.build:skip_test=True \ - '-o &:cxx_modules=${{ matrix.config.cxx_modules }}' -o '&:std_format=${{ env.std_format }}' -o '&:contracts=${{ matrix.contracts }}' ${{ matrix.config.conan-config }} + '-o &:cxx_modules=${{ matrix.config.cxx_modules }}' -o '&:import_std=${{ env.import_std }}' -o '&:std_format=${{ env.std_format }}' -o '&:contracts=${{ matrix.contracts }}' ${{ matrix.config.conan-config }} - name: Clean Conan cache before backup shell: bash run: | diff --git a/.github/workflows/ci-conan.yml b/.github/workflows/ci-conan.yml index 93241774..58df0880 100644 --- a/.github/workflows/ci-conan.yml +++ b/.github/workflows/ci-conan.yml @@ -238,12 +238,13 @@ jobs: sed -i.backup '/^\[settings\]$/,/^\[/ s/^build_type=.*/build_type=${{ matrix.build_type }}/' ~/.conan2/profiles/default conan profile show -pr default - run: echo "std_format=$([ "${{ matrix.formatting }}" == "std::format" ] && echo "True" || echo "False")" >> $GITHUB_ENV + - run: echo "import_std=$([ "${{ matrix.config.cxx_modules }}" == "True" ] && [ "${{ matrix.config.contracts }}" == "none" ] && [ "${{ matrix.formatting }}" == "std::format" ] && echo "True" || echo "False")" >> $GITHUB_ENV - name: Create Conan package shell: bash run: | conan create . --user mpusz --channel ${CHANNEL} --lockfile-out=package.lock \ - -b mp-units/* -b missing -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config" \ - -c user.mp-units.build:all=True -o '&:cxx_modules=${{ matrix.config.cxx_modules }}' -o '&:std_format=${{ env.std_format }}' -o '&:contracts=${{ matrix.contracts }}' ${{ matrix.config.conan-config }} + -b mp-units/* -b missing -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config" -c user.mp-units.build:all=True \ + -o '&:cxx_modules=${{ matrix.config.cxx_modules }}' -o '&:import_std=${{ env.import_std }}' -o '&:std_format=${{ env.std_format }}' -o '&:contracts=${{ matrix.contracts }}' ${{ matrix.config.conan-config }} - name: Obtain package reference id: get-package-ref shell: bash diff --git a/.github/workflows/ci-test-package-cmake.yml b/.github/workflows/ci-test-package-cmake.yml index 4b3cacec..df1cae9f 100644 --- a/.github/workflows/ci-test-package-cmake.yml +++ b/.github/workflows/ci-test-package-cmake.yml @@ -231,11 +231,12 @@ jobs: sed -i.backup '/^\[settings\]$/,/^\[/ s/^build_type=.*/build_type=${{ matrix.build_type }}/' ~/.conan2/profiles/default conan profile show -pr default - run: echo "std_format=$([ "${{ matrix.formatting }}" == "std::format" ] && echo "True" || echo "False")" >> $GITHUB_ENV + - run: echo "import_std=$([ "${{ matrix.config.cxx_modules }}" == "True" ] && [ "${{ matrix.config.contracts }}" == "none" ] && [ "${{ matrix.formatting }}" == "std::format" ] && echo "True" || echo "False")" >> $GITHUB_ENV - name: Install Conan dependencies shell: bash run: | conan install . -b missing -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config" -c user.mp-units.build:all=False \ - -o '&:cxx_modules=${{ matrix.config.cxx_modules }}' -o '&:std_format=${{ env.std_format }}' -o '&:contracts=${{ matrix.contracts }}' + -o '&:cxx_modules=${{ matrix.config.cxx_modules }}' -o '&:import_std=${{ env.import_std }}' -o '&:std_format=${{ env.std_format }}' -o '&:contracts=${{ matrix.contracts }}' - name: Provide dependencies for the build shell: bash working-directory: src diff --git a/conanfile.py b/conanfile.py index 2979b31a..3a8fd5f5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -30,7 +30,7 @@ from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import copy, load, rmdir from conan.tools.scm import Version -required_conan_version = ">=2.0.0" +required_conan_version = ">=2.0.15" class MPUnitsConan(ConanFile): @@ -239,7 +239,7 @@ class MPUnitsConan(ConanFile): raise ConanInvalidConfiguration( "'contracts' should be set to 'none' to use `import std;`" ) - if not self.options.std_format: + if not self.options.get_safe("std_format", default=True): raise ConanInvalidConfiguration( "'std_format' should be enabled to use `import std;`" ) @@ -252,7 +252,9 @@ class MPUnitsConan(ConanFile): tc.absolute_paths = True # only needed for CMake CI if self._build_all: tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True - tc.cache_variables["CMAKE_VERIFY_INTERFACE_HEADER_SETS"] = True + tc.cache_variables[ + "CMAKE_VERIFY_INTERFACE_HEADER_SETS" + ] = not self.options.import_std tc.cache_variables["MP_UNITS_DEV_BUILD_LA"] = not self._skip_la if self._run_clang_tidy: tc.cache_variables["MP_UNITS_DEV_CLANG_TIDY"] = True @@ -287,7 +289,8 @@ class MPUnitsConan(ConanFile): if self._build_all or self.options.cxx_modules: cmake.build() if self._build_all: - cmake.build(target="all_verify_interface_header_sets") + if not self.options.import_std: + cmake.build(target="all_verify_interface_header_sets") if can_run(self): cmake.ctest(cli_args=["--output-on-failure"]) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 611bfcc7..ce9db06b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -126,10 +126,10 @@ if(${projectPrefix}BUILD_CXX_MODULES) endif() if(${projectPrefix}BUILD_IMPORT_STD) - target_compile_definitions(mp-units-core PUBLIC ${projectPrefix}IMPORT_STD) + target_compile_definitions(mp-units-core ${${projectPrefix}TARGET_SCOPE} ${projectPrefix}IMPORT_STD) # https://github.com/llvm/llvm-project/issues/75057 if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) - target_compile_options(mp-units-core PUBLIC "-Wno-deprecated-declarations") + target_compile_options(mp-units-core ${${projectPrefix}TARGET_SCOPE} "-Wno-deprecated-declarations") endif() endif()