/
CMakeLists.txt
153 lines (136 loc) · 5.39 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
##########################################################################################
cmake_minimum_required(VERSION 3.5)
if(NOT PROJECT_NAME)
project(vstgui)
set(VSTGUI_MAIN_PROJECT_BUILD 1)
endif()
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
include(vstgui_init)
##########################################################################################
function(vstgui_set_cxx_version target version)
target_compile_features(${target} PUBLIC cxx_std_${version})
set_property(TARGET ${target} PROPERTY CXX_STANDARD ${version})
set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${target} PROPERTY CMAKE_CXX_STANDARD_REQUIRED ON)
if(APPLE)
target_compile_options(${target} PUBLIC "-stdlib=libc++")
endif()
endfunction(vstgui_set_cxx_version target version)
##########################################################################################
function(vstgui_source_group_by_folder target)
if(CMAKE_CONFIGURATION_TYPES)
set(SOURCE_GROUP_DELIMITER "/")
set(last_dir "")
set(files "")
foreach(file ${${target}_sources})
get_filename_component(dir "${file}" DIRECTORY)
string(FIND "${dir}" ${target} isTargetFolder)
if(${isTargetFolder} EQUAL 0)
string(LENGTH ${target} offset)
string(SUBSTRING "${dir}" ${offset} -1 dir)
endif(${isTargetFolder} EQUAL 0)
if(NOT "${dir}" STREQUAL "${last_dir}")
if(files)
source_group("${last_dir}" FILES ${files})
endif(files)
set(files "")
endif(NOT "${dir}" STREQUAL "${last_dir}")
set(files ${files} ${file})
set(last_dir "${dir}")
endforeach(file)
if(files)
source_group("${last_dir}" FILES ${files})
endif(files)
endif(CMAKE_CONFIGURATION_TYPES)
endfunction(vstgui_source_group_by_folder)
##########################################################################################
if(LINUX)
find_package(X11 REQUIRED)
find_package(Freetype REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBXCB REQUIRED xcb)
pkg_check_modules(LIBXCB_UTIL REQUIRED xcb-util)
pkg_check_modules(LIBXCB_CURSOR REQUIRED xcb-cursor)
pkg_check_modules(LIBXCB_KEYSYMS REQUIRED xcb-keysyms)
pkg_check_modules(LIBXCB_XKB REQUIRED xcb-xkb)
pkg_check_modules(LIBXKB_COMMON REQUIRED xkbcommon)
pkg_check_modules(LIBXKB_COMMON_X11 REQUIRED xkbcommon-x11)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(CAIRO REQUIRED cairo)
pkg_check_modules(PANGO REQUIRED pangocairo pangoft2)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
set(LINUX_LIBRARIES
${X11_LIBRARIES}
${FREETYPE_LIBRARIES}
${LIBXCB_LIBRARIES}
${LIBXCB_UTIL_LIBRARIES}
${LIBXCB_CURSOR_LIBRARIES}
${LIBXCB_KEYSYMS_LIBRARIES}
${LIBXCB_XKB_LIBRARIES}
${LIBXKB_COMMON_LIBRARIES}
${LIBXKB_COMMON_X11_LIBRARIES}
${GLIB_LIBRARIES}
${CAIRO_LIBRARIES}
${PANGO_LIBRARIES}
${FONTCONFIG_LIBRARIES}
dl
)
endif()
##########################################################################################
if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()
if(VSTGUI_MAIN_PROJECT_BUILD)
message(STATUS "Building only vstgui")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
$<$<CONFIG:Debug>:${CMAKE_BINARY_DIR}/Debug/>$<$<CONFIG:Release>:${CMAKE_BINARY_DIR}/Release/>$<$<CONFIG:ReleaseLTO>:${CMAKE_BINARY_DIR}/ReleaseLTO/>
)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
$<$<CONFIG:Debug>:${CMAKE_BINARY_DIR}/Debug/libs/>$<$<CONFIG:Release>:${CMAKE_BINARY_DIR}/Release/libs/>$<$<CONFIG:ReleaseLTO>:${CMAKE_BINARY_DIR}/ReleaseLTO/libs/>
)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
$<$<CONFIG:Debug>:${CMAKE_BINARY_DIR}/Debug/libs>$<$<CONFIG:Release>:${CMAKE_BINARY_DIR}/Release/libs>$<$<CONFIG:ReleaseLTO>:${CMAKE_BINARY_DIR}/ReleaseLTO/libs>
)
endif()
##########################################################################################
add_subdirectory(lib)
add_subdirectory(uidescription)
if(LINUX)
set(VSTGUI_DISABLE_UNITTESTS 1)
endif()
if(NOT DEFINED VSTGUI_STANDALONE)
option(VSTGUI_STANDALONE "VSTGUI Standalone library" ON)
if(NOT DEFINED VSTGUI_STANDALONE_EXAMPLES)
option(VSTGUI_STANDALONE_EXAMPLES "VSTGUI Standalone examples" ON)
endif()
endif()
if(NOT VSTGUI_STANDALONE AND VSTGUI_STANDALONE_EXAMPLES)
set(VSTGUI_STANDALONE_EXAMPLES OFF)
endif()
if(NOT DEFINED VSTGUI_TOOLS)
option(VSTGUI_TOOLS "Build VSTGUI Tools" ON)
endif()
if(VSTGUI_STANDALONE)
add_subdirectory(standalone)
if(NOT VSTGUI_DISABLE_UNITTESTS)
add_subdirectory(tests/gfxtest)
add_subdirectory(tests/base64codecspeed)
endif()
endif()
if(NOT VSTGUI_DISABLE_UNITTESTS)
add_subdirectory(tests)
endif()
if(VSTGUI_TOOLS)
add_subdirectory(tools)
endif()
get_directory_property(hasParent PARENT_DIRECTORY)
if(hasParent)
set(VSTGUI_COMPILE_DEFINITIONS ${VSTGUI_COMPILE_DEFINITIONS} PARENT_SCOPE)
set(VSTGUI_LTO_COMPILER_FLAGS ${VSTGUI_LTO_COMPILER_FLAGS} PARENT_SCOPE)
endif()