Skip to content

Commit c39b1f7

Browse files
authored
Fix CMake modules to allow build on windows (#51)
This patch makes some minor adjustments to top level CMakeLists.txt and CopyDir, Testsuite modules to allow testsuite build on windows.
1 parent 5633212 commit c39b1f7

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ if(TEST_SUITE_FORTRAN)
3737
mark_as_advanced(CLEAR CMAKE_Fortran_COMPILER)
3838
endif()
3939

40+
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_SIMULATE_ID MATCHES "MSVC")
41+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /FIstdio.h")
42+
endif()
43+
4044
# The files in cmake/caches often want to pass along additional flags to select
4145
# the target architecture. Note that you should still use
4246
# CMAKE_OSX_ARCHITECTURES and CMAKE_C_COMPILER_TARGET where possible.
@@ -299,6 +303,12 @@ mark_as_advanced(TEST_SUITE_LIT TEST_SUITE_LIT_FLAGS)
299303
mark_as_advanced(TEST_SUITE_LIT)
300304

301305
add_subdirectory(tools)
306+
307+
# Turn on ignore whitespacing on WIN32 to avoid line-ending mismatch
308+
if(TARGET_OS STREQUAL "Windows")
309+
set(FP_IGNOREWHITESPACE ON)
310+
endif()
311+
302312
# Shortcut for the path to the fpcmp executable
303313
set(FPCMP fpcmp-target)
304314
if (TEST_SUITE_USER_MODE_EMULATION)

cmake/modules/CopyDir.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ function(llvm_copy target to from)
1616
)
1717
endfunction()
1818

19+
# On Windows create_symlink requires special permissions. Use copy_if_different instead.
20+
if(CMAKE_HOST_WIN32)
21+
set(_link_or_copy copy_if_different)
22+
else()
23+
set(_link_or_copy create_symlink)
24+
endif()
25+
1926
function(llvm_create_symlink target to from)
2027
add_custom_command(
2128
TARGET ${target} POST_BUILD
22-
COMMAND ${CMAKE_COMMAND} -E create_symlink ${from} ${to}
29+
COMMAND ${CMAKE_COMMAND} -E ${_link_or_copy} ${from} ${to}
2330
)
2431
endfunction()
2532

cmake/modules/TestSuite.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ function(llvm_test_executable_no_test target)
6565

6666
if(TEST_SUITE_LLVM_SIZE)
6767
add_custom_command(TARGET ${target} POST_BUILD
68-
COMMAND ${TEST_SUITE_LLVM_SIZE} --format=sysv $<TARGET_FILE:${target}>
69-
> $<TARGET_FILE:${target}>.size)
68+
COMMAND ${TEST_SUITE_LLVM_SIZE} --format=sysv $<SHELL_PATH:$<TARGET_FILE:${target}>>
69+
> $<SHELL_PATH:$<TARGET_FILE:${target}>>.size)
7070
endif()
7171
endfunction()
7272

0 commit comments

Comments
 (0)