diff --git a/.gitignore b/.gitignore index 660176b60..f0f1c02aa 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,6 @@ gdlde/ gdlde*.zip .vscode .idea/ +Testing/ 2020.2.zip qhull-2020.2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bcb5c75e..fb63ef82b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,14 +161,7 @@ set(JPEGDIR "" CACHE PATH "GDL: Specify the JPEG directory tree") set(SZIPDIR "" CACHE PATH "GDL: Specify the SZip directory tree") set(GDL_DATA_DIR "/share/gnudatalanguage" CACHE PATH "GDL: data directory relative to CMAKE_INSTALL_PREFIX") -set(GDL_LIB_DIR "" CACHE PATH "GDL: library directory relative to CMAKE_INSTALL_PREFIX") -#define (for plplotdriver/CMakeLists.txt) the GDL_DRV_DIR where the drivers will be installed. -#if GDL_LIB_DIR is empty, it will be the default (GDL_DATA_DIR/drivers) otherwise it is GDL_LIB_DIR (not GDL_LIB_DIR/drivers) -if ( GDL_LIB_DIR STREQUAL "" OR NOT GDL_LIB_DIR) - set (GDL_DRV_DIR "${CMAKE_INSTALL_PREFIX}/${GDL_DATA_DIR}/drivers") # CACHE PATH "GDL: where the drivers will be installed.") -else() - set (GDL_DRV_DIR "${GDL_LIB_DIR}" ) # CACHE PATH "GDL: where the drivers will be installed.") -endif() +set(GDL_LIB_DIR "/lib/gnudatalanguage" CACHE PATH "GDL: library directory relative to CMAKE_INSTALL_PREFIX") # check for 64-bit OS if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) set(HAVE_64BIT_OS 1) diff --git a/INSTALL.CMake b/INSTALL.CMake index f4faa129e..ad9311bbe 100644 --- a/INSTALL.CMake +++ b/INSTALL.CMake @@ -41,6 +41,9 @@ Other options include: - GDL_DATA_DIR (default: /share/gnudatalanguage) to specify a custom installation location for GDL files (a subdirectory of the main installation prefix) +- GDL_LIB_DIR (default: /lib/gnudatalanguage) to specify + a custom installation location for local PlPlot driver files + (a subdirectory of the main installation prefix) The list of all GDL-related options accepted by CMake along with their default values can be obtained by calling: diff --git a/config.h.cmake b/config.h.cmake index 0eb7a2f01..e87c72991 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,10 +1,8 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ -#define EXEC_PREFIX "@CMAKE_INSTALL_PREFIX@" -#define GDLDATADIR "@CMAKE_INSTALL_PREFIX@@GDL_DATA_DIR@" -#define GDLLIBDIR "@GDL_LIB_DIR@" -#define GDL_DRV_DIR "@GDL_DRV_DIR@" +#cmakedefine GDL_DATA_DIR "@GDL_DATA_DIR@" +#cmakedefine GDL_LIB_DIR "@GDL_LIB_DIR@" #define _CRT_SECURE_NO_WARNINGS diff --git a/scripts/build_gdl.sh b/scripts/build_gdl.sh index 2518ecb51..12ae5419f 100755 --- a/scripts/build_gdl.sh +++ b/scripts/build_gdl.sh @@ -559,11 +559,12 @@ function install_gdl { function test_gdl { log "Testing GDL..." - cd ${ROOT_DIR}/build - if [ -f ${GDL_DIR}/CMakeModules/CodeCoverage.cmake ]; then + cd "${ROOT_DIR}/build" || exit 1 + if [ -f "${GDL_DIR}/CMakeModules/CodeCoverage.cmake" ]; then make codecov || exit 1 else - CTEST_OUTPUT_ON_FAILURE=1 make test || exit 1 + # since we do not install anything we need to set the driver path to the directory of the compiles drivers + CTEST_OUTPUT_ON_FAILURE=1 GDL_DRV_DIR="${ROOT_DIR}/build/src/plplotdriver" make test || exit 1 fi } diff --git a/src/gdl.cpp b/src/gdl.cpp index 6b793296f..0c32246fe 100644 --- a/src/gdl.cpp +++ b/src/gdl.cpp @@ -215,7 +215,7 @@ namespace MyPaths { if (length > 0) { path = (char*)malloc(length + 1); - if (!path) return std::string("."); + if (!path) return {"."}; wai_getExecutablePath(path, length, &dirname_length); path[dirname_length] = '\0'; // printf(" dirname: %s\n", path); @@ -223,7 +223,7 @@ namespace MyPaths { free(path); return pathstring; } - return std::string("."); + return {"."}; } } @@ -236,43 +236,44 @@ int main(int argc, char *argv[]) bool setQuietSysvar=false; bool willSuppressEditInput=false; std::string myMessageBoxName=""; - -//The default installation location --- will not always be there. - gdlDataDir = std::string(GDLDATADIR); - gdlLibDir = std::string(GDLLIBDIR); + + // The default installation location --- will not always be there. + gdlDataDir = std::string(GDL_DATA_DIR); + gdlLibDir = std::string(GDL_LIB_DIR); + #ifdef _WIN32 std::replace(gdlDataDir.begin(), gdlDataDir.end(), '/', '\\'); std::replace(gdlLibDir.begin(), gdlLibDir.end(), '/', '\\'); -#endif +#endif + // make sure dirs are prefixed with the system's path separator + if (gdlDataDir.at(0) != lib::PathSeparator()) gdlDataDir.assign(lib::PathSeparator() + gdlDataDir); + if (gdlLibDir.at(0) != lib::PathSeparator()) gdlLibDir.assign(lib::PathSeparator() + gdlLibDir); //check where is the executable being run - whereami_gdl=MyPaths::getExecutablePath(); -// if I am at a 'bin' location, then there are chances that I've bee INSTALLED, so all the resources I need can be accessed relatively to this 'bin' directory. -// if not, then I'm probably just a 'build' gdl and my ressources may (should?) be in the default location GDLDATADIR - std::size_t pos=whereami_gdl.rfind("bin"); - if (pos == whereami_gdl.size()-3) { //we are the installed gdl! - gdlDataDir.assign( whereami_gdl+ lib::PathSeparator() + ".." + lib::PathSeparator() + "share" + lib::PathSeparator() + "gnudatalanguage") ; -// std::cerr<<"installed at: "<