-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
87 lines (73 loc) · 3.22 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
cmake_minimum_required (VERSION 3.1)
project (neo_vague_denoiser CXX)
file(GLOB CODE "src/*.cpp")
file(GLOB SSE_CODE_IMPL "src/*SSE.cpp")
file(GLOB SSE41_CODE_IMPL "src/*SSE41.cpp")
file(GLOB AVX_CODE_IMPL "src/*AVX.cpp")
file(GLOB AVX2_CODE_IMPL "src/*AVX2.cpp")
add_library(neo-vague-denoiser SHARED main.cpp src/version.rc ${CODE} ${CODE_IMPL})
set_property(TARGET neo-vague-denoiser PROPERTY CXX_STANDARD 17)
option(ENABLE_PAR "Enable C++17 Parallel Execution" ON)
add_compile_definitions(VS_TARGET_CPU_X86)
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --first-parent --tags --always OUTPUT_VARIABLE GIT_REPO_VERSION)
string(REGEX REPLACE "(r[0-9]+).*" "\\1" VERSION ${GIT_REPO_VERSION})
configure_file (
"${PROJECT_SOURCE_DIR}/src/version.hpp.in"
"${PROJECT_SOURCE_DIR}/src/version.hpp"
)
configure_file (
"${PROJECT_SOURCE_DIR}/src/version.rc.in"
"${PROJECT_SOURCE_DIR}/src/version.rc"
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVISYNTH avisynth)
if(AVISYNTH_FOUND)
include_directories(${AVISYNTH_INCLUDE_DIRS})
else()
include_directories(include/avisynth)
endif()
pkg_check_modules(VAPOURSYNTH vapoursynth)
if(VAPOURSYNTH_FOUND)
include_directories(${VAPOURSYNTH_INCLUDE_DIRS})
else()
include_directories(include/vapoursynth)
endif()
include_directories(.)
include_directories(include/dualsynth)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_source_files_properties(${SSE_CODE_IMPL} PROPERTIES COMPILE_FLAGS "/arch:SSE")
set_source_files_properties(${SSE41_CODE_IMPL} PROPERTIES COMPILE_FLAGS "/arch:SSE2")
set_source_files_properties(${AVX_CODE_IMPL} PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(${AVX2_CODE_IMPL} PROPERTIES COMPILE_FLAGS "/arch:AVX2")
if (CMAKE_GENERATOR_TOOLSET MATCHES "v[0-9]*_xp")
target_compile_definitions(neo-vague-denoiser PRIVATE WINVER=0x502 _WIN32_WINNT=0x502)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:threadSafeInit-")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set_source_files_properties(${SSE_CODE_IMPL} PROPERTIES COMPILE_FLAGS "/arch:SSE")
set_source_files_properties(${SSE41_CODE_IMPL} PROPERTIES COMPILE_FLAGS "/arch:SSE2")
set_source_files_properties(${AVX_CODE_IMPL} PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(${AVX2_CODE_IMPL} PROPERTIES COMPILE_FLAGS "/arch:AVX2")
target_link_libraries(neo-vague-denoiser libmmds)
else()
set_source_files_properties(${SSE_CODE_IMPL} PROPERTIES COMPILE_FLAGS "-msse")
set_source_files_properties(${SSE41_CODE_IMPL} PROPERTIES COMPILE_FLAGS "-msse4.1")
set_source_files_properties(${AVX_CODE_IMPL} PROPERTIES COMPILE_FLAGS "-mavx")
set_source_files_properties(${AVX2_CODE_IMPL} PROPERTIES COMPILE_FLAGS "-mfma -mavx2")
endif()
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX(execution HAS_EXECUTION)
if(HAS_EXECUTION)
add_definitions(-DHAS_EXECUTION)
endif()
if(ENABLE_PAR AND HAS_EXECUTION)
add_definitions(-DENABLE_PAR)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(neo-vague-denoiser tbb)
endif()
endif()
add_custom_command(
TARGET neo-vague-denoiser POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:neo-vague-denoiser> "../Release_${VERSION}/${_DIR}/$<TARGET_FILE_NAME:neo-vague-denoiser>"
)