From f1a9b04f8253c5a3d3bfc4ae8f2a3ec3a0187ba5 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Thu, 26 Oct 2023 16:57:36 +0200 Subject: [PATCH] Use the standalone test directory name as the project name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tor Arne Vestbø --- .../QtStandaloneTestTemplateProject/CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmake/QtBuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt b/cmake/QtBuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt index 09c4dad4bbb..766e372666a 100644 --- a/cmake/QtBuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt +++ b/cmake/QtBuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt @@ -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")