Skip to content

Commit 600355f

Browse files
committed
Added support for macOS
1 parent 6bf0ee5 commit 600355f

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ if(NOT CMAKE_BUILD_TYPE)
1515
set(CMAKE_BUILD_TYPE Release)
1616
endif()
1717

18+
# Apple
19+
if(APPLE)
20+
set(CMAKE_PREFIX_PATH "/usr/local/opt/")
21+
find_library(OpenMP_omp_LIBRARY omp HINTS "/usr/local/opt/libomp/lib")
22+
23+
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/include")
24+
set(OpenMP_C_LIB_NAMES "omp")
25+
26+
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/include")
27+
set(OpenMP_CXX_LIB_NAMES "omp")
28+
endif()
29+
1830
# Build options
1931
option(BUILD_SHARED_LIBS "Build libvideo2x as a shared library" ON)
2032
option(VIDEO2X_BUILD_CLI "Build the video2x command line interface executable" ON)
@@ -41,7 +53,11 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
4153
add_link_options(/LTCG /OPT:REF /OPT:ICF)
4254
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
4355
add_compile_options(-O3 -ffunction-sections -fdata-sections)
44-
add_link_options(-Wl,-s -flto -Wl,--gc-sections)
56+
if(APPLE)
57+
add_link_options(-dead_strip)
58+
else()
59+
add_link_options(-Wl,-s -flto -Wl,--gc-sections)
60+
endif()
4561
endif()
4662
endif()
4763

src/encoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ int Encoder::init(
266266
return 0;
267267
}
268268

269+
#ifndef __clang__
269270
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
271+
#endif
270272
int Encoder::write_frame(AVFrame* frame, int64_t frame_idx) {
271273
AVFrame* converted_frame = nullptr;
272274
int ret;
@@ -338,7 +340,9 @@ int Encoder::write_frame(AVFrame* frame, int64_t frame_idx) {
338340
return 0;
339341
}
340342

343+
#ifndef __clang__
341344
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
345+
#endif
342346
int Encoder::flush() {
343347
int ret;
344348
AVPacket* enc_pkt = av_packet_alloc();

src/libvideo2x.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ VideoProcessor::VideoProcessor(
2929
hw_device_type_(hw_device_type),
3030
benchmark_(benchmark) {}
3131

32+
#ifndef __clang__
3233
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
34+
#endif
3335
int VideoProcessor::process(
3436
const std::filesystem::path in_fname,
3537
const std::filesystem::path out_fname

0 commit comments

Comments
 (0)