From 0b860bb5dd6d2007db605291d239a6a9d41f57d1 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Mon, 23 Sep 2024 07:36:16 -0500 Subject: Installable library. --- CMakeLists.txt | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 6 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index fc500ab..4d3e399 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,29 +13,36 @@ set(CXX_CPPCHECK "project=build/compile_commands.json;enable=information;force") set(CMAKE_EXPORT_COMPILE_COMMANDS true) -add_library(libfud SHARED +add_library(fud SHARED source/libfud.cpp + source/fud_assert.cpp source/fud_memory.cpp source/fud_c_file.cpp source/fud_string.cpp source/fud_utf8.cpp source/fud_utf8_iterator.cpp - ) +) -target_compile_options(libfud PRIVATE ${FUD_WARNINGS}) +include(cmake/warnings.cmake) +target_compile_options(fud PRIVATE "${FUD_WARNINGS}") -target_include_directories(libfud PUBLIC include) +target_include_directories(fud PUBLIC include) set_target_properties( - libfud PROPERTIES + fud PROPERTIES CXX_STANDARD 20 C_STANDARD 23 CXX_EXTENSIONS OFF C_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON) + if (FUD_TEST) -add_subdirectory(test) + add_subdirectory(test) + # set(CVG_FLAGS -fsanitize=address -fsanitize=undefined --coverage) + set(CVG_FLAGS --coverage) + target_compile_options(fud PUBLIC ${CVG_FLAGS}) + target_link_options(fud PUBLIC ${CVG_FLAGS}) endif () if (FUD_DOC) @@ -48,3 +55,45 @@ if (FUD_DOC) # CONFIG_FILE "Doxyfile" ) endif() + +include(GNUInstallDirs) +set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} + CACHE PATH "Location of header files" ) +set(SYSCONFIG_INSTALL_DIR ${CMAKE_INSTALL_SYSCONFDIR} + CACHE PATH "Location of configuration files" ) + +include(CMakePackageConfigHelpers) +configure_package_config_file(cmake/FudConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/FudConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Foo + PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/FudConfigVersion.cmake + VERSION 1.0.0 + COMPATIBILITY SameMajorVersion ) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FudConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/FudConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fud ) + +set(FUD_HEADERS + "include/fud_array.hpp" + "include/fud_assert.hpp" + "include/fud_c_file.hpp" + "include/fud_fud_type_traits.hpp" + "include/fud_memory.hpp" + "include/fud_result.hpp" + "include/fud_status.hpp" + "include/fud_string.hpp" + "include/fud_unique_array.hpp" + "include/fud_utf8.hpp" + "include/fud_utf8_iterator.hpp" + "include/libfud.hpp" +) + +set_target_properties(fud PROPERTIES PUBLIC_HEADER "${FUD_HEADERS}") + +install(TARGETS fud + EXPORT fud + PUBLIC_HEADER + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ +) -- cgit v1.2.3