Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace forward slashes by backslashes in BMI path for MSVC. #4344

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

tkhyn
Copy link
Contributor

@tkhyn tkhyn commented Feb 6, 2025

Using backslashes in the BMI variable in CMake leads to a build error:

D:\dev\sandbox\fmt_test\main.cpp(1,1): error C7684: module name 'fmt' has an ambiguous resolution to IFC [D:\dev\sandbo
x\fmt_test\build\main.vcxproj]
      D:\dev\sandbox\fmt_test\main.cpp(1,1):
      could be 'D:/dev/sandbox/fmt_test/build/fmt/fmt.ifc'
      D:\dev\sandbox\fmt_test\main.cpp(1,1):
      or       'D:\dev\sandbox\fmt_test\build\fmt\fmt.ifc'

This PR corrects that.

Note that this is doesn't fix Ninja builds which still lead to the result below, but I'm not entirely sure how they could be fixed:

c1xx: error C3472: new output file name fmt\CMakeFiles\fmt.dir\fmt.ifc (set on command line) conflicts with previous file name D:\dev\sandbox\fmt_test\build\fmt\fmt.ifc
ninja: build stopped: subcommand failed.

CMakeLists.txt Outdated
Comment on lines 30 to 31
string(REPLACE "/" "\\" BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(BMI ${BIN_DIR}\\${target}.ifc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reuse existing CMake functionality:

Suggested change
string(REPLACE "/" "\\" BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(BMI ${BIN_DIR}\\${target}.ifc)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${target}.ifc" BMI)

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, please apply Sergiu's suggestion.

Note that this is still broken when using -G Ninja
@tkhyn
Copy link
Contributor Author

tkhyn commented Feb 6, 2025

@sergiud Thanks for the suggestion, I've learnt a new CMake feature!
@vitaut I've updated my PR and tested, good to go

It still breaks with Ninja generator, not sure what to do but if I find something I'll create another PR

@tkhyn
Copy link
Contributor Author

tkhyn commented Feb 6, 2025

Just pushed a fix on the same branch that works with ninja whether building the standalone library or included as a sub-directory in another project. Feel free to have a look.

CMakeLists.txt Outdated
Comment on lines 30 to 38
set(BMI_DIR ${CMAKE_CURRENT_BINARY_DIR}/)
if (CMAKE_GENERATOR STREQUAL "Ninja")
file(RELATIVE_PATH BMI_DIR ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
if (BMI_DIR)
set(BMI_DIR ${BMI_DIR}/)
endif()
set(BMI_DIR ${BMI_DIR}CMakeFiles/${target}.dir/)
endif()
file(TO_NATIVE_PATH "${BMI_DIR}${target}.ifc" BMI)
Copy link
Contributor

@sergiud sergiud Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(BMI_DIR ${CMAKE_CURRENT_BINARY_DIR}/)
if (CMAKE_GENERATOR STREQUAL "Ninja")
file(RELATIVE_PATH BMI_DIR ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
if (BMI_DIR)
set(BMI_DIR ${BMI_DIR}/)
endif()
set(BMI_DIR ${BMI_DIR}CMakeFiles/${target}.dir/)
endif()
file(TO_NATIVE_PATH "${BMI_DIR}${target}.ifc" BMI)
set(BMI_DIR "${CMAKE_CURRENT_BINARY_DIR}/")
if (CMAKE_GENERATOR STREQUAL "Ninja")
file(RELATIVE_PATH BMI_DIR "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
if (BMI_DIR)
set(BMI_DIR "${BMI_DIR}/")
endif()
set(BMI_DIR "${BMI_DIR}CMakeFiles/${target}.dir/")
endif()
file(TO_NATIVE_PATH "${BMI_DIR}${target}.ifc" BMI)

Just in case paths contain spaces, always quote these to avoid CMake creating lists and a mismatch in the number of arguments when invoking commands such as file.

Is the Ninja specific conditional necessary? Can't we always use the Ninja logic regardless of the generator?

What happens if the relative path BMI_DIR cannot be determined (line 33) or is empty? Doesn't this condition need a fallback?

Copy link
Contributor Author

@tkhyn tkhyn Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quotes added, good catch, thanks!

I'm not sure what you mean by 'cannot be determined' for the relative path:

  • Even when the 2nd folder isn't a sub-folder of the first the command does not fail
  • I can't imagine a situation where CMAKE_CURRENT_BINARY_DIR isn't a sub-folder of CMAKE_BINARY_DIR

If CMAKE_BINARY_DIR and CMAKE_CURRENT_BINARY_DIR are the same (which is the case when building fmt standalone), then the relative path is empty, and BMI_DIR ends up being CMakeFiles/${target}.dir/, with no leading slash. If the relative path isn't empty, then a trailing slash is appended to it so that the final path is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the Ninja specific conditional necessary? Can't we always use the Ninja logic regardless of the generator?

Unfortunately, yes it is necessary: when using Visual Studio generator and fmt is in an included subdirectory of the source directory, using the Ninja path fails the build with the same error as previously ('ambiguous resolution to IFC')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have the if (BMI_DIR) check implying that BMI_DIR can be unset or empty. Why do you need this check if determining the relative path always succeeds?

As for the Ninja conditional what I'm saying is that you should always use the Ninja logic. It is not clear why this code path is not expected to work using other generators as well (e.g., MSVC).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have the if (BMI_DIR) check implying that BMI_DIR can be unset or empty. Why do you need this check if determining the relative path always succeeds?

If BMI_DIR is not empty, it has a trailing slash. If it's empty, CMAKE_BINARY_DIR and CMAKE_CURRENT_BINARY_DIR are the same and we need the trailing slash otherwise the concatenation at the next step is wrong. There are 2 ways to deal with that, either remove the trailing slash at the end of BMI_DIR when it's not empty, or add it if it's empty. I chose the 2nd solution as it is easier...

As for the Ninja conditional what I'm saying is that you should always use the Ninja logic. It is not clear why this code path is not expected to work using other generators as well (e.g., MSVC).

I guess it's because different generators generate different binary directory structures? When fmt is added with add_subdirectory(fmt) from a parent project:

  • when building with Ninja, the fmt.ifc file is in ${CMAKE_BINARY_DIR}/fmt/CMakeFiles/fmt.dir
  • when building with Visual Studio generator, the fmt.ifc file is in ${CMAKE_BINARY_DIR}/fmt/fmt/CMakeFiles/fmt.dir, and if we try setting BMI to the ninja path we get:
D:\dev\sandbox\fmt_test\main.cpp(1,1): error C7684: module name 'fmt' has an ambiguous resolution to IFC [D:\dev\sandbox\fmt_test\cmake-build-debug-1\main.vcxproj]
      D:\dev\sandbox\fmt_test\main.cpp(1,1):
      could be 'D:\dev\sandbox\fmt_test\cmake-build-debug-1\fmt\CMakeFiles\fmt.dir\fmt.ifc'
      D:\dev\sandbox\fmt_test\main.cpp(1,1):
      or       'D:\dev\sandbox\fmt_test\cmake-build-debug-1\fmt\fmt\CMakeFiles\fmt.dir\fmt.ifc'

I am not sure why the Visual Studio generator behaves like this but I am not sure we can do anything about it either ...
I'm happy to revert the clauses so that the Ninja behaviour is the default one, but it did not like it was the way it was working before (i.e. as it was coded it expected Visual Studio generator and did not work with Ninja).

Copy link
Contributor

@sergiud sergiud Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried replicating your setup to trigger the reported errors (C7684, C3472) using a simple project that adds fmt via add_subdirectory. I used both Visual Studio 16 2019 and Ninja 1.10.2 generators with CMake 3.20 and modules enabled. I was not able to reproduce the issue.

D:\Projects\fmt_test>cmake -S . -B build-msvc-16 -DCMAKE_CXX_STANDARD=20 -DFMT_MODULE=ON
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.26100.
-- The C compiler identification is MSVC 19.29.30158.0
-- The CXX compiler identification is MSVC 19.29.30158.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- {fmt} version: 11.1.3
-- Build type:
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Projects/fmt_test/build-msvc-16

D:\Projects\fmt_test>cmake --build build-msvc-16
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule D:/Projects/fmt_test/fmt/CMakeLists.txt
  fmt.cc
  fmt.vcxproj -> D:\Projects\fmt_test\build-msvc-16\fmt\Debug\fmtd.lib
  Building Custom Rule D:/Projects/fmt_test/CMakeLists.txt
  main.cpp
     Creating library D:/Projects/fmt_test/build-msvc-16/Debug/fmt_test.lib and object D:/Projects/fmt_test/build-msvc-16/Debug/fmt_test.exp
  fmt_test.vcxproj -> D:\Projects\fmt_test\build-msvc-16\Debug\fmt_test.exe
  Building Custom Rule D:/Projects/fmt_test/CMakeLists.txt

The Ninja build does fail during the first run because the .ifc is missing (probably due to incorrect dependencies) but completes in the second run.

D:\Projects\fmt_test>cmake -S . -B build-ninja -DCMAKE_CXX_STANDARD=20 -DFMT_MODULE=ON -G Ninja
-- The C compiler identification is MSVC 19.29.30158.0
-- The CXX compiler identification is MSVC 19.29.30158.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- {fmt} version: 11.1.3
-- Build type: Debug
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Projects/fmt_test/build-ninja

D:\Projects\fmt_test>cmake --build build-ninja
[1/4] Building CXX object CMakeFiles\fmt_test.dir\main.cpp.obj
FAILED: CMakeFiles/fmt_test.dir/main.cpp.obj
C:\PROGRA~2\MICROS~3\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo /TP  -I..\fmt\include /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd /reference fmt=D:/Projects/fmt_test/build-ninja/fmt/fmt.ifc /utf-8 -std:c++20 /showIncludes /FoCMakeFiles\fmt_test.dir\main.cpp.obj /FdCMakeFiles\fmt_test.dir\ /FS -c ..\main.cpp
..\main.cpp(1): error C2230: could not find module 'fmt'
..\main.cpp(4): error C2653: 'fmt': is not a class or namespace name
..\main.cpp(4): error C3861: 'format': identifier not found
[2/4] Building CXX object fmt\CMakeFiles\fmt.dir\src\fmt.cc.obj
ninja: build stopped: subcommand failed.

D:\Projects\fmt_test>cmake --build build-ninja
[3/3] Linking CXX executable fmt_test.exe

What are the steps here?

Copy link
Contributor Author

@tkhyn tkhyn Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

There are 2 differences:

  1. I also have a main target with a main.cpp source file that imports fmt, to reproduce a real-life use case.
  2. I am using VS 2022

Without the main.cpp, I get the same results whether I use VS2019 or VS2022 generators.
It's lucky that the build works with Ninja 1.10.2 as it doesn't support modules. But it's probably because there are no import statements.

This is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.31)

project(fmt_test)

set(CMAKE_CXX_STANDARD 20) # or 23, but that makes VS2019 unhappy ...

set(FMT_MODULE ON)
add_subdirectory(fmt)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE fmt::fmt)

and main.cpp:

import fmt;

int main() {
    auto hw = fmt::format("{}, {}!", "Hello", "World");
    return static_cast<int>(hw.size());
}

Results below are with the if (${CMAKE_GENERATOR} STREQUAL "Ninja") and its corresponding endif() clause commented out of the code I pushed.

Result with VS 16 2019 generator
PS D:\dev\sandbox\fmt_test> cmake -S . -B build-vs-16 -G "Visual Studio 16 2019"
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.26100.
-- The C compiler identification is MSVC 19.29.30158.0
-- The CXX compiler identification is MSVC 19.29.30158.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- {fmt} version: 11.1.3
-- Build type:
-- Configuring done (2.4s)
-- Generating done (0.0s)
-- Build files have been written to: D:/dev/sandbox/fmt_test/build-vs-16
PS D:\dev\sandbox\fmt_test> cmake --build build-vs-16
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  1>Checking Build System
  Building Custom Rule D:/dev/sandbox/fmt_test/fmt/CMakeLists.txt
  fmt.cc
  fmt.vcxproj -> D:\dev\sandbox\fmt_test\build-vs-16\fmt\Debug\fmtd.lib
  Building Custom Rule D:/dev/sandbox/fmt_test/CMakeLists.txt
  main.cpp
D:\dev\sandbox\fmt_test\main.cpp(1,11): error C2230: could not find module 'fmt' [D:\dev\sandbox\fmt_test\build-vs-16\m
ain.vcxproj]
D:\dev\sandbox\fmt_test\main.cpp(4,15): error C2653: 'fmt': is not a class or namespace name [D:\dev\sandbox\fmt_test\b
uild-vs-16\main.vcxproj]
D:\dev\sandbox\fmt_test\main.cpp(4,20): error C3861: 'format': identifier not found [D:\dev\sandbox\fmt_test\build-vs-1
6\main.vcxproj]
Result with VS 17 2022 generator
PS D:\dev\sandbox\fmt_test> cmake -S . -B build-vs-17 -G "Visual Studio 17 2022"
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.26100.
-- The C compiler identification is MSVC 19.42.34436.0
-- The CXX compiler identification is MSVC 19.42.34436.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- {fmt} version: 11.1.3
-- Build type:
-- Configuring done (2.2s)
-- Generating done (0.0s)
-- Build files have been written to: D:/dev/sandbox/fmt_test/build-vs-17
PS D:\dev\sandbox\fmt_test> cmake --build build-vs-17
MSBuild version 17.12.12+1cce77968 for .NET Framework

  1>Checking Build System
  Building Custom Rule D:/dev/sandbox/fmt_test/fmt/CMakeLists.txt
  Scanning sources for module dependencies...
  fmt.cc
  Compiling...
  fmt.cc
  fmt.vcxproj -> D:\dev\sandbox\fmt_test\build-vs-17\fmt\Debug\fmtd.lib
  Building Custom Rule D:/dev/sandbox/fmt_test/CMakeLists.txt
  Scanning sources for module dependencies...
  main.cpp
  Compiling...
  main.cpp
D:\dev\sandbox\fmt_test\main.cpp(1,1): error C7684: module name 'fmt' has an ambiguous resolution to IFC [D:\dev\sandbo
x\fmt_test\build-vs-17\main.vcxproj]
      D:\dev\sandbox\fmt_test\main.cpp(1,1):
      could be 'D:\dev\sandbox\fmt_test\build-vs-17\fmt\CMakeFiles\fmt.dir\fmt.ifc'
      D:\dev\sandbox\fmt_test\main.cpp(1,1):
      or       'D:\dev\sandbox\fmt_test\build-vs-17\fmt\fmt\CMakeFiles\fmt.dir\fmt.ifc'

D:\dev\sandbox\fmt_test\main.cpp(1,11): error C2230: could not find module 'fmt' [D:\dev\sandbox\fmt_test\build-vs-17\m
ain.vcxproj]
D:\dev\sandbox\fmt_test\main.cpp(4,15): error C2653: 'fmt': is not a class or namespace name [D:\dev\sandbox\fmt_test\b
uild-vs-17\main.vcxproj]
D:\dev\sandbox\fmt_test\main.cpp(4,20): error C3861: 'format': identifier not found [D:\dev\sandbox\fmt_test\build-vs-1
7\main.vcxproj]
Result with Ninja (1.12.1 as 1.10 doesn't work with modules) generator
PS D:\dev\sandbox\fmt_test>cmake -S . -B build-ninja -G Ninja
-- The C compiler identification is MSVC 19.42.34436.0
-- The CXX compiler identification is MSVC 19.42.34436.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- {fmt} version: 11.1.3
-- Build type: Debug
-- Configuring done (1.0s)
-- Generating done (0.0s)
-- Build files have been written to: D:/dev/sandbox/fmt_test/build-ninja

PS D:\dev\sandbox\fmt_test>cmake --build build-ninja
[7/8] Building CXX object CMakeFiles\main.dir\main.cpp.obj
FAILED: CMakeFiles/main.dir/main.cpp.obj
C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1442~1.344\bin\Hostx64\x64\cl.exe  /nologo /TP  -ID:\dev\sandbox\fmt_test\fmt\include /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /reference fmt=fmt\CMakeFiles\fmt.dir\fmt.ifc /utf-8 /showIncludes @CMakeFiles\main.dir\main.cpp.obj.modmap /FoCMakeFiles\main.dir\main.cpp.obj /FdCMakeFiles\main.dir\ /FS -c D:\dev\sandbox\fmt_test\main.cpp
ninja: build stopped: subcommand failed.

The build fails with fmt 1.11.3 because of MSVC crash reported in another issue - which can be fixed by using a version of fmt earlier than commit 985c339.

If I re-enable the commented out if statements in fmt/CMakeLists.txt, both VS generator builds go past the C7684 and C2230 errors, C2230 being a consequence of C7684 not reported by VS 2019. Sorry I misspoke earlier, the error isn't the same as C3472 which was happening before with Ninja.

Copy link
Contributor

@sergiud sergiud Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks. I was able to reproduce both C7684 and C3472. It looks like Ninja dyndep ignores the /ifcOutput argument and hardcodes the path which is why the extra logic is unavoidable. This unexpected behavior is worth documenting (see the suggestion below.)

While Ninja Multi-Config still fails with the proposed changes this is not something that must be fixed in this PR.

CMakeLists.txt Outdated
Comment on lines 30 to 38
set(BMI_DIR "${CMAKE_CURRENT_BINARY_DIR}/")
if (CMAKE_GENERATOR STREQUAL "Ninja")
file(RELATIVE_PATH BMI_DIR "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
if (BMI_DIR)
set(BMI_DIR "${BMI_DIR}/")
endif()
set(BMI_DIR "${BMI_DIR}CMakeFiles/${target}.dir/")
endif()
file(TO_NATIVE_PATH "${BMI_DIR}${target}.ifc" BMI)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(BMI_DIR "${CMAKE_CURRENT_BINARY_DIR}/")
if (CMAKE_GENERATOR STREQUAL "Ninja")
file(RELATIVE_PATH BMI_DIR "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
if (BMI_DIR)
set(BMI_DIR "${BMI_DIR}/")
endif()
set(BMI_DIR "${BMI_DIR}CMakeFiles/${target}.dir/")
endif()
file(TO_NATIVE_PATH "${BMI_DIR}${target}.ifc" BMI)
if(CMAKE_GENERATOR STREQUAL "Ninja")
# Ninja dyndep expects the .ifc output to be located in a specific relative path
file(RELATIVE_PATH BMI_DIR "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir")
else()
set(BMI_DIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
file(TO_NATIVE_PATH "${BMI_DIR}/${target}.ifc" BMI)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's way cleaner! Tested and pushed.

@vitaut vitaut merged commit ed27df5 into fmtlib:master Feb 10, 2025
44 checks passed
@vitaut
Copy link
Contributor

vitaut commented Feb 10, 2025

Merged, thank you and thanks @sergiud for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants