Skip to content

Commit 1090c40

Browse files
authored
Merge pull request #542 from mpusz/test_package_with_modules
test: test_package now is tested also with C++20 modules
2 parents c1d323a + 47b22f1 commit 1090c40

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

.github/workflows/ci-test-package-cmake.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ jobs:
203203
run: |
204204
cmake --preset conan-default -Dmp-units_DIR=../build -Bbuild/local
205205
cmake --build build/local --config ${{ matrix.build_type }}
206+
- name: Run test_package-headers (local build)
207+
shell: bash
208+
working-directory: test_package/build/local/${{ matrix.build_type }}
209+
run: |
210+
./test_package-headers
206211
- name: Run test_package (local build)
212+
if: matrix.config.cxx_modules == 'True'
207213
shell: bash
208214
working-directory: test_package/build/local/${{ matrix.build_type }}
209215
run: |
@@ -223,7 +229,13 @@ jobs:
223229
run: |
224230
cmake --preset conan-default -DCMAKE_INSTALL_PREFIX=../out -Bbuild/install
225231
cmake --build build/install --config ${{ matrix.build_type }}
232+
- name: Run test_package-headers (installation)
233+
shell: bash
234+
working-directory: test_package/build/install/${{ matrix.build_type }}
235+
run: |
236+
./test_package-headers
226237
- name: Run test_package (installation)
238+
if: matrix.config.cxx_modules == 'True'
227239
shell: bash
228240
working-directory: test_package/build/install/${{ matrix.build_type }}
229241
run: |

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def requirements(self):
216216
self.requires("fmt/11.0.1", transitive_headers=True)
217217

218218
def build_requirements(self):
219-
self.tool_requires("cmake/[>=3.30 <4]")
219+
self.tool_requires("cmake/[>=3.31 <4]")
220220
if self._build_all:
221221
if not self.options.freestanding:
222222
self.test_requires("catch2/3.7.0")

test_package/CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
cmake_minimum_required(VERSION 3.25)
23+
cmake_minimum_required(VERSION 3.30.5)
2424
project(test_package LANGUAGES CXX)
2525

26+
message(STATUS "MP_UNITS_BUILD_CXX_MODULES: ${MP_UNITS_BUILD_CXX_MODULES}")
27+
message(STATUS "MP_UNITS_API_STD_FORMAT: ${MP_UNITS_API_STD_FORMAT}")
28+
2629
find_package(mp-units REQUIRED)
2730

28-
add_executable(test_package test_package.cpp)
29-
target_link_libraries(test_package PRIVATE mp-units::mp-units)
31+
add_executable(test_package-headers test_package.cpp)
32+
target_compile_features(test_package-headers PRIVATE cxx_std_20)
33+
target_link_libraries(test_package-headers PRIVATE mp-units::mp-units)
34+
35+
if(MP_UNITS_BUILD_CXX_MODULES)
36+
add_executable(test_package test_package.cpp)
37+
target_compile_features(test_package PRIVATE cxx_std_20)
38+
target_link_libraries(test_package PRIVATE mp-units::mp-units)
39+
endif()

test_package/conanfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def generate(self):
4242
opt = self.dependencies["mp-units"].options
4343
if opt.cxx_modules:
4444
tc.cache_variables["CMAKE_CXX_SCAN_FOR_MODULES"] = True
45+
tc.cache_variables["MP_UNITS_BUILD_CXX_MODULES"] = True
4546
if opt.import_std:
4647
tc.cache_variables["CMAKE_CXX_MODULE_STD"] = True
4748
# Current experimental support according to `Help/dev/experimental.rst`
@@ -64,5 +65,8 @@ def build(self):
6465

6566
def test(self):
6667
if can_run(self):
67-
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
68+
if self.dependencies["mp-units"].options.cxx_modules:
69+
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
70+
self.run(bin_path, env="conanrun")
71+
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package-headers")
6872
self.run(bin_path, env="conanrun")

0 commit comments

Comments
 (0)