Skip to content

Commit 753ceb0

Browse files
committed
add support for Darwin/macOS in the CMake files; it's not perfect since a lot is still hard-coded for Linux but at least it works
1 parent e852a83 commit 753ceb0

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ if( ${TARGET_OS} STREQUAL "Linux" )
4949
message("Unsupported architecture: ${TARGET_ARCHITECTURE}" )
5050
return()
5151
endif()
52+
elseif( ${TARGET_OS} STREQUAL "Darwin" )
53+
set(OS "OSX")
54+
set(OSNAME "Darwin")
55+
if( ${TARGET_ARCHITECTURE} STREQUAL "x86_64" )
56+
set(ARCHNAME x86-64)
57+
set(ARCH X86)
58+
set(WRDSZ 64)
59+
else()
60+
message("Unsupported architecture: ${TARGET_ARCHITECTURE}" )
61+
return()
62+
endif()
5263
else()
5364
message("Unsupported OS: ${TARGET_OS}" )
5465
return()

runtime/CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@
1616

1717
set (RUNTIME_SHARED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/shared)
1818

19+
if( ${TARGET_OS} STREQUAL "Darwin" )
20+
add_definitions(
21+
-DTARGET_OSX
22+
-DTARGET_OSX_X8664
23+
-DOSX86
24+
)
25+
else()
26+
add_definitions(
27+
-DTARGET_LINUX
28+
-DLINUX
29+
)
30+
endif()
31+
1932
add_definitions(
2033
-DMAXCPUS=256
2134
-DMAXCPUSL=8
2235
-DMAXCPUSR=8
23-
-DTARGET_LINUX
2436
-DTARGET_LLVM
25-
-DLINUX
2637
-DPGF90
2738
-DPGFLANG
2839
-DNATIVE_FPCVT

runtime/flang/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,16 @@ add_flang_library(flang_shared
477477
${SHARED_SOURCES}
478478
)
479479
set_property(TARGET flang_shared PROPERTY OUTPUT_NAME flang)
480-
target_link_libraries(flang_shared ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/libflangrti.so)
481-
# Resolve symbols against libm and librt
482-
target_link_libraries(flang_shared m rt)
480+
481+
482+
if( ${TARGET_OS} STREQUAL "Darwin" )
483+
target_link_libraries(flang_shared ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/libflangrti.dylib)
484+
target_link_libraries(flang_shared m pgmath omp)
485+
else()
486+
target_link_libraries(flang_shared ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/libflangrti.so)
487+
# Resolve symbols against libm and librt
488+
target_link_libraries(flang_shared m rt)
489+
endif()
483490

484491
set(SHARED_LIBRARY FALSE)
485492

tools/flang2/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ set(FLANG2_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
3333

3434
include_directories(${FLANG2_INCLUDE_DIR})
3535

36-
if( ${TARGET_OS} STREQUAL "Linux" )
36+
# this is a hack until there is a proper setup
37+
if( ${TARGET_OS} STREQUAL "Linux|Darwin" )
3738
if( ${TARGET_ARCHITECTURE} STREQUAL "x86_64" )
3839
set(X86_64 ON)
3940
set(LINUX86 ON)

0 commit comments

Comments
 (0)