From: Michael Wallner Date: Thu, 6 Feb 2020 15:34:58 +0000 (+0100) Subject: cmake: 3.12 compatibility X-Git-Tag: post_cmake~17 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=96347b612e26411103626cc2d1d11bcc981242bf;p=awesomized%2Flibmemcached cmake: 3.12 compatibility --- diff --git a/.travis.yml b/.travis.yml index f24bf605..d6d8085d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ before_script: - mkdir build script: - - cmake -B build -S . -DCMAKE_BUILD_TYPE=${BUILD} + - cd build && cmake -DCMAKE_BUILD_TYPE=${BUILD} .. - make -C build - make -C build test diff --git a/CMakeVersions.txt b/CMakeVersions.txt index 683f43e7..8f689ee2 100644 --- a/CMakeVersions.txt +++ b/CMakeVersions.txt @@ -1,13 +1,25 @@ +function(to_hex HEX) + set(XNUMBER 0x) + set(XDIGITS 0 1 2 3 4 5 6 7 8 9 a b c d e f) + foreach(DEC IN LISTS ARGN) + if(${DEC} GREATER 255) + message(WARNING "to_hex(HEX ${DEC}): decimal number out of uint8 range (>=256)") + endif() + math(EXPR HIDEC "${DEC} / 16") + math(EXPR LODEC "${DEC} % 16") + list(GET XDIGITS ${HIDEC} HIHEX) + list(GET XDIGITS ${LODEC} LOHEX) + string(APPEND XNUMBER ${HIHEX}${LOHEX}) + endforeach() + set(${HEX} ${XNUMBER} PARENT_SCOPE) +endfunction() set(LIBMEMCACHED_VERSION_MAJOR 1) set(LIBMEMCACHED_VERSION_MINOR 0) set(LIBMEMCACHED_VERSION_PATCH 99) set(LIBMEMCACHED_VERSION ${LIBMEMCACHED_VERSION_MAJOR}.${LIBMEMCACHED_VERSION_MINOR}.${LIBMEMCACHED_VERSION_PATCH}) - -set(LIBMEMCACHED_VERSION_HEX) -math(EXPR LIBMEMCACHED_VERSION_HEX "(${LIBMEMCACHED_VERSION_MAJOR}<<16) + (${LIBMEMCACHED_VERSION_MINOR}<<8) + ${LIBMEMCACHED_VERSION_PATCH}+0" - OUTPUT_FORMAT HEXADECIMAL) +to_hex(LIBMEMCACHED_VERSION_HEX ${LIBMEMCACHED_VERSION_MAJOR} ${LIBMEMCACHED_VERSION_MINOR} ${LIBMEMCACHED_VERSION_PATCH}) set(LIBMEMCACHED_SO_VERSION_CUR 12) set(LIBMEMCACHED_SO_VERSION_REV 0) @@ -32,10 +44,7 @@ set(LIBHASHKIT_VERSION_MINOR 0) set(LIBHASHKIT_VERSION_PATCH 0) set(LIBHASHKIT_VERSION ${LIBHASHKIT_VERSION_MAJOR}.${LIBHASHKIT_VERSION_MINOR}.${LIBHASHKIT_VERSION_PATCH}) - -set(LIBHASHKIT_VERSION_HEX) -math(EXPR LIBHASHKIT_VERSION_HEX "(${LIBHASHKIT_VERSION_MAJOR}<<16) + (${LIBHASHKIT_VERSION_MINOR}<<8) + ${LIBHASHKIT_VERSION_PATCH}+0" - OUTPUT_FORMAT HEXADECIMAL) +to_hex(LIBHASHKIT_VERSION_HEX ${LIBHASHKIT_VERSION_MAJOR} ${LIBHASHKIT_VERSION_MINOR} ${LIBHASHKIT_VERSION_PATCH}) set(LIBHASHKIT_SO_VERSION_CUR 2) set(LIBHASHKIT_SO_VERSION_REV 0) diff --git a/clients/CMakeLists.txt b/clients/CMakeLists.txt index 25815a54..b7815db1 100644 --- a/clients/CMakeLists.txt +++ b/clients/CMakeLists.txt @@ -8,7 +8,8 @@ foreach(CLIENT IN LISTS CLIENTS) add_executable(${CLIENT} ${CLIENT}.cc) target_include_directories(${CLIENT} PRIVATE ..) target_link_libraries(${CLIENT} libclient_utilities) - install(TARGETS ${CLIENT}) + install(TARGETS ${CLIENT} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endforeach() # extra sources @@ -29,6 +30,7 @@ if(ENABLE_MEMASLAP) ms_conn.c ms_setting.c ms_sigsegv.c ms_stats.c ms_task.c ms_thread.c) target_include_directories(memaslap PRIVATE .. ${LIBEVENT_INCLUDEDIR}) target_link_libraries(memaslap libclient_utilities ${LIBEVENT_LIBRARIES} Threads::Threads) - install(TARGETS memaslap) + install(TARGETS memaslap + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() endif() diff --git a/libhashkit-1.0/CMakeLists.txt b/libhashkit-1.0/CMakeLists.txt index d4fb6a49..7fc72a3c 100644 --- a/libhashkit-1.0/CMakeLists.txt +++ b/libhashkit-1.0/CMakeLists.txt @@ -2,6 +2,6 @@ configure_file(configure.h.in configure.h @ONLY) install(DIRECTORY ../libhashkit-1.0 - TYPE INCLUDE + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING REGEX "\\.h(pp)?$" ) diff --git a/libhashkit/CMakeLists.txt b/libhashkit/CMakeLists.txt index b9b500f0..646ffd3f 100644 --- a/libhashkit/CMakeLists.txt +++ b/libhashkit/CMakeLists.txt @@ -38,10 +38,11 @@ target_compile_options(libhashkit PRIVATE -DBUILDING_HASHKIT) configure_file(hashkitcon.h.in hashkitcon.h @ONLY) set_target_properties(libhashkit PROPERTIES SOVERSION ${LIBHASHKIT_SO_VERSION}) -install(TARGETS libhashkit EXPORT libhashkit) +install(TARGETS libhashkit EXPORT libhashkit + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) export(EXPORT libhashkit) install(EXPORT libhashkit DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - TYPE INCLUDE + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN hashkit.h ) diff --git a/libmemcached-1.0/CMakeLists.txt b/libmemcached-1.0/CMakeLists.txt index 094cffb2..061c6f7f 100644 --- a/libmemcached-1.0/CMakeLists.txt +++ b/libmemcached-1.0/CMakeLists.txt @@ -2,7 +2,7 @@ configure_file(configure.h.in configure.h @ONLY) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - TYPE INCLUDE + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING REGEX "\\.h(pp)?$" PATTERN t EXCLUDE ) diff --git a/libmemcached/CMakeLists.txt b/libmemcached/CMakeLists.txt index 19f93a99..2f8b0183 100644 --- a/libmemcached/CMakeLists.txt +++ b/libmemcached/CMakeLists.txt @@ -72,12 +72,13 @@ target_include_directories(libmemcached PRIVATE .. ${LIBSASL_INCLUDEDIR}) target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED) set_target_properties(libmemcached PROPERTIES SOVERSION ${LIBMEMCACHED_SO_VERSION}) -install(TARGETS libmemcached EXPORT libmemcached) +install(TARGETS libmemcached EXPORT libmemcached + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) export(EXPORT libmemcached) install(EXPORT libmemcached DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - TYPE INCLUDE + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING REGEX "(memcached|util)\\.h(pp)?" PATTERN csl EXCLUDE PATTERN memcached EXCLUDE diff --git a/libmemcachedutil-1.0/CMakeLists.txt b/libmemcachedutil-1.0/CMakeLists.txt index c74a6492..c6138875 100644 --- a/libmemcachedutil-1.0/CMakeLists.txt +++ b/libmemcachedutil-1.0/CMakeLists.txt @@ -1,5 +1,5 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - TYPE INCLUDE + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING REGEX "\\.h(pp)?$" ) diff --git a/libmemcachedutil/CMakeLists.txt b/libmemcachedutil/CMakeLists.txt index 1cc32fe3..6ef3a756 100644 --- a/libmemcachedutil/CMakeLists.txt +++ b/libmemcachedutil/CMakeLists.txt @@ -14,6 +14,7 @@ target_compile_definitions(libmemcachedutil PRIVATE -DBUILDING_LIBMEMCACHED) target_link_libraries(libmemcachedutil libmemcached Threads::Threads) set_target_properties(libmemcachedutil PROPERTIES SOVERSION ${LIBMEMCACHEDUTIL_SO_VERSION}) -install(TARGETS libmemcachedutil EXPORT libmemcachedutil) +install(TARGETS libmemcachedutil EXPORT libmemcachedutil + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) export(EXPORT libmemcachedutil) install(EXPORT libmemcachedutil DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)