-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt
110 lines (91 loc) · 2.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
cmake_minimum_required(VERSION 2.6)
project(allegro_tiled)
# Allows us to get CMake stuff from other places
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Utility functions
include(Utils)
# Options
option(WANT_EXAMPLE "build the example" true)
# Use pkg-config for all deps
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
# Note: I've set this to not just run for APPLE
# just in case someone's using linuxbrew
add_homebrew_package_path(libxml2 zlib)
if(APPLE)
pkg_search_module(ALLEGRO REQUIRED allegro-5 allegro-5.0)
pkg_search_module(ALLEGRO_MAIN REQUIRED allegro_main-5 allegro_main-5.0)
pkg_search_module(ALLEGRO_IMAGE REQUIRED allegro_image-5 allegro_image-5.0)
else()
pkg_search_module(ALLEGRO REQUIRED allegro-5 allegro-5.0)
pkg_search_module(ALLEGRO_IMAGE REQUIRED allegro_image-5 allegro_image-5.0)
endif()
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(LIBXML REQUIRED libxml-2.0)
pkg_check_modules(ZLIB REQUIRED zlib)
# Generate pc files
configure_file(
misc/allegro_tiled-5.pc.in
misc/allegro_tiled-5.pc
@ONLY
)
configure_file(
misc/allegro_tiled-5.pc.in
misc/allegro_tiled-5.0.pc
@ONLY
)
install(
FILES misc/allegro_tiled-5.pc misc/allegro_tiled-5.0.pc
DESTINATION lib/pkgconfig
)
else()
message("pkg-config is not installed on this system, using environment variables.")
find_env_deps()
endif()
link_directories(
${ALLEGRO_LIBRARY_DIRS}
${ALLEGRO_MAIN_LIBRARY_DIRS}
${ALLEGRO_LIBRARY_LIBRARY_DIRS}
${GLIB_LIBRARY_DIRS}
${LIBXML_LIBRARY_DIRS}
${ZLIB_LIBRARY_DIRS}
)
include_directories(
${CMAKE_SOURCE_DIR}/include
${ALLEGRO_INCLUDE_DIRS}
${ALLEGRO_MAIN_INCLUDE_DIRS}
${ALLEGRO_INCLUDE_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${LIBXML_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)
file(GLOB allegro_tiled_headers include/allegro5/*.h)
file(GLOB allegro_tiled_sources src/*.c)
# Actually build the library
add_library(
allegro_tiled
${allegro_tiled_sources}
)
# Make sure the library is linked against everything we need
target_link_libraries(
allegro_tiled
${ALLEGRO_LIBRARIES}
${ALLEGRO_MAIN_LIBRARIES}
${ALLEGRO_IMAGE_LIBRARIES}
${GLIB_LIBRARIES}
${LIBXML_LIBRARIES}
${ZLIB_LIBRARIES}
)
install(
TARGETS allegro_tiled
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(
FILES ${allegro_tiled_headers}
DESTINATION include/allegro5
)
# Build the example if the option is enabled
if (WANT_EXAMPLE)
add_subdirectory(example)
endif()