Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: test_package now is tested also with C++20 modules #542

Merged
merged 8 commits into from
Nov 18, 2024
12 changes: 12 additions & 0 deletions .github/workflows/ci-test-package-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 13 additions & 3 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 5 additions & 1 deletion test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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")