diff --git a/cmake/custom_import_sqlite.cmake b/cmake/custom_import_sqlite.cmake index ed2e81d..cf88757 100644 --- a/cmake/custom_import_sqlite.cmake +++ b/cmake/custom_import_sqlite.cmake @@ -1,15 +1,23 @@ if (WIN32) - # In Windows, we use custom way to import SQLite + # In Windows, we use custom way to import SQLite. + # Before using this CMake file in Windows, you should do following steps first. + # 1. Get SQLite SDK (amalgamation) and binaries (sqlite-dll) from http://www.sqlite.org/ + # 2. Extract SQLite SDK and binaries to your preferred directory. + # 3. Open Developer Command Prompt for Visual Studio (embedded with Visual Studio installation) + # 4. Use `cd` command to switch work directory to the directory where you extract binaries. + # 5. Execute `lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x86` (`x86` is the architecture of your SQLite3, you may change it according to your requirement). + # 6. Now you have a generated LIB file for MSVC linking. - # Check variables# Check YYCC path variable + # Check SQLite path variable if (NOT DEFINED SQLITE_AMALGAMATION_PATH) - message(FATAL_ERROR "You must set SQLITE_AMALGAMATION_PATH variable to the header of SQLite library.") + message(FATAL_ERROR "You must set SQLITE_AMALGAMATION_PATH to the directory where the SQLite3 header file locate.") endif() if (NOT DEFINED SQLITE_DLL_PATH) - message(FATAL_ERROR "You must set SQLITE_DLL_PATH variable the directory containing generated linking LIB file.") + message(FATAL_ERROR "You must set SQLITE_DLL_PATH to the directory where the generated SQLite3 LIB file locate for linking.") endif() # Add imported library add_library(SQLite3 INTERFACE IMPORTED) + # Add alias for it to let it has the same behavior with CMake imported SQLite3. add_library(SQLite3::SQLite3 ALIAS SQLite3) # Setup header files set_target_properties(SQLite3 PROPERTIES @@ -22,6 +30,6 @@ if (WIN32) "${SQLITE_DLL_PATH}/sqlite3.lib" ) else () - # In non-Windows, we import SQLite from CMake + # In non-Windows, we simply import SQLite3 from CMake preset. find_package(SQLite3 REQUIRED) endif () diff --git a/cmake/custom_import_yycc.cmake b/cmake/custom_import_yycc.cmake index a72c162..a9db286 100644 --- a/cmake/custom_import_yycc.cmake +++ b/cmake/custom_import_yycc.cmake @@ -1,9 +1,15 @@ -# Check YYCC path variable + +# Check YYCC path environment variable if (NOT DEFINED YYCC_PATH) - message(FATAL_ERROR "You must set YYCC_PATH variable to one of CMake distribution of YYCC installation path.") + message(FATAL_ERROR "You must set YYCC_PATH variable to one of YYCC CMake distribution installation path.") endif() # Find YYCC library -find_package(YYCCommonplace REQUIRED - HINTS ${YYCC_PATH} NO_DEFAULT_PATH -) +# It will produce YYCC::YYCCommonplace target for including and linking. +# +# Please note we MUST set CMake variable YYCCommonplace_ROOT to make sure CMake can found YYCC in out given path. +# The cache status of YYCCommonplace_ROOT is doesn't matter. +# CMake will throw error if we use HINTS feature in find_package to find YYCC. +set(YYCCommonplace_ROOT ${YYCC_PATH} CACHE PATH +"The path to YYCC CMake distribution installation path.") +find_package(YYCCommonplace REQUIRED) diff --git a/decorator/CMakeLists.txt b/decorator/CMakeLists.txt index d01a692..d308639 100644 --- a/decorator/CMakeLists.txt +++ b/decorator/CMakeLists.txt @@ -17,9 +17,6 @@ FILES target_include_directories(VSWDecorator PUBLIC ${CMAKE_CURRENT_LIST_DIR} - YYCC::YYCCommonplace - SQLite3::SQLite3 - VSWShared ) # Setup linked library target_link_libraries(VSWDecorator diff --git a/materializer/CMakeLists.txt b/materializer/CMakeLists.txt index 9b035ec..be7bf1e 100644 --- a/materializer/CMakeLists.txt +++ b/materializer/CMakeLists.txt @@ -54,10 +54,6 @@ FILES target_include_directories(VSWMaterializer PRIVATE ${CMAKE_CURRENT_LIST_DIR} - YYCC::YYCCommonplace - SQLite3::SQLite3 - VirtoolsSDK - VSWShared ) # Setup linked library target_link_libraries(VSWMaterializer diff --git a/materializer/Database.cpp b/materializer/Database.cpp index d5bbc08..7596653 100644 --- a/materializer/Database.cpp +++ b/materializer/Database.cpp @@ -37,7 +37,7 @@ sqlite3_reset(stmt); failed: throw std::runtime_error("fail to bind value for prepared statement."); #define REVEAL_ENUM(enum_val) static_cast>(enum_val) -#define REVEAL_U8STR(u8_str) YYCC::EncodingHelper::ToOrdinary(u8_str.c_str()), -1, SQLITE_TRANSIENT +#define REVEAL_U8STR(u8_str) YYCC::EncodingHelper::ToOrdinary((u8_str).c_str()), -1, SQLITE_TRANSIENT #define REVEAL_BLOB(blob_val) (blob_val).ptr, (blob_val).length, SQLITE_TRANSIENT #define REVEAL_BOOL(bool_val) ((bool_val) ? 1 : 0) diff --git a/shared/CMakeLists.txt b/shared/CMakeLists.txt index 7d60922..613a20a 100644 --- a/shared/CMakeLists.txt +++ b/shared/CMakeLists.txt @@ -18,7 +18,6 @@ FILES target_include_directories(VSWShared PUBLIC ${CMAKE_CURRENT_LIST_DIR} - YYCC::YYCCommonplace ) # Setup linked library target_link_libraries(VSWShared