summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-24 21:34:19 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-24 21:34:19 -0800
commitbe834300a31ffac837b6434650c206aa8e292e1b (patch)
treec6353469918635bd2a08b1c8b83074f8e3a67b00
parent6bd809b6b4836e1026998c2d4c1fc76506de3e8f (diff)
parent9de6890f11cf6d1947132bbf90e3735aabb0a683 (diff)
Merge pull request #218 from nwellnhof/windows_fixes
Windows fixes
-rw-r--r--CMakeLists.txt6
-rw-r--r--Makefile3
-rw-r--r--Makefile.nmake2
-rw-r--r--README.md4
-rw-r--r--api_test/CMakeLists.txt17
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/blocks.c3
7 files changed, 28 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cb1944b..e554266 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,12 @@ add_test(spectest_library
"${CMAKE_SOURCE_DIR}/spec.txt" "--library-dir" "${CMAKE_BINARY_DIR}/src"
)
add_test(NAME api_test COMMAND api_test)
+if (WIN32)
+ file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/src WIN_DLL_DIR)
+ set_tests_properties(api_test PROPERTIES
+ ENVIRONMENT "PATH=${WIN_DLL_DIR};$ENV{PATH}"
+ )
+endif(WIN32)
add_test(spectest_executable
python "${CMAKE_SOURCE_DIR}/runtests.py" "--no-normalize" "--spec" "${CMAKE_SOURCE_DIR}/spec.txt" "--program" "${CMAKE_BINARY_DIR}/src/cmark"
)
diff --git a/Makefile b/Makefile
index 4f8b15b..7d7e78c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
SRCDIR?=src
DATADIR?=data
BUILDDIR?=build
+GENERATOR?=Unix Makefiles
MINGW_BUILDDIR?=build-mingw
MINGW_INSTALLDIR?=windows
SPEC=spec.txt
@@ -28,7 +29,7 @@ check:
$(BUILDDIR): check
mkdir -p $(BUILDDIR); \
cd $(BUILDDIR); \
- cmake .. -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
+ cmake .. -G "$(GENERATOR)" -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
install: $(BUILDDIR) man/man1/cmark.1
make -C $(BUILDDIR) install
diff --git a/Makefile.nmake b/Makefile.nmake
index 0352b6d..54034c4 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -33,7 +33,7 @@ man\man1\cmark.1: man\cmark.1.md
pandoc $? -o $@ -s -t man
test: $(SPEC) all
- @pushd $(BUILDDIR) && $(MAKE) test ARGS="-V" && popd
+ @pushd $(BUILDDIR) && $(MAKE) /nologo test ARGS="-V" && popd
distclean: clean
del /q src\scanners.c 2> nul
diff --git a/README.md b/README.md
index b795b40..43b1769 100644
--- a/README.md
+++ b/README.md
@@ -104,6 +104,10 @@ To test the archives:
Compiling for Windows
---------------------
+To compile with MSVC and NMAKE:
+
+ nmake
+
You can cross-compile a Windows binary and dll on linux if you have the
`mingw32` compiler:
diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt
index b2ab2c8..c25b6c1 100644
--- a/api_test/CMakeLists.txt
+++ b/api_test/CMakeLists.txt
@@ -10,10 +10,15 @@ include_directories(
target_link_libraries(api_test libcmark)
# Compiler flags
-if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
- set_target_properties(api_test PROPERTIES COMPILE_FLAGS
- "-std=c99 -Wall -Wextra"
- )
-elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
- set_target_properties(api_test PROPERTIES COMPILE_FLAGS "/TP /W4")
+if(MSVC)
+ # Force to always compile with W4
+ if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+ string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ else()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
+ endif()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127 /wd4244 /wd4267 /wd4706 /wd4800 /D_CRT_SECURE_NO_WARNINGS")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP")
+elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99 -pedantic")
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 71f45a7..f71f09c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -121,13 +121,14 @@ if(MSVC)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127 /wd4244 /wd4267 /wd4706 /wd4800 /D_CRT_SECURE_NO_WARNINGS")
elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99 -pedantic")
endif()
# Compile as C++ under MSVC
if(MSVC)
- set(CMAKE_C_FLAGS "/TP")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP")
endif()
if($ENV{TIMER})
diff --git a/src/blocks.c b/src/blocks.c
index 5328638..6f995b3 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -439,7 +439,8 @@ extern cmark_node *cmark_parse_document(const char *buffer, size_t len)
cmark_node *document;
while (buffer < end) {
- const char *eol = memchr(buffer, '\n', end - buffer);
+ const char *eol
+ = (const char *)memchr(buffer, '\n', end - buffer);
offset = eol ? (eol - buffer) + 1 : end - buffer;
cmark_process_line(parser, buffer, offset);
buffer += offset;