Skip to content

Commit

Permalink
Cleanup cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jun 14, 2024
1 parent a245a8d commit 98dd673
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ function(enable_module target)
endif ()
endfunction()

set(FMT_USE_CMAKE_MODULES FALSE)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND
CMAKE_GENERATOR STREQUAL "Ninja")
set(FMT_USE_CMAKE_MODULES TRUE)
endif ()

# Adds a library compiled with C++20 module support.
# `enabled` is a CMake variables that specifies if modules are enabled.
# If modules are disabled `add_module_library` falls back to creating a
Expand Down Expand Up @@ -65,8 +71,9 @@ function(add_module_library name)

target_compile_definitions(${name} PRIVATE FMT_MODULE)

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND CMAKE_GENERATOR STREQUAL "Ninja")
target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES FILES ${sources})
if (FMT_USE_CMAKE_MODULES)
target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES
FILES ${sources})
else()
# `std` is affected by CMake options and may be higher than C++20.
get_target_property(std ${name} CXX_STANDARD)
Expand Down Expand Up @@ -403,10 +410,9 @@ if (FMT_INSTALL)

set(INSTALL_TARGETS fmt fmt-header-only)

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND CMAKE_GENERATOR STREQUAL "Ninja")
set(INSTALL_FILE_SET)
if (FMT_USE_CMAKE_MODULES)
set(INSTALL_FILE_SET FILE_SET fmt DESTINATION "${FMT_INC_DIR}/fmt")
else()
set(INSTALL_FILE_SET)
endif()

# Install the library and headers.
Expand Down

0 comments on commit 98dd673

Please sign in to comment.