Build shared libs for tinyxml. (#7914)

This commit is contained in:
健美猫 2018-04-30 23:03:24 +08:00 committed by Adam J. Stewart
parent d02b5b96d3
commit 094eb5f9a8
2 changed files with 20 additions and 9 deletions

View File

@ -1,17 +1,21 @@
cmake_minimum_required(VERSION 2.6)
project(TinyXml)
OPTION(TIXML_USE_STL "Use STL with TIXML" ON)
OPTION(BUILD_SHARED_LIBS "build as shared library" ON)
if(TIXML_USE_STL)
add_definitions(-DTIXML_USE_STL)
endif(TIXML_USE_STL)
add_library(
tinyxml
tinyxml.cpp
tinystr.cpp
tinyxmlerror.cpp
tinyxmlparser.cpp
)
INSTALL( FILES tinyxml.h tinystr.h DESTINATION include )
INSTALL( TARGETS tinyxml ARCHIVE DESTINATION lib )
if(BUILD_SHARED_LIBS)
add_library(tinyxml SHARED tinyxml.cpp tinystr.cpp tinyxmlerror.cpp tinyxmlparser.cpp)
install(TARGETS tinyxml LIBRARY DESTINATION lib)
else()
add_library(tinyxml_static STATIC tinyxml.cpp tinystr.cpp tinyxmlerror.cpp tinyxmlparser.cpp)
set_target_properties(tinyxml_static PROPERTIES OUTPUT_NAME tinyxml)
install(TARGETS tinyxml_static ARCHIVE DESTINATION lib)
endif(BUILD_SHARED_LIBS)
install(FILES tinyxml.h tinystr.h DESTINATION include)

View File

@ -35,6 +35,8 @@ class Tinyxml(CMakePackage):
version('2.6.2', 'cba3f50dd657cb1434674a03b21394df9913d764')
variant('shared', default=True, description='Build a shared library')
def url_for_version(self, version):
url = "https://sourceforge.net/projects/tinyxml/files/tinyxml/{0}/tinyxml_{1}.tar.gz"
return url.format(version.dotted, version.underscored)
@ -42,3 +44,8 @@ def url_for_version(self, version):
def patch(self):
copyfile(join_path(os.path.dirname(__file__),
"CMakeLists.txt"), "CMakeLists.txt")
def cmake_args(self):
spec = self.spec
return [
'-DBUILD_SHARED_LIBS=%s' % ('YES' if '+shared' in spec else 'NO')]