mirror of
https://github.com/shadps4-emu/ext-fmt.git
synced 2024-11-23 09:49:42 +00:00
Update add_module_library
This commit is contained in:
parent
4b5ae0b0ef
commit
d9c19940a3
@ -56,22 +56,16 @@ function(add_module_library name)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
# Check if modules are supported.
|
||||
set(have_modules FALSE)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND
|
||||
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
|
||||
set(have_modules TRUE)
|
||||
endif ()
|
||||
if (NOT have_modules)
|
||||
message(FATAL_ERROR "Modules not supported.")
|
||||
endif ()
|
||||
|
||||
# Modules require C++20.
|
||||
target_compile_features(${name} PUBLIC cxx_std_20)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
target_compile_options(${name} PUBLIC -fmodules-ts)
|
||||
endif ()
|
||||
|
||||
# `std` is affected by CMake options and may be higher than C++20.
|
||||
get_target_property(std ${name} CXX_STANDARD)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(pcms)
|
||||
foreach (src ${sources})
|
||||
get_filename_component(pcm ${src} NAME_WE)
|
||||
@ -80,7 +74,8 @@ function(add_module_library name)
|
||||
# Propagate -fmodule-file=*.pcm to targets that link with this library.
|
||||
target_compile_options(${name} PUBLIC -fmodule-file=${pcm})
|
||||
|
||||
# Use an absolute path to prevent target_link_libraries prepending -l to it.
|
||||
# Use an absolute path to prevent target_link_libraries prepending -l
|
||||
# to it.
|
||||
set(pcms ${pcms} ${CMAKE_CURRENT_BINARY_DIR}/${pcm})
|
||||
add_custom_command(
|
||||
OUTPUT ${pcm}
|
||||
@ -94,19 +89,20 @@ function(add_module_library name)
|
||||
endforeach ()
|
||||
|
||||
# Add .pcm files as sources to make sure they are built before the library.
|
||||
set(files)
|
||||
set(sources)
|
||||
foreach (pcm ${pcms})
|
||||
get_filename_component(pcm_we ${pcm} NAME_WE)
|
||||
set(obj ${pcm_we}.o)
|
||||
# Use an absolute path to prevent target_link_libraries prepending -l.
|
||||
set(files ${files} ${pcm} ${CMAKE_CURRENT_BINARY_DIR}/${obj})
|
||||
set(sources ${sources} ${pcm} ${CMAKE_CURRENT_BINARY_DIR}/${obj})
|
||||
add_custom_command(
|
||||
OUTPUT ${obj}
|
||||
COMMAND ${CMAKE_CXX_COMPILER} $<TARGET_PROPERTY:${name},COMPILE_OPTIONS>
|
||||
-c -o ${obj} ${pcm}
|
||||
DEPENDS ${pcm})
|
||||
endforeach ()
|
||||
target_sources(${name} PRIVATE ${files})
|
||||
endif ()
|
||||
target_sources(${name} PRIVATE ${sources})
|
||||
endfunction()
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
@ -76,10 +76,6 @@ export module fmt;
|
||||
#include "fmt/printf.h"
|
||||
#include "fmt/xchar.h"
|
||||
|
||||
#if !(defined(__cpp_modules) || FMT_CLANG_VERSION >= 1600)
|
||||
# error modules not supported
|
||||
#endif
|
||||
|
||||
// gcc doesn't yet implement private module fragments
|
||||
#if !FMT_GCC_VERSION
|
||||
module : private;
|
||||
|
Loading…
Reference in New Issue
Block a user