mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-20 05:12:07 -05:00
cxxmodules: compute link information for C++ module-consuming targets
Compute link information for all C++ targets which support modules instead of just those which may provide modules, as they may import modules as well. This captures `OBJECT` libraries using modules which otherwise do not have link steps. Fixes: #25592
This commit is contained in:
@@ -553,7 +553,8 @@ bool cmComputeLinkInformation::Compute()
|
|||||||
this->Target->GetType() == cmStateEnums::MODULE_LIBRARY ||
|
this->Target->GetType() == cmStateEnums::MODULE_LIBRARY ||
|
||||||
this->Target->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
this->Target->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
||||||
(this->Target->CanCompileSources() &&
|
(this->Target->CanCompileSources() &&
|
||||||
(this->Target->HaveCxx20ModuleSources() ||
|
(this->Target->HaveCxxModuleSupport(this->Config) ==
|
||||||
|
cmGeneratorTarget::Cxx20SupportLevel::Supported ||
|
||||||
this->Target->HaveFortranSources())))) {
|
this->Target->HaveFortranSources())))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
|||||||
run_cxx_module_test(non-trivial-collation-order-randomized)
|
run_cxx_module_test(non-trivial-collation-order-randomized)
|
||||||
run_cxx_module_test(duplicate)
|
run_cxx_module_test(duplicate)
|
||||||
set(RunCMake_CXXModules_NO_TEST 1)
|
set(RunCMake_CXXModules_NO_TEST 1)
|
||||||
|
run_cxx_module_test(import-from-object)
|
||||||
run_cxx_module_test(circular)
|
run_cxx_module_test(circular)
|
||||||
run_cxx_module_test(try-compile)
|
run_cxx_module_test(try-compile)
|
||||||
run_cxx_module_test(try-run)
|
run_cxx_module_test(try-run)
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24...3.28)
|
||||||
|
project(cxx_modules_import_from_object CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
add_library(a STATIC)
|
||||||
|
target_sources(a
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET CXX_MODULES
|
||||||
|
FILES
|
||||||
|
object-a.cxx)
|
||||||
|
|
||||||
|
add_library(b OBJECT object-b.cxx)
|
||||||
|
target_link_libraries(b PRIVATE a)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
module;
|
||||||
|
export module a;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
import a;
|
||||||
Reference in New Issue
Block a user