Merge pull request #426 from bjornblissing/feature/cmake_pugiconfig

Add Cmake options for pugiconfig.hpp options

Fixes #387 
Closes #388
This commit is contained in:
Arseny Kapoulkine 2021-08-07 09:54:18 -07:00 committed by GitHub
commit a5991972ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -42,7 +42,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: cmake configure - name: cmake configure
run: cmake . -DPUGIXML_BUILD_TESTS=ON -DPUGIXML_BUILD_DEFINES=${{matrix.defines}} -A ${{matrix.arch}} run: cmake . -DPUGIXML_BUILD_TESTS=ON -D${{matrix.defines}}=ON -A ${{matrix.arch}}
- name: cmake test - name: cmake test
shell: bash # necessary for fail-fast shell: bash # necessary for fail-fast
run: | run: |

View File

@ -6,7 +6,6 @@ include(CMakeDependentOption)
include(GNUInstallDirs) include(GNUInstallDirs)
include(CTest) include(CTest)
cmake_dependent_option(PUGIXML_USE_VERSIONED_LIBDIR cmake_dependent_option(PUGIXML_USE_VERSIONED_LIBDIR
"Use a private subdirectory to install the headers and libraries" OFF "Use a private subdirectory to install the headers and libraries" OFF
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF) "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
@ -35,6 +34,23 @@ cmake_dependent_option(PUGIXML_BUILD_SHARED_AND_STATIC_LIBS
"Build both shared and static libraries" OFF "Build both shared and static libraries" OFF
"BUILD_SHARED_LIBS" OFF) "BUILD_SHARED_LIBS" OFF)
# Expose options from the pugiconfig.hpp
option(PUGIXML_WCHAR_MODE "Enable wchar_t mode" OFF)
option(PUGIXML_COMPACT "Enable compact mode" OFF)
# Advanced options from pugiconfig.hpp
option(PUGIXML_NO_XPATH "Disable XPath" OFF)
option(PUGIXML_NO_STL "Disable STL" OFF)
option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF)
mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS)
set(PUGIXML_PUBLIC_DEFINITIONS
$<$<BOOL:${PUGIXML_WCHAR_MODE}>:PUGIXML_WCHAR_MODE>
$<$<BOOL:${PUGIXML_COMPACT}>:PUGIXML_COMPACT>
$<$<BOOL:${PUGIXML_NO_XPATH}>:PUGIXML_NO_XPATH>
$<$<BOOL:${PUGIXML_NO_STL}>:PUGIXML_NO_STL>
$<$<BOOL:${PUGIXML_NO_EXCEPTIONS}>:PUGIXML_NO_EXCEPTIONS>)
# This is used to backport a CMake 3.15 feature, but is also forwards compatible # This is used to backport a CMake 3.15 feature, but is also forwards compatible
if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY set(CMAKE_MSVC_RUNTIME_LIBRARY
@ -88,6 +104,7 @@ if (BUILD_SHARED_LIBS)
target_compile_definitions(pugixml-shared target_compile_definitions(pugixml-shared
PUBLIC PUBLIC
${PUGIXML_BUILD_DEFINES} ${PUGIXML_BUILD_DEFINES}
${PUGIXML_PUBLIC_DEFINITIONS}
PRIVATE PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:PUGIXML_API=__declspec\(dllexport\)>) $<$<CXX_COMPILER_ID:MSVC>:PUGIXML_API=__declspec\(dllexport\)>)
target_compile_options(pugixml-shared target_compile_options(pugixml-shared
@ -110,7 +127,8 @@ if (NOT BUILD_SHARED_LIBS OR PUGIXML_BUILD_SHARED_AND_STATIC_LIBS)
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>) $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
target_compile_definitions(pugixml-static target_compile_definitions(pugixml-static
PUBLIC PUBLIC
${PUGIXML_BUILD_DEFINES}) ${PUGIXML_BUILD_DEFINES}
${PUGIXML_PUBLIC_DEFINITIONS})
target_compile_options(pugixml-static target_compile_options(pugixml-static
PRIVATE PRIVATE
${msvc-rt-mtd-shared} ${msvc-rt-mtd-shared}