diff --git a/CMakeLists.txt b/CMakeLists.txt index f3092888b..97ce75401 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,6 +299,8 @@ include_directories("${CMAKE_SOURCE_DIR}/src" ${CMAKE_BINARY_DIR}) # configure a header file to pass some of the CMake settings # to the source code +include(CheckSymbolExists) +check_symbol_exists(wordexp wordexp.h HAVE_WORDEXP) check_include_files(byteswap.h HAVE_BYTESWAP_H) check_include_file_cxx(experimental/filesystem HAVE_EXPERIMENTAL_FILESYSTEM) diff --git a/config.h.in b/config.h.in index a2ca9d0d3..6a7b06117 100644 --- a/config.h.in +++ b/config.h.in @@ -1,3 +1,4 @@ #cmakedefine HAVE_BYTESWAP_H #cmakedefine HAVE_FILESYSTEM #cmakedefine HAVE_EXPERIMENTAL_FILESYSTEM +#cmakedefine HAVE_WORDEXP diff --git a/src/celutil/util.cpp b/src/celutil/util.cpp index c3ce4fd8e..b1ff7f3da 100644 --- a/src/celutil/util.cpp +++ b/src/celutil/util.cpp @@ -9,6 +9,7 @@ // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. +#include #include #include "util.h" #ifdef _WIN32 @@ -17,8 +18,10 @@ #else #include #include +#ifdef HAVE_WORDEXP #include -#endif +#endif // HAVE_WORDEXP +#endif // !_WIN32 using namespace std; @@ -101,7 +104,7 @@ fs::path PathExp(const fs::path& filename) } return filename; -#else +#elif defined(HAVE_WORDEXP) wordexp_t result; switch(wordexp(filename.string().c_str(), &result, WRDE_NOCMD)) @@ -125,6 +128,8 @@ fs::path PathExp(const fs::path& filename) fs::path::string_type expanded(result.we_wordv[0]); wordfree(&result); return expanded; +#else + return filename; #endif }