Store definitions in variable to avoid duplication

Store compile definitions in variable to avoid duplicated generator
expressions.
This commit is contained in:
Björn Blissing 2021-06-28 19:51:20 +02:00
parent 52a7981b85
commit e7eae035ff

View file

@ -47,6 +47,20 @@ 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:${HAVE_LONG_LONG}>:PUGIXML_HAS_LONG_LONG>
$<$<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>)
set(PUGIXML_PRIVATE_DEFINITIONS
$<$<BOOL:${PUGIXML_MEMORY_PAGE_SIZE}>:PUGIXML_MEMORY_PAGE_SIZE=${PUGIXML_MEMORY_PAGE_SIZE}>
$<$<BOOL:${PUGIXML_MEMORY_OUTPUT_STACK}>:PUGIXML_MEMORY_OUTPUT_STACK=${PUGIXML_MEMORY_OUTPUT_STACK}>
$<$<BOOL:${PUGIXML_MEMORY_XPATH_PAGE_SIZE}>:PUGIXML_MEMORY_XPATH_PAGE_SIZE=${PUGIXML_MEMORY_XPATH_PAGE_SIZE}>
$<$<BOOL:${PUGIXML_XPATH_DEPTH_LIMIT}>:PUGIXML_XPATH_DEPTH_LIMIT=${PUGIXML_XPATH_DEPTH_LIMIT}>)
# This is used to backport a CMake 3.15 feature, but is also forwards compatible
if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY
@ -100,18 +114,10 @@ if (BUILD_SHARED_LIBS)
target_compile_definitions(pugixml-shared
PUBLIC
${PUGIXML_BUILD_DEFINES}
$<$<BOOL:${HAVE_LONG_LONG}>:PUGIXML_HAS_LONG_LONG>
$<$<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>
${PUGIXML_PUBLIC_DEFINITIONS}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:PUGIXML_API=__declspec\(dllexport\)>
$<$<BOOL:${PUGIXML_MEMORY_PAGE_SIZE}>:PUGIXML_MEMORY_PAGE_SIZE=${PUGIXML_MEMORY_PAGE_SIZE}>
$<$<BOOL:${PUGIXML_MEMORY_OUTPUT_STACK}>:PUGIXML_MEMORY_OUTPUT_STACK=${PUGIXML_MEMORY_OUTPUT_STACK}>
$<$<BOOL:${PUGIXML_MEMORY_XPATH_PAGE_SIZE}>:PUGIXML_MEMORY_XPATH_PAGE_SIZE=${PUGIXML_MEMORY_XPATH_PAGE_SIZE}>
$<$<BOOL:${PUGIXML_XPATH_DEPTH_LIMIT}>:PUGIXML_XPATH_DEPTH_LIMIT=${PUGIXML_XPATH_DEPTH_LIMIT}>)
${PUGIXML_PRIVATE_DEFINITIONS})
target_compile_options(pugixml-shared
PRIVATE
${msvc-rt-mtd-shared}
@ -133,17 +139,9 @@ if (NOT BUILD_SHARED_LIBS OR PUGIXML_BUILD_SHARED_AND_STATIC_LIBS)
target_compile_definitions(pugixml-static
PUBLIC
${PUGIXML_BUILD_DEFINES}
$<$<BOOL:${HAVE_LONG_LONG}>:PUGIXML_HAS_LONG_LONG>
$<$<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>
${PUGIXML_PUBLIC_DEFINITIONS}
PRIVATE
$<$<BOOL:${PUGIXML_MEMORY_PAGE_SIZE}>:PUGIXML_MEMORY_PAGE_SIZE=${PUGIXML_MEMORY_PAGE_SIZE}>
$<$<BOOL:${PUGIXML_MEMORY_OUTPUT_STACK}>:PUGIXML_MEMORY_OUTPUT_STACK=${PUGIXML_MEMORY_OUTPUT_STACK}>
$<$<BOOL:${PUGIXML_MEMORY_XPATH_PAGE_SIZE}>:PUGIXML_MEMORY_XPATH_PAGE_SIZE=${PUGIXML_MEMORY_XPATH_PAGE_SIZE}>
$<$<BOOL:${PUGIXML_XPATH_DEPTH_LIMIT}>:PUGIXML_XPATH_DEPTH_LIMIT=${PUGIXML_XPATH_DEPTH_LIMIT}>)
${PUGIXML_PRIVATE_DEFINITIONS})
target_compile_options(pugixml-static
PRIVATE
${msvc-rt-mtd-shared}