From ba965eea645251ce56d1a2e797e77a612f98a09c Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Thu, 21 Dec 2023 22:26:27 +0100 Subject: [PATCH] cmake: use glog specific project variables --- CMakeLists.txt | 110 ++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 845037e65..ff3ce70a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,12 @@ project (glog set (CPACK_PACKAGE_NAME glog) set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Google logging library") -set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) -set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) -set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) -set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set (CPACK_PACKAGE_VERSION_MAJOR ${glog_VERSION_MAJOR}) +set (CPACK_PACKAGE_VERSION_MINOR ${glog_VERSION_MINOR}) +set (CPACK_PACKAGE_VERSION_PATCH ${glog_VERSION_PATCH}) +set (CPACK_PACKAGE_VERSION ${glog_VERSION}) -list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +list (APPEND CMAKE_MODULE_PATH ${glog_SOURCE_DIR}/cmake) include (CheckCXXCompilerFlag) include (CheckCXXSourceCompiles) @@ -385,12 +385,12 @@ endif (WITH_THREADS AND Threads_FOUND) # fopen/open on Cygwin can not handle unix-type paths like /home/.... # therefore we translate TEST_SRC_DIR to windows-path. if (CYGWIN) - execute_process (COMMAND cygpath.exe -m ${CMAKE_CURRENT_SOURCE_DIR} + execute_process (COMMAND cygpath.exe -m ${glog_SOURCE_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE TEST_SRC_DIR) set (TEST_SRC_DIR \"${TEST_SRC_DIR}\") else (CYGWIN) - set (TEST_SRC_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\") + set (TEST_SRC_DIR \"${glog_SOURCE_DIR}\") endif (CYGWIN) configure_file (src/config.h.cmake.in config.h) @@ -409,14 +409,14 @@ set (_glog_CMake_INSTALLDIR ${_glog_CMake_LIBDIR}/cmake/glog) set (_glog_CMake_DIR glog/cmake) set (_glog_CMake_DATADIR ${CMAKE_INSTALL_DATAROOTDIR}/${_glog_CMake_DIR}) set (_glog_BINARY_CMake_DATADIR - ${CMAKE_CURRENT_BINARY_DIR}/${_glog_CMake_DATADIR}) + ${glog_BINARY_DIR}/${_glog_CMake_DATADIR}) # Add additional CMake find modules here. set (_glog_CMake_MODULES) if (Unwind_FOUND) # Copy the module only if libunwind is actually used. - list (APPEND _glog_CMake_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindUnwind.cmake) + list (APPEND _glog_CMake_MODULES ${glog_SOURCE_DIR}/cmake/FindUnwind.cmake) endif (Unwind_FOUND) # Generate file name for each module in the binary directory @@ -440,11 +440,11 @@ if (_glog_CMake_MODULES) endif (_glog_CMake_MODULES) set (GLOG_PUBLIC_H - ${CMAKE_CURRENT_BINARY_DIR}/glog/export.h - ${CMAKE_CURRENT_BINARY_DIR}/glog/logging.h - ${CMAKE_CURRENT_BINARY_DIR}/glog/raw_logging.h - ${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h - ${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h + ${glog_BINARY_DIR}/glog/export.h + ${glog_BINARY_DIR}/glog/logging.h + ${glog_BINARY_DIR}/glog/raw_logging.h + ${glog_BINARY_DIR}/glog/stl_logging.h + ${glog_BINARY_DIR}/glog/vlog_is_on.h src/glog/log_severity.h src/glog/platform.h ) @@ -536,7 +536,7 @@ if (ANDROID) set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -llog") endif (ANDROID) -set_target_properties (glog PROPERTIES VERSION ${PROJECT_VERSION}) +set_target_properties (glog PROPERTIES VERSION ${glog_VERSION}) set_target_properties (glog PROPERTIES SOVERSION 1) if (CYGWIN OR WIN32) @@ -546,20 +546,20 @@ endif (CYGWIN OR WIN32) set_target_properties (glog PROPERTIES PUBLIC_HEADER "${GLOG_PUBLIC_H}") target_include_directories (glog BEFORE PUBLIC - "$" - "$" + "$" + "$" "$" - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) + PRIVATE ${glog_BINARY_DIR} + PRIVATE ${glog_SOURCE_DIR}/src) if (CYGWIN OR WIN32) target_include_directories (glog_internal PUBLIC - "$" - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/windows) + "$" + PRIVATE ${glog_SOURCE_DIR}/src/windows) target_include_directories (glog PUBLIC - "$" - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/windows) + "$" + PRIVATE ${glog_SOURCE_DIR}/src/windows) endif (CYGWIN OR WIN32) set_target_properties (glog PROPERTIES DEFINE_SYMBOL GOOGLE_GLOG_IS_A_DLL) @@ -572,20 +572,20 @@ target_compile_definitions (glog_internal PUBLIC generate_export_header (glog EXPORT_MACRO_NAME GLOG_EXPORT - EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/glog/export.h) + EXPORT_FILE_NAME ${glog_BINARY_DIR}/glog/export.h) string (STRIP "${glog_libraries_options_for_static_linking}" glog_libraries_options_for_static_linking) if (WITH_PKGCONFIG) - set (VERSION ${PROJECT_VERSION}) + set (VERSION ${glog_VERSION}) set (prefix ${CMAKE_INSTALL_PREFIX}) set (exec_prefix ${CMAKE_INSTALL_FULL_BINDIR}) set (libdir ${CMAKE_INSTALL_FULL_LIBDIR}) set (includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) configure_file ( - "${PROJECT_SOURCE_DIR}/libglog.pc.in" - "${PROJECT_BINARY_DIR}/libglog.pc" + "${glog_SOURCE_DIR}/libglog.pc.in" + "${glog_BINARY_DIR}/libglog.pc" @ONLY ) @@ -734,15 +734,15 @@ if (BUILD_TESTING) get_cache_variables (_CACHEVARS) set (_INITIAL_CACHE - ${CMAKE_CURRENT_BINARY_DIR}/test_package_config/glog_package_config_initial_cache.cmake) + ${glog_BINARY_DIR}/test_package_config/glog_package_config_initial_cache.cmake) # Package config test add_test (NAME cmake_package_config_init COMMAND ${CMAKE_COMMAND} - -DTEST_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/test_package_config + -DTEST_BINARY_DIR=${glog_BINARY_DIR}/test_package_config -DINITIAL_CACHE=${_INITIAL_CACHE} -DCACHEVARS=${_CACHEVARS} - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestInitPackageConfig.cmake + -P ${glog_SOURCE_DIR}/cmake/TestInitPackageConfig.cmake ) add_test (NAME cmake_package_config_generate COMMAND ${CMAKE_COMMAND} @@ -750,21 +750,21 @@ if (BUILD_TESTING) -DGENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DGENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DINITIAL_CACHE=${_INITIAL_CACHE} - -DPACKAGE_DIR=${CMAKE_CURRENT_BINARY_DIR} + -DPACKAGE_DIR=${glog_BINARY_DIR} -DPATH=$ENV{PATH} - -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src/package_config_unittest/working_config - -DTEST_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/test_package_config/working_config - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestPackageConfig.cmake + -DSOURCE_DIR=${glog_SOURCE_DIR}/src/package_config_unittest/working_config + -DTEST_BINARY_DIR=${glog_BINARY_DIR}/test_package_config/working_config + -P ${glog_SOURCE_DIR}/cmake/TestPackageConfig.cmake ) add_test (NAME cmake_package_config_build COMMAND - ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/test_package_config/working_config + ${CMAKE_COMMAND} --build ${glog_BINARY_DIR}/test_package_config/working_config --config $ ) add_test (NAME cmake_package_config_cleanup COMMAND ${CMAKE_COMMAND} -E remove_directory - ${CMAKE_CURRENT_BINARY_DIR}/test_package_config + ${glog_BINARY_DIR}/test_package_config ) # Fixtures setup @@ -798,7 +798,7 @@ if (BUILD_TESTING) target_link_libraries (cleanup_with_relative_prefix_unittest PRIVATE glog_test) - set (CLEANUP_LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/cleanup_tests) + set (CLEANUP_LOG_DIR ${glog_BINARY_DIR}/cleanup_tests) add_test (NAME cleanup_init COMMAND ${CMAKE_COMMAND} -E make_directory ${CLEANUP_LOG_DIR}) @@ -809,21 +809,21 @@ if (BUILD_TESTING) -DLOGCLEANUP=$ # NOTE The trailing slash is important -DTEST_DIR=${CLEANUP_LOG_DIR}/ - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunCleanerTest1.cmake - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + -P ${glog_SOURCE_DIR}/cmake/RunCleanerTest1.cmake + WORKING_DIRECTORY ${glog_BINARY_DIR}) add_test (NAME cleanup_with_absolute_prefix COMMAND ${CMAKE_COMMAND} -DLOGCLEANUP=$ - -DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/ - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunCleanerTest2.cmake - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + -DTEST_DIR=${glog_BINARY_DIR}/ + -P ${glog_SOURCE_DIR}/cmake/RunCleanerTest2.cmake + WORKING_DIRECTORY ${glog_BINARY_DIR}) add_test (NAME cleanup_with_relative_prefix COMMAND ${CMAKE_COMMAND} -DLOGCLEANUP=$ - -DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/ + -DTEST_DIR=${glog_BINARY_DIR}/ -DTEST_SUBDIR=test_subdir/ - -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunCleanerTest3.cmake - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + -P ${glog_SOURCE_DIR}/cmake/RunCleanerTest3.cmake + WORKING_DIRECTORY ${glog_BINARY_DIR}) # Fixtures setup set_tests_properties (cleanup_init PROPERTIES FIXTURES_SETUP logcleanuptest) @@ -844,7 +844,7 @@ install (TARGETS glog if (WITH_PKGCONFIG) install ( - FILES "${PROJECT_BINARY_DIR}/libglog.pc" + FILES "${glog_BINARY_DIR}/libglog.pc" DESTINATION "${_glog_CMake_LIBDIR}/pkgconfig" ) endif (WITH_PKGCONFIG) @@ -865,12 +865,12 @@ if (gflags_FOUND) endif (gflags_FOUND) configure_package_config_file (glog-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake + ${glog_BINARY_DIR}/glog-config.cmake INSTALL_DESTINATION ${_glog_CMake_INSTALLDIR} NO_CHECK_REQUIRED_COMPONENTS_MACRO) write_basic_package_version_file ( - ${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake + ${glog_BINARY_DIR}/glog-config-version.cmake COMPATIBILITY SameMajorVersion) export (TARGETS glog NAMESPACE glog:: FILE glog-targets.cmake) @@ -888,10 +888,10 @@ get_filename_component (glog_REL_CMake_DATADIR ${glog_REL_CMake_MODULES} DIRECTORY) set (glog_FULL_CMake_DATADIR - ${CMAKE_CURRENT_BINARY_DIR}/${_glog_CMake_DATADIR}) + ${glog_BINARY_DIR}/${_glog_CMake_DATADIR}) configure_file (glog-modules.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/glog-modules.cmake @ONLY) + ${glog_BINARY_DIR}/glog-modules.cmake @ONLY) install (CODE " @@ -902,10 +902,10 @@ if (NOT IS_ABSOLUTE ${_glog_CMake_INSTALLDIR}) set (glog_DATADIR_DESTINATION \"\${CMAKE_INSTALL_PREFIX}/\${glog_DATADIR_DESTINATION}\") endif (NOT IS_ABSOLUTE ${_glog_CMake_INSTALLDIR}) -configure_file (\"${CMAKE_CURRENT_SOURCE_DIR}/glog-modules.cmake.in\" - \"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/glog-modules.cmake\" @ONLY) +configure_file (\"${glog_SOURCE_DIR}/glog-modules.cmake.in\" + \"${glog_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/glog-modules.cmake\" @ONLY) file (INSTALL - \"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/glog-modules.cmake\" + \"${glog_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/glog-modules.cmake\" DESTINATION \"\${glog_DATADIR_DESTINATION}\") " @@ -913,8 +913,8 @@ file (INSTALL ) install (FILES - ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake + ${glog_BINARY_DIR}/glog-config.cmake + ${glog_BINARY_DIR}/glog-config-version.cmake DESTINATION ${_glog_CMake_INSTALLDIR}) # Find modules in share/glog/cmake