From 74a6bc11ef347c3016f38b55c8f6028054882e6d Mon Sep 17 00:00:00 2001 From: Nicholas Frizzell Date: Sun, 23 Jul 2023 23:23:48 -0400 Subject: [PATCH 1/2] Add cmake cache var to allow for use of system sqlite Signed-off-by: Nicholas Frizzell --- package-system/sqlite/FindSQLite.cmake | 48 ++++++++++++++++---------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/package-system/sqlite/FindSQLite.cmake b/package-system/sqlite/FindSQLite.cmake index c117ed3d..57567827 100644 --- a/package-system/sqlite/FindSQLite.cmake +++ b/package-system/sqlite/FindSQLite.cmake @@ -6,26 +6,38 @@ # # -# this file actually ingests the library and defines targets. -set(TARGET_WITH_NAMESPACE "3rdParty::SQLite") +set(MY_NAME "SQLite") +set(TARGET_WITH_NAMESPACE "3rdParty::${MY_NAME}") if (TARGET ${TARGET_WITH_NAMESPACE}) return() endif() -set(MY_NAME "SQLite") - - -set(${MY_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/SQLite) -set(${MY_NAME}_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/SQLite/lib) -set(${MY_NAME}_LIBRARY ${${MY_NAME}_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}sqlite3${CMAKE_STATIC_LIBRARY_SUFFIX}) - -add_library(${TARGET_WITH_NAMESPACE} STATIC IMPORTED GLOBAL) +if (LY_SYSTEM_PACKAGE_${MY_NAME}) + + find_package(SQLite3) + if (NOT SQLite3_FOUND) + message(FATAL_ERROR "LY_SYSTEM_PACKAGE_${MY_NAME} specified but development files for ${MY_NAME} not found.") + else() + set_target_properties(SQLite::SQLite3 PROPERTIES LY_SYSTEM_LIBRARY TRUE) + add_library(${TARGET_WITH_NAMESPACE} ALIAS SQLite::SQLite3) + set(${MY_NAME}_FOUND True) + endif() + +else() + + set(${MY_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/SQLite) + set(${MY_NAME}_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/SQLite/lib) + set(${MY_NAME}_LIBRARY ${${MY_NAME}_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}sqlite3${CMAKE_STATIC_LIBRARY_SUFFIX}) + + add_library(${TARGET_WITH_NAMESPACE} STATIC IMPORTED GLOBAL) + + set_target_properties(${TARGET_WITH_NAMESPACE} PROPERTIES IMPORTED_LOCATION "${${MY_NAME}_LIBRARY}") + + ly_target_include_system_directories(TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${${MY_NAME}_INCLUDE_DIR}) + + target_link_libraries(${TARGET_WITH_NAMESPACE} + INTERFACE ${CMAKE_DL_LIBS}) + + set(${MY_NAME}_FOUND True) -set_target_properties(${TARGET_WITH_NAMESPACE} PROPERTIES IMPORTED_LOCATION "${${MY_NAME}_LIBRARY}") - -ly_target_include_system_directories(TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${${MY_NAME}_INCLUDE_DIR}) - -target_link_libraries(${TARGET_WITH_NAMESPACE} - INTERFACE ${CMAKE_DL_LIBS}) - -set(${MY_NAME}_FOUND True) +endif() From bf5a68f0ccb4ba5241429a8142597f22075fea2b Mon Sep 17 00:00:00 2001 From: Nicholas Frizzell Date: Mon, 24 Jul 2023 12:31:25 -0400 Subject: [PATCH 2/2] Only allow use of sqlite system package on Linux for now Signed-off-by: Nicholas Frizzell --- ...indSQLite.cmake => FindSQLite.cmake.Linux} | 0 .../sqlite/FindSQLite.cmake.NonLinux | 31 +++++++++++++++++++ package-system/sqlite/build_config.json | 4 ++- 3 files changed, 34 insertions(+), 1 deletion(-) rename package-system/sqlite/{FindSQLite.cmake => FindSQLite.cmake.Linux} (100%) create mode 100644 package-system/sqlite/FindSQLite.cmake.NonLinux diff --git a/package-system/sqlite/FindSQLite.cmake b/package-system/sqlite/FindSQLite.cmake.Linux similarity index 100% rename from package-system/sqlite/FindSQLite.cmake rename to package-system/sqlite/FindSQLite.cmake.Linux diff --git a/package-system/sqlite/FindSQLite.cmake.NonLinux b/package-system/sqlite/FindSQLite.cmake.NonLinux new file mode 100644 index 00000000..c117ed3d --- /dev/null +++ b/package-system/sqlite/FindSQLite.cmake.NonLinux @@ -0,0 +1,31 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +# this file actually ingests the library and defines targets. +set(TARGET_WITH_NAMESPACE "3rdParty::SQLite") +if (TARGET ${TARGET_WITH_NAMESPACE}) + return() +endif() + +set(MY_NAME "SQLite") + + +set(${MY_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/SQLite) +set(${MY_NAME}_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/SQLite/lib) +set(${MY_NAME}_LIBRARY ${${MY_NAME}_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}sqlite3${CMAKE_STATIC_LIBRARY_SUFFIX}) + +add_library(${TARGET_WITH_NAMESPACE} STATIC IMPORTED GLOBAL) + +set_target_properties(${TARGET_WITH_NAMESPACE} PROPERTIES IMPORTED_LOCATION "${${MY_NAME}_LIBRARY}") + +ly_target_include_system_directories(TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${${MY_NAME}_INCLUDE_DIR}) + +target_link_libraries(${TARGET_WITH_NAMESPACE} + INTERFACE ${CMAKE_DL_LIBS}) + +set(${MY_NAME}_FOUND True) diff --git a/package-system/sqlite/build_config.json b/package-system/sqlite/build_config.json index b0ed81b1..24117002 100644 --- a/package-system/sqlite/build_config.json +++ b/package-system/sqlite/build_config.json @@ -5,7 +5,6 @@ "package_url":"https://www.sqlite.org", "package_license":"CUSTOM", "package_license_file":"copyright.txt", - "cmake_find_source":"FindSQLite.cmake", "cmake_find_target":"FindSQLite.cmake", "additional_src_files":[ "copyright.txt" @@ -13,6 +12,7 @@ "Platforms":{ "Windows":{ "Windows":{ + "cmake_find_source":"FindSQLite.cmake.NonLinux", "package_version":"3.37.2-rev1", "custom_build_cmd": [ "build_windows.cmd" @@ -24,6 +24,7 @@ }, "Darwin":{ "Mac":{ + "cmake_find_source":"FindSQLite.cmake.NonLinux", "package_version":"3.37.2-rev2", "custom_build_cmd": [ "./build_unix_like.sh" @@ -35,6 +36,7 @@ }, "Linux":{ "Linux":{ + "cmake_find_source":"FindSQLite.cmake.Linux", "package_version":"3.37.2-rev1", "custom_build_cmd": [ "./build_unix_like.sh"