Merge pull request #542 from mpusz/test_package_with_modules

test: test_package now is tested also with C++20 modules
This commit is contained in:
Mateusz Pusz
2024-11-18 15:38:28 +01:00
committed by GitHub
4 changed files with 31 additions and 5 deletions

View File

@ -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: |

View File

@ -216,7 +216,7 @@ class MPUnitsConan(ConanFile):
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")

View File

@ -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()

View File

@ -42,6 +42,7 @@ class TestPackageConan(ConanFile):
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 @@ class TestPackageConan(ConanFile):
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")