Skip to content

Fix CMake modules to allow build on windows #51

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

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ if(TEST_SUITE_FORTRAN)
mark_as_advanced(CLEAR CMAKE_Fortran_COMPILER)
endif()

if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_SIMULATE_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /FIstdio.h")
endif()

# The files in cmake/caches often want to pass along additional flags to select
# the target architecture. Note that you should still use
# CMAKE_OSX_ARCHITECTURES and CMAKE_C_COMPILER_TARGET where possible.
Expand Down Expand Up @@ -299,6 +303,12 @@ mark_as_advanced(TEST_SUITE_LIT TEST_SUITE_LIT_FLAGS)
mark_as_advanced(TEST_SUITE_LIT)

add_subdirectory(tools)

# Turn on ignore whitespacing on WIN32 to avoid line-ending mismatch
if(TARGET_OS STREQUAL "Windows")
set(FP_IGNOREWHITESPACE ON)
endif()

# Shortcut for the path to the fpcmp executable
set(FPCMP fpcmp-target)
if (TEST_SUITE_USER_MODE_EMULATION)
Expand Down
9 changes: 8 additions & 1 deletion cmake/modules/CopyDir.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ function(llvm_copy target to from)
)
endfunction()

# On Windows create_symlink requires special permissions. Use copy_if_different instead.
if(CMAKE_HOST_WIN32)
set(_link_or_copy copy_if_different)
else()
set(_link_or_copy create_symlink)
endif()

function(llvm_create_symlink target to from)
add_custom_command(
TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${from} ${to}
COMMAND ${CMAKE_COMMAND} -E ${_link_or_copy} ${from} ${to}
)
endfunction()

Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/TestSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function(llvm_test_executable_no_test target)

if(TEST_SUITE_LLVM_SIZE)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${TEST_SUITE_LLVM_SIZE} --format=sysv $<TARGET_FILE:${target}>
> $<TARGET_FILE:${target}>.size)
COMMAND ${TEST_SUITE_LLVM_SIZE} --format=sysv $<SHELL_PATH:$<TARGET_FILE:${target}>>
> $<SHELL_PATH:$<TARGET_FILE:${target}>>.size)
endif()
endfunction()

Expand Down