Overhaul CMake build
This commit is contained in:
20
.github/workflows/ci-unixish.yml
vendored
20
.github/workflows/ci-unixish.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: C/C++ CI Unixish
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: make
|
||||
run: make
|
||||
- name: make check
|
||||
run: make check
|
||||
- name: Install
|
||||
run: sudo make install
|
||||
111
.github/workflows/test.yml
vendored
Normal file
111
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
name: Test
|
||||
on: [ push, pull_request ]
|
||||
jobs:
|
||||
test:
|
||||
name: ${{ matrix.os }}, ${{ matrix.cmake_name }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ windows-2019, macos-10.15, ubuntu-20.04 ]
|
||||
cmake: [ 3.15, 3.x ]
|
||||
include:
|
||||
- os: windows-2019
|
||||
static_postfix: _static
|
||||
tree: tree /F
|
||||
CXX: cl
|
||||
|
||||
- os: ubuntu-20.04
|
||||
tree: tree
|
||||
|
||||
- os: macos-10.15
|
||||
tree: find
|
||||
|
||||
- cmake: 3.15
|
||||
cmake_name: CMake 3.15
|
||||
- cmake: 3.x
|
||||
cmake_name: Latest CMake
|
||||
env:
|
||||
# CMake 3.15 doesn't detect Visual Studio correctly without these.
|
||||
CXX: ${{ matrix.CXX }}
|
||||
CC: ${{ matrix.CXX }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
# System set-up
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- uses: seanmiddleditch/gha-setup-ninja@master
|
||||
- uses: jwlawson/actions-setup-cmake@v1.8
|
||||
with:
|
||||
cmake-version: ${{ matrix.cmake }}
|
||||
|
||||
# Static Debug
|
||||
- name: "Static Debug: Configure"
|
||||
run: cmake -G Ninja -S . -B build-static-dbg -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_DEBUG_POSTFIX=d${{matrix.static_postfix}}"
|
||||
- name: "Static Debug: Build"
|
||||
run: cmake --build build-static-dbg
|
||||
- name: "Static Debug: Test"
|
||||
run: ctest --output-on-failure
|
||||
working-directory: build-static-dbg
|
||||
|
||||
# Shared Debug
|
||||
- name: "Shared Debug: Configure"
|
||||
run: cmake -G Ninja -S . -B build-shared-dbg -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=d -DBUILD_SHARED_LIBS=ON
|
||||
- name: "Shared Debug: Build"
|
||||
run: cmake --build build-shared-dbg
|
||||
- name: "Shared Debug: Test"
|
||||
run: ctest --output-on-failure
|
||||
working-directory: build-shared-dbg
|
||||
|
||||
# Static Release
|
||||
- name: "Static Release: Configure"
|
||||
run: cmake -G Ninja -S . -B build-static-rel -DCMAKE_BUILD_TYPE=Release "-DCMAKE_RELEASE_POSTFIX=${{matrix.static_postfix}}"
|
||||
- name: "Static Release: Build"
|
||||
run: cmake --build build-static-rel
|
||||
- name: "Static Release: Test"
|
||||
run: ctest --output-on-failure
|
||||
working-directory: build-static-rel
|
||||
|
||||
# Shared Release
|
||||
- name: "Shared Release: Configure"
|
||||
run: cmake -G Ninja -S . -B build-shared-rel -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
|
||||
- name: "Shared Release: Build"
|
||||
run: cmake --build build-shared-rel
|
||||
- name: "Shared Release: Test"
|
||||
run: ctest --output-on-failure
|
||||
working-directory: build-shared-rel
|
||||
|
||||
# Joint install
|
||||
- name: Install
|
||||
run: |
|
||||
cmake --install build-shared-dbg --prefix install
|
||||
cmake --install build-static-dbg --prefix install
|
||||
cmake --install build-shared-rel --prefix install
|
||||
cmake --install build-static-rel --prefix install
|
||||
- name: List install tree
|
||||
run: ${{matrix.tree}} install
|
||||
|
||||
# Test find_package
|
||||
- name: "Test find_package: Static Debug"
|
||||
run: >-
|
||||
ctest --build-and-test test test-static-dbg
|
||||
--build-generator Ninja
|
||||
--build-options -DCMAKE_BUILD_TYPE=Debug -Dtinyxml2_SHARED_LIBS=NO -DCMAKE_PREFIX_PATH=${{github.workspace}}/install
|
||||
--test-command ctest --output-on-failure
|
||||
- name: "Test find_package: Static Release"
|
||||
run: >-
|
||||
ctest --build-and-test test test-static-rel
|
||||
--build-generator Ninja
|
||||
--build-options -DCMAKE_BUILD_TYPE=Release -Dtinyxml2_SHARED_LIBS=NO -DCMAKE_PREFIX_PATH=${{github.workspace}}/install
|
||||
--test-command ctest --output-on-failure
|
||||
- name: "Test find_package: Shared Debug"
|
||||
run: >-
|
||||
ctest --build-and-test test test-shared-dbg
|
||||
--build-generator Ninja
|
||||
--build-options -DCMAKE_BUILD_TYPE=Debug -Dtinyxml2_SHARED_LIBS=YES -DCMAKE_PREFIX_PATH=${{github.workspace}}/install
|
||||
--test-command ctest --output-on-failure
|
||||
- name: "Test find_package: Shared Release"
|
||||
run: >-
|
||||
ctest --build-and-test test test-shared-rel
|
||||
--build-generator Ninja
|
||||
--build-options -DCMAKE_BUILD_TYPE=Release -Dtinyxml2_SHARED_LIBS=YES -DCMAKE_PREFIX_PATH=${{github.workspace}}/install
|
||||
--test-command ctest --output-on-failure
|
||||
15
.travis.yml
15
.travis.yml
@@ -1,15 +0,0 @@
|
||||
language: cpp
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
compiler:
|
||||
- g++
|
||||
- clang
|
||||
|
||||
before_script: cmake .
|
||||
|
||||
script:
|
||||
- make -j3
|
||||
- make test
|
||||
239
CMakeLists.txt
239
CMakeLists.txt
@@ -1,148 +1,129 @@
|
||||
IF(BIICODE)
|
||||
ADD_BIICODE_TARGETS()
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
ENDIF()
|
||||
RETURN()
|
||||
ENDIF(BIICODE)
|
||||
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
|
||||
cmake_policy(VERSION 2.6)
|
||||
if(POLICY CMP0063)
|
||||
cmake_policy(SET CMP0063 OLD)
|
||||
endif()
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(tinyxml2 VERSION 8.0.0)
|
||||
|
||||
project(tinyxml2)
|
||||
include(GNUInstallDirs)
|
||||
include(CTest)
|
||||
#enable_testing()
|
||||
option(tinyxml2_BUILD_TESTING "Build tests for tinyxml2" "${BUILD_TESTING}")
|
||||
|
||||
#CMAKE_BUILD_TOOL
|
||||
##
|
||||
## Honor tinyxml2_SHARED_LIBS to match install interface
|
||||
##
|
||||
|
||||
################################
|
||||
# set lib version here
|
||||
if (DEFINED tinyxml2_SHARED_LIBS)
|
||||
set(BUILD_SHARED_LIBS "${tinyxml2_SHARED_LIBS}")
|
||||
endif ()
|
||||
|
||||
set(GENERIC_LIB_VERSION "8.0.0")
|
||||
set(GENERIC_LIB_SOVERSION "8")
|
||||
|
||||
################################
|
||||
# Add definitions
|
||||
|
||||
################################
|
||||
# Add targets
|
||||
# By Default shared library is being built
|
||||
# User can choose to build static library by using cmake -DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
# To build the tests, use cmake . -DBUILD_TESTS:BOOL=ON
|
||||
# To disable the building of the tests, use cmake . -DBUILD_TESTS:BOOL=OFF
|
||||
|
||||
option(BUILD_SHARED_LIBS "build as shared library" ON)
|
||||
option(BUILD_TESTS "build xmltest (deprecated: Use BUILD_TESTING)" ON)
|
||||
|
||||
# To allow using tinyxml in another shared library
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
##
|
||||
## Main library build
|
||||
##
|
||||
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
||||
|
||||
# to distinguish between debug and release lib
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(TARGETS_EXPORT_NAME "${CMAKE_PROJECT_NAME}Targets")
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
|
||||
|
||||
add_library(tinyxml2 tinyxml2.cpp tinyxml2.h)
|
||||
add_library(tinyxml2::tinyxml2 ALIAS tinyxml2)
|
||||
|
||||
set_target_properties(tinyxml2 PROPERTIES
|
||||
DEFINE_SYMBOL "TINYXML2_EXPORT"
|
||||
VERSION "${GENERIC_LIB_VERSION}"
|
||||
SOVERSION "${GENERIC_LIB_SOVERSION}")
|
||||
# Uncomment the following line to require C++11 (or greater) to use tinyxml2
|
||||
# target_compile_features(tinyxml2 PUBLIC cxx_std_11)
|
||||
target_include_directories(tinyxml2 PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")
|
||||
|
||||
target_compile_definitions(tinyxml2 PUBLIC $<$<CONFIG:Debug>:TINYXML2_DEBUG>)
|
||||
target_compile_definitions(
|
||||
tinyxml2
|
||||
PUBLIC $<$<CONFIG:Debug>:TINYXML2_DEBUG>
|
||||
INTERFACE $<$<BOOL:${BUILD_SHARED_LIBS}>:TINYXML2_IMPORT>
|
||||
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
|
||||
)
|
||||
|
||||
if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
||||
target_include_directories(tinyxml2 PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
set_target_properties(
|
||||
tinyxml2
|
||||
PROPERTIES
|
||||
DEFINE_SYMBOL "TINYXML2_EXPORT"
|
||||
VERSION "${tinyxml2_VERSION}"
|
||||
SOVERSION "${tinyxml2_VERSION_MAJOR}"
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif(MSVC)
|
||||
else()
|
||||
include_directories(${PROJECT_SOURCE_DIR})
|
||||
if (tinyxml2_BUILD_TESTING)
|
||||
add_executable(xmltest xmltest.cpp)
|
||||
target_link_libraries(xmltest PRIVATE tinyxml2::tinyxml2)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif(MSVC)
|
||||
endif()
|
||||
add_test(
|
||||
NAME xmltest
|
||||
COMMAND xmltest
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
# Export cmake script that can be used by downstream project
|
||||
# via `include()`
|
||||
export(TARGETS tinyxml2
|
||||
NAMESPACE tinyxml2::
|
||||
FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake)
|
||||
set_tests_properties(xmltest PROPERTIES PASS_REGULAR_EXPRESSION ", Fail 0")
|
||||
endif ()
|
||||
|
||||
install(TARGETS tinyxml2
|
||||
EXPORT ${TARGETS_EXPORT_NAME}
|
||||
RUNTIME
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT tinyxml2_runtime
|
||||
LIBRARY
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT tinyxml2_libraries
|
||||
ARCHIVE
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT tinyxml2_libraries)
|
||||
|
||||
if(BUILD_TESTING AND BUILD_TESTS)
|
||||
add_executable(xmltest xmltest.cpp)
|
||||
add_dependencies(xmltest tinyxml2)
|
||||
target_link_libraries(xmltest tinyxml2)
|
||||
|
||||
# Copy test resources and create test output directory
|
||||
add_custom_command(TARGET xmltest POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/resources $<TARGET_FILE_DIR:xmltest>/resources
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:xmltest>/resources/out
|
||||
COMMENT "Configuring xmltest resources directory: ${CMAKE_CURRENT_BINARY_DIR}/resources"
|
||||
)
|
||||
|
||||
add_test(NAME xmltest COMMAND xmltest WORKING_DIRECTORY $<TARGET_FILE_DIR:xmltest>)
|
||||
endif()
|
||||
|
||||
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT tinyxml2_headers)
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
endif()
|
||||
configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT tinyxml2_config)
|
||||
|
||||
# uninstall target
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
endif()
|
||||
##
|
||||
## Installation
|
||||
##
|
||||
|
||||
## Standard modules
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file(
|
||||
"Config.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}"
|
||||
)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"
|
||||
VERSION ${GENERIC_LIB_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
install(FILES
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
|
||||
COMPONENT tinyxml2_config)
|
||||
|
||||
# Export targets for find_package config mode
|
||||
install(EXPORT ${TARGETS_EXPORT_NAME} NAMESPACE tinyxml2::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
|
||||
COMPONENT tinyxml2_config)
|
||||
## Custom locations
|
||||
set(tinyxml2_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
||||
CACHE PATH "Directory for pkgconfig files")
|
||||
|
||||
set(tinyxml2_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/tinyxml2"
|
||||
CACHE STRING "Path to tinyxml2 CMake files")
|
||||
|
||||
## CMake targets and export scripts
|
||||
|
||||
install(
|
||||
TARGETS tinyxml2 EXPORT tinyxml2-targets
|
||||
RUNTIME COMPONENT tinyxml2_runtime
|
||||
LIBRARY COMPONENT tinyxml2_runtime
|
||||
NAMELINK_COMPONENT tinyxml2_development
|
||||
ARCHIVE COMPONENT tinyxml2_development
|
||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
# Type-specific targets
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set(type shared)
|
||||
else ()
|
||||
set(type static)
|
||||
endif ()
|
||||
|
||||
install(
|
||||
EXPORT tinyxml2-targets
|
||||
DESTINATION "${tinyxml2_INSTALL_CMAKEDIR}"
|
||||
NAMESPACE tinyxml2::
|
||||
FILE tinyxml2-${type}-targets.cmake
|
||||
COMPONENT tinyxml2_development
|
||||
)
|
||||
|
||||
# Auto-generated version compatibility file
|
||||
write_basic_package_version_file(
|
||||
tinyxml2-config-version.cmake
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/tinyxml2-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tinyxml2-config-version.cmake"
|
||||
DESTINATION "${tinyxml2_INSTALL_CMAKEDIR}"
|
||||
COMPONENT tinyxml2_development
|
||||
)
|
||||
|
||||
## Headers
|
||||
|
||||
install(
|
||||
FILES tinyxml2.h
|
||||
TYPE INCLUDE
|
||||
COMPONENT tinyxml2_development
|
||||
)
|
||||
|
||||
## pkg-config
|
||||
|
||||
configure_file(cmake/tinyxml2.pc.in tinyxml2.pc.gen @ONLY)
|
||||
file(GENERATE OUTPUT tinyxml2.pc INPUT "${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc.gen")
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc"
|
||||
DESTINATION "${tinyxml2_INSTALL_PKGCONFIGDIR}"
|
||||
COMPONENT tinyxml2_development
|
||||
)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
10
appveyor.yml
10
appveyor.yml
@@ -1,10 +0,0 @@
|
||||
before_build:
|
||||
- cmake .
|
||||
|
||||
build_script:
|
||||
- msbuild tinyxml2.sln /m /p:Configuration=Debug /t:ALL_BUILD
|
||||
- msbuild tinyxml2.sln /m /p:Configuration=Release /t:ALL_BUILD
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\Debug
|
||||
- xmltest.exe
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\Release
|
||||
- xmltest.exe
|
||||
@@ -1,7 +0,0 @@
|
||||
# Biicode configuration file
|
||||
|
||||
[paths]
|
||||
/
|
||||
|
||||
[dependencies]
|
||||
xmltest.cpp + resources/*.xml
|
||||
57
cmake/tinyxml2-config.cmake
Normal file
57
cmake/tinyxml2-config.cmake
Normal file
@@ -0,0 +1,57 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
set(tinyxml2_known_comps static shared)
|
||||
set(tinyxml2_comp_static NO)
|
||||
set(tinyxml2_comp_shared NO)
|
||||
foreach (tinyxml2_comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
|
||||
if (tinyxml2_comp IN_LIST tinyxml2_known_comps)
|
||||
set(tinyxml2_comp_${tinyxml2_comp} YES)
|
||||
else ()
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
|
||||
"tinyxml2 does not recognize component `${tinyxml2_comp}`.")
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
||||
return()
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
if (tinyxml2_comp_static AND tinyxml2_comp_shared)
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
|
||||
"tinyxml2 `static` and `shared` components are mutually exclusive.")
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
set(tinyxml2_static_targets "${CMAKE_CURRENT_LIST_DIR}/tinyxml2-static-targets.cmake")
|
||||
set(tinyxml2_shared_targets "${CMAKE_CURRENT_LIST_DIR}/tinyxml2-shared-targets.cmake")
|
||||
|
||||
macro(tinyxml2_load_targets type)
|
||||
if (NOT EXISTS "${tinyxml2_${type}_targets}")
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
|
||||
"tinyxml2 `${type}` libraries were requested but not found.")
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
||||
return()
|
||||
endif ()
|
||||
include("${tinyxml2_${type}_targets}")
|
||||
endmacro()
|
||||
|
||||
if (tinyxml2_comp_static)
|
||||
tinyxml2_load_targets(static)
|
||||
elseif (tinyxml2_comp_shared)
|
||||
tinyxml2_load_targets(shared)
|
||||
elseif (DEFINED tinyxml2_SHARED_LIBS AND tinyxml2_SHARED_LIBS)
|
||||
tinyxml2_load_targets(shared)
|
||||
elseif (DEFINED tinyxml2_SHARED_LIBS AND NOT tinyxml2_SHARED_LIBS)
|
||||
tinyxml2_load_targets(static)
|
||||
elseif (BUILD_SHARED_LIBS)
|
||||
if (EXISTS "${tinyxml2_shared_targets}")
|
||||
tinyxml2_load_targets(shared)
|
||||
else ()
|
||||
tinyxml2_load_targets(static)
|
||||
endif ()
|
||||
else ()
|
||||
if (EXISTS "${tinyxml2_static_targets}")
|
||||
tinyxml2_load_targets(static)
|
||||
else ()
|
||||
tinyxml2_load_targets(shared)
|
||||
endif ()
|
||||
endif ()
|
||||
@@ -5,6 +5,6 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
|
||||
Name: TinyXML2
|
||||
Description: simple, small, C++ XML parser
|
||||
Version: @GENERIC_LIB_VERSION@
|
||||
Libs: -L${libdir} -ltinyxml2@LIB_POSTFIX@
|
||||
Version: @tinyxml2_VERSION@
|
||||
Libs: -L${libdir} -l$<TARGET_FILE_BASE_NAME:tinyxml2::tinyxml2>
|
||||
Cflags: -I${includedir}
|
||||
@@ -1,21 +0,0 @@
|
||||
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
exec_program(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
if(NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# Python program to set the version.
|
||||
##############################################
|
||||
|
||||
@@ -18,14 +19,14 @@ def fileProcess( name, lineFunction ):
|
||||
if not line: break
|
||||
output += lineFunction( line )
|
||||
filestream.close()
|
||||
|
||||
|
||||
if not output: return # basic error checking
|
||||
|
||||
|
||||
print( "Writing file " + name )
|
||||
filestream = open( name, "w" );
|
||||
filestream.write( output );
|
||||
filestream.close()
|
||||
|
||||
|
||||
def echoInput( line ):
|
||||
return line
|
||||
|
||||
@@ -108,31 +109,19 @@ fileProcess( "dox", doxRule )
|
||||
|
||||
#### Write the CMakeLists.txt ####
|
||||
|
||||
def cmakeRule1( line ):
|
||||
def cmakeRule( line ):
|
||||
|
||||
matchVersion = "set(GENERIC_LIB_VERSION"
|
||||
matchVersion = "project(tinyxml2 VERSION"
|
||||
|
||||
if line[0:len(matchVersion)] == matchVersion:
|
||||
print( "1)tinyxml2.h Major found" )
|
||||
return matchVersion + " \"" + major + "." + minor + "." + build + "\")" + "\n"
|
||||
return matchVersion + " " + major + "." + minor + "." + build + ")\n"
|
||||
|
||||
else:
|
||||
return line;
|
||||
|
||||
fileProcess( "CMakeLists.txt", cmakeRule1 )
|
||||
fileProcess( "CMakeLists.txt", cmakeRule )
|
||||
|
||||
def cmakeRule2( line ):
|
||||
|
||||
matchSoversion = "set(GENERIC_LIB_SOVERSION"
|
||||
|
||||
if line[0:len(matchSoversion)] == matchSoversion:
|
||||
print( "1)tinyxml2.h Major found" )
|
||||
return matchSoversion + " \"" + major + "\")" + "\n"
|
||||
|
||||
else:
|
||||
return line;
|
||||
|
||||
fileProcess( "CMakeLists.txt", cmakeRule2 )
|
||||
|
||||
def mesonRule(line):
|
||||
match = re.search(r"(\s*version) : '(\d+.\d+.\d+)',", line)
|
||||
@@ -150,5 +139,3 @@ print( '3. Tag. git tag ' + versionStr )
|
||||
print( ' OR git tag -a ' + versionStr + ' -m [tag message]' )
|
||||
print( 'Remember to "git push" both code and tag. For the tag:' )
|
||||
print( 'git push origin [tagname]')
|
||||
|
||||
|
||||
20
test/CMakeLists.txt
Normal file
20
test/CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(tinyxml2-test)
|
||||
|
||||
enable_testing()
|
||||
|
||||
find_package(tinyxml2 REQUIRED)
|
||||
|
||||
add_executable(xmltest ../xmltest.cpp)
|
||||
target_link_libraries(xmltest PRIVATE tinyxml2::tinyxml2)
|
||||
|
||||
add_test(
|
||||
NAME xmltest
|
||||
COMMAND xmltest
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.."
|
||||
)
|
||||
|
||||
set_tests_properties(xmltest
|
||||
PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION ", Fail 0"
|
||||
ENVIRONMENT "PATH=$<TARGET_FILE_DIR:tinyxml2::tinyxml2>")
|
||||
Reference in New Issue
Block a user