Use the standalone test directory name as the project name

Using this trick we force CMake xcode generator to give the more
specific project name when configuring standalone tests.

Change-Id: Ic679003c574c0407bdc8df9eecf3762db214fd50
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Alexey Edelev 2023-10-26 16:57:36 +02:00
parent 9f3d6e325f
commit f1a9b04f82

View File

@ -2,11 +2,6 @@
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(qt_single_test VERSION 6.0.0 LANGUAGES C CXX ASM)
find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core)
include(${CMAKE_CURRENT_LIST_DIR}/Main.cmake NO_POLICY_SCOPE)
# Get the absolute path of the passed-in project dir, relative to the current working directory
# of the calling script, rather than relative to this source directory.
@ -30,5 +25,14 @@ if(NOT IS_DIRECTORY "${absolute_project_path}")
endif()
endif()
# Get the project name base on test directory name
get_filename_component(project_name "${absolute_project_path}" NAME)
project(${project_name} VERSION 6.0.0 LANGUAGES C CXX ASM)
find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core)
include(${CMAKE_CURRENT_LIST_DIR}/Main.cmake NO_POLICY_SCOPE)
# Add the test project path as a subdirectory project.
add_subdirectory("${absolute_project_path}" "build_dir")