-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
120 lines (93 loc) · 4.67 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Visual Studio 2019 is supported from CMake 3.14.1
# Tested generators:
# "MinGW Makefiles": MSYS2/Mingw32 GCC 8.3 build
# "Visual Studio 16 2019" optional platform generator Win32 and x64
# "Visual Studio 16 2019" + LLVM 8.0 (clang) optional platform generator Win32 and x64
CMAKE_MINIMUM_REQUIRED( VERSION 3.8.2 )
set(PluginName "PerfPan")
if (NOT WIN32)
string(TOLOWER "${PluginName}" PluginName)
endif()
set(ProjectName "${PluginName}")
project(${ProjectName} LANGUAGES CXX)
Include("Files.cmake")
add_library(${PluginName} SHARED ${PerfPan_Sources})
set_target_properties(${PluginName} PROPERTIES "OUTPUT_NAME" "${PluginName}")
if (MINGW)
set_target_properties(${PluginName} PROPERTIES PREFIX "")
set_target_properties(${PluginName} PROPERTIES IMPORT_PREFIX "")
endif()
#require sse4.1, there are mixed parts in the source
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DINTEL_INTRINSICS -msse4.1")
# Automatically group source files according to directory structure
foreach(FILE ${PerfPan_Sources})
get_filename_component(PARENT_DIR "${FILE}" PATH)
string(REGEX REPLACE "(\\./)" "" GROUP "${PARENT_DIR}")
string(REPLACE "/" "\\" GROUP "${GROUP}")
# group into "Source Files" and "Header Files"
if ("${FILE}" MATCHES ".*\\.cpp")
set(GROUP "Source Files\\${GROUP}")
elseif("${FILE}" MATCHES ".*\\.h")
set(GROUP "Header Files\\${GROUP}")
endif()
source_group("${GROUP}" FILES "${FILE}")
endforeach()
if (MSVC_IDE)
IF(CLANG_IN_VS STREQUAL "1")
# special SSSE3 option for source files with *_ssse3.cpp pattern
file(GLOB_RECURSE SRCS_SSSE3 "*_ssse3.cpp")
set_source_files_properties(${SRCS_SSSE3} PROPERTIES COMPILE_FLAGS " -mssse3 ")
# special SSE4.1 option for source files with *_sse41.cpp pattern
file(GLOB_RECURSE SRCS_SSE41 "*_sse41.cpp")
set_source_files_properties(${SRCS_SSE41} PROPERTIES COMPILE_FLAGS " -msse4.1 ")
# special AVX option for source files with *_avx.cpp pattern
file(GLOB_RECURSE SRCS_AVX "*_avx.cpp")
set_source_files_properties(${SRCS_AVX} PROPERTIES COMPILE_FLAGS " -mavx ")
# special AVX2 option for source files with *_avx2.cpp pattern
file(GLOB_RECURSE SRCS_AVX2 "*_avx2.cpp")
set_source_files_properties(${SRCS_AVX2} PROPERTIES COMPILE_FLAGS " -mavx2 -mfma ")
# special AVX512 option for source files with *_avx512.cpp pattern
file(GLOB_RECURSE SRCS_AVX512 "*_avx512.cpp")
set_source_files_properties(${SRCS_AVX512} PROPERTIES COMPILE_FLAGS " -mavx512f -mavx512bw ")
ELSE()
# special AVX option for source files with *_avx.cpp pattern
file(GLOB_RECURSE SRCS_AVX "*_avx.cpp")
set_source_files_properties(${SRCS_AVX} PROPERTIES COMPILE_FLAGS " /arch:AVX ")
# special AVX2 option for source files with *_avx2.cpp pattern
file(GLOB_RECURSE SRCS_AVX2 "*_avx2.cpp")
set_source_files_properties(${SRCS_AVX2} PROPERTIES COMPILE_FLAGS " /arch:AVX2 ")
# special AVX512 option for source files with *_avx512.cpp pattern
file(GLOB_RECURSE SRCS_AVX512 "*_avx512.cpp")
set_source_files_properties(${SRCS_AVX512} PROPERTIES COMPILE_FLAGS " /arch:AVX512 ")
ENDIF()
else()
# special SSSE3 option for source files with *_ssse3.cpp pattern
file(GLOB_RECURSE SRCS_SSSE3 "*_ssse3.cpp")
set_source_files_properties(${SRCS_SSSE3} PROPERTIES COMPILE_FLAGS " -mssse3 ")
# special SSE4.1 option for source files with *_sse41.cpp pattern
file(GLOB_RECURSE SRCS_SSE41 "*_sse41.cpp")
set_source_files_properties(${SRCS_SSE41} PROPERTIES COMPILE_FLAGS " -msse4.1 ")
# special AVX option for source files with *_avx.cpp pattern
file(GLOB_RECURSE SRCS_AVX "*_avx.cpp")
set_source_files_properties(${SRCS_AVX} PROPERTIES COMPILE_FLAGS " -mavx ")
# special AVX2 option for source files with *_avx2.cpp pattern
file(GLOB_RECURSE SRCS_AVX2 "*_avx2.cpp")
set_source_files_properties(${SRCS_AVX2} PROPERTIES COMPILE_FLAGS " -mavx2 -mfma ")
# special AVX512 option for source files with *_avx512.cpp pattern
file(GLOB_RECURSE SRCS_AVX512 "*_avx512.cpp")
set_source_files_properties(${SRCS_AVX512} PROPERTIES COMPILE_FLAGS " -mavx512f -mavx512bw ")
endif()
# Specify include directories
target_include_directories(${ProjectName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
#dedicated include dir for avisynth.h
target_include_directories(${ProjectName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Windows DLL dependencies
if (MSVC OR MINGW)
target_link_libraries(${ProjectName} "uuid" "winmm" "vfw32" "msacm32" "gdi32" "user32" "advapi32" "ole32" "imagehlp")
else()
target_link_libraries(${ProjectName} "dl")
# "pthread" "dl"
endif()
include(GNUInstallDirs)
INSTALL(TARGETS ${ProjectName}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/avisynth")