forked from libkml/libkml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
128 lines (101 loc) · 4.1 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
cmake_minimum_required(VERSION 2.8)
project(LibKML)
set(VERSION_MAJOR "1")
set(VERSION_MINOR "3")
set(VERSION_PATCH "1")
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
option(BUILD_TESTING "Build testing." OFF)
option(BUILD_EXAMPLES "Build examples." OFF)
option(INSTALL_EXAMPLES "Install examples sources and executables" OFF)
option(BUILD_SHARED_LIBS "Build shared libs." ON)
option(WITH_SWIG "Build all swig bindings" OFF)
option(WITH_PYTHON "Build python bindings" OFF)
option(WITH_JAVA "Build java bindings" OFF)
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
if(POLICY CMP0022)
cmake_policy(SET CMP0022 NEW)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#AM_CXXFLAGS = -Wall -Wextra -Wno-unused-parameter -pedantic -fno-rtti
#AM_TEST_CXXFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror -fno-rtti -DGTEST_HAS_RTTI=0
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -pedantic -fno-rtti")
set(TEST_FLAGS "-Wall -Wextra -Wno-unused-parameter -fno-rtti -DGTEST_HAS_RTTI=0")
else()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DUNICODE /D_UNICODE /EHsc /D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DUNICODE /D_UNICODE /EHsc /D_CRT_SECURE_NO_WARNINGS")
# set(BUILD_SHARED_LIBS OFF)
endif()
endif()
if(NOT DEFINED BIN_INSTALL_DIR)
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
endif(NOT DEFINED BIN_INSTALL_DIR)
if(NOT DEFINED LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif(NOT DEFINED LIB_INSTALL_DIR)
if(NOT DEFINED DATA_INSTALL_DIR)
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share")
endif(NOT DEFINED DATA_INSTALL_DIR)
if(NOT DEFINED INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/kml")
endif(NOT DEFINED INCLUDE_INSTALL_DIR)
if(NOT DEFINED MAN_INSTALL_DIR)
set(MAN_INSTALL_DIR "${DATA_INSTALL_DIR}/man")
endif(NOT DEFINED MAN_INSTALL_DIR)
if(NOT DEFINED RESOURCE_INSTALL_DIR)
set(RESOURCE_INSTALL_DIR "${DATA_INSTALL_DIR}/libkml${VERSION_MAJOR}/resource/")
endif(NOT DEFINED RESOURCE_INSTALL_DIR)
if(NOT DEFINED LOCALE_INSTALL_DIR)
set(LOCALE_INSTALL_DIR "${DATA_INSTALL_DIR}/locale/")
endif(NOT DEFINED LOCALE_INSTALL_DIR)
if(NOT DEFINED JAVA_INSTALL_DIR)
set(JAVA_INSTALL_DIR "${DATA_INSTALL_DIR}/java")
endif(NOT DEFINED JAVA_INSTALL_DIR)
if(NOT DEFINED JNI_INSTALL_DIR)
set(JNI_INSTALL_DIR "${LIB_INSTALL_DIR}/jni")
endif(NOT DEFINED JNI_INSTALL_DIR)
if(NOT DEFINED PKGCONFIG_INSTALL_DIR)
set(PKGCONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/pkgconfig")
endif(NOT DEFINED PKGCONFIG_INSTALL_DIR)
set(LIBKML_URIPARSER_LIBRARY)
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake
${CMAKE_MODULE_PATH})
set(LIBKML_DATA_DIR ${CMAKE_SOURCE_DIR}/testdata CACHE "Directory containing test data" PATH)
include(LibKMLHelper)
add_subdirectory(third_party)
if(NOT BUILD_SHARED_LIBS)
add_definitions(-DXML_STATIC) #for static expat
endif()
include_directories(${LIBKML_EXPAT_INCLUDE_DIRS})
include_directories(${LIBKML_BOOST_INCLUDE_DIRS})
include_directories(${LIBKML_ZLIB_INCLUDE_DIRS})
include_directories(${LIBKML_URIPARSER_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/src/kml)
set(LIBKML_LINK_LIBRARIES ${LIBKML_ZLIB_LIBRARY} ${LIBKML_EXPAT_LIBRARY})
if(LIBKML_URIPARSER_LIBRARY)
set(LIBKML_LINK_LIBRARIES ${BASE_LINK_LIBRARIES} ${LIBKML_URIPARSER_LIBRARY})
endif()
if(LIBKML_MINIZIP_LIBRARY)
set(LIBKML_LINK_LIBRARIES ${BASE_LINK_LIBRARIES} ${LIBKML_MINIZIP_LIBRAY})
endif()
add_subdirectory(src)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/examples")
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
if(NOT WIN32 OR MINGW)
configure_file("${CMAKE_SOURCE_DIR}/cmake/libkml.pc.in"
"${CMAKE_BINARY_DIR}/libkml.pc" @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/libkml.pc
DESTINATION ${PKGCONFIG_INSTALL_DIR})
endif()