@@ -65,73 +65,23 @@ if(NOT HPX_WITH_CXX_MODULES)
6565 return ()
6666endif ()
6767
68- # hpx_configure_module_producer(<producer> [MODULE_OUT_DIR <dir>] )
68+ # hpx_configure_module_producer(<producer>)
6969#
70- # * Ensures a stable module output dir for producer target
71- # * Adds compiler flags to write module cache there (Clang/GCC)
7270# * Creates an interface target '<producer>_if' for consumers to link to
71+ # * Marks the interface target for CMake's native module scanning
7372function (hpx_configure_module_producer producer )
7473 if (NOT TARGET ${producer} )
7574 hpx_error ("hpx_configure_module_producer: target '${producer} ' not found" )
7675 endif ()
7776
78- # parse optional args
79- set (options)
80- set (one_value_args MODULE_OUT_DIR)
81- set (multi_value_args)
82- cmake_parse_arguments (
83- _args "${options} " "${one_value_args} " "${multi_value_args} " ${ARGN}
84- )
85-
86- if (_args_MODULE_OUT_DIR)
87- set (_moddir "${_args_MODULE_OUT_DIR} " )
88- else ()
89- set (_moddir "$<TARGET_FILE_DIR :${producer} >" )
90- endif ()
91-
9277 set (_iface "${producer} _if" )
9378 if (NOT TARGET ${_iface} )
9479 add_library (${_iface} INTERFACE )
9580 target_link_libraries (${_iface} INTERFACE ${producer} )
9681 endif ()
9782
98- # Set a property so consumers can query the BMI directory via
99- # get_target_property.
100- set_target_properties (
101- ${_iface} PROPERTIES INTERFACE_EXPORT_MODULE_DIR "${_moddir} "
102- )
103-
104- # Make sure consumers scan for the BMI
83+ # Make sure consumers scan for modules through CMake's native module handling
10584 set_target_properties (${_iface} PROPERTIES INTERFACE_CXX_SCAN_FOR_MODULES On )
106-
107- if (MSVC )
108- # MSVC: CMake/MSVC handle IFCs automatically; create a target for
109- # convenience, consumers can link to this to get ordering and include info
110- return ()
111- endif ()
112-
113- # Compiler-specific flags to instruct where to write module cache
114- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES
115- "AppleClang"
116- )
117- # Clang common flags
118- target_compile_options (${producer} PRIVATE "-fmodule-output=${_moddir} " )
119- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
120- # GCC: modern flags
121- hpx_add_target_compile_option_if_available (
122- ${producer} PRIVATE "-fmodule-output=${_moddir} " RESULT ok
123- )
124- if (NOT ok)
125- hpx_error (
126- "hpx_configure_module_producer: the used version of gcc does not support '-fmodule-output'"
127- )
128- endif ()
129- else ()
130- hpx_warn (
131- "hpx_configure_module_producer: unknown compiler '${CMAKE_CXX_COMPILER_ID} '; "
132- "exposing EXPORT_MODULE_DIR='${_moddir} ' for manual handling"
133- )
134- endif ()
13585endfunction ()
13686
13787# hpx_configure_module_consumer(<consumer> <producer>])
@@ -150,37 +100,15 @@ function(hpx_configure_module_consumer consumer producer)
150100 get_target_property (_scan ${producer} INTERFACE_CXX_SCAN_FOR_MODULES )
151101 if (_scan)
152102 set_target_properties (${consumer} PROPERTIES CXX_SCAN_FOR_MODULES ${_scan} )
153- endif ()
154103
155- get_target_property (_module_dir ${producer} INTERFACE_EXPORT_MODULE_DIR )
156- if (_module_dir)
157- if (MSVC )
158- return ()
159- elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID
160- MATCHES "AppleClang"
104+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID
105+ MATCHES "AppleClang"
161106 )
162- target_compile_options (
163- ${consumer} PRIVATE "-fprebuilt-module-path=${_module_dir} "
164- )
165107 get_target_property (_type ${consumer} TYPE )
166108 if ((_type STREQUAL "SHARED_LIBRARY" ) OR (_type STREQUAL "EXECUTABLE" ))
167109 target_link_options (${consumer} PRIVATE "-fuse-ld=lld" )
168110 target_link_options (${consumer} PRIVATE "-Wl,--error-limit=0" )
169111 endif ()
170- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
171- hpx_add_target_compile_option_if_available (
172- ${consumer} PRIVATE "-fprebuilt-module-path=${_module_dir} " RESULT ok
173- )
174- if (NOT ok)
175- hpx_error (
176- "hpx_configure_module_consumer: the used version of gcc does not "
177- "support '-fprebuilt-module-path='"
178- )
179- endif ()
180- else ()
181- hpx_warn (
182- "hpx_configure_module_consumer: unknown compiler '${CMAKE_CXX_COMPILER_ID} '"
183- )
184112 endif ()
185113 endif ()
186114endfunction ()
0 commit comments