11from __future__ import annotations
22
33import importlib .metadata
4+ import shutil
45import zipfile
56from pathlib import Path
67
@@ -15,7 +16,7 @@ def test_version():
1516 assert importlib .metadata .version ("cython_cmake" ) == m .__version__
1617
1718
18- def test_scikit_build_core (monkeypatch , tmp_path ):
19+ def test_simple (monkeypatch , tmp_path ):
1920 monkeypatch .chdir (DIR / "packages/simple" )
2021 build_dir = tmp_path / "build"
2122
@@ -30,3 +31,59 @@ def test_scikit_build_core(monkeypatch, tmp_path):
3031 build_files = {x .name for x in build_dir .iterdir ()}
3132 assert "simple.c.dep" in build_files
3233 assert "simple.c" in build_files
34+
35+
36+ def test_implicit_cxx (monkeypatch , tmp_path ):
37+ package_dir = tmp_path / "pkg2"
38+ shutil .copytree (DIR / "packages/simple" , package_dir )
39+ monkeypatch .chdir (package_dir )
40+
41+ cmakelists = Path ("CMakeLists.txt" )
42+ txt = (
43+ cmakelists .read_text ()
44+ .replace ("LANGUAGE C" , "" )
45+ .replace ("LANGUAGES C" , "LANGUAGES CXX" )
46+ )
47+ cmakelists .write_text (txt )
48+
49+ wheel = build_wheel (
50+ str (tmp_path ), {"build-dir" : "build" , "wheel.license-files" : []}
51+ )
52+
53+ with zipfile .ZipFile (tmp_path / wheel ) as f :
54+ file_names = set (f .namelist ())
55+ assert len (file_names ) == 4
56+
57+ build_files = {x .name for x in Path ("build" ).iterdir ()}
58+ assert "simple.cxx.dep" in build_files
59+ assert "simple.cxx" in build_files
60+
61+
62+ def test_directive_cxx (monkeypatch , tmp_path ):
63+ package_dir = tmp_path / "pkg3"
64+ shutil .copytree (DIR / "packages/simple" , package_dir )
65+ monkeypatch .chdir (package_dir )
66+
67+ cmakelists = Path ("CMakeLists.txt" )
68+ txt = (
69+ cmakelists .read_text ()
70+ .replace ("LANGUAGE C" , "" )
71+ .replace ("LANGUAGES C" , "LANGUAGES CXX" )
72+ )
73+ cmakelists .write_text (txt )
74+
75+ simple = Path ("simple.pyx" )
76+ txt = simple .read_text ()
77+ simple .write_text (f"# distutils: language=c++\n { txt } " )
78+
79+ wheel = build_wheel (
80+ str (tmp_path ), {"build-dir" : "build" , "wheel.license-files" : []}
81+ )
82+
83+ with zipfile .ZipFile (tmp_path / wheel ) as f :
84+ file_names = set (f .namelist ())
85+ assert len (file_names ) == 4
86+
87+ build_files = {x .name for x in Path ("build" ).iterdir ()}
88+ assert "simple.cxx.dep" in build_files
89+ assert "simple.cxx" in build_files
0 commit comments