-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
147 lines (124 loc) · 3.96 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
# Creates C resources file from files in given directory
function(create_resources dir output)
# Create empty output file
file(WRITE ${output} "")
# Collect input files
file(GLOB bins ${dir}/*)
# Iterate through input files
foreach(bin ${bins})
# Get short filename
string(REGEX MATCH "([^/]+)$" filename ${bin})
# Replace filename spaces & extension separator for C compatibility
string(REGEX REPLACE "\\.| |-" "_" filename ${filename})
# Read hex data from file
file(READ ${bin} filedata HEX)
# Convert hex data for C compatibility
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata})
# Append data to output file
file(APPEND ${output} "const unsigned char ${filename}[] = {${filedata}};\nconst unsigned ${filename}_size = sizeof(${filename});\n")
endforeach()
endfunction()
project(oamlStudio)
set(oamlStudio_VERSION_MAJOR 1)
set(oamlStudio_VERSION_MINOR 1)
set(oamlStudio_VERSION_PATCH 1)
# Configuration types
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Debug mode: Yes (Disable by param -DCMAKE_BUILD_TYPE=Release)")
else()
message("Debug mode: No (Enable by param -DCMAKE_BUILD_TYPE=Debug)")
endif()
find_package(wxWidgets REQUIRED html adv core base net aui xrc qa richtext)
include(${wxWidgets_USE_FILE})
##
# Set CXX_FLAGS depending on compiler
#
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra")
endif()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
##
# Find VorbisFile lib
#
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
find_package(OggVorbis REQUIRED)
find_package(VorbisFile REQUIRED)
if (OGGVORBIS_FOUND AND VORBISFILE_FOUND)
include_directories(${VORBISFILE_INCLUDE_DIR})
set(LIBS ${LIBS} ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARIES})
endif()
##
# Find liblzip
#
if (APPLE)
set(LibArchive_INCLUDE_DIR "/usr/local/opt/libarchive/include")
endif()
find_package(LibArchive REQUIRED)
set(LIBS ${LIBS} ${LibArchive_LIBRARIES})
##
# Find oaml
#
find_package(OAML REQUIRED)
set(LIBS ${LIBS} ${OAML_LIBRARIES})
##
# Resource files
#
create_resources(images ${CMAKE_CURRENT_BINARY_DIR}/resources.h)
##
#
#
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${LibArchive_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(SRCS
src/audioFile.cpp
src/audioPanel.cpp
src/audioFilePanel.cpp
src/oamlCallbacks.cpp
src/controlPanel.cpp
src/layerPanel.cpp
src/oamlStudio.cpp
src/playbackFrame.cpp
src/settingsFrame.cpp
src/startupFrame.cpp
src/studioFrame.cpp
src/trackControl.cpp
src/trackPanel.cpp
src/waveformDisplay.cpp
src/aif.cpp
src/ogg.cpp
src/wav.cpp)
if (APPLE)
add_executable(oamlStudio MACOSX_BUNDLE ${SRCS} images/play.png images/pause.png)
set_source_files_properties(images/play.png images/pause.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
else()
add_executable(oamlStudio WIN32 ${SRCS})
endif()
target_link_libraries(oamlStudio ${wxWidgets_LIBRARIES} ${LIBS})
##
# Install rules
#
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP ON)
set(CMAKE_INSTALL_DEBUG_LIBRARIES ON)
include(InstallRequiredSystemLibraries)
install(TARGETS oamlStudio DESTINATION bin)
if (APPLE)
set(APPS ${CMAKE_CURRENT_BINARY_DIR}/oamlStudio.app) # paths to executables
set(DIRS . /usr/lib /usr/local/lib) # directories to search for prerequisites
install(CODE "
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
" COMPONENT Runtime)
endif()