Skip to content

Fix macos cmake build#829

Merged
aaronj0 merged 1 commit intocompiler-research:mainfrom
tryh4rd-26:fix-macos-cmake-build
Mar 4, 2026
Merged

Fix macos cmake build#829
aaronj0 merged 1 commit intocompiler-research:mainfrom
tryh4rd-26:fix-macos-cmake-build

Conversation

@tryh4rd-26
Copy link
Contributor

Fixed macOS single-config CMake test invocation by avoiding an empty config value in the check-cppinterop path.
On macOS with Unix Makefiles/Ninja, $ can resolve to empty, which breaks CTest when passed via --build-config; the target now uses the non-config form in that case.
Behavior for multi-config generators remains unchanged.
Validation: cmake --build build --target check-cppinterop --parallel 4 → 100% tests passed (3/3), 0 failed.

@aaronj0
Copy link
Collaborator

aaronj0 commented Mar 2, 2026

What was the used cmake configuration command? Can you paste that along with the error from ctest

@tryh4rd-26
Copy link
Contributor Author

What was the used cmake configuration command? Can you paste that along with the error from ctest

@aaronj0

Used CMake configure command:

cmake -DBUILD_SHARED_LIBS=ON -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..

CTest/check target error before the fix:

CMake Error: Invalid value used with --build-config

Full tail from the failing run:

[100%] Built target CppInterOpUnitTests
CMake Error: Invalid value used with --build-config
gmake[3]: *** [unittests/CMakeFiles/check-cppinterop.dir/build.make:70: unittests/CMakeFiles/check-cppinterop] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:659: unittests/CMakeFiles/check-cppinterop.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:666: unittests/CMakeFiles/check-cppinterop.dir/rule] Error 2
gmake: *** [Makefile:351: check-cppinterop] Error 2

@aaronj0
Copy link
Collaborator

aaronj0 commented Mar 2, 2026

What was the used cmake configuration command? Can you paste that along with the error from ctest

@aaronj0

Used CMake configure command:

cmake -DBUILD_SHARED_LIBS=ON -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..

CTest/check target error before the fix:

CMake Error: Invalid value used with --build-config

Full tail from the failing run:

[100%] Built target CppInterOpUnitTests
CMake Error: Invalid value used with --build-config
gmake[3]: *** [unittests/CMakeFiles/check-cppinterop.dir/build.make:70: unittests/CMakeFiles/check-cppinterop] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:659: unittests/CMakeFiles/check-cppinterop.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:666: unittests/CMakeFiles/check-cppinterop.dir/rule] Error 2
gmake: *** [Makefile:351: check-cppinterop] Error 2

You're missing a build type. What this boils down to is the fact that CppInterOp doesn't spell out a default build type when not provided.

Copy link
Collaborator

@aaronj0 aaronj0 left a comment

Choose a reason for hiding this comment

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

add_custom_target(check-cppinterop COMMAND ${CMAKE_CTEST_COMMAND} -V --build-config $<CONFIG>
DEPENDS CppInterOpUnitTests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# macOS single-configuration generators produce an empty $<CONFIG>, so omit
# --build-config there. Keep existing behavior on other platforms.
Copy link
Collaborator

@aaronj0 aaronj0 Mar 2, 2026

Choose a reason for hiding this comment

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

I don't understand the point of duplicating the command without $<CONFIG>, that's a hacky solution.
Can you try patching the CMake with the suggestion above and see if that solves your build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi,
I’ve updated the PR to follow the LLVM-style approach instead of duplicating the check-cppinterop command

add_subdirectory(CppInterOp)

add_custom_target(check-cppinterop COMMAND ${CMAKE_CTEST_COMMAND} -V --build-config $<CONFIG>
if(CMAKE_CONFIGURATION_TYPES)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't be required

else()
set(config_cmd ${CMAKE_COMMAND})
set(build_cmd ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/unittests/googletest-prefix/src/googletest-build/ --config $<CONFIG>)
# Only add --config for multi-configuration generators (Visual Studio, Xcode)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please drop these changes. CMake will propagate the right config since you set the default build type

@aaronj0
Copy link
Collaborator

aaronj0 commented Mar 2, 2026

Can you make this a single commit with a more useful/correct commit message? something like "Set default build type if not provided"

@tryh4rd-26 tryh4rd-26 force-pushed the fix-macos-cmake-build branch from 9c73e11 to c0f4a18 Compare March 2, 2026 20:21
@tryh4rd-26
Copy link
Contributor Author

Can you make this a single commit with a more useful/correct commit message? something like "Set default build type if not provided"

@aaronj0 made changes as requested

Copy link
Collaborator

@aaronj0 aaronj0 left a comment

Choose a reason for hiding this comment

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

I'd not want to point to LLVM's cmake options for CppInterOp

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.56%. Comparing base (3b67f16) to head (7ef721a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #829   +/-   ##
=======================================
  Coverage   79.56%   79.56%           
=======================================
  Files          11       11           
  Lines        4013     4013           
=======================================
  Hits         3193     3193           
  Misses        820      820           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tryh4rd-26 tryh4rd-26 force-pushed the fix-macos-cmake-build branch from 6eac892 to 7ef721a Compare March 3, 2026 11:43
@tryh4rd-26
Copy link
Contributor Author

@aaronj0
done

@aaronj0 aaronj0 merged commit 5b9435c into compiler-research:main Mar 4, 2026
54 of 57 checks passed
@aaronj0 aaronj0 mentioned this pull request Mar 4, 2026
4 tasks
@tryh4rd-26 tryh4rd-26 deleted the fix-macos-cmake-build branch March 4, 2026 12:06
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.

2 participants