cmake: improve handling of EXT_LIB_PATH (and in windows)
@@ -32,34 +32,42 @@ endif ()
include_directories (inc)
include_directories (lib)
-if (LINUX AND EXISTS "${PROJECT_SOURCE_DIR}/linux_dependencies")
- include_directories (linux_dependencies)
- set (EXT_LIB_PATH "${PROJECT_SOURCE_DIR}/linux_dependencies" CACHE STRING "Absolute path to libraries")
+if (DEFINED EXT_LIB_PATH AND NOT EXISTS "${EXT_LIB_PATH}")
+ message (FATAL_ERROR "The provided folder for dependencies (EXT_LIB_PATH=${EXT_LIB_PATH}) doesn't exist. Please, either provide a correct folder or don't provide it (and remove cmake cache) to search in default folders.")
+endif()
+
+# default folder for dependencies (written by install_dependencies.sh), unless provided by the user
+if (LINUX)
+ set (DEFAULT_EXT_LIB_PATH "${PROJECT_SOURCE_DIR}/linux_dependencies")
+ if (NOT EXISTS "${DEFAULT_EXT_LIB_PATH}")
+ set (EXT_LIB_PATH "/usr/local/bin" CACHE STRING "Absolute path to libraries")
+ else()
+ set (EXT_LIB_PATH "${DEFAULT_EXT_LIB_PATH}" CACHE STRING "Absolute path to libraries") # cached: this instruction is ignored if the user provided the variable
set (ODB_PATH "${EXT_LIB_PATH}/odb-2.4.0-x86_64-linux-gnu/bin/" CACHE STRING "Path to odb binaries")
- if (EXISTS "${PROJECT_SOURCE_DIR}/linux_dependencies/boost")
+ if (EXISTS "${EXT_LIB_PATH}/boost")
set (SELF_COMPILED_BOOST TRUE)
else ()
set (SELF_COMPILED_BOOST FALSE)
endif()
-elseif (OSX AND EXISTS "${PROJECT_SOURCE_DIR}/osx_dependencies")
- include_directories (osx_dependencies)
+ endif()
+elseif (OSX)
set (EXT_LIB_PATH "${PROJECT_SOURCE_DIR}/osx_dependencies" CACHE STRING "Absolute path to libraries")
set (ODB_PATH "${EXT_LIB_PATH}/odb-2.4.0-i686-macosx/bin/" CACHE STRING "Path to odb binaries")
-elseif (WINDOWS AND EXISTS "${PROJECT_SOURCE_DIR}/windows_dependencies")
+ if (NOT EXISTS "${EXT_LIB_PATH}")
+ message(FATAL_ERROR "Please run first install_dependencies.sh osx")
+ endif()
+elseif (WINDOWS)
include_directories (lib/sqlite) # Windows specific
- include_directories (windows_dependencies)
- include_directories (windows_dependencies/curl/include)
set (EXT_LIB_PATH "${PROJECT_SOURCE_DIR}/lib/windows_specific" CACHE STRING "Absolute path to libraries")
-else ()
- set (EXT_LIB_PATH "/usr/local/bin" CACHE STRING "Absolute path to libraries")
- if (OSX)
- message(ERROR "Please run first install_dependencies.sh osx")
- elseif (WINDOWS)
- message(ERROR "Please run first install_dependencies.bat")
+ if (NOT EXISTS "${PROJECT_SOURCE_DIR}/windows_dependencies")
+ message(FATAL_ERROR "Please run first install_dependencies.bat")
endif ()
+ include_directories (windows_dependencies)
+ include_directories (windows_dependencies/curl/include)
endif ()
-include_directories (${EXT_LIB_PATH}/curl/include)
+include_directories ("${EXT_LIB_PATH}")
+include_directories ("${EXT_LIB_PATH}/curl/include")
# Compiler and linkers flags
if (LINUX)
