summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Landscheidt <tim@tim-landscheidt.de>2019-01-16 14:37:13 +0000
committerTim Landscheidt <tim@tim-landscheidt.de>2019-01-16 14:38:38 +0000
commit347029a803475c21bf9fa508f27b0ed7233ff312 (patch)
tree69bce85e03aa0c580213a377c907758f9c609142
parent5682f377aed5b0db6b6c4a44b1d8868103b7e9f7 (diff)
downloadfork-ledger-347029a803475c21bf9fa508f27b0ed7233ff312.tar.gz
fork-ledger-347029a803475c21bf9fa508f27b0ed7233ff312.tar.bz2
fork-ledger-347029a803475c21bf9fa508f27b0ed7233ff312.zip
Compile strptime.cc only on Windows
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/strptime.cc7
2 files changed, 12 insertions, 5 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 71d9478a..9cd54dbe 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -52,7 +52,6 @@ set(LEDGER_SOURCES
times.cc
error.cc
utils.cc
- strptime.cc
wcwidth.cc)
if (HAVE_BOOST_PYTHON)
@@ -134,9 +133,16 @@ set(LEDGER_INCLUDES
value.h
views.h
xact.h
- strptime.h
${PROJECT_BINARY_DIR}/system.hh)
+# Windows provides no strptime(), so supply our own.
+if (WIN32 OR CYGWIN)
+ list(APPEND LEDGER_INCLUDES
+ strptime.h)
+ list(APPEND LEDGER_SOURCES
+ strptime.cc)
+endif()
+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (CMAKE_CXX_COMPILER MATCHES "clang\\+\\+")
add_definitions(
diff --git a/src/strptime.cc b/src/strptime.cc
index 069b9267..ac6885a6 100644
--- a/src/strptime.cc
+++ b/src/strptime.cc
@@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if !(defined(_WIN32) || defined(__CYGWIN__))
+#error This file should only be compiled on Windows.
+#endif
+
// Implement strptime under windows
#include "strptime.h"
@@ -200,5 +203,3 @@ static char* _strptime(const char *s, const char *format, struct tm *tm) {
char* strptime(const char *buf, const char *fmt, struct tm *tm) {
return _strptime(buf, fmt, tm);
}
-
-#endif // _WIN32