2012-09-09 04:23:33 +00:00
|
|
|
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
|
|
|
|
cmake_policy(VERSION 2.6)
|
|
|
|
|
|
|
|
project(tinyxml2)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
#enable_testing()
|
|
|
|
|
|
|
|
#CMAKE_BUILD_TOOL
|
|
|
|
|
|
|
|
################################
|
|
|
|
# set lib version here
|
|
|
|
|
2014-11-14 18:40:58 +00:00
|
|
|
set(GENERIC_LIB_VERSION "2.2.0")
|
|
|
|
set(GENERIC_LIB_SOVERSION "2")
|
2012-09-09 04:23:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Add common source
|
|
|
|
|
|
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/.")
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Add custom target to copy all data
|
|
|
|
|
|
|
|
set(TARGET_DATA_COPY DATA_COPY)
|
|
|
|
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
add_custom_target(
|
|
|
|
${TARGET_DATA_COPY}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "In source build")
|
|
|
|
else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
make_directory(${CMAKE_CURRENT_BINARY_DIR}/resources/)
|
|
|
|
add_custom_target(
|
|
|
|
${TARGET_DATA_COPY}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/dream.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
|
2013-05-11 08:21:07 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/empty.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
|
2012-09-09 04:23:33 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/utf8test.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/utf8testverify.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/)
|
|
|
|
endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Add definitions
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif(MSVC)
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Add targets
|
2014-11-14 18:40:58 +00:00
|
|
|
option(BUILD_SHARED_LIBS "build shared or static libraries" ON)
|
|
|
|
add_library(tinyxml2 tinyxml2.cpp tinyxml2.h)
|
2012-09-09 04:23:33 +00:00
|
|
|
set_target_properties(tinyxml2 PROPERTIES
|
2013-12-12 12:07:34 +00:00
|
|
|
COMPILE_DEFINITIONS "TINYXML2_EXPORT"
|
2012-09-09 04:23:33 +00:00
|
|
|
VERSION "${GENERIC_LIB_VERSION}"
|
|
|
|
SOVERSION "${GENERIC_LIB_SOVERSION}")
|
|
|
|
|
2014-11-14 18:46:18 +00:00
|
|
|
add_executable(xmltest xmltest.cpp)
|
|
|
|
add_dependencies(xmltest tinyxml2)
|
|
|
|
add_dependencies(xmltest ${TARGET_DATA_COPY})
|
|
|
|
target_link_libraries(xmltest tinyxml2)
|
2012-09-09 04:23:33 +00:00
|
|
|
|
|
|
|
|
2014-11-14 18:40:58 +00:00
|
|
|
install(TARGETS tinyxml2
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
|
2012-09-09 04:23:33 +00:00
|
|
|
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
|
|
|
|
foreach(p LIB INCLUDE)
|
|
|
|
set(var CMAKE_INSTALL_${p}DIR)
|
|
|
|
if(NOT IS_ABSOLUTE "${${var}}")
|
|
|
|
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
|
|
|
|
2014-11-14 18:46:18 +00:00
|
|
|
#add_test(xmltest ${SAMPLE_NAME} COMMAND $<TARGET_FILE:${SAMPLE_NAME}>)
|