From 1ab7c0172911fb99144c0896286fa5860e2b641f Mon Sep 17 00:00:00 2001 From: nilsnolde Date: Sat, 13 Jan 2024 20:58:49 +0100 Subject: [PATCH 1/3] fill out pc template a bit more and make cmake configuration compatible with autotools --- .gitignore | 1 + CMakeLists.txt | 12 +++++++++--- libprime_server.pc.in | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5a9203b..b2d412e 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ coverage/ .project .settings .idea/ +.vscode cmake-build-debug/ # CMake out-of-source build directories diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e64db4..fd5a809 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,9 +128,15 @@ install(TARGETS prime_echod prime_proxyd prime_workerd DESTINATION ${CMAKE_INSTALL_BINDIR}) -CONFIGURE_FILE( - "${CMAKE_CURRENT_SOURCE_DIR}/libprime_server.pc.in" - "${CMAKE_CURRENT_BINARY_DIR}/libprime_server.pc" +# pkg-config stuff, also make it compatible with autotools +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix ${prefix}) +set(libdir ${prefix}/${CMAKE_INSTALL_LIBDIR}) +set(includedir ${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/libprime_server.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/libprime_server.pc @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libprime_server.pc" DESTINATION ${pkgconfigdir}) diff --git a/libprime_server.pc.in b/libprime_server.pc.in index 3a3cef9..688d7bd 100644 --- a/libprime_server.pc.in +++ b/libprime_server.pc.in @@ -7,4 +7,6 @@ Name: libprime_server Description: prime_server c++ library Version: @VERSION@ Libs: -L${libdir} -lprime_server +Requires: libzmq +Requires.private: libczmq Cflags: -I${includedir} From b8fdb868534e3dd52beed6ade4b2af8ee0dceed3 Mon Sep 17 00:00:00 2001 From: nilsnolde Date: Mon, 29 Jan 2024 13:47:09 +0100 Subject: [PATCH 2/3] add uninstall target --- CMakeLists.txt | 5 ++++ cmake/uninstall.cmake.in | 65 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 cmake/uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index fd5a809..3364add 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,7 @@ target_link_libraries(prime_proxyd prime_server ${CMAKE_THREAD_LIBS_INIT}) add_executable(prime_workerd ${CMAKE_SOURCE_DIR}/src/prime_workerd.cpp) target_link_libraries(prime_workerd prime_server ${CMAKE_THREAD_LIBS_INIT}) +# TODO(nils): AFAIU the project version shouldn't be the SO version set_target_properties(prime_server PROPERTIES PUBLIC_HEADER "${PRIME_LIBRARY_HEADERS}" SOVERSION ${PROJECT_VERSION_MAJOR} @@ -140,6 +141,10 @@ configure_file( @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libprime_server.pc" DESTINATION ${pkgconfigdir}) +# uninstall target +configure_file(cmake/uninstall.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/prime_server_uninstall.cmake @ONLY) +add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/prime_server_uninstall.cmake) + # Add tests - Requires CTest enable_testing() diff --git a/cmake/uninstall.cmake.in b/cmake/uninstall.cmake.in new file mode 100644 index 0000000..e544d0a --- /dev/null +++ b/cmake/uninstall.cmake.in @@ -0,0 +1,65 @@ +# from https://github.com/OSGeo/PROJ/blob/5920e2998318189970c0fe1e2db60f643515b9ea/cmake/uninstall.cmake.in + +# install_manifest.txt is created in the top build tree, not the project one +if (NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"") +endif() + +set(uninstall_file_list "@CMAKE_BINARY_DIR@/install_manifest.txt") +if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest_extra.txt") + list(APPEND uninstall_file_list "@CMAKE_CURRENT_BINARY_DIR@/install_manifest_extra.txt") +endif() + +set(dir_list) +foreach (manifest_file IN ITEMS ${uninstall_file_list}) + file(READ "${manifest_file}" files) + string(REGEX REPLACE "\n$" "" files "${files}") + string(REGEX REPLACE "\n" ";" files "${files}") + list(REVERSE files) + foreach (file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if (IS_DIRECTORY "$ENV{DESTDIR}${file}") + list(APPEND dir_list "${file}") + elseif (EXISTS "$ENV{DESTDIR}${file}") + get_filename_component(dir "${file}" DIRECTORY) + list(APPEND dir_list "${dir}") + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + if(NOT ${rm_retval} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif (NOT ${rm_retval} EQUAL 0) + else () + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif () + endforeach(file) +endforeach() + +while(NOT "${dir_list}" STREQUAL "") + list(REMOVE_DUPLICATES dir_list) + set(new_dir_list) + foreach (file IN ITEMS ${dir_list}) + if (IS_DIRECTORY "$ENV{DESTDIR}${file}" AND "${file}" MATCHES "@CMAKE_INSTALL_PREFIX@[/\\].+") + file(GLOB file_list "$ENV{DESTDIR}${file}/*") + list(LENGTH file_list file_list_len) + # Only remove empty directories + if(file_list_len EQUAL 0) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove_directory "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + if(${rm_retval} EQUAL 0) + get_filename_component(upper_dir "${file}" DIRECTORY) + list(APPEND new_dir_list "${upper_dir}") + else() + message(STATUS "Problem when removing directory \"$ENV{DESTDIR}${file}\"") + endif() + endif() + endif() + endforeach() + set(dir_list "${new_dir_list}") +endwhile() \ No newline at end of file From fd278c4cb7392616d82319d832ec05a9f291de16 Mon Sep 17 00:00:00 2001 From: Nils Date: Wed, 12 Jun 2024 14:29:52 +0200 Subject: [PATCH 3/3] add libcurl to pc.requires Co-authored-by: Kevin Kreiser --- libprime_server.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libprime_server.pc.in b/libprime_server.pc.in index 688d7bd..80007fc 100644 --- a/libprime_server.pc.in +++ b/libprime_server.pc.in @@ -8,5 +8,5 @@ Description: prime_server c++ library Version: @VERSION@ Libs: -L${libdir} -lprime_server Requires: libzmq -Requires.private: libczmq +Requires.private: libczmq libcurl Cflags: -I${includedir}