From 6ea2adf936daea67caa32cf7f03d97244853c374 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Nov 2024 13:56:18 +0100 Subject: [PATCH 1/8] test: test_package now is tested also with C++20 modules --- test_package/CMakeLists.txt | 14 ++++++++++++-- test_package/conanfile.py | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index e57d1d8b3..9b76bf9b7 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -23,7 +23,17 @@ cmake_minimum_required(VERSION 3.25) 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..ef15fe3cc 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -64,5 +64,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") From 2a9248e82ea2b1ec89ded3db697740086e4200c0 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Nov 2024 13:59:28 +0100 Subject: [PATCH 2/8] ci: two test binaries properly set for testing for CMake CI --- .github/workflows/ci-test-package-cmake.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci-test-package-cmake.yml b/.github/workflows/ci-test-package-cmake.yml index d58db7083..8ee4ce8fb 100644 --- a/.github/workflows/ci-test-package-cmake.yml +++ b/.github/workflows/ci-test-package-cmake.yml @@ -223,7 +223,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: | From 81c810ad4288cb60fb991172f4013ba3ce8e71ba Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Nov 2024 13:59:28 +0100 Subject: [PATCH 3/8] build: running test_package fixed for local build --- .github/workflows/ci-test-package-cmake.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci-test-package-cmake.yml b/.github/workflows/ci-test-package-cmake.yml index 8ee4ce8fb..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: | From 05c5ca5871ff065287b0fcebbe3c40231db4fc8b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Nov 2024 14:17:52 +0100 Subject: [PATCH 4/8] build: missing compilation options added to `test_package` --- test_package/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index ef15fe3cc..55141865a 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` @@ -54,6 +55,7 @@ def generate(self): tc.cache_variables["MP_UNITS_API_FREESTANDING"] = True else: tc.cache_variables["MP_UNITS_API_STD_FORMAT"] = opt.std_format + tc.cache_variables["MP_UNITS_API_NO_CRTP"] = opt.no_crtp tc.cache_variables["MP_UNITS_API_CONTRACTS"] = str(opt.contracts).upper() tc.generate() From cef720c24373df19b2c0bb7374c99903868fd910 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Nov 2024 14:39:37 +0100 Subject: [PATCH 5/8] build: `MP_UNITS_API_NO_CRTP` removed from `test_package` CMake --- test_package/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 55141865a..882f57199 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -55,7 +55,6 @@ def generate(self): tc.cache_variables["MP_UNITS_API_FREESTANDING"] = True else: tc.cache_variables["MP_UNITS_API_STD_FORMAT"] = opt.std_format - tc.cache_variables["MP_UNITS_API_NO_CRTP"] = opt.no_crtp tc.cache_variables["MP_UNITS_API_CONTRACTS"] = str(opt.contracts).upper() tc.generate() From 42738754d93c78b439e84e0dce810e5ef04e5dec Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Nov 2024 14:42:39 +0100 Subject: [PATCH 6/8] build: require at least CMake 3.31 for `test_package` --- test_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 9b76bf9b7..0230d2d72 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -20,7 +20,7 @@ # 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.31) project(test_package LANGUAGES CXX) message(STATUS "MP_UNITS_BUILD_CXX_MODULES: ${MP_UNITS_BUILD_CXX_MODULES}") From 82d12a8a749178c555f3d80d9aa6685a6710dcc5 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Nov 2024 14:45:27 +0100 Subject: [PATCH 7/8] build: require at least CMake 3.31 with Conan --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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") From 47b22f193efcd34d454df7badaffbc4457b0eace Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Nov 2024 14:51:44 +0100 Subject: [PATCH 8/8] build: minimum CMake required changed to 3.30.5 for `test_package` to make some jobs on CI to work --- test_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 0230d2d72..fa7cc1a85 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cmake_minimum_required(VERSION 3.31) +cmake_minimum_required(VERSION 3.30.5) project(test_package LANGUAGES CXX) message(STATUS "MP_UNITS_BUILD_CXX_MODULES: ${MP_UNITS_BUILD_CXX_MODULES}")