-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
130 lines (115 loc) · 5.46 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
121
122
123
124
125
126
127
128
129
130
cmake_minimum_required(VERSION 3.5)
project(win-smtc-qt VERSION 0.5 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
if(DEFINED ENV{AUDACIOUS_ROOT_DIR})
set(AUDACIOUS_ROOT_DIR_DEFAULT "$ENV{AUDACIOUS_ROOT_DIR}")
else()
set(AUDACIOUS_ROOT_DIR_DEFAULT "$ENV{ProgramFiles\(x86\)}\\Audacious")
endif()
set(AUDACIOUS_ROOT_DIR "${AUDACIOUS_ROOT_DIR_DEFAULT}" CACHE PATH "Path to Audacions binaries root directory")
set(AUDCORE_DLL_NAME)
foreach(AUDCORE_DLL_NAME_TEST "audcore" "audcore5")
if(EXISTS "${AUDACIOUS_ROOT_DIR}/bin/${AUDCORE_DLL_NAME_TEST}.dll")
set(AUDCORE_DLL_NAME "${AUDCORE_DLL_NAME_TEST}")
break()
endif()
endforeach()
if(NOT AUDCORE_DLL_NAME)
message(FATAL_ERROR "AUDCORE was not found, please check AUDACIOUS_ROOT_DIR=\"${AUDACIOUS_ROOT_DIR}\"")
endif()
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/libaudcore.dll.a")
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${AUDCORE_DLL_NAME}.def")
message("Generating ${AUDCORE_DLL_NAME}.def ...")
find_program(GENDEF_PROG gendef REQUIRED)
execute_process(
COMMAND "${GENDEF_PROG}" "${AUDACIOUS_ROOT_DIR}/bin/${AUDCORE_DLL_NAME}.dll"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
message("Patching ${AUDCORE_DLL_NAME}.def ...")
file(READ "${CMAKE_CURRENT_BINARY_DIR}/${AUDCORE_DLL_NAME}.def" AUDCORE_DEF_DATA)
string(REGEX REPLACE "@[0-9]*" "" AUDCORE_DEF_DATA "${AUDCORE_DEF_DATA}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${AUDCORE_DLL_NAME}.def" "${AUDCORE_DEF_DATA}")
endif()
message("Generating libaudcore.dll.a ...")
find_program(DLLTOOL_PROG dlltool REQUIRED)
execute_process(
COMMAND "${DLLTOOL_PROG}" -d "${AUDCORE_DLL_NAME}.def" -D "${AUDCORE_DLL_NAME}.dll" -l "libaudcore.dll.a"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
endif()
add_library(audcore SHARED IMPORTED)
set_property(TARGET audcore PROPERTY IMPORTED_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/libaudcore.dll.a")
set(AUDQT_DLL_NAME)
foreach(AUDQT_DLL_NAME_TEST "audqt" "audqt2" "audqt3")
if(EXISTS "${AUDACIOUS_ROOT_DIR}/bin/${AUDQT_DLL_NAME_TEST}.dll")
set(AUDQT_DLL_NAME "${AUDQT_DLL_NAME_TEST}")
break()
endif()
endforeach()
if(NOT AUDQT_DLL_NAME)
message(FATAL_ERROR "AUDQT was not found, please check AUDACIOUS_ROOT_DIR=\"${AUDACIOUS_ROOT_DIR}\"")
endif()
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/libaudqt.dll.a")
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${AUDQT_DLL_NAME}.def")
message("Generating ${AUDQT_DLL_NAME}.def ...")
find_program(GENDEF_PROG gendef REQUIRED)
execute_process(
COMMAND "${GENDEF_PROG}" "${AUDACIOUS_ROOT_DIR}/bin/${AUDQT_DLL_NAME}.dll"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
message("Patching ${AUDQT_DLL_NAME}.def ...")
file(READ "${CMAKE_CURRENT_BINARY_DIR}/${AUDQT_DLL_NAME}.def" AUDQT_DEF_DATA)
string(REGEX REPLACE "@[0-9]*" "" AUDQT_DEF_DATA "${AUDQT_DEF_DATA}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${AUDQT_DLL_NAME}.def" "${AUDQT_DEF_DATA}")
endif()
message("Generating libaudqt.dll.a ...")
find_program(DLLTOOL_PROG dlltool REQUIRED)
execute_process(
COMMAND "${DLLTOOL_PROG}" -d "${AUDQT_DLL_NAME}.def" -D "${AUDQT_DLL_NAME}.dll" -l "libaudqt.dll.a"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
endif()
add_library(audqt SHARED IMPORTED)
set_property(TARGET audqt PROPERTY IMPORTED_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/libaudqt.dll.a")
include(TestBigEndian)
test_big_endian(BIGENDIAN)
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/audacious/src/libaudcore/audio.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/libaudcore/audio.h"
@ONLY
)
include_directories(SYSTEM "${CMAKE_CURRENT_LIST_DIR}/audacious/src" "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_LIST_DIR}/cppwinrt")
set(PLUGIN_VERSION "v${CMAKE_PROJECT_VERSION}")
find_package(Git)
if(Git_FOUND)
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_REVISION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
message("Git revision: ${GIT_REVISION}")
set(PLUGIN_VERSION "${PLUGIN_VERSION} \(${GIT_REVISION}\)")
endif()
set(QT_MAJOR_VERSION)
if(EXISTS "${AUDACIOUS_ROOT_DIR}/bin/Qt6Core.dll")
set(QT_MAJOR_VERSION 6)
elseif(EXISTS "${AUDACIOUS_ROOT_DIR}/bin/Qt5Core.dll")
set(QT_MAJOR_VERSION 5)
else()
message(FATAL_ERROR "QtXCore.dll was not found, please check AUDACIOUS_ROOT_DIR=\"${AUDACIOUS_ROOT_DIR}\"")
endif()
find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Core Gui Widgets)
add_library(${CMAKE_PROJECT_NAME} SHARED win-smtc.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE audqt audcore Qt${QT_MAJOR_VERSION}::Widgets Qt${QT_MAJOR_VERSION}::Gui Qt${QT_MAJOR_VERSION}::Core oleaut32 ole32)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "-fcoroutines")
endif()
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE -s)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE "PLUGIN_VERSION=\"${PLUGIN_VERSION}\"")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE "EXPORT=__declspec(dllexport)")