From 107d54969a9950d3c9ac95b63b28149698e51806 Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Thu, 6 Jun 2024 09:17:48 -0300 Subject: [PATCH] Added install procedure in CMake --- CMakeLists.txt | 54 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a282691b..db54a845 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,30 @@ project(SQLiteModernCpp LANGUAGES CXX) hunter_add_package(sqlite3) find_package(sqlite3 CONFIG REQUIRED) +add_library(SQLiteModernCpp INTERFACE) + +target_include_directories(SQLiteModernCpp INTERFACE + $ +) + +include(GNUInstallDirs) + +install( + TARGETS SQLiteModernCpp + EXPORT SQLiteModernCpp +) + +install( + EXPORT SQLiteModernCpp + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SQLiteModernCpp" + FILE SQLiteModernCppConfig.cmake + NAMESPACE SQLiteModernCpp:: +) + +install( + DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/hdr/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) if(BUILD_TESTING) hunter_add_package(Catch) @@ -34,22 +58,22 @@ if(BUILD_TESTING) set(TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests) file(GLOB TEST_SOURCES ${TEST_SOURCE_DIR}/*.cc) -IF(NOT ENABLE_SQLCIPHER_TESTS) - list(REMOVE_ITEM TEST_SOURCES ${TEST_SOURCE_DIR}/sqlcipher.cc) -ENDIF(NOT ENABLE_SQLCIPHER_TESTS) + IF(NOT ENABLE_SQLCIPHER_TESTS) + list(REMOVE_ITEM TEST_SOURCES ${TEST_SOURCE_DIR}/sqlcipher.cc) + ENDIF(NOT ENABLE_SQLCIPHER_TESTS) -enable_testing() + enable_testing() -add_executable(tests_runner ${TEST_SOURCES}) -target_include_directories(tests_runner INTERFACE ${SQLITE3_INCLUDE_DIRS}) + add_executable(tests_runner ${TEST_SOURCES}) + target_include_directories(tests_runner INTERFACE ${SQLITE3_INCLUDE_DIRS}) -if(ENABLE_SQLCIPHER_TESTS) - target_link_libraries(tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3 -lsqlcipher) -else() - target_link_libraries(tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3) -endif() + if(ENABLE_SQLCIPHER_TESTS) + target_link_libraries(tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3 -lsqlcipher) + else() + target_link_libraries(tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3) + endif() -catch_discover_tests(tests_runner) + catch_discover_tests(tests_runner) target_compile_options(tests_runner PUBLIC $<$:/Zc:__cplusplus>) endif() @@ -58,7 +82,7 @@ endif() # YCM is the code-completion engine for (neo)vim https://github.com/Valloric/YouCompleteMe IF(EXISTS "${CMAKE_BINARY_DIR}/compile_commands.json") EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_BINARY_DIR}/compile_commands.json - ${CMAKE_SOURCE_DIR}/compile_commands.json - ) + ${CMAKE_BINARY_DIR}/compile_commands.json + ${CMAKE_SOURCE_DIR}/compile_commands.json + ) ENDIF() \ No newline at end of file