mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-26 21:04:25 +08:00
Add PUGIXML as prefix to CMake options
Added PUGIXML as prefix to all CMake options to avoid naming collisions with downstream projects. Removed the cached variable BUILD_DEFINES, since it was unused.
This commit is contained in:
parent
5c4225b5c9
commit
91fde92fc2
@ -7,32 +7,33 @@ include(GNUInstallDirs)
|
||||
include(CTest)
|
||||
|
||||
|
||||
cmake_dependent_option(USE_VERSIONED_LIBDIR
|
||||
cmake_dependent_option(PUGIXML_USE_VERSIONED_LIBDIR
|
||||
"Use a private subdirectory to install the headers and libraries" OFF
|
||||
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
|
||||
|
||||
cmake_dependent_option(USE_POSTFIX
|
||||
cmake_dependent_option(PUGIXML_USE_POSTFIX
|
||||
"Use separate postfix for each configuration to make sure you can install multiple build outputs" OFF
|
||||
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
|
||||
|
||||
cmake_dependent_option(STATIC_CRT
|
||||
cmake_dependent_option(PUGIXML_STATIC_CRT
|
||||
"Use static MSVC RT libraries" OFF
|
||||
"MSVC" OFF)
|
||||
|
||||
cmake_dependent_option(BUILD_TESTS
|
||||
cmake_dependent_option(PUGIXML_BUILD_TESTS
|
||||
"Build pugixml tests" OFF
|
||||
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
|
||||
|
||||
option(BUILD_SHARED_AND_STATIC_LIBS "Build both shared and static libraries" OFF)
|
||||
# Technically not needed for this file. This is builtin.
|
||||
option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
|
||||
option(PUGIXML_BUILD_SHARED_AND_STATIC_LIBS "Build both shared and static libraries" OFF)
|
||||
|
||||
set(BUILD_DEFINES CACHE STRING "Build defines")
|
||||
# Expose option to build PUGIXML as static even when the global BUILD_SHARED_LIBS variable is set
|
||||
cmake_dependent_option(PUGIXML_BUILD_SHARED_LIBS
|
||||
"Build shared instead of static library" OFF
|
||||
"BUILD_SHARED_LIBS" ON)
|
||||
|
||||
# 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
|
||||
MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<NOT:$<BOOL:${STATIC_CRT}>>:DLL>)
|
||||
MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<NOT:$<BOOL:${PUGIXML_STATIC_CRT}>>:DLL>)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
|
||||
@ -43,7 +44,7 @@ if (NOT DEFINED CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
|
||||
if (USE_POSTFIX)
|
||||
if (PUGIXML_USE_POSTFIX)
|
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX _r)
|
||||
set(CMAKE_MINSIZEREL_POSTFIX _m)
|
||||
set(CMAKE_DEBUG_POSTFIX _d)
|
||||
@ -64,11 +65,11 @@ if (CMAKE_VERSION VERSION_LESS 3.15)
|
||||
set(msvc-rt-mt-static $<${msvc-rt-mt-static}:-MT>)
|
||||
endif()
|
||||
|
||||
set(versioned-dir $<$<BOOL:${USE_VERSIONED_LIBDIR}>:/pugixml-${PROJECT_VERSION}>)
|
||||
set(versioned-dir $<$<BOOL:${PUGIXML_USE_VERSIONED_LIBDIR}>:/pugixml-${PROJECT_VERSION}>)
|
||||
|
||||
set(libs)
|
||||
|
||||
if (BUILD_SHARED_LIBS OR BUILD_SHARED_AND_STATIC_LIBS)
|
||||
if (PUGIXML_BUILD_SHARED_LIBS OR PUGIXML_BUILD_SHARED_AND_STATIC_LIBS)
|
||||
add_library(pugixml-shared SHARED
|
||||
${PROJECT_SOURCE_DIR}/scripts/pugixml_dll.rc
|
||||
${PROJECT_SOURCE_DIR}/src/pugixml.cpp)
|
||||
@ -90,7 +91,7 @@ if (BUILD_SHARED_LIBS OR BUILD_SHARED_AND_STATIC_LIBS)
|
||||
${msvc-rt-mt-static})
|
||||
endif()
|
||||
|
||||
if (NOT BUILD_SHARED_LIBS OR BUILD_SHARED_AND_STATIC_LIBS)
|
||||
if (NOT PUGIXML_BUILD_SHARED_LIBS OR PUGIXML_BUILD_SHARED_AND_STATIC_LIBS)
|
||||
add_library(pugixml-static STATIC
|
||||
${PROJECT_SOURCE_DIR}/src/pugixml.cpp)
|
||||
add_library(pugixml::static ALIAS pugixml-static)
|
||||
@ -108,7 +109,7 @@ if (NOT BUILD_SHARED_LIBS OR BUILD_SHARED_AND_STATIC_LIBS)
|
||||
${msvc-rt-mt-static})
|
||||
endif()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
if (PUGIXML_BUILD_SHARED_LIBS)
|
||||
set(pugixml-alias pugixml-shared)
|
||||
else()
|
||||
set(pugixml-alias pugixml-static)
|
||||
@ -142,7 +143,7 @@ write_basic_package_version_file(
|
||||
"${PROJECT_BINARY_DIR}/pugixml-config-version.cmake"
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
if (USE_POSTFIX)
|
||||
if (PUGIXML_USE_POSTFIX)
|
||||
if(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
||||
set(LIB_POSTFIX ${CMAKE_RELWITHDEBINFO_POSTFIX})
|
||||
elseif(CMAKE_BUILD_TYPE MATCHES MinSizeRel)
|
||||
@ -199,7 +200,7 @@ install(
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_INCLUDEDIR}${versioned-dir} COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT})
|
||||
|
||||
if (BUILD_TESTS)
|
||||
if (PUGIXML_BUILD_TESTS)
|
||||
set(fuzz-pattern "tests/fuzz_*.cpp")
|
||||
set(test-pattern "tests/*.cpp")
|
||||
if (CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
|
Loading…
x
Reference in New Issue
Block a user