forked from sainteos/tmxparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (58 loc) · 2.21 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
cmake_minimum_required(VERSION 2.8)
project(tmxparser)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
set(VERSION_MAJOR 2)
set(VERSION_MINOR 0)
set(VERSION_PATCH 1)
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message("Configuring tmxparser version ${VERSION}")
configure_file(
"${PROJECT_SOURCE_DIR}/src/Tmx.h.in"
"${PROJECT_BINARY_DIR}/Tmx.h"
)
option(USE_MINIZ "Use miniz.c instead of zlib" OFF)
if (USE_MINIZ)
add_definitions(-DUSE_MINIZ)
endif (USE_MINIZ)
file(GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${PROJECT_SOURCE_DIR}/src/*.h
${PROJECT_BINARY_DIR}/Tmx.h)
if (USE_MINIZ)
set(SOURCES ${SOURCES} ${PROJECT_SOURCE_DIR}/src/miniz.c)
endif (USE_MINIZ)
find_package(TinyXML2)
if (NOT USE_MINIZ)
find_package(ZLIB)
endif (NOT USE_MINIZ)
set(LIB_CFLAGS "-pedantic")
if (NOT USE_MINIZ)
list(APPEND ${LIB_CFLAGS} "")
endif (NOT USE_MINIZ)
set(EXAMPLE_CFLAGS "-pedantic")
#include_directories("${PROJECT_SOURCE_DIR}/include")
add_library(tmxparser_static STATIC ${SOURCES} ${HEADERS})
set_target_properties(tmxparser_static PROPERTIES
OUTPUT_NAME tmxparser
COMPILE_FLAGS ${LIB_CFLAGS})
add_library(tmxparser SHARED ${SOURCES} ${HEADERS})
set_target_properties(tmxparser PROPERTIES
SOVERSION ${VERSION_MAJOR}
VERSION ${VERSION}
COMPILE_FLAGS ${LIB_CFLAGS})
target_link_libraries(tmxparser debug ${TINYXML2_LIBRARY_DEBUG})
target_link_libraries(tmxparser optimized ${TINYXML2_LIBRARY_RELEASE})
include_directories(${TINYXML2_INCLUDE_DIR})
if (NOT USE_MINIZ)
target_link_libraries(tmxparser ${ZLIB_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIRS})
endif (NOT USE_MINIZ)
add_executable(run_tests test/test.cpp)
set_target_properties(run_tests PROPERTIES
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(run_tests tmxparser ${TINYXML2_LIBRARIES})
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/src")
install(FILES ${HEADERS} DESTINATION include/tmxparser)
install(TARGETS tmxparser tmxparser_static DESTINATION lib)
configure_file(src/tmxparser.pc.in tmxparser.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tmxparser.pc DESTINATION lib/pkgconfig)