Skip to content

Make it available for find_package() #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2025
Merged

Conversation

Pichas
Copy link
Contributor

@Pichas Pichas commented May 17, 2025

For now when you run cmake --target install it copies only headers and lib files, but fails if you try to use find_package(sqlite3mc)

This PR adds cmake code to generate sqlite3mcConfig.cmake, sqlite3mcConfigVersion.cmake, sqlite3mcTargets.cmake. So now you can compile and install it into linux system and use find_package() to compile another projects with this library. All other libraries which uses this lib can be exported and installed without target "sqlite3mc" that is not in any export set error.

This PR was also tested as conan package and git submodule.

Example for static lib. Shared version works too.

# execute in the root folder to compile and install
cmake -D SQLITE3MC_STATIC=ON -Bbuild -S. --fresh
cmake --build ./build --target install
# cmake file for tests
cmake_minimum_required(VERSION 3.20...4.0)

project(my_test)

add_executable(${PROJECT_NAME} main.cpp)

find_package(sqlite3mc_static REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE sqlite3mc_static)
// main.cpp
#include <sqlite3mc/sqlite3mc.h>
#include <stdio.h>

int main() {
  printf("cipher_count: %d\n", sqlite3mc_cipher_count());
  return 0;
}

@Pichas Pichas force-pushed the make-it-installable branch from 34290d2 to aa57e1a Compare May 17, 2025 23:28
@@ -401,14 +432,13 @@ if(SQLITE3MC_BUILD_SHELL)

if(SQLITE3MC_RUNTIME_LINK)
message("Will build ${SQLITE3MC_SHELL_TARGET} with static runtime")
_Enable_MT(${SQLIT3MC_SHELL_TARGET})
_Enable_MT(${SQLITE3MC_SHELL_TARGET})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed typo here

@Pichas Pichas force-pushed the make-it-installable branch from aa57e1a to 930edeb Compare May 18, 2025 03:56
@Pichas Pichas force-pushed the make-it-installable branch from 930edeb to 0b6535d Compare May 18, 2025 03:57
@utelle
Copy link
Owner

utelle commented May 18, 2025

For now when you run cmake --target install it copies only headers and lib files, but fails if you try to use find_package(sqlite3mc)

This PR adds cmake code to generate sqlite3mcConfig.cmake, sqlite3mcConfigVersion.cmake, sqlite3mcTargets.cmake. So now you can compile and install it into linux system and use find_package() to compile another projects with this library. All other libraries which uses this lib can be exported and installed without target "sqlite3mc" that is not in any export set error.

Sounds great. Thank you for your efforts!

This PR was also tested as conan package and git submodule.

Fantastic. This improvement of cmake support will certainly be very welcome by many users of SQLite3MC. I will merge your PR soon.

@utelle utelle merged commit 757ed99 into utelle:main May 18, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants