From 7f7ddf9825754691a3839a2d0db6efbb53190288 Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Thu, 5 Oct 2023 22:47:12 +0200 Subject: [PATCH] wip --- CMakeLists.txt | 137 +++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5c1e5535..a60d28676 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,14 +6,7 @@ project (glog LANGUAGES CXX ) -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}) - -list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +list (APPEND CMAKE_MODULE_PATH ${glog_SOURCE_DIR}/cmake) include (CheckCXXCompilerFlag) include (CheckCXXSourceCompiles) @@ -27,7 +20,6 @@ include (CheckTypeSize) include (CMakeDependentOption) include (CMakePackageConfigHelpers) include (CMakePushCheckState) -include (CPack) include (CTest) include (DetermineGflagsNamespace) include (GenerateExportHeader) @@ -238,7 +230,7 @@ if (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT) foreach (_PC_FIELD ${_PC_FIELDS}) foreach (_PC_HEADER ${_PC_HEADERS}) set (_TMP - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/uctfield.cpp) + ${glog_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/uctfield.cpp) file (WRITE ${_TMP} " #define _GNU_SOURCE 1 #include <${_PC_HEADER}> @@ -248,7 +240,7 @@ int main(void) return u.${_PC_FIELD} == 0; } ") - try_compile (HAVE_PC_FROM_UCONTEXT ${CMAKE_CURRENT_BINARY_DIR} ${_TMP} + try_compile (HAVE_PC_FROM_UCONTEXT ${glog_BINARY_DIR} ${_TMP} COMPILE_DEFINITIONS _GNU_SOURCE=1) if (HAVE_PC_FROM_UCONTEXT) @@ -395,12 +387,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) @@ -419,14 +411,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 @@ -450,11 +442,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 ) @@ -546,20 +538,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,7 +564,7 @@ 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) @@ -584,8 +576,8 @@ if (WITH_PKGCONFIG) 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 ) @@ -747,15 +739,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} @@ -763,21 +755,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 @@ -811,7 +803,7 @@ if (BUILD_TESTING) target_link_libraries (cleanup_with_relative_prefix_unittest PRIVATE ${_GLOG_TEST_LIBS}) - 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}) @@ -822,21 +814,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) @@ -850,15 +842,17 @@ endif (BUILD_TESTING) install (TARGETS glog EXPORT glog-targets - RUNTIME DESTINATION ${_glog_CMake_BINDIR} - PUBLIC_HEADER DESTINATION ${_glog_CMake_INCLUDE_DIR}/glog - LIBRARY DESTINATION ${_glog_CMake_LIBDIR} - ARCHIVE DESTINATION ${_glog_CMake_LIBDIR}) + RUNTIME DESTINATION ${_glog_CMake_BINDIR} COMPONENT Runtime + PUBLIC_HEADER DESTINATION ${_glog_CMake_INCLUDE_DIR}/glog COMPONENT Development + LIBRARY DESTINATION ${_glog_CMake_LIBDIR} COMPONENT Runtime + ARCHIVE DESTINATION ${_glog_CMake_LIBDIR} COMPONENT Development +) if (WITH_PKGCONFIG) install ( - FILES "${PROJECT_BINARY_DIR}/libglog.pc" + FILES "${glog_BINARY_DIR}/libglog.pc" DESTINATION "${_glog_CMake_LIBDIR}/pkgconfig" + COMPONENT Development ) endif (WITH_PKGCONFIG) @@ -878,12 +872,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) @@ -901,10 +895,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 " @@ -915,10 +909,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}\") " @@ -926,9 +920,11 @@ file (INSTALL ) install (FILES - ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake - DESTINATION ${_glog_CMake_INSTALLDIR}) + ${glog_BINARY_DIR}/glog-config.cmake + ${glog_BINARY_DIR}/glog-config-version.cmake + DESTINATION ${_glog_CMake_INSTALLDIR} + COMPONENT Development +) # Find modules in share/glog/cmake install (DIRECTORY ${_glog_BINARY_CMake_DATADIR} @@ -937,5 +933,14 @@ install (DIRECTORY ${_glog_BINARY_CMake_DATADIR} FILES_MATCHING PATTERN "*.cmake" ) -install (EXPORT glog-targets NAMESPACE glog:: DESTINATION - ${_glog_CMake_INSTALLDIR}) +install (EXPORT glog-targets NAMESPACE glog:: + DESTINATION ${_glog_CMake_INSTALLDIR} + COMPONENT Development +) + +set (CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +set (CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) +set (CPACK_PACKAGE_CONTACT "Google Log maintainers") +set (CPACK_DEBIAN_PACKAGE_NAME google-glog) + +include (CPack)