-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
135 lines (110 loc) · 3.86 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
131
132
133
134
135
cmake_minimum_required(VERSION 3.15)
project(reasolotus VERSION 0.2.0 LANGUAGES C CXX)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# path for external 3rd party library dependencies
include(FetchContent)
set(PROJECT_LIB_DIR ${PROJECT_SOURCE_DIR}/lib)
FetchContent_Declare(WDL
GIT_REPOSITORY https://github.com/justinfrankel/WDL
GIT_TAG "origin/main" # or specify a tag or branch here
SOURCE_DIR "${PROJECT_LIB_DIR}/WDL"
)
FetchContent_Declare(reaper-sdk
GIT_REPOSITORY https://github.com/justinfrankel/reaper-sdk
GIT_TAG "origin/main" # or specify a tag or branch here
SOURCE_DIR "${PROJECT_LIB_DIR}/reaper-sdk"
)
FetchContent_MakeAvailable(WDL reaper-sdk)
# symlink WDL to reaper-sdk
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
# source
"${PROJECT_LIB_DIR}/WDL/WDL"
# target
"${PROJECT_LIB_DIR}/reaper-sdk/WDL"
)
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
endif()
FILE(GLOB header_paths
${PROJECT_LIB_DIR}/*/include
${PROJECT_LIB_DIR}/*/sdk
)
add_library(reaper-sdk IMPORTED INTERFACE)
target_include_directories(reaper-sdk INTERFACE ${header_paths})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(WDL REQUIRED)
if(NOT WIN32)
find_package(SWELL REQUIRED)
endif()
target_link_libraries(reaper-sdk INTERFACE WDL::WDL)
if(SWELL_FOUND)
target_link_libraries(reaper-sdk INTERFACE SWELL::swell)
# Transpile the Win32 resource file
# find_package(PHP REQUIRED)
# add_custom_command(
# OUTPUT resource.rc_mac_dlg resource.rc_mac_menu
# COMMAND ${CMAKE_COMMAND} -E copy
# ${CMAKE_CURRENT_SOURCE_DIR}/resource.rc ${CMAKE_CURRENT_BINARY_DIR}
# COMMAND ${PHP_EXECUTABLE} ${SWELL_RESGEN} --quiet resource.rc
# DEPENDS ${SWELL_RESGEN}
# MAIN_DEPENDENCY resource.rc
# )
endif()
# if(WIN32)
# add_link_options(
# # Use relative path to the PDB file to avoid exposing the full path
# /PDBALTPATH:%_PDB%
# )
# endif()
add_library(${PROJECT_NAME} SHARED)
add_subdirectory(src)
target_link_libraries(${PROJECT_NAME} PRIVATE reaper-sdk)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 23)
if(WIN32)
add_compile_definitions(NOMINMAX _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
target_compile_options(
${PROJECT_NAME}
PRIVATE
/W3 /WX)
endif()
if(UNIX AND NOT APPLE)
target_compile_options(${PROJECT_NAME} PRIVATE -fno-unsigned-char)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(WIN32)
set(USER_CONFIG_DIR "$ENV{APPDATA}")
elseif(APPLE)
set(USER_CONFIG_DIR "~/Library/Application Support")
else()
set(USER_CONFIG_DIR "~/.config")
endif()
set(CMAKE_INSTALL_PREFIX "${USER_CONFIG_DIR}/REAPER" CACHE PATH
"REAPER resource path where to install ReaPack" FORCE)
endif()
if(CMAKE_OSX_ARCHITECTURES)
list(JOIN CMAKE_OSX_ARCHITECTURES "-" ARCH_NAME)
elseif(MSVC_CXX_ARCHITECTURE_ID)
set(ARCH_NAME ${MSVC_CXX_ARCHITECTURE_ID})
else()
set(ARCH_NAME ${CMAKE_SYSTEM_PROCESSOR})
endif()
STRING(TOLOWER "${ARCH_NAME}" ARCH_NAME)
set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX "" # disable the "lib" prefix
OUTPUT_NAME "reaper_${PROJECT_NAME}-${ARCH_NAME}"
)
set(REAPER_USER_PLUGINS "UserPlugins")
install(TARGETS ${PROJECT_NAME}
COMPONENT ${PROJECT_NAME}
RUNTIME DESTINATION "${REAPER_USER_PLUGINS}" # Windows .dll
LIBRARY DESTINATION "${REAPER_USER_PLUGINS}" # Linux .so/macOS .dylib
)