Debian Codegraph @

cmake/QtBuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt

raw
1 # Copyright (C) 2022 The Qt Company Ltd.
2 # SPDX-License-Identifier: BSD-3-Clause
3
4 cmake_minimum_required(VERSION 3.16)
5
6 # Get the absolute path of the passed-in project dir, relative to the current working directory
7 # of the calling script, rather than relative to this source directory.
8 # The calling script sets PWD. If not set, just use the passed-in value as-is.
9 if(DEFINED PWD)
10 get_filename_component(absolute_project_path "${QT_STANDALONE_TEST_PATH}" ABSOLUTE
11 BASE_DIR "${PWD}")
12 else()
13 set(absolute_project_path "${QT_STANDALONE_TEST_PATH}")
14 endif()
15
16 # If path does not include the drive letter, we try to add it.
17 get_filename_component(absolute_project_path "." REALPATH BASE_DIR "${absolute_project_path}")
18
19 if(NOT IS_DIRECTORY "${absolute_project_path}")
20 get_filename_component(filename "${absolute_project_path}" NAME)
21 get_filename_component(directory "${absolute_project_path}" DIRECTORY)
22
23 if(filename STREQUAL "CMakeLists.txt")
24 set(absolute_project_path "${directory}")
25 endif()
26 endif()
27
28 # Get the project name base on test directory name
29 get_filename_component(project_name "${absolute_project_path}" NAME)
30
31 project(${project_name} VERSION 6.0.0 LANGUAGES C CXX)
32
33 find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core)
34
35 include(${CMAKE_CURRENT_LIST_DIR}/Main.cmake NO_POLICY_SCOPE)
36
37 # Add the test project path as a subdirectory project.
38 add_subdirectory("${absolute_project_path}" "build_dir")