[M8] reusable libraries: install layout + cargoxx-path deps

This commit is contained in:
2026-05-17 18:13:15 +00:00
parent fdf97861a4
commit e6c39914b3
25 changed files with 932 additions and 21 deletions

View File

@@ -72,10 +72,15 @@ TEST_CASE("cmake_lists for a binary-only project", "[codegen][cmake]") {
GenerateInputs in{m, layout, lock, {}, {}, ROOT};
auto out = cmake_lists(in);
REQUIRE(out.find("project(hello LANGUAGES CXX)") != std::string::npos);
REQUIRE(out.find("project(hello VERSION 0.1.0 LANGUAGES CXX)") != std::string::npos);
REQUIRE(out.find("include(GNUInstallDirs)") != std::string::npos);
REQUIRE(out.find("set(CMAKE_CXX_STANDARD 23)") != std::string::npos);
REQUIRE(out.find("add_executable(hello_bin ../src/main.cpp)") != std::string::npos);
REQUIRE(out.find("set_target_properties(hello_bin PROPERTIES OUTPUT_NAME hello)") !=
REQUIRE(out.find("set_target_properties(hello_bin PROPERTIES\n"
" OUTPUT_NAME hello\n"
" RUNTIME_OUTPUT_DIRECTORY \"${CMAKE_BINARY_DIR}/bin\")") !=
std::string::npos);
REQUIRE(out.find("install(TARGETS hello_bin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})") !=
std::string::npos);
REQUIRE(out.find("add_library") == std::string::npos);
REQUIRE(out.find("enable_testing") == std::string::npos);
@@ -98,6 +103,15 @@ TEST_CASE("cmake_lists for a library-only project", "[codegen][cmake]") {
REQUIRE(out.find("FILE_SET CXX_MODULES") != std::string::npos);
REQUIRE(out.find("../src/lib.cppm") != std::string::npos);
REQUIRE(out.find("add_executable") == std::string::npos);
// Library projects emit install rules + Config.cmake + .pc.
REQUIRE(out.find("install(TARGETS widget\n EXPORT widgetTargets") !=
std::string::npos);
REQUIRE(out.find("install(EXPORT widgetTargets") != std::string::npos);
REQUIRE(out.find("configure_package_config_file(") != std::string::npos);
REQUIRE(out.find("write_basic_package_version_file(") != std::string::npos);
REQUIRE(out.find("widget.pc.in") != std::string::npos);
REQUIRE(out.find("DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig") !=
std::string::npos);
}
TEST_CASE("cmake_lists wires up library + primary binary", "[codegen][cmake]") {
@@ -138,6 +152,13 @@ TEST_CASE("cmake_lists emits extra binaries from src/bin/", "[codegen][cmake]")
auto out = cmake_lists(in);
REQUIRE(out.find("add_executable(app_bin ../src/main.cpp)") != std::string::npos);
REQUIRE(out.find("add_executable(tool ../src/bin/tool.cpp)") != std::string::npos);
REQUIRE(out.find("set_target_properties(app_bin PROPERTIES\n"
" OUTPUT_NAME app\n"
" RUNTIME_OUTPUT_DIRECTORY \"${CMAKE_BINARY_DIR}/bin\")") !=
std::string::npos);
REQUIRE(out.find("set_target_properties(tool PROPERTIES\n"
" RUNTIME_OUTPUT_DIRECTORY \"${CMAKE_BINARY_DIR}/bin\")") !=
std::string::npos);
}
TEST_CASE("cmake_lists emits tests with add_test", "[codegen][cmake]") {