11# Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
22
3- cmake_minimum_required (VERSION 3.10...3.31 )
3+ cmake_minimum_required (VERSION 3.10...4.3 )
44
55# ---------------------------------------------------------------------------------------
66# Start spdlog project
@@ -10,7 +10,6 @@ include(cmake/ide.cmake)
1010
1111spdlog_extract_version ()
1212
13- set (CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake)
1413project (spdlog VERSION ${SPDLOG_VERSION} LANGUAGES CXX )
1514message (STATUS "Build spdlog: ${SPDLOG_VERSION} " )
1615
@@ -303,9 +302,10 @@ if(MSVC)
303302 # fmtlib requires the /utf-8 flag when building with msvc. see https://github.com/fmtlib/fmt/pull/4159 on the
304303 # purpose of the additional
305304 # "$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>"
306- target_compile_options (spdlog PUBLIC $<$<AND :$<COMPILE_LANGUAGE :CXX >,$<CXX_COMPILER_ID :MSVC >>:/utf -8>)
307- target_compile_options (spdlog_header_only
308- INTERFACE $<$<AND :$<COMPILE_LANGUAGE :CXX >,$<CXX_COMPILER_ID :MSVC >>:/utf -8>)
305+ # which has been removed because generator expressions aren't supported by CPS
306+ # see fmt issue https://github.com/externpro/fmt/issues/35 for explanation
307+ target_compile_options (spdlog PUBLIC /utf-8 )
308+ target_compile_options (spdlog_header_only INTERFACE /utf-8 )
309309 endif ()
310310endif ()
311311
@@ -351,24 +351,23 @@ endif()
351351# ---------------------------------------------------------------------------------------
352352if (SPDLOG_INSTALL)
353353 message (STATUS "Generating install" )
354- if (COMMAND xpExternPackage)
355- set (targetsFile "spdlogConfigTargets" )
356- xpExternPackage (TARGETS_FILE ${targetsFile} LIBRARIES spdlog spdlog_header_only
357- BASE v${SPDLOG_VERSION} XPDIFF "patch" FIND_THREADS DEPS fmt
358- WEB "https://github.com/gabime/spdlog/wiki" UPSTREAM "github.com/gabime/spdlog"
359- DESC "Fast C++ logging library"
360- LICENSE "[MIT](https://github.com/gabime/spdlog?tab=License-1-ov-file 'MIT License')"
361- )
362- set (config_targets_file "${targetsFile} .cmake" )
363- set (export_dest_dir "${CMAKE_INSTALL_CMAKEDIR} " )
364- else ()
365354 set (project_config_in "${CMAKE_CURRENT_LIST_DIR} /cmake/spdlogConfig.cmake.in" )
366355 set (project_config_out "${CMAKE_CURRENT_BINARY_DIR} /spdlogConfig.cmake" )
367356 set (config_targets_file "spdlogConfigTargets.cmake" )
368357 set (version_config_file "${CMAKE_CURRENT_BINARY_DIR} /spdlogConfigVersion.cmake" )
369358 set (export_dest_dir "${CMAKE_INSTALL_LIBDIR} /cmake/spdlog" )
370359 set (pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR} /pkgconfig" )
371360 set (pkg_config "${CMAKE_BINARY_DIR} /${PROJECT_NAME} .pc" )
361+ if (COMMAND xpExternPackage)
362+ xpExternPackage (EXPORT spdlog TARGETS_FILE spdlogConfigTargets
363+ LIBRARIES spdlog spdlog_header_only DEFAULT_TARGETS spdlog
364+ BASE v${SPDLOG_VERSION} XPDIFF "patch" DEPS fmt Threads
365+ WEB "https://github.com/gabime/spdlog/wiki" UPSTREAM "github.com/gabime/spdlog"
366+ DESC "Fast C++ logging library"
367+ LICENSE "[MIT](https://github.com/gabime/spdlog?tab=License-1-ov-file 'MIT License')"
368+ )
369+ set (export_dest_dir "${CMAKE_INSTALL_CMAKEDIR} " )
370+ set (pkgconfig_install_dir "${CMAKE_INSTALL_DATADIR} /pkgconfig" )
372371 endif ()
373372
374373 # ---------------------------------------------------------------------------------------
@@ -390,7 +389,6 @@ if(SPDLOG_INSTALL)
390389 # ---------------------------------------------------------------------------------------
391390 # Install pkg-config file
392391 # ---------------------------------------------------------------------------------------
393- if (NOT COMMAND xpExternPackage)
394392 if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR} " )
395393 set (PKG_CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR} " )
396394 else ()
@@ -406,7 +404,6 @@ if(SPDLOG_INSTALL)
406404 string (CONCAT PKG_CONFIG_DEFINES "-D" "${PKG_CONFIG_DEFINES} " )
407405 configure_file ("cmake/${PROJECT_NAME} .pc.in" "${pkg_config} " @ONLY )
408406 install (FILES "${pkg_config} " DESTINATION "${pkgconfig_install_dir} " )
409- endif ()
410407
411408 # ---------------------------------------------------------------------------------------
412409 # Install CMake config files
@@ -415,11 +412,13 @@ if(SPDLOG_INSTALL)
415412 FILE "${CMAKE_CURRENT_BINARY_DIR} /${config_targets_file} " )
416413 install (EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE spdlog:: FILE ${config_targets_file} )
417414
418- if (NOT COMMAND xpExternPackage)
419415 include (CMakePackageConfigHelpers )
420416 configure_package_config_file ("${project_config_in} " "${project_config_out} " INSTALL_DESTINATION ${export_dest_dir} )
421417
422418 write_basic_package_version_file ("${version_config_file} " COMPATIBILITY SameMajorVersion )
419+ if (COMMAND xpExternPackage)
420+ install (FILES "${version_config_file} " DESTINATION "${export_dest_dir} " )
421+ else ()
423422 install (FILES "${project_config_out} " "${version_config_file} " DESTINATION "${export_dest_dir} " )
424423 endif ()
425424
0 commit comments