-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
84 lines (70 loc) · 2.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
cmake_minimum_required(VERSION 2.8)
project(WIDGETZ C)
include_directories(
${WIDGETZ_SOURCE_DIR}/include
)
file(GLOB_RECURSE SOURCES "src/*.c")
if(NOT USE_INTERNAL_LIB)
file(GLOB_RECURSE EXAMPLE_DATA RELATIVE "${WIDGETZ_SOURCE_DIR}/example/" "example/data/*")
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g")
set(ALLEGRO_SUB_VERSION "0" CACHE STRING "Sub version of Allegro to use (0 - stable, 1 - unstable")
set(ALLEGRO_WIP_VERSION "0" CACHE STRING "WIP version of Allegro to use")
include(FindPkgConfig)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/Modules")
find_package(Allegro REQUIRED)
find_package(Freetype REQUIRED)
include_directories(${ALLEGRO_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIR})
set(WZ_ALLEGRO_LDFLAGS ${ALLEGRO_LIBRARIES} ${FREETYPE_LIBRARIES})
if(WIN32)
set(EXECUTABLE_TYPE "WIN32")
endif(WIN32)
if(APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
if(IPHONE)
set(WZ_ALLEGRO_LDFLAGS ${WZ_ALLEGRO_LDFLAGS} "-framework CoreGraphics -framework QuartzCore -framework UIKit -framework Foundation -framework CoreFoundation -framework OpenGLES -framework OpenAL -lm")
set(SDKROOT "iphoneos")
set(CMAKE_OSX_SYSROOT "${SDKROOT}")
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
add_definitions(-DIPHONE)
else(IPHONE)
set(WZ_ALLEGRO_LDFLAGS ${WZ_ALLEGRO_LDFLAGS} "-framework Cocoa -framework QuartzCore -framework Foundation -framework CoreFoundation -framework OpenGL -framework IOKit -framework AudioToolbox -framework OpenAL -lm")
add_definitions(-DAPPLE)
endif(IPHONE)
endif(APPLE)
add_custom_target(example_data ALL DEPENDS ${EXAMPLE_DATA})
if(IPHONE)
add_executable(example MACOSX_BUNDLE "example/example.c")
set_target_properties(example PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.widgetz.example")
set_target_properties(example PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
set(APP_RES_DIR \${TARGET_BUILD_DIR}/\${FULL_PRODUCT_NAME})
foreach(file ${EXAMPLE_DATA})
add_custom_command(
TARGET example
POST_BUILD
COMMAND mkdir -p ${APP_RES_DIR} &&
ditto "${CMAKE_CURRENT_SOURCE_DIR}/example/${file}" ${APP_RES_DIR} &&
echo "Copied Data to Bundle."
)
endforeach(file)
else(IPHONE)
add_executable(example "example/example.c")
foreach(file ${EXAMPLE_DATA})
add_custom_command(
OUTPUT ${file}
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/example/${file}" "${file}"
)
endforeach(file)
endif(IPHONE)
add_library(widgetz ${SOURCES})
target_link_libraries(widgetz ${WZ_ALLEGRO_LDFLAGS})
set(EXAMPLE_LIBS widgetz ${WZ_ALLEGRO_LDFLAGS})
if(NOT MSVC)
list(APPEND EXAMPLE_LIBS m)
endif()
target_link_libraries(example ${EXAMPLE_LIBS})
install(DIRECTORY "${WIDGETZ_SOURCE_DIR}/include/widgetz" DESTINATION include)
install(TARGETS widgetz ARCHIVE DESTINATION lib)
else(NOT USE_INTERNAL_LIB)
add_library(widgetz ${SOURCES})
target_link_libraries(widgetz ${ALLEGRO_LIBRARIES})
endif(NOT USE_INTERNAL_LIB)