2017-09-09 02:33:18 +08:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
2017-03-02 21:47:16 +08:00
|
|
|
project(libstudxml)
|
|
|
|
|
2017-09-09 02:33:18 +08:00
|
|
|
# Require C++11 compiler
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
2017-03-06 11:39:27 +08:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2017-03-02 21:47:16 +08:00
|
|
|
set(LIBSTUDXML_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(LIBSTUDXML_INCLUDE_DIR ${LIBSTUDXML_ROOT_DIR})
|
|
|
|
|
2017-09-13 22:30:38 +08:00
|
|
|
if(STATIC_CRT)
|
2017-09-09 02:33:18 +08:00
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ucm.cmake)
|
|
|
|
ucm_set_runtime(STATIC)
|
|
|
|
endif()
|
|
|
|
|
2017-03-02 21:47:16 +08:00
|
|
|
set(LIBSTUDXML
|
2019-12-27 01:49:05 +08:00
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/parser.cxx
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/qname.cxx
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/serializer.cxx
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/value-traits.cxx
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/content
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/exception
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/forward
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/parser
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/qname
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/serializer
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/value-traits)
|
2017-03-02 21:47:16 +08:00
|
|
|
|
|
|
|
set(GENX
|
2019-12-27 01:49:05 +08:00
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/char-props.c
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/genx.c
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/genx/genx.h)
|
2017-03-02 21:47:16 +08:00
|
|
|
|
2017-04-11 23:08:16 +08:00
|
|
|
set(EXPAT
|
2019-12-27 01:49:05 +08:00
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlparse.c
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlrole.c
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmltok.c
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/ascii.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/asciitab.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/config.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/expat_external.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/expat.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/iasciitab.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/internal.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/latin1tab.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/nametab.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/utf8tab.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmlrole.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmltok_impl.h
|
|
|
|
${LIBSTUDXML_ROOT_DIR}/libstudxml/details/expat/xmltok.h)
|
2017-03-12 03:05:50 +08:00
|
|
|
|
2017-04-12 04:04:17 +08:00
|
|
|
add_library(libstudxml OBJECT ${LIBSTUDXML} ${GENX} ${EXPAT})
|
2017-03-21 07:24:34 +08:00
|
|
|
|
2017-04-12 06:21:01 +08:00
|
|
|
target_compile_definitions(libstudxml PUBLIC LIBSTUDXML_STATIC_LIB=1)
|
2017-03-12 03:05:50 +08:00
|
|
|
target_include_directories(libstudxml
|
2017-09-09 02:33:18 +08:00
|
|
|
PUBLIC ${LIBSTUDXML_ROOT_DIR}
|
|
|
|
PUBLIC ${EXPAT_INCLUDE_DIRS})
|
2017-03-21 07:24:34 +08:00
|
|
|
|
2017-04-12 06:21:01 +08:00
|
|
|
if(STATIC)
|
2017-09-09 02:33:18 +08:00
|
|
|
target_compile_definitions(libstudxml PUBLIC XML_STATIC=1)
|
2017-04-12 06:21:01 +08:00
|
|
|
endif()
|
|
|
|
|
2017-03-21 07:24:34 +08:00
|
|
|
# Prevent warning C4996 caused by strcpy, strncpy, sprintf in genx
|
|
|
|
# TODO: would it be better to define this only in genx.c?
|
|
|
|
if(MSVC)
|
2017-09-09 02:33:18 +08:00
|
|
|
target_compile_definitions(libstudxml PRIVATE _CRT_SECURE_NO_WARNINGS=1)
|
2017-03-21 07:24:34 +08:00
|
|
|
endif()
|
2017-03-02 21:47:16 +08:00
|
|
|
|
2017-03-21 07:24:34 +08:00
|
|
|
# Build with -fPIC when xlnt is a shared library
|
|
|
|
# TODO: is this still necessary? try removing
|
2017-03-02 21:47:16 +08:00
|
|
|
if(NOT STATIC)
|
2017-09-09 02:33:18 +08:00
|
|
|
set_target_properties(libstudxml PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
2017-03-21 07:24:34 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# When xlnt is a static library, assume expat will be linked statically too
|
|
|
|
# TODO: is this a valid assumption?
|
|
|
|
if(STATIC)
|
2017-09-09 02:33:18 +08:00
|
|
|
target_compile_definitions(libstudxml PUBLIC XML_STATIC=1)
|
2017-03-02 21:47:16 +08:00
|
|
|
endif()
|