diff --git a/.github/workflows/ci-test-package-cmake.yml b/.github/workflows/ci-test-package-cmake.yml index d58db7083..5367355de 100644 --- a/.github/workflows/ci-test-package-cmake.yml +++ b/.github/workflows/ci-test-package-cmake.yml @@ -203,7 +203,13 @@ jobs: run: | cmake --preset conan-default -Dmp-units_DIR=../build -Bbuild/local cmake --build build/local --config ${{ matrix.build_type }} + - name: Run test_package-headers (local build) + shell: bash + working-directory: test_package/build/local/${{ matrix.build_type }} + run: | + ./test_package-headers - name: Run test_package (local build) + if: matrix.config.cxx_modules == 'True' shell: bash working-directory: test_package/build/local/${{ matrix.build_type }} run: | @@ -223,7 +229,13 @@ jobs: run: | cmake --preset conan-default -DCMAKE_INSTALL_PREFIX=../out -Bbuild/install cmake --build build/install --config ${{ matrix.build_type }} + - name: Run test_package-headers (installation) + shell: bash + working-directory: test_package/build/install/${{ matrix.build_type }} + run: | + ./test_package-headers - name: Run test_package (installation) + if: matrix.config.cxx_modules == 'True' shell: bash working-directory: test_package/build/install/${{ matrix.build_type }} run: | diff --git a/conanfile.py b/conanfile.py index 7b9c1853b..8026ddf63 100644 --- a/conanfile.py +++ b/conanfile.py @@ -216,7 +216,7 @@ def requirements(self): self.requires("fmt/11.0.1", transitive_headers=True) def build_requirements(self): - self.tool_requires("cmake/[>=3.30 <4]") + self.tool_requires("cmake/[>=3.31 <4]") if self._build_all: if not self.options.freestanding: self.test_requires("catch2/3.7.0") diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index e57d1d8b3..fa7cc1a85 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -20,10 +20,20 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.25) +cmake_minimum_required(VERSION 3.30.5) project(test_package LANGUAGES CXX) +message(STATUS "MP_UNITS_BUILD_CXX_MODULES: ${MP_UNITS_BUILD_CXX_MODULES}") +message(STATUS "MP_UNITS_API_STD_FORMAT: ${MP_UNITS_API_STD_FORMAT}") + find_package(mp-units REQUIRED) -add_executable(test_package test_package.cpp) -target_link_libraries(test_package PRIVATE mp-units::mp-units) +add_executable(test_package-headers test_package.cpp) +target_compile_features(test_package-headers PRIVATE cxx_std_20) +target_link_libraries(test_package-headers PRIVATE mp-units::mp-units) + +if(MP_UNITS_BUILD_CXX_MODULES) + add_executable(test_package test_package.cpp) + target_compile_features(test_package PRIVATE cxx_std_20) + target_link_libraries(test_package PRIVATE mp-units::mp-units) +endif() diff --git a/test_package/conanfile.py b/test_package/conanfile.py index f81cf891b..882f57199 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -42,6 +42,7 @@ def generate(self): opt = self.dependencies["mp-units"].options if opt.cxx_modules: tc.cache_variables["CMAKE_CXX_SCAN_FOR_MODULES"] = True + tc.cache_variables["MP_UNITS_BUILD_CXX_MODULES"] = True if opt.import_std: tc.cache_variables["CMAKE_CXX_MODULE_STD"] = True # Current experimental support according to `Help/dev/experimental.rst` @@ -64,5 +65,8 @@ def build(self): def test(self): if can_run(self): - bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + if self.dependencies["mp-units"].options.cxx_modules: + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package-headers") self.run(bin_path, env="conanrun")