-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
145 lines (126 loc) · 4.07 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
cmake_minimum_required(VERSION 2.8)
set(appName Shotwell)
project(${appName})
# Definitions
set(EXECUTABLE_OUTPUT_PATH build)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/src/cmake-modules ${CMAKE_MODULE_PATH})
set(vendorPrefix ${CMAKE_CURRENT_SOURCE_DIR}/vendor/build)
set(vendorLib ${vendorPrefix}/lib)
find_program(IBTOOL ibtool)
add_subdirectory(vendor)
find_library(accelerate Accelerate)
find_library(appKit AppKit)
find_library(audioToolbox AudioToolbox)
find_library(audioUnit AudioUnit)
find_library(carbon Carbon)
find_library(cocoa Cocoa)
find_library(coreAudio CoreAudio)
find_library(coreFoundation CoreFoundation)
find_library(coreServices CoreServices)
find_library(foundation Foundation)
find_library(iokit IOKit)
find_library(javascriptCore JavaScriptCore)
find_library(quartz Quartz)
find_library(quartzCore QuartzCore)
find_library(stdcpp stdc++)
find_library(videoDecodeAcceleration VideoDecodeAcceleration)
find_library(webKit WebKit)
set(systemLibs
${accelerate}
${appKit}
${audioToolbox}
${audioUnit}
${carbon}
${cocoa}
${coreAudio}
${coreFoundation}
${coreServices}
${foundation}
${iokit}
${javascriptCore}
${quartz}
${quartzCore}
${stdcpp}
${videoDecodeAcceleration}
${webKit}
pthread
bz2
ssl
crypto
z)
set(vendorLibs
${vendorLib}/libavcodec.a
${vendorLib}/libavdevice.a
${vendorLib}/libavfilter.a
${vendorLib}/libavformat.a
${vendorLib}/libavutil.a
${vendorLib}/libchromaprint.a
${vendorLib}/libleveldb.a
${vendorLib}/libevent.a
${vendorLib}/libevent_pthreads.a
${vendorLib}/libicuuc.a
${vendorLib}/libicudata.a
${vendorLib}/libsnappy.a
${vendorLib}/libjansson.a
${vendorLib}/libswscale.a)
file(GLOB sources src/*.mm)
foreach (f ${sources})
if ($"${f}" MATCHES ".*main[.]m|test[.]mm.*")
list(APPEND mainSources "${f}")
elseif("${f}" MATCHES ".*(Test|test).*")
list(APPEND testSources "${f}")
else()
list(APPEND appSources "${f}")
endif()
endforeach(f)
# Make local includes work
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg -ggdb -iquote ${PROJECT_SOURCE_DIR}/src")
# Resources
file(GLOB appResources assets/*.png assets/*.icns assets/*.pdf)
foreach(f ${appResources})
string(REPLACE "${PROJECT_SOURCE_DIR}/assets" "" dst ${f})
string(REGEX REPLACE "/[^/]+$" "" dst ${dst})
set_source_files_properties(${f} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${dst})
endforeach(f)
# nib setup
set(nib ${EXECUTABLE_OUTPUT_PATH}/MainMenu.nib)
set(appResources ${appResources} ${nib})
set(xib ${PROJECT_SOURCE_DIR}/assets/en.lproj/MainMenu.xib)
add_custom_command(
OUTPUT ${nib}
DEPENDS ${xib}
COMMAND ${IBTOOL} --compile ${nib} ${xib}
COMMENT "Compiling ${xib} => ${nib}")
set_source_files_properties(${nib} PROPERTIES
GENERATED TRUE
MACOSX_PACKAGE_LOCATION Resources/en.lproj)
# maybe move this to the bottom?
add_executable(${appName} MACOSX_BUNDLE src/main.m ${appResources} ${appSources})
target_link_libraries(${appName} ${vendorLibs} ${systemLibs})
include_directories(${vendorPrefix}/include)
# Make sure that the vendor library step is complete before building the application
add_dependencies(${appName} BuildVendorLibraries)
# Add target to run gdb:
add_custom_target(
gdb
DEPENDS src/debug.gdb ${appName}
COMMAND gdb -f -x src/debug.gdb ${EXECUTABLE_OUTPUT_PATH}/${appName}.app/Contents/MacOS/${appName})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -iquote ${PROJECT_SOURCE_DIR}/vendor/build/share/gtest-1.6.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -iquote ${PROJECT_SOURCE_DIR}/vendor/build/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
# vendor/build/share/gtest-1.6.0/src/gtest_main.cc
add_executable(testit
src/test.mm
vendor/build/share/gtest-1.6.0/src/gtest-all.cc
${appSources}
${testSources})
target_link_libraries(testit ${vendorLibs} ${systemLibs})
add_custom_target(
test
DEPENDS testit
COMMAND ${EXECUTABLE_OUTPUT_PATH}/testit --gtest_catch_exceptions=0)
add_custom_target(
gdbtest
DEPENDS testit src/debugtestit.gdb
COMMAND gdb -f -x src/debugtestit.gdb ${EXECUTABLE_OUTPUT_PATH}/testit)