From 9f28851d00b0079b15b05cbbd0cdb7ad41ae24b7 Mon Sep 17 00:00:00 2001 From: Karim ElDeeb Date: Sat, 1 Dec 2018 15:58:48 +0200 Subject: [PATCH] Allow overriding a library path from the commandline when using CMake on Windows Change the path of used libraries to a cache entry instead of a normal variable. More info https://cmake.org/cmake/help/latest/command/set.html#set-cache-entry If you are automating Windows build, you have to change the path of every library in CMakeLists.txt, to match your system, after every update to DB4S source. This commit will set every library path to a cache entry instead of a normal value so it can be changed from the commandline using the `-D` flag. For example, to change Qt5 path run `cmake -DQT5_PATH=/path/to/qt5 ...` to let CMake use this path instead of the one in CMakeLists.txt. This doesn't affect the current used paths and they will continue to work, and be used, if they are not replaced on the commandline. --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83711885..198c6284 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,27 +34,27 @@ endif () if(WIN32 AND MSVC) if(CMAKE_CL_64) # Paths for 64-bit windows builds - set(OPENSSL_PATH "C:/dev/OpenSSL-Win64") - set(QT5_PATH "C:/dev/Qt/5.11.2/msvc2017_64") + set(OPENSSL_PATH "C:/dev/OpenSSL-Win64" CACHE PATH "OpenSSL Path") + set(QT5_PATH "C:/dev/Qt/5.11.2/msvc2017_64" CACHE PATH "Qt5 Path") # Choose between SQLCipher or SQLite, depending whether # -Dsqlcipher=1 is passed on the command line if(sqlcipher) - set(SQLITE3_PATH "C:/git_repos/SQLCipher-Win64") + set(SQLITE3_PATH "C:/git_repos/SQLCipher-Win64" CACHE PATH "SQLCipher Path") else() - set(SQLITE3_PATH "C:/dev/SQLite-Win64") + set(SQLITE3_PATH "C:/dev/SQLite-Win64" CACHE PATH "SQLite Path") endif() else() # Paths for 32-bit windows builds - set(OPENSSL_PATH "C:/dev/OpenSSL-Win32") - set(QT5_PATH "C:/dev/Qt/5.7/msvc2013") + set(OPENSSL_PATH "C:/dev/OpenSSL-Win32" CACHE PATH "OpenSSL Path") + set(QT5_PATH "C:/dev/Qt/5.7/msvc2013" CACHE PATH "Qt5 Path") # Choose between SQLCipher or SQLite, depending whether # -Dsqlcipher=1 is passed on the command line if(sqlcipher) - set(SQLITE3_PATH "C:/git_repos/SQLCipher-Win32") + set(SQLITE3_PATH "C:/git_repos/SQLCipher-Win32" CACHE PATH "SQLCipher Path") else() - set(SQLITE3_PATH "C:/dev/SQLite-Win32") + set(SQLITE3_PATH "C:/dev/SQLite-Win32" CACHE PATH "SQLite Path") endif() endif() set(CMAKE_PREFIX_PATH "${QT5_PATH};${SQLITE3_PATH}")