diff options
| author | ruki <[email protected]> | 2023-01-12 08:36:43 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-12 08:36:43 +0800 |
| commit | 4a911fb47f4fd12cefbc4580d5ddceb9f65b9a81 (patch) | |
| tree | 738e993d5055ec7e701e31631dd5818510f8f95a /tests/projects/c++ | |
| parent | 15733580777f5a1c0a15da835a27d2c832539c93 (diff) | |
| parent | 9793894c1d2e055a4cfe044002bea4c7e6bb075d (diff) | |
Merge pull request #3255 from Arthapz/improve-clang-modules-support-with-libc++
improve clang libc++ module support
Diffstat (limited to 'tests/projects/c++')
29 files changed, 95 insertions, 97 deletions
diff --git a/tests/projects/c++/modules/class/xmake.lua b/tests/projects/c++/modules/class/xmake.lua index 6d6eaddee..42da78369 100644 --- a/tests/projects/c++/modules/class/xmake.lua +++ b/tests/projects/c++/modules/class/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("class") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + diff --git a/tests/projects/c++/modules/cpp_with_moduledeps/xmake.lua b/tests/projects/c++/modules/cpp_with_moduledeps/xmake.lua index 5c7a8a6f7..6a9b3538f 100644 --- a/tests/projects/c++/modules/cpp_with_moduledeps/xmake.lua +++ b/tests/projects/c++/modules/cpp_with_moduledeps/xmake.lua @@ -1,10 +1,11 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") target("mod") set_kind("static") add_files("src/mod.mpp", "src/mod.cpp") -target("main") +target("cpp_with_moduledeps") set_kind("binary") add_deps("mod") add_files("src/main.cpp") diff --git a/tests/projects/c++/modules/dependence/xmake.lua b/tests/projects/c++/modules/dependence/xmake.lua index 6d64b49b1..4d035c42b 100644 --- a/tests/projects/c++/modules/dependence/xmake.lua +++ b/tests/projects/c++/modules/dependence/xmake.lua @@ -1,4 +1,7 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("dependence") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + diff --git a/tests/projects/c++/modules/dependence2/xmake.lua b/tests/projects/c++/modules/dependence2/xmake.lua index 6d64b49b1..4f2905fe9 100644 --- a/tests/projects/c++/modules/dependence2/xmake.lua +++ b/tests/projects/c++/modules/dependence2/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("dependence") + +target("dependence2") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/headerunits_person/xmake.lua b/tests/projects/c++/modules/headerunits_person/xmake.lua index c9290833b..d11b49824 100644 --- a/tests/projects/c++/modules/headerunits_person/xmake.lua +++ b/tests/projects/c++/modules/headerunits_person/xmake.lua @@ -1,4 +1,7 @@ +add_rules("mode.release", "mode.debug")
set_languages("c++20")
-target("hello")
+
+target("headerunits_person")
set_kind("binary")
add_files("src/*.cpp", "src/*.mpp")
+
diff --git a/tests/projects/c++/modules/hello with spaces/xmake.lua b/tests/projects/c++/modules/hello with spaces/xmake.lua index 4f46b699d..4369a892f 100644 --- a/tests/projects/c++/modules/hello with spaces/xmake.lua +++ b/tests/projects/c++/modules/hello with spaces/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") -target("A hello") + +target("hello with spaces") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/hello/xmake.lua b/tests/projects/c++/modules/hello/xmake.lua index de13fc409..4f6fdab98 100644 --- a/tests/projects/c++/modules/hello/xmake.lua +++ b/tests/projects/c++/modules/hello/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") + target("hello") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/ifdef_module/xmake.lua b/tests/projects/c++/modules/ifdef_module/xmake.lua index ee931a801..25933a35f 100644 --- a/tests/projects/c++/modules/ifdef_module/xmake.lua +++ b/tests/projects/c++/modules/ifdef_module/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") + target("ifdef_module") set_kind("binary") add_files("src/*.cpp") diff --git a/tests/projects/c++/modules/impl_unit/xmake.lua b/tests/projects/c++/modules/impl_unit/xmake.lua index abe41d20a..991f2a895 100644 --- a/tests/projects/c++/modules/impl_unit/xmake.lua +++ b/tests/projects/c++/modules/impl_unit/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("impl_unit") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/inline_and_template/xmake.lua b/tests/projects/c++/modules/inline_and_template/xmake.lua index 4810edb85..8c981fae9 100644 --- a/tests/projects/c++/modules/inline_and_template/xmake.lua +++ b/tests/projects/c++/modules/inline_and_template/xmake.lua @@ -1,4 +1,7 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("inline_and_template") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + diff --git a/tests/projects/c++/modules/internal_partition/xmake.lua b/tests/projects/c++/modules/internal_partition/xmake.lua index f7ca6f7cf..422292295 100644 --- a/tests/projects/c++/modules/internal_partition/xmake.lua +++ b/tests/projects/c++/modules/internal_partition/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") + target("internal_partition") set_kind("binary") add_files("src/*.cpp", "src/hello.mpp") diff --git a/tests/projects/c++/modules/partitions/test.lua b/tests/projects/c++/modules/partitions/test.lua index c18e5a1d0..e77adc4ae 100644 --- a/tests/projects/c++/modules/partitions/test.lua +++ b/tests/projects/c++/modules/partitions/test.lua @@ -1 +1 @@ -inherit(".test_headerunits") +inherit(".test_stdmodules") diff --git a/tests/projects/c++/modules/partitions/xmake.lua b/tests/projects/c++/modules/partitions/xmake.lua index 672034947..4b575432a 100644 --- a/tests/projects/c++/modules/partitions/xmake.lua +++ b/tests/projects/c++/modules/partitions/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("math") + +target("partition") set_kind("binary") - add_files("src/*.cpp", "src/*.mpp") + add_files("src/*.cpp", "src/*.mpp")
\ No newline at end of file diff --git a/tests/projects/c++/modules/partitions2/test.lua b/tests/projects/c++/modules/partitions2/test.lua index c18e5a1d0..e77adc4ae 100644 --- a/tests/projects/c++/modules/partitions2/test.lua +++ b/tests/projects/c++/modules/partitions2/test.lua @@ -1 +1 @@ -inherit(".test_headerunits") +inherit(".test_stdmodules") diff --git a/tests/projects/c++/modules/partitions2/xmake.lua b/tests/projects/c++/modules/partitions2/xmake.lua index c9290833b..9e0ab37bb 100644 --- a/tests/projects/c++/modules/partitions2/xmake.lua +++ b/tests/projects/c++/modules/partitions2/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug")
set_languages("c++20")
-target("hello")
+
+target("partition2")
set_kind("binary")
add_files("src/*.cpp", "src/*.mpp")
diff --git a/tests/projects/c++/modules/private_module/xmake.lua b/tests/projects/c++/modules/private_module/xmake.lua index 1930f1188..57ede6993 100644 --- a/tests/projects/c++/modules/private_module/xmake.lua +++ b/tests/projects/c++/modules/private_module/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") + target("private_module") add_rules("c++") set_kind("$(kind)") diff --git a/tests/projects/c++/modules/staticlib/xmake.lua b/tests/projects/c++/modules/staticlib/xmake.lua index 93045c18f..5a3a9f4c6 100644 --- a/tests/projects/c++/modules/staticlib/xmake.lua +++ b/tests/projects/c++/modules/staticlib/xmake.lua @@ -1,10 +1,11 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") target("mod") set_kind("static") add_files("src/mod.mpp", "src/mod.cpp") -target("test") +target("staticlib") set_kind("binary") add_deps("mod") add_files("src/main.cpp") diff --git a/tests/projects/c++/modules/stdmodules/test.lua b/tests/projects/c++/modules/stdmodules/test.lua index 0657ead56..e77adc4ae 100644 --- a/tests/projects/c++/modules/stdmodules/test.lua +++ b/tests/projects/c++/modules/stdmodules/test.lua @@ -1 +1 @@ -inherit(".test_msvc") +inherit(".test_stdmodules") diff --git a/tests/projects/c++/modules/stdmodules/xmake.lua b/tests/projects/c++/modules/stdmodules/xmake.lua index 85e738d14..5cf4ccb9d 100644 --- a/tests/projects/c++/modules/stdmodules/xmake.lua +++ b/tests/projects/c++/modules/stdmodules/xmake.lua @@ -1,14 +1,15 @@ add_rules("mode.debug", "mode.release") - -add_cxxflags("clang::-stdlib=libc++") - set_languages("c++latest") target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") -target("test") + set_policy("build.c++.clang.stdmodules", true) + +target("stdmodules") set_kind("binary") add_files("test/*.cpp") add_deps("mod") + + set_policy("build.c++.clang.stdmodules", true) diff --git a/tests/projects/c++/modules/stdmodules_multiple_targets/test.lua b/tests/projects/c++/modules/stdmodules_multiple_targets/test.lua index 0657ead56..e77adc4ae 100644 --- a/tests/projects/c++/modules/stdmodules_multiple_targets/test.lua +++ b/tests/projects/c++/modules/stdmodules_multiple_targets/test.lua @@ -1 +1 @@ -inherit(".test_msvc") +inherit(".test_stdmodules") diff --git a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua index 859dddc7c..32bed613b 100644 --- a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua +++ b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua @@ -1,13 +1,14 @@ add_rules("mode.debug", "mode.release") - -add_cxxflags("clang::-stdlib=libc++") - set_languages("c++latest") target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") + set_policy("build.c++.clang.stdmodules", true) + target("mod2") set_kind("static") add_files("src/*.cpp", "src/*.mpp") + + set_policy("build.c++.clang.stdmodules", true) diff --git a/tests/projects/c++/modules/stl_headerunit/xmake.lua b/tests/projects/c++/modules/stl_headerunit/xmake.lua index e85378c46..55d55a5fd 100644 --- a/tests/projects/c++/modules/stl_headerunit/xmake.lua +++ b/tests/projects/c++/modules/stl_headerunit/xmake.lua @@ -1,4 +1,7 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("stl_headerunit") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + diff --git a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua index 101a95fe7..97a260e1e 100644 --- a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua +++ b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua @@ -1,76 +1,8 @@ -add_rules("mode.debug", "mode.release") +add_rules("mode.release", "mode.debug") +set_languages("c++20") -target("test") +target("stl_headerunit_cpp_only") set_kind("binary") add_files("src/*.cpp") - set_languages("c++20") set_policy("build.c++.modules", true) --- --- If you want to known more usage about xmake, please see https://xmake.io --- --- ## FAQ --- --- You can enter the project directory firstly before building project. --- --- $ cd projectdir --- --- 1. How to build project? --- --- $ xmake --- --- 2. How to configure project? --- --- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release] --- --- 3. Where is the build output directory? --- --- The default output directory is `./build` and you can configure the output directory. --- --- $ xmake f -o outputdir --- $ xmake --- --- 4. How to run and debug target after building project? --- --- $ xmake run [targetname] --- $ xmake run -d [targetname] --- --- 5. How to install target to the system directory or other output directory? --- --- $ xmake install --- $ xmake install -o installdir --- --- 6. Add some frequently-used compilation flags in xmake.lua --- --- @code --- -- add debug and release modes --- add_rules("mode.debug", "mode.release") --- --- -- add macro defination --- add_defines("NDEBUG", "_GNU_SOURCE=1") --- --- -- set warning all as error --- set_warnings("all", "error") --- --- -- set language: c99, c++11 --- set_languages("c99", "c++11") --- --- -- set optimization: none, faster, fastest, smallest --- set_optimize("fastest") --- --- -- add include search directories --- add_includedirs("/usr/include", "/usr/local/include") --- --- -- add link libraries and search directories --- add_links("tbox") --- add_linkdirs("/usr/local/lib", "/usr/lib") --- --- -- add system link libraries --- add_syslinks("z", "pthread") --- --- -- add compilation and link flags --- add_cxflags("-stdnolib", "-fno-strict-aliasing") --- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true}) --- --- @endcode --- diff --git a/tests/projects/c++/modules/submodules/xmake.lua b/tests/projects/c++/modules/submodules/xmake.lua index 672034947..e84b63a9f 100644 --- a/tests/projects/c++/modules/submodules/xmake.lua +++ b/tests/projects/c++/modules/submodules/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("math") + +target("submodule") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/submodules2/xmake.lua b/tests/projects/c++/modules/submodules2/xmake.lua index 672034947..9dc2ee320 100644 --- a/tests/projects/c++/modules/submodules2/xmake.lua +++ b/tests/projects/c++/modules/submodules2/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("math") + +target("submodules2") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index 4aee9f8e7..efef15520 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -16,7 +16,7 @@ function main(t) _build() elseif is_host("linux") then local gcc = find_tool("gcc", {version = true}) - if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then os.exec("xmake f -c") _build() end @@ -25,6 +25,9 @@ function main(t) os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang -c") _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + _build() end end end diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index 78c999497..6a942e583 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -25,10 +25,17 @@ function main(t) _build() end local clang = find_tool("clang", {version = true}) - if clang and clang.version and semver.compare(clang.version, "16.0") >= 0 then - os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang -c --yes") - _build() + if clang and clang.version then + if semver.compare(clang.version, "15.0") >= 0 then + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang -c") + _build() + -- elseif semver.compare(clang.version, "15.0") >= 0 then + -- there is currently a bug on llvm git that prevent to build STL header units https://github.com/llvm/llvm-project/issues/58540 + -- os.exec("xmake clean -a") + -- os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + -- _build() + end end end end diff --git a/tests/projects/c++/modules/test_msvc.lua b/tests/projects/c++/modules/test_stdmodules.lua index a436b5814..360a56cbc 100644 --- a/tests/projects/c++/modules/test_msvc.lua +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -24,5 +24,22 @@ function main(t) end end end + elseif is_host("linux") then -- or is_host("macosx") then + -- gcc don't support std modules atm + -- local gcc = find_tool("gcc", {version = true}) + -- if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + -- os.exec("xmake f -c") + -- _build() + -- end + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then + -- clang don't support libstdc++ std modules atm + -- os.exec("xmake clean -a") + -- os.exec("xmake f --toolchain=clang -c") + -- _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + _build() + end end end diff --git a/tests/projects/c++/modules/user_headerunit/xmake.lua b/tests/projects/c++/modules/user_headerunit/xmake.lua index dae91d11f..e305044b5 100644 --- a/tests/projects/c++/modules/user_headerunit/xmake.lua +++ b/tests/projects/c++/modules/user_headerunit/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("user_headerunit") set_kind("binary") add_headerfiles("src/*.hpp") |
