tinyxml: use cmake to simply shared and static build

This commit is contained in:
Rashad M 2015-06-21 19:12:11 +02:00
parent 4f45a0cf2c
commit 20b514bd47
3 changed files with 29 additions and 41 deletions

View File

@ -0,0 +1,22 @@
diff -burN tinyxml.orig/CMakeLists.txt tinyxml/CMakeLists.txt
--- tinyxml.orig/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
+++ tinyxml/CMakeLists.txt 2015-06-21 19:03:09.878168410 +0200
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 2.8)
+
+file(GLOB SRCS "${CMAKE_SOURCE_DIR}/tiny*.cpp" )
+
+include_directories(${CMAKE_SOURCE_DIR})
+add_definitions(-DTIXML_USE_STL)
+
+add_library(tinyxml ${SRCS})
+
+install(TARGETS tinyxml
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+
+file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/*.h")
+install(FILES ${HEADERS}
+ DESTINATION include
+)

View File

@ -1,24 +0,0 @@
/*
* This file is part of MXE.
* See index.html for further information.
*/
#include <iostream>
#include <tinyxml.h>
int main(int argc, char *argv[])
{
if (argc != 2) {
std::cerr << "Usage: tinyxml-test <xml-file>" << std::endl;
return 1;
}
std::string fpn = argv[1];
TiXmlDocument doc(fpn);
if (!doc.LoadFile()) {
std::cerr << "failed to load " << fpn << std::endl;
return 1;
}
return 0;
}

View File

@ -17,25 +17,15 @@ define $(PKG)_UPDATE
endef
define $(PKG)_BUILD
cd '$(1)' && $(TARGET)-g++ -c -O3 -Wall -Wno-unknown-pragmas -Wno-format -D TIXML_USE_STL tiny*.cpp
$(if $(BUILD_STATIC),
$(TARGET)-ar cr libtinyxml.a *.o
$(TARGET)-ranlib '$(1)/libtinyxml.a'
,
cd '$(1)' && $(TARGET)-g++ -shared -Wl,-soname,libtinyxml.so -o libtinyxml.so *.o
)
$(INSTALL) -d '$(PREFIX)/$(TARGET)/lib'
$(if $(BUILD_STATIC),
$(INSTALL) -m644 '$(1)'/*.a '$(PREFIX)/$(TARGET)/lib/'
,
$(INSTALL) -m644 '$(1)'/*.so '$(PREFIX)/$(TARGET)/lib/'
)
$(INSTALL) -d '$(PREFIX)/$(TARGET)/include'
$(INSTALL) -m644 '$(1)'/*.h '$(PREFIX)/$(TARGET)/include/'
mkdir '$(1).build'
cd '$(1).build' && cmake \
-DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
-DBUILD_SHARED_LIBS=$(if $(BUILD_STATIC),FALSE,TRUE) \
'$(1)'
$(MAKE) -C '$(1).build' install
'$(TARGET)-g++' \
-W -Wall -D TIXML_USE_STL -ansi -pedantic \
-Wall -DTIXML_USE_STL -ansi -pedantic \
'$(1)/xmltest.cpp' -o '$(PREFIX)/$(TARGET)/bin/test-tinyxml.exe' \
-ltinyxml
endef