slint/api/cpp/tests/CMakeLists.txt
Olivier Goffart 14f7fe4ba2
cmake: add flags to only build the compiler
... and to use an external compiler

For example, this is how one only build the compiler:

```
cmake .. -DSLINT_BUILD_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX=/tmp/slint_compiler
make install
```

And this only build the runtime
```
cmake .. -DSLINT_FEATURE_COMPILER=OFF -DCMAKE_INSTALL_PREFIX=/tmp/install_runtime
make install
```

And then this can be used in a project like so:
```
cmake .. -DCMAKE_PREFIX_PATH=/tmp/install_runtime/ -DSLINT_COMPILER=/tmp/install_compiler/bin/slint-compiler
```
2023-09-15 14:42:52 +02:00

54 lines
1.5 KiB
CMake

# Copyright © SixtyFPS GmbH <info@slint.dev>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.8
)
FetchContent_MakeAvailable(Catch2)
find_package(Threads REQUIRED)
macro(slint_test NAME)
add_executable(test_${NAME} ${NAME}.cpp)
target_link_libraries(test_${NAME} PRIVATE Slint Catch2::Catch2)
target_compile_definitions(test_${NAME} PRIVATE
SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"
)
add_test(NAME test_${NAME} COMMAND test_${NAME})
if(MSVC)
target_compile_options(test_${NAME} PRIVATE /W3)
else()
target_compile_options(test_${NAME} PRIVATE -Wall -Wextra -Werror)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
# that warning has false positives
target_compile_options(test_${NAME} PRIVATE -Wno-maybe-uninitialized)
endif()
endmacro(slint_test)
slint_test(datastructures)
if(SLINT_FEATURE_INTERPRETER)
slint_test(interpreter)
slint_test(window)
endif()
slint_test(properties)
if(NOT SLINT_FEATURE_FREESTANDING)
slint_test(eventloop)
target_link_libraries(test_eventloop PRIVATE Threads::Threads)
endif()
slint_test(models)
if(SLINT_FEATURE_COMPILER OR SLINT_COMPILER)
add_subdirectory(multiple-includes)
endif()
slint_test(platform_eventloop)
target_link_libraries(test_platform_eventloop PRIVATE Threads::Threads)