cmake_minimum_required(VERSION 3.19...3.27) if(${CMAKE_VERSION} VERSION_LESS 3.12) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) endif() project(libfud VERSION 0.42.0 DESCRIPTION "Library of FUD" LANGUAGES CXX) set(CXX_CPPCHECK "project=build/compile_commands.json;enable=information;force") set(CMAKE_EXPORT_COMPILE_COMMANDS true) find_package(SQLite3 REQUIRED) add_library(fud SHARED source/libfud.cpp source/fud_allocator.cpp source/fud_assert.cpp source/fud_memory.cpp source/fud_c_file.cpp source/fud_string_view.cpp source/fud_string.cpp source/fud_utf8.cpp source/fud_utf8_iterator.cpp source/fud_sqlite.cpp source/fud_directory.cpp ) include(cmake/warnings.cmake) target_compile_options(fud PRIVATE "${FUD_WARNINGS}" -fno-rtti -fno-exceptions) target_include_directories(fud PUBLIC include ${SQLite3_INCLUDE_DIRS}) target_include_directories(fud PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include) target_link_libraries(fud ${SQLite3_LIBRARIES}) set_target_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) # 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) find_package(Doxygen REQUIRED dot OPTIONAL_COMPONENTS mscgen dia) set(DOXYGEN_GENERATE_HTML YES) set(DOXYGEN_GENERATE_MAN YES) doxygen_add_docs(fudDocs include # CONFIG_FILE "Doxyfile" Comment "Generate man pages and html" ) 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/libfud.hpp" "include/fud_allocator.hpp" "include/fud_array.hpp" "include/fud_assert.hpp" "include/fud_c_file.hpp" "include/fud_directory.hpp" "include/fud_fud_type_traits.hpp" "include/fud_memory.hpp" "include/fud_permissions.hpp" "include/fud_result.hpp" "include/fud_span.hpp" "include/fud_status.hpp" "include/fud_string.hpp" "include/fud_string_view.hpp" "include/fud_sqlite.hpp" "include/fud_unique_array.hpp" "include/fud_utf8.hpp" "include/fud_utf8_iterator.hpp" ) set_target_properties(fud PROPERTIES PUBLIC_HEADER "${FUD_HEADERS}") install(TARGETS fud EXPORT fud PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ ) include(cmake/CheckGit.cmake) CheckGitSetup(GIT_HASH) configure_file(cmake/fud_version.hpp.in include/fud_version.hpp @ONLY) add_dependencies(fud AlwaysCheckGit)