diff --git a/.devcontainer b/.devcontainer new file mode 160000 index 0000000..3c2726c --- /dev/null +++ b/.devcontainer @@ -0,0 +1 @@ +Subproject commit 3c2726c144307ce537c946acc30e03b2947e3e8e diff --git a/.github/workflows/xpbuild.yml b/.github/workflows/xpbuild.yml new file mode 100644 index 0000000..151d481 --- /dev/null +++ b/.github/workflows/xpbuild.yml @@ -0,0 +1,30 @@ +name: Build +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + workflow_dispatch: +jobs: + linux: + uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.1 + with: + cmake-workflow-preset: Linux + runon: ubuntu-latest + secrets: inherit + linux-arm64: + uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.1 + with: + cmake-workflow-preset: Linux + runon: ubuntu-24.04-arm + secrets: inherit + macos: + uses: externpro/externpro/.github/workflows/build-macos.yml@25.05.1 + with: + cmake-workflow-preset: Darwin + secrets: inherit + windows: + uses: externpro/externpro/.github/workflows/build-windows.yml@25.05.1 + with: + cmake-workflow-preset: Windows + secrets: inherit diff --git a/.github/workflows/xprelease.yml b/.github/workflows/xprelease.yml new file mode 100644 index 0000000..f868a82 --- /dev/null +++ b/.github/workflows/xprelease.yml @@ -0,0 +1,20 @@ +name: Release +on: + workflow_dispatch: + inputs: + workflow_run_url: + description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)' + required: true + type: string +jobs: + # Upload build artifacts as release assets + release-from-build: + uses: externpro/externpro/.github/workflows/release-from-build.yml@25.05.1 + with: + workflow_run_url: ${{ github.event.inputs.workflow_run_url }} + artifact_pattern: "*.tar.xz" + permissions: + contents: write + id-token: write + attestations: write + secrets: inherit diff --git a/.gitignore b/.gitignore index 57c513c..1dc0e94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,16 @@ # ignore all subdirectories **/ +# track .devcontainer, .github directory, and contents +!.devcontainer +!.github +!.github/* + +# externpro +.env +_bld*/ +docker-compose.override.yml + # YouCompleteMe .ycm_extra_conf.* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..18932ab --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".devcontainer"] + path = .devcontainer + url = https://github.com/externpro/externpro diff --git a/CMakeLists.txt b/CMakeLists.txt index 7345d9d..5db279b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,30 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.31) +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake) project(SQLite3 - VERSION 3.31.1 + VERSION 3.38.2 LANGUAGES C ) include(GNUInstallDirs) +#------------------------------------------------------------------------------ +# externpro +include(xpflags) +set(targetsFile ${PROJECT_NAME}Config) +if(NOT DEFINED XP_NAMESPACE) + set(XP_NAMESPACE SQLite) + set(debugPostfix DEBUG_POSTFIX d) + set(XP_INSTALL_CMAKEDIR cmake) +else() + set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake) + string(JOIN "\n" EXT1 + "set(THREAD_PREFER_PTHREAD_FLAG ON)" + "find_package(Threads REQUIRED) # depends on Threads::Threads" + "" + ) + xpPackageDevel(TARGETS_FILE ${targetsFile} LIBRARIES ${XP_NAMESPACE}::${PROJECT_NAME}) +endif() + #------------------------------------------------------------------------------ # build options and optional modules: option(SQLITE_ENABLE_COLUMN_METADATA "enables column metadata" OFF) @@ -41,7 +60,7 @@ add_library(${PROJECT_NAME} STATIC sqlite3.c) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME sqlite3 PUBLIC_HEADER sqlite3.h - DEBUG_POSTFIX d + ${debugPostfix} ) target_include_directories(${PROJECT_NAME} PUBLIC $) target_compile_definitions(${PROJECT_NAME} PUBLIC # inject user's options @@ -88,18 +107,25 @@ elseif(WIN32 AND ${CMAKE_SIZEOF_VOID_P} LESS 8) # this is a 32bit windows ) endif() endif() +if(SQLITE_ENABLE_MATH_FUNCTIONS) + include(CheckLibraryExists) + check_library_exists(m sin "m" HAVE_LIBM) + if(HAVE_LIBM) + target_link_libraries(${PROJECT_NAME} PRIVATE m) + endif() +endif() #------------------------------------------------------------------------------ configure_file(sqlite3_config.h.in ${CMAKE_BINARY_DIR}/sqlite3_config.h) -install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config +install(TARGETS ${PROJECT_NAME} EXPORT ${targetsFile} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -install(EXPORT ${PROJECT_NAME}Config - NAMESPACE SQLite:: - DESTINATION cmake +install(EXPORT ${targetsFile} + NAMESPACE ${XP_NAMESPACE}:: + DESTINATION ${XP_INSTALL_CMAKEDIR} ) install(FILES ${CMAKE_BINARY_DIR}/sqlite3_config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} @@ -115,7 +141,7 @@ if(BUILD_SHELL) if(UNIX) if(CMAKE_BUILD_TYPE STREQUAL Release) add_custom_command(TARGET shell_app POST_BUILD - COMMAND ${CMAKE_STRIP} sqlite3 + COMMAND ${CMAKE_STRIP} $ ) endif() elseif(MSVC) @@ -129,7 +155,7 @@ if(BUILD_SHELL) set(${flag} "${${flag}}" CACHE STRING "msvc flags" FORCE) endforeach() endif() - install(TARGETS shell_app - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + install(TARGETS shell_app EXPORT ${targetsFile} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Release ) endif() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..f82cfdd --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,8 @@ +{ + "version": 8, + "include": [ + ".devcontainer/cmake/presets/xpLinuxNinja.json", + ".devcontainer/cmake/presets/xpDarwinNinja.json", + ".devcontainer/cmake/presets/xpWindowsVs2022.json" + ] +} diff --git a/CMakePresetsBase.json b/CMakePresetsBase.json new file mode 100644 index 0000000..4a99ccc --- /dev/null +++ b/CMakePresetsBase.json @@ -0,0 +1,14 @@ +{ + "version": 8, + "configurePresets": [ + { + "name": "config-base", + "hidden": true, + "binaryDir": "${sourceDir}/_bld-${presetName}", + "cacheVariables": { + "XP_NAMESPACE": "xpro", + "BUILD_SHELL": "ON" + } + } + ] +} diff --git a/docker-compose.sh b/docker-compose.sh new file mode 120000 index 0000000..85f182f --- /dev/null +++ b/docker-compose.sh @@ -0,0 +1 @@ +.devcontainer/compose.pro.sh \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 120000 index 0000000..46c1f89 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1 @@ +.devcontainer/compose.bld.yml \ No newline at end of file