Skip to content

Commit

Permalink
Added install procedure in CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges committed Jun 6, 2024
1 parent 1a98087 commit 107d549
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/hdr>
)

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)
Expand All @@ -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 $<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>)
endif()
Expand All @@ -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()

0 comments on commit 107d549

Please sign in to comment.