diff --git a/CMakeLists.txt b/CMakeLists.txt index b28eece..13367d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,10 @@ cmake_minimum_required(VERSION 3.14...3.25) -include(cmake/git.cmake) - project(SC LANGUAGES C HOMEPAGE_URL https://www.p4est.org/ DESCRIPTION "The SC library supports parallel scientific applications." -VERSION ${PROJECT_VERSION}) +VERSION 2.8.5) enable_testing() @@ -20,6 +18,10 @@ endif() include(cmake/options.cmake) message(STATUS "libsc ${PROJECT_VERSION} " "install prefix: ${CMAKE_INSTALL_PREFIX}") + +set(PROJECT_MAJOR ${PROJECT_VERSION_MAJOR}) +set(PROJECT_MINOR ${PROJECT_VERSION_MINOR}) +set(PROJECT_PATCH ${PROJECT_VERSION_PATCH}) # options.cmake before config.cmake to determine user intent include(cmake/config.cmake) @@ -39,8 +41,13 @@ target_include_directories(libb64 PRIVATE libb64) # --- sc add_library(sc $ $) target_compile_features(sc PRIVATE c_std_99) -set_property(TARGET sc PROPERTY EXPORT_NAME SC) -set_property(TARGET sc PROPERTY VERSION ${PROJECT_VERSION}) +set_target_properties( + sc PROPERTIES + EXPORT_NAME SC + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} +) + target_include_directories(sc PRIVATE iniparser libb64 PUBLIC @@ -62,13 +69,14 @@ target_link_libraries(SC::SC INTERFACE sc) install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ ${PROJECT_BINARY_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" +PATTERN "sc_builtin" EXCLUDE ) install(TARGETS sc EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) add_subdirectory(src) add_subdirectory(example) @@ -79,10 +87,6 @@ endif(BUILD_TESTING) # --- packaging -install(FILES -${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindSC.cmake -DESTINATION cmake) - include(cmake/pkgconf.cmake) include(cmake/install.cmake) diff --git a/cmake/install.cmake b/cmake/install.cmake index f093fa9..de6b2f2 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -4,7 +4,7 @@ include(CMakePackageConfigHelpers) configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake -INSTALL_DESTINATION cmake +INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) write_basic_package_version_file( @@ -14,13 +14,13 @@ COMPATIBILITY SameMajorVersion install(EXPORT ${PROJECT_NAME}-targets NAMESPACE ${PROJECT_NAME}:: -DESTINATION cmake +DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake -DESTINATION cmake +DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) export(EXPORT ${PROJECT_NAME}-targets diff --git a/cmake/pkgconf.cmake b/cmake/pkgconf.cmake index 10f742b..a8387a9 100644 --- a/cmake/pkgconf.cmake +++ b/cmake/pkgconf.cmake @@ -13,18 +13,17 @@ convert_yn(SC_HAVE_JSON sc_have_json_pc) convert_yn(zlib zlib_pc) convert_yn(SC_ENABLE_DEBUG debug_build_pc) -set(pc_filename libsc-${git_version}.pc) +set(pc_filename "libsc-${PROJECT_VERSION}.pc") configure_file(${CMAKE_CURRENT_LIST_DIR}/pkgconf.pc.in ${pc_filename} @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pc_filename} - DESTINATION lib/pkgconfig) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -set(pc_target ${pc_filename}) -set(pc_link ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/libsc.pc) +set(pc_link libsc.pc) -install(CODE "execute_process( \ - COMMAND ${CMAKE_COMMAND} -E create_symlink \ - ${pc_target} \ - ${pc_link} \ - )" - ) +execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + ${pc_filename} + ${pc_link} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pc_link} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/cmake/pkgconf.pc.in b/cmake/pkgconf.pc.in index 6bbb72e..8244856 100644 --- a/cmake/pkgconf.pc.in +++ b/cmake/pkgconf.pc.in @@ -1,11 +1,7 @@ - prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -libsc_CC=@SC_CC@ -libsc_CFLAGS=@SC_CPPFLAGS@ @SC_CFLAGS@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ have_mpi=@mpi_pc@ have_json=@sc_have_json_pc@ diff --git a/libsc.pc b/libsc.pc new file mode 120000 index 0000000..c5cd578 --- /dev/null +++ b/libsc.pc @@ -0,0 +1 @@ +lib64/pkgconfig/libsc-2.8.5.pc \ No newline at end of file