@@ -4,9 +4,10 @@ project(tmx-loader)
4
4
5
5
# Set options
6
6
set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" )
7
- set (BUILD_SHARED_LIBS TRUE CACHE BOOL "TRUE to build light as shared libraries, FALSE to build it as static libraries" )
7
+ set (BUILD_SHARED_LIBS TRUE CACHE BOOL "TRUE to build as shared libraries, FALSE to build it as static libraries" )
8
8
set (SFML_STATIC_LIBS FALSE CACHE BOOL "Choose whether SFML is linked statically or not." )
9
9
set (TMX_STATIC_STD_LIBS FALSE CACHE BOOL "Use statically linked standard/runtime libraries? This option must match the one used for SFML." )
10
+ set (USE_BOX2D FALSE CACHE BOOL "Use the Box2D functions of the map loader - Requires Box2D if true" )
10
11
set (TMX_BUILD_EXAMPLE FALSE BOOL CACHE BOOL "TRUE to build the tmx-loader example, FALSE to ignore them" )
11
12
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR} /cmake/Modules/" )
12
13
@@ -54,27 +55,40 @@ set(pugi_SRCS
54
55
src/pugixml/pugixml.cpp)
55
56
56
57
set (tmx_HDRS
57
- include /tmx/MapLayer.h
58
- include /tmx/MapLoader.h
59
- include /tmx/MapObject.h
60
- include /tmx/QuadTreeNode.h
61
- include /tmx/DebugShape.h
62
- include /tmx/Helpers.h
63
- include /tmx/Log .h)
58
+ include /tmx/MapLayer.hpp
59
+ include /tmx/MapLoader.hpp
60
+ include /tmx/MapObject.hpp
61
+ include /tmx/QuadTreeNode.hpp
62
+ include /tmx/DebugShape.hpp
63
+ include /tmx/Helpers.hpp
64
+ include /tmx/Log .hpp
65
+ include /tmx/Export.hpp)
64
66
65
67
set (tmx_SRCS
66
- src/DebugShape.cpp
68
+ src/DebugShape.cpp
67
69
src/MapLoaderPublic.cpp
68
70
src/MapLoaderPrivate.cpp
69
71
src/MapLayer.cpp
70
72
src/MapObject.cpp
71
- src/QuadTreeNode.cpp)
72
-
73
+ src/QuadTreeNode.cpp
74
+ src/Log .cpp)
75
+
76
+ if (USE_BOX2D)
77
+ list (APPEND ${tmx_HDRS}
78
+ include /tmx/tmx2box2d.hpp)
79
+ list (APPEND ${tmx_SRCS}
80
+ src/tmx2box2d.cpp)
81
+ endif ()
82
+
73
83
set (maps_SRCS "${PROJECT_SOURCE_DIR} /maps/" )
74
84
set (fonts_SRCS "${PROJECT_SOURCE_DIR} /fonts/" )
75
85
76
86
add_library (pugi ${pugi_HDRS} ${pugi_SRCS} )
77
- add_library (${PROJECT_NAME} ${tmx_HDRS} ${tmx_SRCS} )
87
+ if (BUILD_SHARED_LIBS )
88
+ add_library (${PROJECT_NAME} SHARED ${tmx_HDRS} ${tmx_SRCS} )
89
+ else ()
90
+ add_library (${PROJECT_NAME} STATIC ${tmx_HDRS} ${tmx_SRCS} )
91
+ endif ()
78
92
79
93
80
94
find_package (SFML 2 REQUIRED graphics window system )
@@ -97,17 +111,18 @@ elseif(NOT ZLIB_FOUND)
97
111
message ("-> Make sure the zlib libraries with the same configuration (Release/Debug, Static/Dynamic) exist.\n " )
98
112
endif ()
99
113
114
+ if (USE_BOX2D)
115
+ find_package (BOX2D)
100
116
101
- find_package (BOX2D)
102
-
103
- if (BOX2D_FOUND)
104
- include_directories (${BOX2D_INCLUDE_DIR} )
105
- elseif (NOT BOX2D_FOUND)
106
- set (BOX2D_INCLUDE_DIR "" CACHE PATH "Box2D include directory" )
107
- set (BOX2D_LIBRARIES "" CACHE PATH "Box2D lib directory" )
117
+ if (BOX2D_FOUND)
118
+ include_directories (${BOX2D_INCLUDE_DIR} )
119
+ elseif (NOT BOX2D_FOUND)
120
+ set (BOX2D_INCLUDE_DIR "" CACHE PATH "Box2D include directory" )
121
+ set (BOX2D_LIBRARIES "" CACHE PATH "Box2D lib directory" )
108
122
message ("\n -> Box2D directories not found. Set BOX2D_INCLUDE_DIR to Box2D's include path and BOX2D_LIBRARIES to Box2D's lib directory path." )
109
123
message ("-> Make sure the Box2D libraries with the same configuration (Release/Debug, Static/Dynamic) exist.\n " )
110
124
endif ()
125
+ endif ()
111
126
112
127
#target_link_libraries(pugi ${ZLIB_LIBRARIES})
113
128
target_link_libraries (tmx-loader pugi ${SFML_LIBRARIES} ${SFML_DEPENDENCIES} ${ZLIB_LIBRARIES} )
@@ -146,7 +161,7 @@ install(
146
161
147
162
# Install tmx-loader
148
163
install (
149
- TARGETS tmx-loader
164
+ TARGETS tmx-loader EXPORT tmx-loader-targets
150
165
RUNTIME DESTINATION bin COMPONENT bin
151
166
LIBRARY DESTINATION lib COMPONENT bin
152
167
ARCHIVE DESTINATION lib COMPONENT dev
0 commit comments