CMake: Add support for LIBRARY_PATHS to slint_target_sources

This makes it possible to use component libraries with C++.
This commit is contained in:
Simon Hausmann 2024-06-04 14:18:11 +02:00 committed by Simon Hausmann
parent b9052ecf8a
commit 6f2a6c3f09
8 changed files with 62 additions and 6 deletions

View file

@ -53,6 +53,7 @@ endif()
if(SLINT_FEATURE_COMPILER OR SLINT_COMPILER)
add_subdirectory(multiple-includes)
add_subdirectory(libraries)
endif()
slint_test(platform_eventloop)

View file

@ -0,0 +1,11 @@
# Copyright © SixtyFPS GmbH <info@slint.dev>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
add_executable(libraries main.cpp)
target_link_libraries(libraries PRIVATE Slint::Slint)
slint_target_sources(libraries appwindow.slint
LIBRARY_PATHS
helper_components=${CMAKE_CURRENT_SOURCE_DIR}/../../../../tests/helper_components/
helper_buttons=${CMAKE_CURRENT_SOURCE_DIR}/../../../../tests/helper_components/test_button.slint
)

View file

@ -0,0 +1,3 @@
<!-- Copyright © SixtyFPS GmbH <info@slint.dev> ; SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 -->
This is a test making sure that slint_target_sources accepts slint component library paths.

View file

@ -0,0 +1,12 @@
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import { TestButton } from "@helper_components/test_button.slint";
import { ColorButton } from "@helper_buttons";
export component App inherits Window {
TestButton { }
ColorButton { }
}

View file

@ -0,0 +1,10 @@
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
#include "appwindow.h"
int main(int argc, char **argv)
{
auto my_ui = App::create();
my_ui->run();
}