Skip to content

Commit

Permalink
Always use an object library for fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Dec 9, 2024
1 parent c8d157d commit cea3015
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ if(LIBTYPE STREQUAL "STATIC")
add_library(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS})
target_compile_definitions(${IMPL_TARGET} PUBLIC AL_LIBTYPE_STATIC)
target_link_libraries(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}
$<BUILD_LOCAL_INTERFACE:alsoft::fmt-objects>)
$<BUILD_LOCAL_INTERFACE:alsoft::fmt>)

if(WIN32)
# This option is for static linking OpenAL Soft into another project
Expand Down
43 changes: 1 addition & 42 deletions fmt-11.0.2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ add_headers(FMT_HEADERS args.h base.h chrono.h color.h compile.h core.h format.h
xchar.h)
set(FMT_SOURCES src/format.cc src/os.cc)

add_library(alsoft.fmt STATIC ${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md)
add_library(alsoft.fmt OBJECT ${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md)
add_library(alsoft::fmt ALIAS alsoft.fmt)

if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
Expand All @@ -73,53 +73,12 @@ target_include_directories(alsoft.fmt PUBLIC
set_target_properties(alsoft.fmt PROPERTIES ${ALSOFT_STD_VERSION_PROPS}
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}
DEBUG_POSTFIX "${ALSOFT_FMT_DEBUG_POSTFIX}"
POSITION_INDEPENDENT_CODE TRUE
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
EXCLUDE_FROM_ALL TRUE

# Workaround for Visual Studio 2017:
# Ensure the .pdb is created with the same name and in the same directory
# as the .lib. Newer VS versions already do this by default, but there is no
# harm in setting it for those too. Ignored by other generators.
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
COMPILE_PDB_NAME "fmt"
COMPILE_PDB_NAME_DEBUG "fmt${ALSOFT_FMT_DEBUG_POSTFIX}")



add_library(alsoft.fmt-objects OBJECT ${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md)
add_library(alsoft::fmt-objects ALIAS alsoft.fmt-objects)

if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
target_compile_features(alsoft.fmt-objects PUBLIC cxx_std_11)
else ()
message(WARNING "Feature cxx_std_11 is unknown for the CXX compiler")
endif ()

target_include_directories(alsoft.fmt-objects PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)

set_target_properties(alsoft.fmt-objects PROPERTIES ${ALSOFT_STD_VERSION_PROPS}
POSITION_INDEPENDENT_CODE TRUE
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
EXCLUDE_FROM_ALL TRUE)



add_library(alsoft.fmt-header-only INTERFACE EXCLUDE_FROM_ALL)
add_library(alsoft::fmt-header-only ALIAS alsoft.fmt-header-only)

if (MSVC)
# Unicode support requires compiling with /utf-8.
target_compile_options(alsoft.fmt PUBLIC $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
target_compile_options(alsoft.fmt-objects PUBLIC $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
target_compile_options(alsoft.fmt-header-only INTERFACE $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
endif ()

target_compile_definitions(alsoft.fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
target_compile_features(alsoft.fmt-header-only INTERFACE cxx_std_11)

target_include_directories(alsoft.fmt-header-only INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)

0 comments on commit cea3015

Please sign in to comment.